use of org.apache.chemistry.opencmis.commons.impl.ReturnVersion in project copper-cms by PogeyanOSS.
the class ObjectActor method getProperties.
private JSONObject getProperties(QueryGetRequest t) throws CmisInvalidArgumentException, IllegalArgumentException, CmisRuntimeException {
String permission = t.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
}
String objectId = t.getObjectId();
ReturnVersion returnVersion = t.getEnumParameter(QueryGetRequest.PARAM_RETURN_VERSION, ReturnVersion.class);
String filter = t.getParameter(QueryGetRequest.PARAM_FILTER);
boolean succinct = t.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = t.getDateTimeFormatParameter();
LOG.info("getObject->ObjectID{}", objectId);
if (returnVersion == ReturnVersion.LATEST || returnVersion == ReturnVersion.LASTESTMAJOR) {
// TODO: implement version
return null;
} else {
ObjectData object = CmisObjectService.Impl.getObject(t.getRepositoryId(), objectId, filter, true, IncludeRelationships.NONE, "cmis:none", false, false, null, t.getUserObject().getUserDN(), t.getBaseTypeId());
Properties properties = object.getProperties();
if (properties == null) {
throw new CmisRuntimeException("Properties are null!");
}
JSONObject result = JSONConverter.convert(properties, objectId.toString(), CmisTypeCacheService.get(t.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return result;
}
}
use of org.apache.chemistry.opencmis.commons.impl.ReturnVersion in project copper-cms by PogeyanOSS.
the class ObjectActor method getObject.
private JSONObject getObject(QueryGetRequest t) throws CmisInvalidArgumentException, IllegalArgumentException, CmisRuntimeException, CmisObjectNotFoundException {
String permission = t.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
}
String objectId = t.getObjectId();
boolean acessPermission = false;
IBaseObject data = DBUtils.BaseDAO.getByObjectId(t.getRepositoryId(), objectId, null);
acessPermission = CmisObjectService.Impl.getAclAccess(t.getRepositoryId(), data, t.getUserObject());
if (data != null && !data.getName().equals(ROOT) && acessPermission == false) {
throw new CmisInvalidArgumentException("{} does not have valid acces control permission to access this object", t.getUserName());
}
ReturnVersion returnVersion = t.getEnumParameter(QueryGetRequest.PARAM_RETURN_VERSION, ReturnVersion.class);
String filter = t.getParameter(QueryGetRequest.PARAM_FILTER);
Boolean includeAllowableActions = t.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
IncludeRelationships includeRelationships = t.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = t.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includePolicyIds = t.getBooleanParameter(QueryGetRequest.PARAM_POLICY_IDS);
Boolean includeAcl = t.getBooleanParameter(QueryGetRequest.PARAM_ACL);
boolean succinct = t.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = t.getDateTimeFormatParameter();
ObjectData object = null;
if (returnVersion == ReturnVersion.LATEST || returnVersion == ReturnVersion.LASTESTMAJOR) {
object = CmisVersioningServices.Impl.getObjectOfLatestVersion(t.getRepositoryId(), objectId, null, returnVersion == ReturnVersion.LASTESTMAJOR, filter, includeAllowableActions, null, includePolicyIds, includeAcl, null, null, t.getUserObject().getUserDN());
} else {
object = CmisObjectService.Impl.getObject(t.getRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, null, t.getUserObject().getUserDN(), t.getBaseTypeId());
}
JSONObject result = JSONConverter.convert(object, CmisTypeCacheService.get(t.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return result;
}
Aggregations