use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getObject.
@Override
public ObjectData getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
long start = System.currentTimeMillis();
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// create a CMIS object
ObjectData object = connector.createCMISObject(info, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl);
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired) {
getObjectInfo(repositoryId, info.getObjectId(), includeRelationships);
}
logGetObjectCall("getObject", start, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, isObjectInfoRequired, extension);
return object;
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getRenditions.
@Override
public List<RenditionData> getRenditions(String repositoryId, String objectId, String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
if (info.isVariant(CMISObjectVariant.ASSOC)) {
return Collections.emptyList();
} else {
return connector.getRenditions(info.getNodeRef(), renditionFilter, maxItems, skipCount);
}
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class CMISNodeInfoImpl method getParents.
@Override
public List<CMISNodeInfo> getParents() {
if ((objecVariant == CMISObjectVariant.INVALID_ID) || (objecVariant == CMISObjectVariant.NOT_A_CMIS_OBJECT) || (objecVariant == CMISObjectVariant.NOT_EXISTING) || (objecVariant == CMISObjectVariant.PERMISSION_DENIED)) {
return Collections.<CMISNodeInfo>emptyList();
}
if (parents == null) {
parents = new ArrayList<CMISNodeInfo>();
NodeRef nodeRefForParent = (isCurrentVersion() ? getCurrentNodeNodeRef() : nodeRef);
List<ChildAssociationRef> nodeParents = connector.getNodeService().getParentAssocs(nodeRefForParent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
if (nodeParents != null) {
for (ChildAssociationRef parent : nodeParents) {
if (connector.getType(parent.getParentRef()) instanceof FolderTypeDefintionWrapper) {
parents.add(new CMISNodeInfoImpl(connector, parent.getParentRef()));
}
}
}
}
return parents;
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getPropertiesOfLatestVersion.
@Override
public Properties getPropertiesOfLatestVersion(String repositoryId, String objectId, String versionSeriesId, Boolean major, String filter, ExtensionsData extension) {
checkRepositoryId(repositoryId);
if (objectId != null) {
// it's an AtomPub call
versionSeriesId = connector.getCurrentVersionId(objectId);
}
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
if (info.isVariant(CMISObjectVariant.ASSOC)) {
return connector.getAssocProperties(info, filter);
} else {
CMISNodeInfo versionInfo = createNodeInfo(((CMISNodeInfoImpl) info).getLatestVersionNodeRef(major));
addNodeInfo(versionInfo);
return connector.getNodeProperties(versionInfo, filter);
}
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method deleteObjectOrCancelCheckOut.
@Override
public void deleteObjectOrCancelCheckOut(String repositoryId, final String objectId, final Boolean allVersions, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// what kind of object is it?
final CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
do {
// handle relationships
if (info.isVariant(CMISObjectVariant.ASSOC)) {
AssociationRef assocRef = info.getAssociationRef();
connector.getNodeService().removeAssociation(assocRef.getSourceRef(), assocRef.getTargetRef(), assocRef.getTypeQName());
// Reason for do-while
break;
}
NodeRef nodeRef = info.getNodeRef();
// handle PWC
if (info.isVariant(CMISObjectVariant.PWC)) {
connector.getCheckOutCheckInService().cancelCheckout(nodeRef);
// Reason for do-while
break;
}
// handle folders
if (info.isFolder()) {
// Check if there is at least one child
if (connector.getNodeService().getChildAssocs(nodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL, 1, false).size() > 0) {
throw new CmisConstraintException("Could not delete folder with at least one child!");
}
connector.deleteNode(nodeRef, true);
// Reason for do-while
break;
}
if (info.hasPWC()) {
// checkout, not allowed.
throw new CmisConstraintException("Could not delete/cancel checkout on the original checked out document");
}
// handle versions
if (info.isVariant(CMISObjectVariant.VERSION)) {
nodeRef = info.getCurrentNodeNodeRef();
}
if (allVersions) {
NodeRef workingCopy = connector.getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (workingCopy != null) {
connector.getCheckOutCheckInService().cancelCheckout(workingCopy);
}
} else if (info.isVariant(CMISObjectVariant.VERSION)) {
// Check the DELETE permission since the version service has no restrictions.
AccessStatus perm = connector.getServiceRegistry().getPermissionService().hasPermission(nodeRef, PermissionService.DELETE);
if (AccessStatus.ALLOWED != perm) {
throw new CmisPermissionDeniedException("Cannot delete the node version.");
}
Version version = ((CMISNodeInfoImpl) info).getVersion();
connector.getVersionService().deleteVersion(nodeRef, version);
// Reason for do-while
break;
}
// attempt to delete the node
if (allVersions) {
connector.deleteNode(nodeRef, true);
} else {
CMISNodeInfoImpl infoImpl = (CMISNodeInfoImpl) info;
Version version = infoImpl.getVersion();
if (infoImpl.getVersionHistory().getPredecessor(version) == null) {
connector.deleteNode(nodeRef, true);
} else {
AccessStatus perm = connector.getServiceRegistry().getPermissionService().hasPermission(nodeRef, PermissionService.DELETE);
if (AccessStatus.ALLOWED != perm) {
throw new CmisPermissionDeniedException("Cannot delete the node version.");
}
connector.getVersionService().deleteVersion(nodeRef, version);
// MNT-10032 revert node version to predecessor
connector.getVersionService().revert(nodeRef);
}
}
} while (// Dodgey, but avoided having to play with too much code during refactor
false);
}
Aggregations