use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class PolicyActor method applyPolicy.
private JSONObject applyPolicy(PostRequest request) throws CmisObjectNotFoundException, CmisInvalidArgumentException, 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();
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
CmisPolicyService.Impl.applyPolicy(request.getRepositoryId(), request.getPolicyId(), objectId);
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), objectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_POLICY);
if (object == null) {
throw new CmisRuntimeException("Object is null!");
}
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class PolicyActor method policies.
private JSONArray policies(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 objectId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
List<ObjectData> policies = CmisPolicyService.Impl.getAppliedPolicies(request.getRepositoryId(), objectId, filter, null);
JSONArray jsonPolicies = new JSONArray();
if (policies != null) {
for (ObjectData policy : policies) {
jsonPolicies.add(JSONConverter.convert(policy, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat));
}
}
return jsonPolicies;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class VersioningActor method checkIn.
private JSONObject checkIn(PostRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
// get parameters
String objectId = request.getObjectId();
Boolean major = request.getBooleanParameter(QueryGetRequest.PARAM_MAJOR);
String checkinComment = request.getParameter(QueryGetRequest.PARAM_CHECKIN_COMMENT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
// execute
Holder<String> objectIdHolder = new Holder<String>(objectId);
Map<String, List<String>> listProperties = request.getPropertyData();
Map<String, Object> properties = new HashMap<String, Object>();
if (listProperties != null) {
for (Map.Entry<String, List<String>> entry : listProperties.entrySet()) {
if (entry.getValue() == null || StringUtils.isBlank(entry.getValue().get(0))) {
continue;
} else {
properties.put(entry.getKey(), entry.getValue());
}
}
}
/*
* if (listProperties != null) { properties =
* listProperties.entrySet().stream().collect(Collectors.toMap(p ->
* p.getKey(), p -> p.getValue() !=
* null||!StringUtils.isBlank(p.getValue().get(0)) ? p.getValue().get(0)
* :null)); }
*/
String versionId = CmisVersioningServices.Impl.checkIn(request.getRepositoryId(), properties, request.getContentStream(), objectIdHolder, major, checkinComment, null, request.getUserName());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), versionId, request.getUserName(), BaseTypeId.CMIS_DOCUMENT);
if (object == null) {
throw new CmisRuntimeException("New document is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class VersioningActor method cancelCheckOut.
private JSONObject cancelCheckOut(PostRequest request) throws CmisUpdateConflictException, CmisUpdateConflictException, 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();
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
String docId = CmisVersioningServices.Impl.cancelCheckOut(request.getRepositoryId(), objectId, null, request.getUserName());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), docId, request.getUserName(), BaseTypeId.CMIS_DOCUMENT);
if (object == null) {
throw new CmisRuntimeException("New document is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class VersioningActor method getAllVersions.
private JSONArray getAllVersions(QueryGetRequest request) throws CmisObjectNotFoundException, CmisUpdateConflictException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
String objectId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
String versionSeriesId = request.getParameter(QueryGetRequest.PARAM_VERSION_SERIES_ID);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
String userName = request.getUserName();
List<ObjectData> versions = CmisVersioningServices.Impl.getAllVersions(request.getRepositoryId(), objectId, versionSeriesId, filter, includeAllowableActions, null, null, userName);
if (versions == null) {
throw new CmisRuntimeException("version are null!");
}
JSONArray allVersions = new JSONArray();
for (ObjectData version1 : versions) {
allVersions.add(JSONConverter.convert(version1, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat));
}
return allVersions;
}
Aggregations