use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat 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.enums.DateTimeFormat 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.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class RelationshipActor method getRelationships.
private JSONObject getRelationships(QueryGetRequest request) throws CmisObjectNotFoundException, MongoException, 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();
Boolean includeSubRelationshipTypes = request.getBooleanParameter(QueryGetRequest.PARAM_SUB_RELATIONSHIP_TYPES);
RelationshipDirection relationshipDirection = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIP_DIRECTION, RelationshipDirection.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
String typeId = request.getParameter(QueryGetRequest.PARAM_TYPE_ID);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
ObjectList relationships = CmisRelationshipService.Impl.getObjectRelationships(request.getRepositoryId(), objectId, includeSubRelationshipTypes, relationshipDirection, typeId, renditionFilter, includeAllowableActions, maxItems, skipCount, null, request.getUserName());
if (relationships == null) {
throw new CmisRuntimeException("Relationships are null!");
}
JSONObject jsonChildren = JSONConverter.convert(relationships, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonChildren;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class RepositoryActor method getTypeChildren.
private JSONObject getTypeChildren(QueryGetRequest request) throws IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeId = request.getParameter(QueryGetRequest.PARAM_TYPE_ID);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
boolean includePropertyDefinitions = request.getBooleanParameter(QueryGetRequest.PARAM_PROPERTY_DEFINITIONS, false);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
TypeDefinitionList typeList = CmisTypeServices.Impl.getTypeChildren(request.getRepositoryId(), typeId, includePropertyDefinitions, maxItems, skipCount, null);
JSONObject jsonTypeList = JSONConverter.convert(typeList, dateTimeFormat);
return jsonTypeList;
}
use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat in project copper-cms by PogeyanOSS.
the class RepositoryActor method createType.
private JSONObject createType(PostRequest request) throws IllegalArgumentException, CmisInvalidArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeStr = request.getParameter(QueryGetRequest.CONTROL_TYPE);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
if (typeStr == null) {
throw new CmisInvalidArgumentException("Type definition missing!");
}
// convert type definition
JSONParser parser = new JSONParser();
Object typeJson = null;
try {
typeJson = parser.parse(typeStr);
} catch (JSONParseException e) {
LOG.error("JSON Parser error: {}", ExceptionUtils.getStackTrace(e));
}
if (!(typeJson instanceof Map)) {
throw new CmisInvalidArgumentException("Invalid type definition!");
}
@SuppressWarnings("unchecked") TypeDefinition typeIn = JSONConverter.convertTypeDefinition((Map<String, Object>) typeJson);
TypeDefinition typeOut = CmisTypeServices.Impl.createType(request.getRepositoryId(), typeIn, null, request.getUserName());
JSONObject jsonType = JSONConverter.convert(typeOut, dateTimeFormat);
return jsonType;
}
Aggregations