Search in sources :

Example 1 with IncludeRelationships

use of org.apache.chemistry.opencmis.commons.enums.IncludeRelationships 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;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) BigInteger(java.math.BigInteger) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 2 with IncludeRelationships

use of org.apache.chemistry.opencmis.commons.enums.IncludeRelationships 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;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) BigInteger(java.math.BigInteger) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) ObjectInFolderContainer(org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 3 with IncludeRelationships

use of org.apache.chemistry.opencmis.commons.enums.IncludeRelationships 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;
}
Also used : ReturnVersion(org.apache.chemistry.opencmis.commons.impl.ReturnVersion) 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) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) IBaseObject(com.pogeyan.cmis.api.data.IBaseObject) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 4 with IncludeRelationships

use of org.apache.chemistry.opencmis.commons.enums.IncludeRelationships in project copper-cms by PogeyanOSS.

the class NavigationActor method getChildren.

private JSONObject getChildren(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 folderId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    String orderBy = request.getParameter(QueryGetRequest.PARAM_ORDER_BY);
    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);
    BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
    BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    ObjectInFolderList children = CmisNavigationService.Impl.getChildren(request.getRepositoryId(), folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, null, request.getUserObject());
    if (children == null) {
        throw new CmisRuntimeException("Children are null!");
    }
    JSONObject jsonChildren = JSONConverter.convert(children, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat);
    return jsonChildren;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) BigInteger(java.math.BigInteger) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 5 with IncludeRelationships

use of org.apache.chemistry.opencmis.commons.enums.IncludeRelationships in project copper-cms by PogeyanOSS.

the class NavigationActor method getParents.

private JSONArray getParents(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 objectId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    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 includeRelativePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_RELATIVE_PATH_SEGMENT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    List<ObjectParentData> parents = CmisNavigationService.Impl.getObjectParents(request.getRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, null, request.getUserObject().getUserDN());
    if (parents == null) {
        throw new CmisRuntimeException("Parents are null!");
    }
    JSONArray jsonParents = new JSONArray();
    for (ObjectParentData parent : parents) {
        jsonParents.add(JSONConverter.convert(parent, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
    }
    return jsonParents;
}
Also used : ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Aggregations

DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)6 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)6 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)6 BigInteger (java.math.BigInteger)4 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)3 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)3 ObjectInFolderContainer (org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer)2 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)1 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)1 ObjectInFolderList (org.apache.chemistry.opencmis.commons.data.ObjectInFolderList)1 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)1 ObjectParentData (org.apache.chemistry.opencmis.commons.data.ObjectParentData)1 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)1 ReturnVersion (org.apache.chemistry.opencmis.commons.impl.ReturnVersion)1