mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Site Service: refactor container API (Java & JS) to have separate create method, fix-up UI fallout, expose node details on site details (Java/JS/REST), fixup web scripts with correct permission levels
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9918 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,9 +43,7 @@ import org.mozilla.javascript.Scriptable;
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class Site implements Serializable
|
||||
{
|
||||
// TODO: DC - Should Site derive from ScriptNode?
|
||||
|
||||
{
|
||||
/** Serializable serial verion UID */
|
||||
private static final long serialVersionUID = 8013569574120957923L;
|
||||
|
||||
@@ -160,6 +158,22 @@ public class Site implements Serializable
|
||||
this.siteInfo.setIsPublic(isPublic);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the site node, null if none
|
||||
*
|
||||
* @return ScriptNode site node
|
||||
*/
|
||||
public ScriptNode getNode()
|
||||
{
|
||||
ScriptNode node = null;
|
||||
if (this.siteInfo.getNodeRef() != null)
|
||||
{
|
||||
node = new ScriptNode(this.siteInfo.getNodeRef(), this.serviceRegistry, this.scope);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves any outstanding updates to the site details.
|
||||
* <p>
|
||||
@@ -262,32 +276,20 @@ public class Site implements Serializable
|
||||
/**
|
||||
* Gets (or creates) the "container" folder for the specified component id
|
||||
*
|
||||
* NOTE: The container is of type cm:folder.
|
||||
*
|
||||
* @param componentId
|
||||
* @return node representing the "container" folder
|
||||
*/
|
||||
public ScriptNode getContainer(String componentId)
|
||||
{
|
||||
return getContainer(componentId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets (or creates) the "container" folder for the specified component id
|
||||
*
|
||||
* @param componentId
|
||||
* @param folderType type of folder to create (if null, creates a standard folder)
|
||||
* @return node representing the "container" folder (or null, if for some reason
|
||||
* the container can not be created)
|
||||
*/
|
||||
public ScriptNode getContainer(String componentId, String folderType)
|
||||
public ScriptNode getContainer(String componentId)
|
||||
{
|
||||
ScriptNode container = null;
|
||||
try
|
||||
{
|
||||
QName folderQName = (folderType == null) ? null : QName.createQName(folderType, serviceRegistry.getNamespaceService());
|
||||
NodeRef containerNodeRef = this.siteService.getContainer(getShortName(), componentId, folderQName);
|
||||
container = new ScriptNode(containerNodeRef, this.serviceRegistry, this.scope);
|
||||
NodeRef containerNodeRef = this.siteService.getContainer(getShortName(), componentId);
|
||||
if (containerNodeRef != null)
|
||||
{
|
||||
container = new ScriptNode(containerNodeRef, this.serviceRegistry, this.scope);
|
||||
}
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
@@ -296,7 +298,42 @@ public class Site implements Serializable
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new site container
|
||||
*
|
||||
* @param componentId component id
|
||||
* @return ScriptNode the created container
|
||||
*/
|
||||
public ScriptNode createContainer(String componentId)
|
||||
{
|
||||
return createContainer(componentId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new site container
|
||||
*
|
||||
* @param componentId component id
|
||||
* @param folderType folder type to create
|
||||
* @return ScriptNode the created container
|
||||
*/
|
||||
public ScriptNode createContainer(String componentId, String folderType)
|
||||
{
|
||||
ScriptNode container = null;
|
||||
try
|
||||
{
|
||||
QName folderQName = (folderType == null) ? null : QName.createQName(folderType, serviceRegistry.getNamespaceService());
|
||||
NodeRef containerNodeRef = this.siteService.createContainer(getShortName(), componentId, folderQName, null);
|
||||
container = new ScriptNode(containerNodeRef, this.serviceRegistry, this.scope);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e)
|
||||
{
|
||||
// NOTE: not good practice to catch all, but in general we're not throwing exceptions
|
||||
// into the script layer
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the "container" folder for the specified component exists
|
||||
*
|
||||
|
Reference in New Issue
Block a user