use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method applyPolicy.
// --- policy service ---
@Override
public void applyPolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
TypeDefinitionWrapper type = info.getType();
if (type == null) {
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
connector.applyPolicies(info.getNodeRef(), type, Collections.singletonList(policyId));
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getObjectParents.
@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension) {
long start = System.currentTimeMillis();
checkRepositoryId(repositoryId);
List<ObjectParentData> result = new ArrayList<ObjectParentData>();
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships are not filed
if (info.isRelationship()) {
throw new CmisConstraintException("Relationships are not fileable!");
}
if (info.isItem() || (info.isFolder() && !info.isRootFolder())) {
List<CMISNodeInfo> parentInfos = info.getParents();
if (!parentInfos.isEmpty()) {
for (CMISNodeInfo parent : parentInfos) {
CMISNodeInfo parentInfo = addNodeInfo(parent);
ObjectData object = connector.createCMISObject(parentInfo, filter, includeAllowableActions, includeRelationships, renditionFilter, false, false);
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired) {
getObjectInfo(repositoryId, object.getId(), includeRelationships);
}
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
objectParent.setObject(object);
// include relative path segment
if (includeRelativePathSegment) {
objectParent.setRelativePathSegment(info.getName());
}
result.add(objectParent);
}
}
} else if (info.isCurrentVersion() || info.isPWC()) {
List<CMISNodeInfo> parentInfos = info.getParents();
for (CMISNodeInfo parentInfo : parentInfos) {
addNodeInfo(parentInfo);
ObjectData object = connector.createCMISObject(parentInfo, filter, includeAllowableActions, includeRelationships, renditionFilter, false, false);
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired) {
getObjectInfo(repositoryId, object.getId(), includeRelationships);
}
ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
objectParent.setObject(object);
// include relative path segment
if (includeRelativePathSegment) {
objectParent.setRelativePathSegment(info.getName());
}
result.add(objectParent);
}
}
logGetObjectsCall("getObjectParents", start, objectId, result.size(), filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, extension, null, null, null, null);
return result;
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getObjectOfLatestVersion.
@Override
public ObjectData getObjectOfLatestVersion(String repositoryId, String objectId, String versionSeriesId, Boolean major, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension) {
long start = System.currentTimeMillis();
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");
CMISNodeInfo versionInfo = createNodeInfo(((CMISNodeInfoImpl) info).getLatestVersionNodeRef(major));
ObjectData object = connector.createCMISObject(versionInfo, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl);
boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired) {
getObjectInfo(repositoryId, info.getObjectId(), includeRelationships);
}
StringBuilder sb = new StringBuilder();
sb.append(objectId).append("-").append(versionSeriesId);
logGetObjectCall("getObjectOfLatestVersion", start, sb.toString(), 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 getAllowableActions.
@Override
public AllowableActions getAllowableActions(String repositoryId, String objectId, ExtensionsData extension) {
checkRepositoryId(repositoryId);
// what kind of object is it?
CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
return connector.getAllowableActions(info);
}
use of org.alfresco.opencmis.dictionary.CMISNodeInfo in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method checkOut.
// --- versioning service ---
@Override
public void checkOut(String repositoryId, final Holder<String> objectId, ExtensionsData extension, final Holder<Boolean> contentCopied) {
checkRepositoryId(repositoryId);
CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
// Check for current version
if (info.isVariant(CMISObjectVariant.CURRENT_VERSION)) {
// Good
} else if (info.isVariant(CMISObjectVariant.VERSION)) {
throw new CmisInvalidArgumentException("Can't check out an old version of a document");
} else {
throw new CmisInvalidArgumentException("Only documents can be checked out! Object was a " + info.getObjectVariant().toString());
}
// get object
final NodeRef nodeRef = info.getNodeRef();
if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable()) {
throw new CmisConstraintException("Document is not versionable!");
}
// check out
NodeRef pwcNodeRef = connector.getCheckOutCheckInService().checkout(nodeRef);
CMISNodeInfo pwcNodeInfo = createNodeInfo(pwcNodeRef);
objectId.setValue(pwcNodeInfo.getObjectId());
if (contentCopied != null) {
contentCopied.setValue(connector.getFileFolderService().getReader(pwcNodeRef) != null);
}
}
Aggregations