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);
}
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;
}
Aggregations