mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (Cloud33/4.3) to HEAD (Cloud33/4.3)
62905: Merged PLATFORM1 (Cloud33) to HEAD-BUG-FIX (Cloud33/4.3) 61335: ACE-33 implementation of cmis:items add permissions create and delete of cmis:items some unit test fixes new unit test for items git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62958 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -988,6 +988,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
case CMIS_POLICY:
|
||||
newId = createPolicy(repositoryId, properties, folderId, policies, null, null, extension);
|
||||
break;
|
||||
case CMIS_ITEM:
|
||||
newId = createItem(repositoryId, properties, folderId, policies, null, null, extension);
|
||||
|
||||
}
|
||||
|
||||
// check new object id
|
||||
@@ -1043,6 +1046,44 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
String objectId = connector.createObjectId(nodeRef);
|
||||
return objectId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies,
|
||||
Acl addAces, Acl removeAces, ExtensionsData extension)
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
// get the parent folder node ref
|
||||
final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");
|
||||
|
||||
// get name and type
|
||||
final String name = connector.getNameProperty(properties, null);
|
||||
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
|
||||
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_ITEM);
|
||||
|
||||
connector.checkChildObjectType(parentInfo, type.getTypeId());
|
||||
|
||||
/**
|
||||
* The above code specifies a folder - so the contents of a folder (as defined by the alfresco model) are
|
||||
* ASSOC cm:contains to a TYPE sys:base
|
||||
*/
|
||||
QName assocQName = QName.createQName(
|
||||
NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||
QName.createValidLocalName(name));
|
||||
|
||||
ChildAssociationRef newRef = connector.getNodeService().createNode(parentInfo.getNodeRef(), ContentModel.ASSOC_CONTAINS, assocQName, type.getAlfrescoClass());
|
||||
|
||||
NodeRef nodeRef = newRef.getChildRef();
|
||||
|
||||
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
|
||||
connector.applyPolicies(nodeRef, type, policies);
|
||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||
|
||||
String objectId = connector.createObjectId(nodeRef);
|
||||
return objectId;
|
||||
|
||||
}
|
||||
|
||||
private String parseMimeType(ContentStream contentStream)
|
||||
{
|
||||
|
@@ -1262,7 +1262,15 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
*/
|
||||
public String createObjectId(NodeRef currentVersionNodeRef)
|
||||
{
|
||||
if(getFileFolderService().getFileInfo(currentVersionNodeRef).isFolder())
|
||||
FileInfo fileInfo = getFileFolderService().getFileInfo(currentVersionNodeRef);
|
||||
|
||||
if(fileInfo == null)
|
||||
{
|
||||
// not a file or a folder
|
||||
return constructObjectId(currentVersionNodeRef, null);
|
||||
}
|
||||
|
||||
if(fileInfo.isFolder())
|
||||
{
|
||||
return constructObjectId(currentVersionNodeRef, null);
|
||||
}
|
||||
@@ -1407,7 +1415,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!childTypes.contains(childType))
|
||||
{
|
||||
throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
|
||||
|
@@ -31,6 +31,7 @@ import org.alfresco.opencmis.dictionary.CMISNodeInfo;
|
||||
import org.alfresco.opencmis.dictionary.CMISObjectVariant;
|
||||
import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper;
|
||||
import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
|
||||
import org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper;
|
||||
import org.alfresco.opencmis.dictionary.RelationshipTypeDefintionWrapper;
|
||||
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
@@ -74,6 +75,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
private String name;
|
||||
private boolean hasPWC;
|
||||
private Boolean isRootFolder;
|
||||
|
||||
private String cmisPath;
|
||||
private VersionHistory versionHistory;
|
||||
private Version version;
|
||||
@@ -281,6 +283,12 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(isItem())
|
||||
{
|
||||
objecVariant = CMISObjectVariant.ITEM;
|
||||
return;
|
||||
}
|
||||
|
||||
if (versionLabel == null)
|
||||
{
|
||||
@@ -448,6 +456,13 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
currentObjectId = objectId;
|
||||
return;
|
||||
}
|
||||
else if (isItem())
|
||||
{
|
||||
objecVariant = CMISObjectVariant.ITEM;
|
||||
objectId = connector.constructObjectId(nodeRef, null);
|
||||
currentObjectId = objectId;
|
||||
return;
|
||||
}
|
||||
else if (getType() == null)
|
||||
{
|
||||
objecVariant = CMISObjectVariant.NOT_A_CMIS_OBJECT;
|
||||
@@ -687,6 +702,11 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
return getType() instanceof FolderTypeDefintionWrapper;
|
||||
}
|
||||
|
||||
public boolean isItem()
|
||||
{
|
||||
return getType() instanceof ItemTypeDefinitionWrapper;
|
||||
}
|
||||
|
||||
public boolean isRootFolder()
|
||||
{
|
||||
@@ -807,7 +827,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
return getVersion().getVersionProperty(VersionBaseModel.PROP_CREATED_DATE);
|
||||
}
|
||||
} else if (isFolder())
|
||||
} else if (isFolder() || isItem())
|
||||
{
|
||||
return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATED);
|
||||
} else
|
||||
@@ -827,7 +847,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
return getVersion().getVersionProperty(ContentModel.PROP_MODIFIED.getLocalName());
|
||||
}
|
||||
} else if (isFolder())
|
||||
} else if (isFolder() || isItem())
|
||||
{
|
||||
return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_MODIFIED);
|
||||
} else
|
||||
|
@@ -48,10 +48,15 @@ public class BaseTypeIdProperty extends AbstractProperty
|
||||
if (nodeInfo.isFolder())
|
||||
{
|
||||
return BaseTypeId.CMIS_FOLDER.value();
|
||||
} else if (nodeInfo.isRelationship())
|
||||
}
|
||||
else if (nodeInfo.isRelationship())
|
||||
{
|
||||
return BaseTypeId.CMIS_RELATIONSHIP.value();
|
||||
}
|
||||
else if(nodeInfo.isItem())
|
||||
{
|
||||
return BaseTypeId.CMIS_ITEM.value();
|
||||
}
|
||||
|
||||
return BaseTypeId.CMIS_DOCUMENT.value();
|
||||
}
|
||||
|
@@ -279,6 +279,23 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
|
||||
false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry, Action.CAN_APPLY_ACL,
|
||||
false));
|
||||
|
||||
// permissions for ITEMS in order of CMIS-Core.xsd
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new PermissionActionEvaluator(serviceRegistry,
|
||||
Action.CAN_DELETE_OBJECT, PermissionService.DELETE_NODE));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new PermissionActionEvaluator(serviceRegistry,
|
||||
Action.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new PermissionActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_OBJECT_RELATIONSHIPS, true));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new ParentActionEvaluator(new PermissionActionEvaluator(
|
||||
serviceRegistry, Action.CAN_GET_OBJECT_PARENTS, PermissionService.READ_PERMISSIONS)));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_ACL,
|
||||
PermissionService.READ_PERMISSIONS));
|
||||
registerEvaluator(BaseTypeId.CMIS_ITEM, new PermissionActionEvaluator(serviceRegistry, Action.CAN_APPLY_ACL,
|
||||
PermissionService.CHANGE_PERMISSIONS));
|
||||
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
Reference in New Issue
Block a user