use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class NavigationActor method getChildren.
private JSONObject getChildren(QueryGetRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
String orderBy = request.getParameter(QueryGetRequest.PARAM_ORDER_BY);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
includeAllowableActions = includeAllowableActions == null ? false : includeAllowableActions;
IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
ObjectInFolderList children = CmisNavigationService.Impl.getChildren(request.getRepositoryId(), folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, null, request.getUserObject());
if (children == null) {
throw new CmisRuntimeException("Children are null!");
}
JSONObject jsonChildren = JSONConverter.convert(children, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat);
return jsonChildren;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class NavigationActor method getParents.
private JSONArray getParents(QueryGetRequest request) throws CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includeRelativePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_RELATIVE_PATH_SEGMENT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
List<ObjectParentData> parents = CmisNavigationService.Impl.getObjectParents(request.getRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, null, request.getUserObject().getUserDN());
if (parents == null) {
throw new CmisRuntimeException("Parents are null!");
}
JSONArray jsonParents = new JSONArray();
for (ObjectParentData parent : parents) {
jsonParents.add(JSONConverter.convert(parent, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
}
return jsonParents;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class NavigationActor method getCheckedOutDocs.
private JSONObject getCheckedOutDocs(QueryGetRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
String orderBy = request.getParameter(QueryGetRequest.PARAM_ORDER_BY);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
includeAllowableActions = includeAllowableActions == null ? false : includeAllowableActions;
IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
ObjectList docs = CmisNavigationService.Impl.getCheckedOutDocs(request.getRepositoryId(), folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount, null, null, request.getUserObject());
if (docs == null) {
throw new CmisRuntimeException("Children are null!");
}
JSONObject jsonDocs = JSONConverter.convert(docs, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonDocs;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException 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;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException 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;
}
Aggregations