Search in sources :

Example 41 with CmisInvalidArgumentException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method addObjectToFolder.

// --- multifiling service ---
@Override
public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    if (!allVersions) {
        throw new CmisInvalidArgumentException("Only allVersions=true supported!");
    }
    // get node ref
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
    if (!info.isDocument()) {
        throw new CmisInvalidArgumentException("Object is not a document!");
    }
    final NodeRef nodeRef = info.getNodeRef();
    // get the folder node ref
    final CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder");
    connector.checkChildObjectType(folderInfo, info.getType().getTypeId());
    final QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String) connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME)));
    connector.getNodeService().addChild(folderInfo.getNodeRef(), nodeRef, ContentModel.ASSOC_CONTAINS, name);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Example 42 with CmisInvalidArgumentException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException in project alfresco-repository by Alfresco.

the class AlfrescoCmisServiceImpl method getFolderParent.

@Override
public ObjectData getFolderParent(String repositoryId, String folderId, String filter, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    // get the node ref
    CMISNodeInfo info = getOrCreateFolderInfo(folderId, "Folder");
    // the root folder has no parent
    if (info.isRootFolder()) {
        throw new CmisInvalidArgumentException("Root folder has no parent!");
    }
    // get the parent
    List<CMISNodeInfo> parentInfos = info.getParents();
    if (parentInfos.isEmpty()) {
        throw new CmisRuntimeException("Folder has no parent and is not the root folder?!");
    }
    CMISNodeInfo parentInfo = addNodeInfo(parentInfos.get(0));
    ObjectData result = connector.createCMISObject(parentInfo, filter, false, IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false);
    boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
    if (isObjectInfoRequired) {
        getObjectInfo(repositoryId, parentInfo.getObjectId(), IncludeRelationships.NONE);
    }
    return result;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) CMISNodeInfo(org.alfresco.opencmis.dictionary.CMISNodeInfo)

Aggregations

CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)42 CMISNodeInfo (org.alfresco.opencmis.dictionary.CMISNodeInfo)14 NodeRef (org.alfresco.service.cmr.repository.NodeRef)13 CmisConstraintException (org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException)12 ArrayList (java.util.ArrayList)11 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)10 TypeDefinitionWrapper (org.alfresco.opencmis.dictionary.TypeDefinitionWrapper)9 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)8 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 DocumentTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper)6 ItemTypeDefinitionWrapper (org.alfresco.opencmis.dictionary.ItemTypeDefinitionWrapper)6 CmisStreamNotSupportedException (org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException)6 List (java.util.List)5 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)5 CmisContentAlreadyExistsException (org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException)5 IOException (java.io.IOException)4 QName (org.alfresco.service.namespace.QName)4 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)4