Site Service: fix issue when non-admin users create site containers

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9963 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-07-21 15:52:51 +00:00
parent 1fcbb2eca2
commit cef534a8c1

View File

@@ -332,16 +332,20 @@ public class Site implements Serializable
* @param folderType folder type to create
* @return ScriptNode the created container
*/
public ScriptNode createContainer(String componentId, String folderType, Object permissions)
public ScriptNode createContainer(final String componentId, final String folderType, final Object permissions)
{
ScriptNode container = null;
try
{
NodeRef containerNodeRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
// Get the container type
QName folderQName = (folderType == null) ? null : QName.createQName(folderType, serviceRegistry.getNamespaceService());
// Create the container node
final NodeRef containerNodeRef = this.siteService.createContainer(getShortName(), componentId, folderQName, null);
NodeRef containerNodeRef = Site.this.siteService.createContainer(getShortName(), componentId, folderQName, null);
// Set any permissions that might have been provided for the container
if (permissions != null && permissions instanceof ScriptableObject)
@@ -360,20 +364,17 @@ public class Site implements Serializable
final String key = (String)propId;
final Object value = scriptable.get(key, scriptable);
if (value instanceof String)
{
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
// Set the permission on the container
Site.this.serviceRegistry.getPermissionService().setPermission(containerNodeRef, key, (String)value, true);
return null;
}
}
}
}
return containerNodeRef;
}
}, AuthenticationUtil.SYSTEM_USER_NAME);
}
}
}
}
// Create the script node for the container
container = new ScriptNode(containerNodeRef, this.serviceRegistry, this.scope);