Search in sources :

Example 1 with Holder

use of org.apache.chemistry.opencmis.commons.spi.Holder in project copper-cms by PogeyanOSS.

the class ObjectActor method setContent.

private JSONObject setContent(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 overwriteFlag = request.getBooleanParameter(QueryGetRequest.PARAM_OVERWRITE_FLAG);
    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.setContentStream(request.getRepositoryId(), objectIdHolder, overwriteFlag, changeTokenHolder, null);
    } else {
        CmisObjectService.Impl.setContentStream(request.getRepositoryId(), objectIdHolder, overwriteFlag, changeTokenHolder, request.getContentStream());
    }
    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) {
        MetricsInputs.markUploadErrorMeter();
        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 2 with Holder

use of org.apache.chemistry.opencmis.commons.spi.Holder in project copper-cms by PogeyanOSS.

the class DiscoveryActor method getContentChanges.

private JSONObject getContentChanges(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 changeLogToken = request.getParameter(QueryGetRequest.PARAM_CHANGE_LOG_TOKEN);
    Boolean includeProperties = request.getBooleanParameter(QueryGetRequest.PARAM_PROPERTIES);
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    Boolean includePolicyIds = request.getBooleanParameter(QueryGetRequest.PARAM_POLICY_IDS);
    Boolean includeAcl = request.getBooleanParameter(QueryGetRequest.PARAM_ACL);
    BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    Holder<String> changeLogTokenHolder = new Holder<String>(changeLogToken);
    ObjectList changes = CmisDiscoveryService.Impl.getContentChanges(request.getRepositoryId(), changeLogTokenHolder, includeProperties, filter, includePolicyIds, includeAcl, maxItems, null, request.getUserObject());
    JSONObject jsonChanges = JSONConverter.convert(changes, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
    jsonChanges.put(JSONConstants.JSON_OBJECTLIST_CHANGE_LOG_TOKEN, changeLogTokenHolder.getValue());
    return jsonChanges;
}
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) BigInteger(java.math.BigInteger) ObjectList(org.apache.chemistry.opencmis.commons.data.ObjectList) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 3 with Holder

use of org.apache.chemistry.opencmis.commons.spi.Holder in project alfresco-remote-api by Alfresco.

the class GetMethodRegressionTest method getLastAuditRecordTime.

private Long getLastAuditRecordTime() {
    final Holder<Long> lastTime = new Holder<Long>();
    AuditQueryParameters parameters = new AuditQueryParameters();
    parameters.setForward(false);
    auditService.auditQuery(new AuditQueryCallback() {

        @Override
        public boolean valuesRequired() {
            return false;
        }

        @Override
        public boolean handleAuditEntryError(Long entryId, String errorMsg, Throwable error) {
            return false;
        }

        @Override
        public boolean handleAuditEntry(Long entryId, String applicationName, String user, long time, Map<String, Serializable> values) {
            lastTime.setValue(time);
            return false;
        }
    }, parameters, 1);
    return lastTime.getValue();
}
Also used : Serializable(java.io.Serializable) Holder(org.apache.chemistry.opencmis.commons.spi.Holder) AuditQueryParameters(org.alfresco.service.cmr.audit.AuditQueryParameters) AuditQueryCallback(org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback)

Example 4 with Holder

use of org.apache.chemistry.opencmis.commons.spi.Holder 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 5 with Holder

use of org.apache.chemistry.opencmis.commons.spi.Holder 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)

Aggregations

Holder (org.apache.chemistry.opencmis.commons.spi.Holder)9 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)8 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)8 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)8 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)7 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)1 Serializable (java.io.Serializable)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 AuditQueryParameters (org.alfresco.service.cmr.audit.AuditQueryParameters)1 AuditQueryCallback (org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback)1 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)1 Properties (org.apache.chemistry.opencmis.commons.data.Properties)1