mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge WCM_SERVICES TO HEAD Changes 12213, 12214
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12215 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,13 +24,16 @@
|
||||
*/
|
||||
package org.alfresco.wcm.sandbox.script;
|
||||
|
||||
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.sandbox.SandboxService;
|
||||
|
||||
/**
|
||||
* Asset in a sandbox exposed over Java Script API.
|
||||
* WCM Asset in a sandbox exposed over Java Script API.
|
||||
* @author mrogers
|
||||
*
|
||||
*/
|
||||
@@ -45,6 +48,10 @@ public class Asset
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* The creator of this asset
|
||||
* @return the creator
|
||||
*/
|
||||
public String getCreator()
|
||||
{
|
||||
return desc.getCreator();
|
||||
@@ -85,9 +92,23 @@ public class Asset
|
||||
return desc.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full path of this asset eg. /www/avm_webapps/ROOT/myFile.jpg
|
||||
* @return the path of this asset.
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return desc.getPath();
|
||||
String path = desc.getPath();
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
String[] splits = path.split(":");
|
||||
return splits[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFile()
|
||||
@@ -105,6 +126,32 @@ public class Asset
|
||||
return desc.isDeleted();
|
||||
}
|
||||
|
||||
|
||||
public int getVersion()
|
||||
{
|
||||
return desc.getVersionID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit this asset to staging
|
||||
* @param submitLabel
|
||||
* @param submitComment
|
||||
*/
|
||||
public void submit(String submitLabel, String submitComment)
|
||||
{
|
||||
List<String> items = new ArrayList<String>(1);
|
||||
items.add(this.getPath());
|
||||
getSandboxService().submitList(getSandbox().getSandboxRef(), items, submitLabel, submitComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* revert this asset
|
||||
*/
|
||||
public void revert()
|
||||
{
|
||||
//getSandboxService().revertList(getSandbox().getSandboxRef(), items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent sandbox which contains this asset
|
||||
* @return the parent sandbox which contains this asset
|
||||
@@ -113,4 +160,9 @@ public class Asset
|
||||
{
|
||||
return this.sandbox;
|
||||
}
|
||||
|
||||
private SandboxService getSandboxService()
|
||||
{
|
||||
return getSandbox().getWebproject().getWebProjects().getSandboxService();
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import java.util.List;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.util.ISO8601DateFormat;
|
||||
import org.alfresco.wcm.sandbox.SandboxInfo;
|
||||
import org.alfresco.wcm.sandbox.SandboxConstants;
|
||||
import org.alfresco.wcm.sandbox.SandboxService;
|
||||
import org.alfresco.wcm.webproject.script.WebProject;
|
||||
|
||||
@@ -81,7 +82,7 @@ public class Sandbox implements Serializable
|
||||
{
|
||||
// read only
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit the modified contents of this sandbox
|
||||
*/
|
||||
@@ -90,6 +91,35 @@ public class Sandbox implements Serializable
|
||||
getSandboxService().submitAll(getSandboxRef(), submitLabel, submitComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the specified assets (files and directories) modified contents of this sandbox
|
||||
*/
|
||||
public void submitAssets(Asset[] files, String submitLabel, String submitComment)
|
||||
{
|
||||
List<String> items = new ArrayList<String>(files.length);
|
||||
|
||||
for(int i = 0; i < files.length; i++)
|
||||
{
|
||||
items.add(i, files[i].getPath());
|
||||
}
|
||||
|
||||
getSandboxService().submitList(getSandboxRef(), items, submitLabel, submitComment);
|
||||
}
|
||||
/**
|
||||
* Submit the specified files and directories modified contents of this sandbox
|
||||
*/
|
||||
public void submit(String[] files, String submitLabel, String submitComment)
|
||||
{
|
||||
List<String> items = new ArrayList<String>(files.length);
|
||||
|
||||
for(int i = 0; i < files.length; i++)
|
||||
{
|
||||
items.add(i, files[i]);
|
||||
}
|
||||
|
||||
getSandboxService().submitList(getSandboxRef(), items, submitLabel, submitComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the modified contents of the webapp within this sandbox
|
||||
*/
|
||||
@@ -171,19 +201,38 @@ public class Sandbox implements Serializable
|
||||
return si.getStoreNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an author sandbox ?
|
||||
* @return is this an author sandbox
|
||||
*/
|
||||
public boolean isAuthorSandbox()
|
||||
{
|
||||
return si.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a staging sandbox ?
|
||||
* @return is this an author sandbox
|
||||
*/
|
||||
public boolean isStagingSandbox()
|
||||
{
|
||||
return si.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_STAGING_MAIN);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the modified assets within this sandbox
|
||||
* @return the list of changed assets
|
||||
*/
|
||||
public List<Asset> getModifiedAssets()
|
||||
public Asset[] getModifiedAssets()
|
||||
{
|
||||
List<AVMNodeDescriptor> items = getSandboxService().listChangedAll(getSandboxRef(), true);
|
||||
ArrayList<Asset> ret = new ArrayList<Asset>(items.size());
|
||||
Asset[] ret = new Asset[items.size()];
|
||||
|
||||
int i = 0;
|
||||
for(AVMNodeDescriptor item : items)
|
||||
{
|
||||
Asset a = new Asset(this, item);
|
||||
ret.add(a);
|
||||
ret[i++] = new Asset(this, item);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -192,38 +241,32 @@ public class Sandbox implements Serializable
|
||||
* Get the modified assets within this sandbox
|
||||
* @return the list of changed assets
|
||||
*/
|
||||
public List<Asset> getModifiedAssetsWebApp(String webApp)
|
||||
public Asset[] getModifiedAssetsWebApp(String webApp)
|
||||
{
|
||||
List<AVMNodeDescriptor> items = getSandboxService().listChangedWebApp(getSandboxRef(), webApp, true);
|
||||
ArrayList<Asset> ret = new ArrayList<Asset>(items.size());
|
||||
|
||||
Asset[] ret = new Asset[items.size()];
|
||||
|
||||
int i = 0;
|
||||
for(AVMNodeDescriptor item : items)
|
||||
{
|
||||
Asset a = new Asset(this, item);
|
||||
ret.add(a);
|
||||
ret[i++] = new Asset(this, item);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a list of files
|
||||
* Get the web project that owns this sandbox
|
||||
* @return the web project
|
||||
*/
|
||||
public void submitList(List<String> toSubmit, String submitLabel, String submitComment)
|
||||
{
|
||||
// TODO - Interface will add string list
|
||||
//ss.submitList(sbStoreId, items, submitLabel, submitComment)
|
||||
}
|
||||
|
||||
public List<Asset> getAssets(String path)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public WebProject getWebproject()
|
||||
{
|
||||
return this.webproject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sandbox service
|
||||
* @return the sandbox service
|
||||
*/
|
||||
private SandboxService getSandboxService()
|
||||
{
|
||||
return webproject.getWebProjects().getSandboxService();
|
||||
|
Reference in New Issue
Block a user