Search in sources :

Example 21 with DateTimeFormat

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;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 22 with DateTimeFormat

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;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 23 with DateTimeFormat

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;
}
Also used : RelationshipDirection(org.apache.chemistry.opencmis.commons.enums.RelationshipDirection) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) BigInteger(java.math.BigInteger) ObjectList(org.apache.chemistry.opencmis.commons.data.ObjectList) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 24 with DateTimeFormat

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;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) TypeDefinitionList(org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList) BigInteger(java.math.BigInteger) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 25 with DateTimeFormat

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;
}
Also used : JSONParseException(org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParseException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) CmisInvalidArgumentException(org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException) JSONParser(org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat) TypeDefinition(org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)

Aggregations

DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)35 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)35 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)29 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)22 Properties (org.apache.chemistry.opencmis.commons.data.Properties)9 BigInteger (java.math.BigInteger)8 Holder (org.apache.chemistry.opencmis.commons.spi.Holder)8 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 Acl (org.apache.chemistry.opencmis.commons.data.Acl)6 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)6 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)6 Map (java.util.Map)3 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)3 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)3 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)3 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)2 LinkedHashMap (java.util.LinkedHashMap)2 ObjectInFolderContainer (org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)2 VersioningState (org.apache.chemistry.opencmis.commons.enums.VersioningState)2 ReturnVersion (org.apache.chemistry.opencmis.commons.impl.ReturnVersion)2