Search in sources :

Example 21 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData 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 ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData 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 ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.

the class VersioningActor method checkIn.

private JSONObject checkIn(PostRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "post")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    // get parameters
    String objectId = request.getObjectId();
    Boolean major = request.getBooleanParameter(QueryGetRequest.PARAM_MAJOR);
    String checkinComment = request.getParameter(QueryGetRequest.PARAM_CHECKIN_COMMENT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    // execute
    Holder<String> objectIdHolder = new Holder<String>(objectId);
    Map<String, List<String>> listProperties = request.getPropertyData();
    Map<String, Object> properties = new HashMap<String, Object>();
    if (listProperties != null) {
        for (Map.Entry<String, List<String>> entry : listProperties.entrySet()) {
            if (entry.getValue() == null || StringUtils.isBlank(entry.getValue().get(0))) {
                continue;
            } else {
                properties.put(entry.getKey(), entry.getValue());
            }
        }
    }
    /*
		 * if (listProperties != null) { properties =
		 * listProperties.entrySet().stream().collect(Collectors.toMap(p ->
		 * p.getKey(), p -> p.getValue() !=
		 * null||!StringUtils.isBlank(p.getValue().get(0)) ? p.getValue().get(0)
		 * :null)); }
		 */
    String versionId = CmisVersioningServices.Impl.checkIn(request.getRepositoryId(), properties, request.getContentStream(), objectIdHolder, major, checkinComment, null, request.getUserName());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), versionId, request.getUserName(), BaseTypeId.CMIS_DOCUMENT);
    if (object == null) {
        throw new CmisRuntimeException("New document is null!");
    }
    // return object
    JSONObject jsonObject = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) HashMap(java.util.HashMap) Holder(org.apache.chemistry.opencmis.commons.spi.Holder) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) List(java.util.List) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 24 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.

the class VersioningActor method cancelCheckOut.

private JSONObject cancelCheckOut(PostRequest request) throws CmisUpdateConflictException, CmisUpdateConflictException, 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();
    String docId = CmisVersioningServices.Impl.cancelCheckOut(request.getRepositoryId(), objectId, null, request.getUserName());
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), docId, request.getUserName(), BaseTypeId.CMIS_DOCUMENT);
    if (object == null) {
        throw new CmisRuntimeException("New document 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) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 25 with ObjectData

use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.

the class VersioningActor method getAllVersions.

private JSONArray getAllVersions(QueryGetRequest request) throws CmisObjectNotFoundException, CmisUpdateConflictException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    String objectId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    String versionSeriesId = request.getParameter(QueryGetRequest.PARAM_VERSION_SERIES_ID);
    Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
    String userName = request.getUserName();
    List<ObjectData> versions = CmisVersioningServices.Impl.getAllVersions(request.getRepositoryId(), objectId, versionSeriesId, filter, includeAllowableActions, null, null, userName);
    if (versions == null) {
        throw new CmisRuntimeException("version are null!");
    }
    JSONArray allVersions = new JSONArray();
    for (ObjectData version1 : versions) {
        allVersions.add(JSONConverter.convert(version1, null, JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat));
    }
    return allVersions;
}
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)

Aggregations

ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)32 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)23 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)22 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)20 Properties (org.apache.chemistry.opencmis.commons.data.Properties)8 Holder (org.apache.chemistry.opencmis.commons.spi.Holder)7 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 Acl (org.apache.chemistry.opencmis.commons.data.Acl)6 CmisNotSupportedException (org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException)3 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)3 App (org.structr.core.app.App)3 StructrApp (org.structr.core.app.StructrApp)3 Tx (org.structr.core.graph.Tx)3 BaseMessage (com.pogeyan.cmis.api.BaseMessage)2 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)2 ArrayList (java.util.ArrayList)2 Document (org.apache.chemistry.opencmis.client.api.Document)2 Folder (org.apache.chemistry.opencmis.client.api.Folder)2 Policy (org.apache.chemistry.opencmis.client.api.Policy)2 ObjectParentData (org.apache.chemistry.opencmis.commons.data.ObjectParentData)2