Search in sources :

Example 11 with Properties

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

the class VersioningActor method getPropertiesOfLatestVersion.

private JSONObject getPropertiesOfLatestVersion(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.");
    }
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    String objectId = request.getObjectId();
    String versionSeriesId = request.getParameter(QueryGetRequest.PARAM_VERSION_SERIES_ID);
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    Boolean major = request.getBooleanParameter(QueryGetRequest.PARAM_MAJOR);
    String userName = request.getUserName();
    Properties properties = CmisVersioningServices.Impl.getPropertiesOfLatestVersion(request.getRepositoryId(), objectId, versionSeriesId, major, filter, null, userName);
    if (properties == null) {
        throw new CmisRuntimeException("properties is not present!");
    }
    JSONObject jsonObject = JSONConverter.convert(properties, objectId, 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) Properties(org.apache.chemistry.opencmis.commons.data.Properties) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 12 with Properties

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

the class ServletHelpers method getStringPropertyValue.

/**
 * Extracts a property from an object.
 */
static String getStringPropertyValue(ObjectData object, String name) {
    if (object == null) {
        return null;
    }
    Properties propData = object.getProperties();
    if (propData == null) {
        return null;
    }
    Map<String, PropertyData<?>> properties = propData.getProperties();
    if (properties == null) {
        return null;
    }
    PropertyData<?> property = properties.get(name);
    if (property == null) {
        return null;
    }
    Object value = property.getFirstValue();
    if (!(value instanceof String)) {
        return null;
    }
    return (String) value;
}
Also used : PropertyData(org.apache.chemistry.opencmis.commons.data.PropertyData) IUserObject(com.pogeyan.cmis.api.auth.IUserObject) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) Properties(org.apache.chemistry.opencmis.commons.data.Properties)

Aggregations

Properties (org.apache.chemistry.opencmis.commons.data.Properties)12 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)10 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)10 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)9 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)8 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 Acl (org.apache.chemistry.opencmis.commons.data.Acl)6 ArrayList (java.util.ArrayList)2 PropertyData (org.apache.chemistry.opencmis.commons.data.PropertyData)2 VersioningState (org.apache.chemistry.opencmis.commons.enums.VersioningState)2 IUserObject (com.pogeyan.cmis.api.auth.IUserObject)1 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CMISNodeInfoImpl (org.alfresco.opencmis.CMISNodeInfoImpl)1 BulkUpdateObjectIdAndChangeToken (org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken)1 CmisExtensionElement (org.apache.chemistry.opencmis.commons.data.CmisExtensionElement)1 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)1 ReturnVersion (org.apache.chemistry.opencmis.commons.impl.ReturnVersion)1 BulkUpdateObjectIdAndChangeTokenImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl)1