use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class ObjectActor method createRelationship.
private JSONObject createRelationship(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
String principalId = request.getUserObject().getUserDN();
IUserGroupObject[] groups = request.getUserObject().getGroups();
if (!Helpers.getGroupPermission(permission, groups)) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
String folderId = request.getObjectId() != null ? request.getObjectId() : null;
Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
String newObjectId = CmisObjectService.Impl.createRelationship(request.getRepositoryId(), folderId, prop, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_RELATIONSHIP);
if (object == null) {
throw new CmisRuntimeException("New folder is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class ObjectActor method deleteContent.
private JSONObject deleteContent(PostRequest request) throws CmisStorageException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
String changeToken = request.getParameter(QueryGetRequest.PARAM_CHANGE_TOKEN);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
// execute
Holder<String> objectIdHolder = new Holder<String>(objectId);
Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
CmisObjectService.Impl.deleteContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder);
String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_DOCUMENT);
if (object == null) {
throw new CmisRuntimeException("Object is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class ObjectActor method moveObject.
private static JSONObject moveObject(PostRequest request) throws CmisObjectNotFoundException, CmisNotSupportedException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String objectId = request.getObjectId();
String targetFolderId = request.getParameter(QueryGetRequest.PARAM_TARGET_FOLDER_ID);
String sourceFolderId = request.getParameter(QueryGetRequest.PARAM_SOURCE_FOLDER_ID);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
// execute
Holder<String> objectIdHolder = new Holder<String>(objectId);
ObjectData object = CmisObjectService.Impl.moveObject(request.getRepositoryId(), objectIdHolder, targetFolderId, sourceFolderId, null, request.getUserObject());
JSONObject result = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return result;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class ObjectActor method createPolicy.
private JSONObject createPolicy(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
String principalId = request.getUserObject().getUserDN();
IUserGroupObject[] groups = request.getUserObject().getGroups();
if (!Helpers.getGroupPermission(permission, groups)) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId() != null ? request.getObjectId() : null;
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
String newObjectId = CmisObjectService.Impl.createPolicy(request.getRepositoryId(), prop, folderId, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_POLICY);
if (object == null) {
throw new CmisRuntimeException("New folder is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class ObjectActor method getObject.
private JSONObject getObject(QueryGetRequest t) throws CmisInvalidArgumentException, IllegalArgumentException, CmisRuntimeException, CmisObjectNotFoundException {
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 acessPermission = false;
IBaseObject data = DBUtils.BaseDAO.getByObjectId(t.getRepositoryId(), objectId, null);
acessPermission = CmisObjectService.Impl.getAclAccess(t.getRepositoryId(), data, t.getUserObject());
if (data != null && !data.getName().equals(ROOT) && acessPermission == false) {
throw new CmisInvalidArgumentException("{} does not have valid acces control permission to access this object", t.getUserName());
}
ReturnVersion returnVersion = t.getEnumParameter(QueryGetRequest.PARAM_RETURN_VERSION, ReturnVersion.class);
String filter = t.getParameter(QueryGetRequest.PARAM_FILTER);
Boolean includeAllowableActions = t.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
IncludeRelationships includeRelationships = t.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = t.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includePolicyIds = t.getBooleanParameter(QueryGetRequest.PARAM_POLICY_IDS);
Boolean includeAcl = t.getBooleanParameter(QueryGetRequest.PARAM_ACL);
boolean succinct = t.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = t.getDateTimeFormatParameter();
ObjectData object = null;
if (returnVersion == ReturnVersion.LATEST || returnVersion == ReturnVersion.LASTESTMAJOR) {
object = CmisVersioningServices.Impl.getObjectOfLatestVersion(t.getRepositoryId(), objectId, null, returnVersion == ReturnVersion.LASTESTMAJOR, filter, includeAllowableActions, null, includePolicyIds, includeAcl, null, null, t.getUserObject().getUserDN());
} else {
object = CmisObjectService.Impl.getObject(t.getRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, t.getUserObject().getUserDN(), t.getBaseTypeId());
}
JSONObject result = JSONConverter.convert(object, CmisTypeCacheService.get(t.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return result;
}
Aggregations