Search in sources :

Example 11 with DateTimeFormat

use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat 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 12 with DateTimeFormat

use of org.apache.chemistry.opencmis.commons.enums.DateTimeFormat 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 13 with DateTimeFormat

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

the class ObjectActor method appendContent.

private JSONObject appendContent(PostRequest request) throws 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 isLastChunk = request.getBooleanParameter(QueryGetRequest.CONTROL_IS_LAST_CHUNK, false);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Holder<String> objectIdHolder = new Holder<String>(objectId);
    Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
    if (request.getContentStream() == null) {
        CmisObjectService.Impl.appendContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder, null, isLastChunk);
    } else {
        CmisObjectService.Impl.appendContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder, request.getContentStream(), isLastChunk);
    }
    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.CHANGE, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) Holder(org.apache.chemistry.opencmis.commons.spi.Holder) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 14 with DateTimeFormat

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

the class ObjectActor method update.

@SuppressWarnings("unused")
private JSONObject update(PostRequest request) throws CmisRuntimeException, CmisObjectNotFoundException, CmisRuntimeException, CmisUpdateConflictException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "post")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String objectId = request.getObjectId();
    IBaseObject data = DBUtils.BaseDAO.getByObjectId(request.getRepositoryId(), objectId, null);
    String typeId = CmisPropertyConverter.Impl.getTypeIdForObject(request.getRepositoryId(), objectId);
    String changeToken = request.getParameter(QueryGetRequest.CONTROL_CHANGE_TOKEN);
    String token = request.getParameter(QueryGetRequest.PARAM_TOKEN);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Holder<String> objectIdHolder = new Holder<String>(objectId.toString());
    Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
    Properties properties = CmisPropertyConverter.Impl.createUpdateProperties(request.getPropertyData(), typeId, null, Collections.singletonList(objectId.toString()), request.getRepositoryId(), data);
    CmisObjectService.Impl.updateProperties(request.getRepositoryId(), objectIdHolder, changeTokenHolder, properties, null, null, request.getUserObject());
    String newObjectId = (objectIdHolder.getValue() == null ? objectId : objectIdHolder.getValue());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), request.getBaseTypeId());
    if (object == null) {
        throw new CmisRuntimeException("Object is null!");
    }
    // return object
    JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) Holder(org.apache.chemistry.opencmis.commons.spi.Holder) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) Properties(org.apache.chemistry.opencmis.commons.data.Properties) IBaseObject(com.pogeyan.cmis.api.data.IBaseObject) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 15 with DateTimeFormat

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

the class ObjectActor method createItem.

private JSONObject createItem(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.createItem(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_ITEM);
    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;
}
Also used : IUserGroupObject(com.pogeyan.cmis.api.auth.IUserGroupObject) 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) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Properties(org.apache.chemistry.opencmis.commons.data.Properties) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

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