use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createTypeWithoutProperties.
private void createTypeWithoutProperties(Session session, ObjectType parentType) {
CmisTestResult failure = null;
// define the type
DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_without_properties", parentType);
// create the type
ObjectType newType = createType(session, newTypeDef);
if (newType == null) {
return;
}
// get the type
ObjectType newType2 = null;
try {
newType2 = session.getTypeDefinition(newType.getId());
// assert type definitions
failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
addResult(assertEquals(newType, newType2, null, failure));
} catch (CmisObjectNotFoundException e) {
addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
}
// delete the type
deleteType(session, newType.getId());
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISAclService method applyAcl.
/**
* Applies the given Acl exclusively, i.e. removes all other permissions / grants first.
*
* @param repositoryId
* @param objectId
* @param acl
* @param aclPropagation
*
* @return the resulting Acl
*/
public Acl applyAcl(final String repositoryId, final String objectId, final Acl acl, final AclPropagation aclPropagation) {
final App app = StructrApp.getInstance(securityContext);
try (final Tx tx = app.tx()) {
final AbstractNode node = app.get(AbstractNode.class, objectId);
if (node != null) {
node.revokeAll();
// process add ACL entries
for (final Ace toAdd : acl.getAces()) {
applyAce(node, toAdd, false);
}
tx.success();
// return the wrapper which implements the Acl interface
return CMISObjectWrapper.wrap(node, null, false);
}
} catch (FrameworkException fex) {
logger.warn("", fex);
}
throw new CmisObjectNotFoundException("Object with ID " + objectId + " does not exist");
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISNavigationService method getChildrenQuery.
public Query<AbstractFile> getChildrenQuery(final App app, final String folderId) throws FrameworkException {
final Query<AbstractFile> query = app.nodeQuery(AbstractFile.class).sort(AbstractNode.name);
final PropertyKey<Folder> parent = StructrApp.key(AbstractFile.class, "parent");
final PropertyKey<Boolean> hasParent = StructrApp.key(AbstractFile.class, "hasParent");
final PropertyKey<Boolean> isThumbnail = StructrApp.key(Image.class, "isThumbnail");
if (CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
query.and(hasParent, false).and(isThumbnail, false);
} else {
final Folder folder = app.get(Folder.class, folderId);
if (folder != null) {
query.and(parent, folder).and(isThumbnail, false);
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
return query;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISNavigationService method getFolderTree.
@Override
public List<ObjectInFolderContainer> getFolderTree(final String repositoryId, final String folderId, final BigInteger depth, final String filter, final Boolean includeAllowableActions, final IncludeRelationships includeRelationships, final String renditionFilter, final Boolean includePathSegment, final ExtensionsData extension) {
final PropertyKey<Folder> parentKey = StructrApp.key(AbstractFile.class, "parent");
final List<ObjectInFolderContainer> result = new LinkedList<>();
final App app = StructrApp.getInstance();
try (final Tx tx = app.tx()) {
int maxDepth = Integer.MAX_VALUE;
if (depth != null && depth.intValue() >= 0) {
maxDepth = depth.intValue();
}
if (CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
for (final Folder folder : app.nodeQuery(Folder.class).and(parentKey, null).sort(AbstractNode.name).getAsList()) {
recursivelyCollectFolderTree(result, folder, maxDepth, 1, includeAllowableActions);
}
} else {
final Folder folder = app.get(Folder.class, folderId);
if (folder != null) {
final List<Folder> children = Iterables.toList(folder.getFolders());
Collections.sort(children, new GraphObjectComparator(AbstractNode.name, false));
for (final Folder child : children) {
recursivelyCollectFolderTree(result, child, maxDepth, 1, includeAllowableActions);
}
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
tx.success();
} catch (final FrameworkException fex) {
logger.warn("", fex);
}
return result;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project structr by structr.
the class CMISObjectService method createDocumentFromSource.
@Override
public String createDocumentFromSource(String repositoryId, String sourceId, Properties properties, String folderId, VersioningState versioningState, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
// copy existing document
final App app = StructrApp.getInstance(securityContext);
String uuid = null;
try (final Tx tx = app.tx()) {
final File existingDocument = app.get(File.class, sourceId);
if (existingDocument != null) {
try (final InputStream inputStream = existingDocument.getInputStream()) {
final ContentStreamImpl copyContentStream = new ContentStreamImpl();
copyContentStream.setFileName(existingDocument.getName());
copyContentStream.setMimeType(existingDocument.getContentType());
copyContentStream.setLength(BigInteger.valueOf(existingDocument.getSize()));
copyContentStream.setStream(inputStream);
uuid = createDocument(repositoryId, properties, folderId, copyContentStream, versioningState, policies, addAces, removeAces, extension);
}
} else {
throw new CmisObjectNotFoundException("Document with ID " + sourceId + " does not exist");
}
tx.success();
} catch (Throwable t) {
throw new CmisRuntimeException("New document could not be created: " + t.getMessage());
}
return uuid;
}
Aggregations