Search in sources :

Example 6 with CMISNodeInfo

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));
}
Also used : CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) TypeDefinitionWrapper(org.alfresco.opencmis.dictionary.TypeDefinitionWrapper) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 7 with CMISNodeInfo

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;
}
Also used : ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) ArrayList(java.util.ArrayList) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) ArrayList(java.util.ArrayList) TypeDefinitionList(org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList) ObjectList(org.apache.chemistry.opencmis.commons.data.ObjectList) List(java.util.List) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo) ObjectParentDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl)

Example 8 with CMISNodeInfo

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;
}
Also used : ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 9 with CMISNodeInfo

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);
}
Also used : CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 10 with CMISNodeInfo

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);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) CmisConstraintException(org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Aggregations

CMISNodeInfo (org.alfresco.opencmis.dictionary.CMISNodeInfo)42 NodeRef (org.alfresco.service.cmr.repository.NodeRef)26 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)15 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)13 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)13 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)10 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)8 ArrayList (java.util.ArrayList)6 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)6 FileInfo (org.alfresco.service.cmr.model.FileInfo)5 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)5 CmisStreamNotSupportedException (org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException)5 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)4 FileNotFoundException (org.alfresco.service.cmr.model.FileNotFoundException)4 QName (org.alfresco.service.namespace.QName)4 CmisContentAlreadyExistsException (org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException)4 IOException (java.io.IOException)3 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)3 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)3 Serializable (java.io.Serializable)2