Search in sources :

Example 21 with JSONObject

use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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 22 with JSONObject

use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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)

Example 23 with JSONObject

use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.

the class ObjectActor method createRelationship.

private JSONObject createRelationship(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.");
    }
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
    String folderId = request.getObjectId() != null ? request.getObjectId() : null;
    Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
    String newObjectId = CmisObjectService.Impl.createRelationship(request.getRepositoryId(), folderId, prop, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_RELATIONSHIP);
    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)

Example 24 with JSONObject

use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.

the class ObjectActor method deleteContent.

private JSONObject deleteContent(PostRequest request) throws CmisStorageException, 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 succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    // execute
    Holder<String> objectIdHolder = new Holder<String>(objectId);
    Holder<String> changeTokenHolder = (changeToken == null ? null : new Holder<String>(changeToken));
    CmisObjectService.Impl.deleteContentStream(request.getRepositoryId(), objectIdHolder, changeTokenHolder);
    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.OBJECT, 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 25 with JSONObject

use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.

the class ObjectActor method moveObject.

private static JSONObject moveObject(PostRequest request) throws CmisObjectNotFoundException, CmisNotSupportedException, 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 targetFolderId = request.getParameter(QueryGetRequest.PARAM_TARGET_FOLDER_ID);
    String sourceFolderId = request.getParameter(QueryGetRequest.PARAM_SOURCE_FOLDER_ID);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    // execute
    Holder<String> objectIdHolder = new Holder<String>(objectId);
    ObjectData object = CmisObjectService.Impl.moveObject(request.getRepositoryId(), objectIdHolder, targetFolderId, sourceFolderId, null, request.getUserObject());
    JSONObject result = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
    return result;
}
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)

Aggregations

JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)42 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)36 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)29 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)20 Properties (org.apache.chemistry.opencmis.commons.data.Properties)9 Acl (org.apache.chemistry.opencmis.commons.data.Acl)8 Holder (org.apache.chemistry.opencmis.commons.spi.Holder)8 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 BigInteger (java.math.BigInteger)6 Map (java.util.Map)5 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)5 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)5 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)3 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)3 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)3 CmisBaseException (org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException)3 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)2 IRepository (com.pogeyan.cmis.api.repo.IRepository)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2