Merged V1.3 to HEAD (3068:3083, 3084:3086)

svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3068 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3083 .
   svn merge svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3084 svn://www.alfresco.org:3691/alfresco/BRANCHES/V1.3@3086 .


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3342 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-07-18 15:42:28 +00:00
parent dbffd532f7
commit 6564a5011e
3 changed files with 125 additions and 46 deletions

View File

@@ -483,6 +483,12 @@
<property name="searchService"> <property name="searchService">
<ref bean="SearchService" /> <ref bean="SearchService" />
</property> </property>
<property name="permissionService">
<ref bean="PermissionService" />
</property>
<property name="authenticationService">
<ref bean="AuthenticationService" />
</property>
</bean> </bean>
<!-- --> <!-- -->

View File

@@ -47,6 +47,10 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.rule.RuleService; import org.alfresco.service.cmr.rule.RuleService;
import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
@@ -73,6 +77,12 @@ public class CopyServiceImpl implements CopyService
/** Rule service */ /** Rule service */
private RuleService ruleService; private RuleService ruleService;
/** Permission service */
private PermissionService permissionService;
/** Authentication service */
private AuthenticationService authenticationService;
/** Policy delegates */ /** Policy delegates */
private ClassPolicyDelegate<CopyServicePolicies.OnCopyNodePolicy> onCopyNodeDelegate; private ClassPolicyDelegate<CopyServicePolicies.OnCopyNodePolicy> onCopyNodeDelegate;
@@ -128,6 +138,26 @@ public class CopyServiceImpl implements CopyService
this.ruleService = ruleService; this.ruleService = ruleService;
} }
/**
* Set the permission service
*
* @param permissionService the permission service
*/
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
/**
* Sets the authentication service
*
* @param authenticationService the authentication service
*/
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
/** /**
* Initialise method * Initialise method
*/ */
@@ -395,6 +425,9 @@ public class CopyServiceImpl implements CopyService
// Copy the associations // Copy the associations
copyAssociations(destinationNodeRef, copyDetails, copyChildren, copiedChildren); copyAssociations(destinationNodeRef, copyDetails, copyChildren, copiedChildren);
// Copy permissions
copyPermissions(sourceNodeRef, destinationNodeRef);
} }
finally finally
{ {
@@ -404,6 +437,34 @@ public class CopyServiceImpl implements CopyService
return destinationNodeRef; return destinationNodeRef;
} }
/**
* Copies the permissions of the source node reference onto the destination node reference
*
* @param sourceNodeRef the source node reference
* @param destinationNodeRef the destination node reference
*/
private void copyPermissions(NodeRef sourceNodeRef, NodeRef destinationNodeRef)
{
// Get the permission details of the source node reference
Set<AccessPermission> permissions = this.permissionService.getAllSetPermissions(sourceNodeRef);
boolean includeInherited = this.permissionService.getInheritParentPermissions(sourceNodeRef);
AccessStatus writePermission = permissionService.hasPermission(destinationNodeRef, PermissionService.CHANGE_PERMISSIONS);
if (this.authenticationService.isCurrentUserTheSystemUser() || writePermission.equals(AccessStatus.ALLOWED))
{
// Set the permission values on the destination node
for (AccessPermission permission : permissions)
{
this.permissionService.setPermission(
destinationNodeRef,
permission.getAuthority(),
permission.getPermission(),
permission.getAccessStatus().equals(AccessStatus.ALLOWED));
}
this.permissionService.setInheritParentPermissions(destinationNodeRef, includeInherited);
}
}
/** /**
* Gets the copy details. This calls the appropriate policies that have been registered * Gets the copy details. This calls the appropriate policies that have been registered
* against the node and aspect types in order to pick-up any type specific copy behaviour. * against the node and aspect types in order to pick-up any type specific copy behaviour.

View File

@@ -847,56 +847,68 @@ public final class Node implements Serializable
for (String key : this.properties.keySet()) for (String key : this.properties.keySet())
{ {
Serializable value = (Serializable)this.properties.get(key); Serializable value = (Serializable)this.properties.get(key);
if (value instanceof Node)
{ // perform the conversion from script wrapper object to repo serializable values
// convert back to NodeRef value = convertValue(value);
value = ((Node)value).getNodeRef();
}
else if (value instanceof ScriptContentData)
{
// convert back to ContentData
value = ((ScriptContentData)value).contentData;
}
else if (value instanceof Wrapper)
{
// unwrap a Java object from a JavaScript wrapper
value = (Serializable)((Wrapper)value).unwrap();
}
else if (value instanceof ScriptableObject)
{
// a scriptable object will probably indicate a multi-value property
// set using a JavaScript Array object
ScriptableObject values = (ScriptableObject)value;
// convert JavaScript array of values to a List of Serializable objects
Object[] propIds = values.getIds();
List<Serializable> propValues = new ArrayList<Serializable>(propIds.length);
for (int i=0; i<propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that indicate a list of values
if (propId instanceof Integer)
{
// get the value out for the specified key - make sure it is Serializable
Object val = values.get((Integer)propId, values);
if (val instanceof Wrapper)
{
val = ((Wrapper)val).unwrap();
}
if (val instanceof Serializable)
{
propValues.add((Serializable)val);
}
}
}
value = (Serializable)propValues;
}
props.put(createQName(key), value); props.put(createQName(key), value);
} }
this.nodeService.setProperties(this.nodeRef, props); this.nodeService.setProperties(this.nodeRef, props);
} }
/**
* Convert an object from any script wrapper value to a valid repository serializable value.
* This includes converting JavaScript Array objects to Lists of valid objects.
*
* @param value Value to convert from script wrapper object to repo serializable value
*
* @return valid repo value
*/
private static Serializable convertValue(Serializable value)
{
if (value instanceof Node)
{
// convert back to NodeRef
value = ((Node)value).getNodeRef();
}
else if (value instanceof ScriptContentData)
{
// convert back to ContentData
value = ((ScriptContentData)value).contentData;
}
else if (value instanceof Wrapper)
{
// unwrap a Java object from a JavaScript wrapper
// recursively call this method to convert the unwrapped value
value = convertValue((Serializable)((Wrapper)value).unwrap());
}
else if (value instanceof ScriptableObject)
{
// a scriptable object will probably indicate a multi-value property
// set using a JavaScript Array object
ScriptableObject values = (ScriptableObject)value;
// convert JavaScript array of values to a List of Serializable objects
Object[] propIds = values.getIds();
List<Serializable> propValues = new ArrayList<Serializable>(propIds.length);
for (int i=0; i<propIds.length; i++)
{
// work on each key in turn
Object propId = propIds[i];
// we are only interested in keys that indicate a list of values
if (propId instanceof Integer)
{
// get the value out for the specified key
Serializable val = (Serializable)values.get((Integer)propId, values);
// recursively call this method to convert the value
propValues.add(convertValue(val));
}
}
value = (Serializable)propValues;
}
return value;
}
/** /**
* Create a new File (cm:content) node as a child of this node. * Create a new File (cm:content) node as a child of this node.