use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class AclActor method getAcl.
private JSONObject getAcl(QueryGetRequest t) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = t.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
}
String objectId = t.getObjectId();
Boolean onlyBasicPermissions = t.getBooleanParameter(QueryGetRequest.PARAM_ONLY_BASIC_PERMISSIONS);
Acl objectAcl = CmisAclServices.Impl.getAcl(t.getRepositoryId(), objectId, onlyBasicPermissions, null, null, t.getUserObject().getUserDN());
if (objectAcl == null) {
throw new CmisRuntimeException("object acl is null!");
}
JSONObject jsonObject = JSONConverter.convert(objectAcl);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class DiscoveryActor method getContentChanges.
private JSONObject getContentChanges(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 changeLogToken = request.getParameter(QueryGetRequest.PARAM_CHANGE_LOG_TOKEN);
Boolean includeProperties = request.getBooleanParameter(QueryGetRequest.PARAM_PROPERTIES);
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
Boolean includePolicyIds = request.getBooleanParameter(QueryGetRequest.PARAM_POLICY_IDS);
Boolean includeAcl = request.getBooleanParameter(QueryGetRequest.PARAM_ACL);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Holder<String> changeLogTokenHolder = new Holder<String>(changeLogToken);
ObjectList changes = CmisDiscoveryService.Impl.getContentChanges(request.getRepositoryId(), changeLogTokenHolder, includeProperties, filter, includePolicyIds, includeAcl, maxItems, null, request.getUserObject());
JSONObject jsonChanges = JSONConverter.convert(changes, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
jsonChanges.put(JSONConstants.JSON_OBJECTLIST_CHANGE_LOG_TOKEN, changeLogTokenHolder.getValue());
return jsonChanges;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class NavigationActor method getFolderTree.
private JSONArray getFolderTree(QueryGetRequest request) throws CmisInvalidArgumentException, 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);
BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
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 includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
List<ObjectInFolderContainer> folderTree = CmisNavigationService.Impl.getFolderTree(request.getRepositoryId(), folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null, request.getUserObject());
if (folderTree == null) {
throw new CmisRuntimeException("Folder Tree are null!");
}
JSONArray jsonDescendants = new JSONArray();
for (ObjectInFolderContainer descendant : folderTree) {
jsonDescendants.add(JSONConverter.convert(descendant, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
}
return jsonDescendants;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.
the class NavigationActor method getDescendants.
private JSONArray getDescendants(QueryGetRequest request) throws CmisInvalidArgumentException, 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);
BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
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);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
List<ObjectInFolderContainer> descendants = CmisNavigationService.Impl.getDescendants(request.getRepositoryId(), folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null, request.getUserObject());
if (descendants == null) {
throw new CmisRuntimeException("Descendants are null!");
}
JSONArray jsonDescendants = new JSONArray();
for (ObjectInFolderContainer descendant : descendants) {
jsonDescendants.add(JSONConverter.convert(descendant, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
}
return jsonDescendants;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project structr by structr.
the class CMISObjectService method createDocument.
@Override
public String createDocument(final String repositoryId, final Properties properties, final String folderId, final ContentStream contentStream, final VersioningState versioningState, final List<String> policies, final Acl addAces, final Acl removeAces, final ExtensionsData extension) {
final App app = StructrApp.getInstance(securityContext);
File newFile = null;
String uuid = null;
try (final Tx tx = app.tx()) {
final String objectTypeId = getStringValue(properties, PropertyIds.OBJECT_TYPE_ID);
final String fileName = getStringValue(properties, PropertyIds.NAME);
final Class type = typeFromObjectTypeId(objectTypeId, BaseTypeId.CMIS_DOCUMENT, File.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_DOCUMENT.equals(baseTypeId)) {
final String mimeType = contentStream != null ? contentStream.getMimeType() : null;
// create file
newFile = FileHelper.createFile(securityContext, new byte[0], mimeType, type, fileName);
if (newFile != null) {
// 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) {
newFile.setParent(parent);
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
uuid = newFile.getUuid();
if (contentStream != null) {
final InputStream inputStream = contentStream.getStream();
if (inputStream != null) {
// copy file and update metadata
try (final OutputStream outputStream = newFile.getOutputStream(false, false)) {
IOUtils.copy(inputStream, outputStream);
}
inputStream.close();
FileHelper.updateMetadata(newFile);
}
}
}
} else {
throw new CmisConstraintException("Cannot create cmis:document of type " + objectTypeId);
}
} else {
throw new CmisObjectNotFoundException("Type with ID " + objectTypeId + " does not exist");
}
tx.success();
} catch (Throwable t) {
throw new CmisRuntimeException("New document could not be created: " + t.getMessage());
}
// start indexing after transaction is finished
if (newFile != null) {
newFile.notifyUploadCompletion();
}
return uuid;
}
Aggregations