Merged DEV/WCM_SERVICES2 to HEAD

12236: Implementation of Sandbox Revert REST API
  12305: WCM Services - "asset service" initial checkpoint (more tests to be added)
  12334: placeholder for WCM Asset implementation
  12338: Check in to get server working ...
  12341: WCM Services - "asset service" checkpoint (locking fixes, bulk import, more tests added)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-12-23 14:48:34 +00:00
parent c4e9d6f97b
commit eb906a0d52
23 changed files with 2709 additions and 334 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -28,8 +28,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.wcm.asset.AssetInfo;
import org.alfresco.wcm.sandbox.SandboxService;
/**
@@ -39,13 +39,13 @@ import org.alfresco.wcm.sandbox.SandboxService;
*/
public class Asset
{
private AVMNodeDescriptor desc;
private AssetInfo asset;
private Sandbox sandbox;
public Asset(Sandbox sandbox, AVMNodeDescriptor desc)
public Asset(Sandbox sandbox, AssetInfo asset)
{
this.sandbox = sandbox;
this.desc = desc;
this.asset = asset;
}
/**
@@ -54,12 +54,12 @@ public class Asset
*/
public String getCreator()
{
return desc.getCreator();
return asset.getCreator();
}
public Date getCreatedDate()
{
return new Date(desc.getCreateDate());
return asset.getCreatedDate();
}
public String getCreatedDateAsISO8601()
@@ -69,12 +69,12 @@ public class Asset
public String getModifier()
{
return desc.getLastModifier();
return asset.getModifier();
}
public Date getModifiedDate()
{
return new Date(desc.getModDate());
return asset.getModifiedDate();
}
public String getModifiedDateAsISO8601()
@@ -82,14 +82,16 @@ public class Asset
return ISO8601DateFormat.format(getModifiedDate());
}
/*
public String getAssetRef()
{
return desc.getGuid();
return asset.getGuid();
}
*/
public String getName()
{
return desc.getName();
return asset.getName();
}
/**
@@ -98,39 +100,35 @@ public class Asset
*/
public String getPath()
{
String path = desc.getPath();
if (path != null)
{
String[] splits = path.split(":");
return splits[1];
}
else
{
return path;
}
return asset.getPath();
}
public boolean isFile()
{
return desc.isFile();
return asset.isFile();
}
public boolean isDirectory()
{
return desc.isDirectory();
return asset.isFolder();
}
public boolean isDeleted()
{
return desc.isDeleted();
return asset.isDeleted();
}
public boolean isLocked()
{
return asset.isLocked();
}
/* TODO review
public int getVersion()
{
return desc.getVersionID();
return asset.getVersion();
}
*/
/**
* Submit this asset to staging

View File

@@ -31,6 +31,8 @@ import java.util.List;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.wcm.asset.AssetInfo;
import org.alfresco.wcm.asset.AssetService;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.wcm.sandbox.SandboxService;
@@ -138,6 +140,7 @@ public class Sandbox implements Serializable
getSandboxService().submitList(getSandboxRef(), items, submitLabel, submitComment);
}
/**
* Submit the specified files and directories modified contents of this sandbox
*/
@@ -260,28 +263,55 @@ public class Sandbox implements Serializable
*/
public Asset[] getModifiedAssets()
{
List<AVMNodeDescriptor> items = getSandboxService().listChangedAll(getSandboxRef(), true);
List<AssetInfo> items = getSandboxService().listChangedAll(getSandboxRef(), true);
Asset[] ret = new Asset[items.size()];
int i = 0;
for(AVMNodeDescriptor item : items)
for(AssetInfo item : items)
{
ret[i++] = new Asset(this, item);
}
return ret;
}
/**
* Get the specified asset (Either folder or file)
* @param path the full path e.g. /www/web_apps/ROOT/index.html
* @return the asset
*/
public Asset getAsset(String path)
{
AssetService as = getAssetService();
AssetInfo item = as.getAsset(getSandboxRef(), path);
Asset newAsset = new Asset(this, item);
return newAsset;
}
/**
* Get the specified asset with a path relative to the specified web app.
* @param path e.g. index.html
* @param webApp e.g. ROOT
* @return the asset
*/
public Asset getAssetWebApp(String webApp, String path)
{
AssetService as = getAssetService();
AssetInfo item = as.getAssetWebApp(getSandboxRef(), webApp, path);
Asset newAsset = new Asset(this, item);
return newAsset;
}
/**
* Get the modified assets within this sandbox
* @return the list of changed assets
*/
public Asset[] getModifiedAssetsWebApp(String webApp)
{
List<AVMNodeDescriptor> items = getSandboxService().listChangedWebApp(getSandboxRef(), webApp, true);
List<AssetInfo> items = getSandboxService().listChangedWebApp(getSandboxRef(), webApp, true);
Asset[] ret = new Asset[items.size()];
int i = 0;
for(AVMNodeDescriptor item : items)
for(AssetInfo item : items)
{
ret[i++] = new Asset(this, item);
}
@@ -305,4 +335,13 @@ public class Sandbox implements Serializable
{
return webproject.getWebProjects().getSandboxService();
}
/**
* Get the asset service
* @return the asset service
*/
private AssetService getAssetService()
{
return webproject.getWebProjects().getAssetService();
}
}