use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISObjectService method createFolder.
@Override
public String createFolder(final String repositoryId, final Properties properties, final String folderId, final List<String> policies, final Acl addAces, final Acl removeAces, final ExtensionsData extension) {
final App app = StructrApp.getInstance(securityContext);
String uuid = null;
try (final Tx tx = app.tx()) {
final String objectTypeId = getStringValue(properties, PropertyIds.OBJECT_TYPE_ID);
final Class type = typeFromObjectTypeId(objectTypeId, BaseTypeId.CMIS_FOLDER, Folder.class);
// check if type exists
if (type != null) {
// check that base type is cmis:folder
final BaseTypeId baseTypeId = getBaseTypeId(type);
if (baseTypeId != null && BaseTypeId.CMIS_FOLDER.equals(baseTypeId)) {
// create folder
final AbstractFile newFolder = (AbstractFile) app.create(type, PropertyMap.cmisTypeToJavaType(securityContext, type, properties));
// find and set parent if it exists
if (!CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
final Folder parent = app.get(Folder.class, folderId);
if (parent != null) {
newFolder.setParent(parent);
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
uuid = newFolder.getUuid();
} else {
throw new CmisConstraintException("Cannot create cmis:folder of type " + objectTypeId);
}
} else {
throw new CmisObjectNotFoundException("Type with ID " + objectTypeId + " does not exist");
}
tx.success();
} catch (Throwable t) {
throw new CmisRuntimeException("New folder could not be created: " + t.getMessage());
}
return uuid;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISRepositoryService method getTypeChildren.
@Override
public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
// important: children are the direct children of a type, as opposed to the descendants
final CMISTypeDefinitionListWrapper results = new CMISTypeDefinitionListWrapper(maxItems, skipCount);
if (typeId != null) {
final BaseTypeId baseTypeId = getBaseTypeId(typeId);
if (baseTypeId != null) {
results.addAll(getBaseTypeChildren(baseTypeId, includePropertyDefinitions));
} else {
final Class type = StructrApp.getConfiguration().getNodeEntityClass(typeId);
if (type != null) {
results.addAll(getTypeChildren(typeId, includePropertyDefinitions));
} else {
throw new CmisObjectNotFoundException("Type with ID " + typeId + " does not exist");
}
}
} else {
results.add(getDocumentTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value(), includePropertyDefinitions, true));
results.add(getFolderTypeDefinition(BaseTypeId.CMIS_FOLDER.value(), includePropertyDefinitions, true));
results.add(getItemTypeDefinition(BaseTypeId.CMIS_ITEM.value(), includePropertyDefinitions, true));
results.add(getPolicyTypeDefinition(BaseTypeId.CMIS_POLICY.value(), includePropertyDefinitions, true));
results.add(getRelationshipTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value(), includePropertyDefinitions, true));
results.add(getSecondaryTypeDefinition(BaseTypeId.CMIS_SECONDARY.value(), includePropertyDefinitions, true));
}
return results;
}
Aggregations