use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class VersioningActor method checkOut.
private JSONObject checkOut(PostRequest request) throws CmisObjectNotFoundException, CmisUpdateConflictException, CmisNotSupportedException, 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();
Holder<String> objectsId = new Holder<String>(objectId.toString());
String pwcId = CmisVersioningServices.Impl.checkOut(request.getRepositoryId(), objectsId, null, null, request.getUserName());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), pwcId, 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;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class ServletHelpers method writeErrorInActor.
static void writeErrorInActor(CmisErrorResponse res, HttpServletRequest request, HttpServletResponse response) {
int statusCode = res.getErrorCode();
String msg = res.getError();
response.setStatus(statusCode);
JSONObject jsonResponse = new JSONObject();
jsonResponse.put(BrowserConstants.MESSAGE, msg);
try {
writeJSON(jsonResponse, request, response);
} catch (Exception e) {
try {
response.sendError(statusCode, msg);
} catch (Exception en) {
// there is nothing else we can do
}
}
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class AclActor method applyACL.
private JSONObject applyACL(PostRequest t) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = t.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
}
String aclPro = t.getAclPropagation();
String objectId = t.getObjectId();
Acl objectAcl = CmisAclServices.Impl.applyAcl(t.getRepositoryId(), objectId, t.getAddAcl(), t.getRemoveAcl(), AclPropagation.fromValue(aclPro), null, null, CapabilityAcl.NONE, t.getUserObject().getUserDN());
if (objectAcl == null) {
throw new CmisRuntimeException("object acl is null!");
}
JSONObject jsonObject = JSONConverter.convert(objectAcl);
return jsonObject;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class NavigationActor method getParent.
private JSONObject getParent(QueryGetRequest request) throws CmisInvalidArgumentException, 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.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
ObjectData parent = CmisNavigationService.Impl.getFolderParent(request.getRepositoryId(), objectId, filter, null, request.getUserObject().getUserDN());
if (parent == null) {
throw new CmisRuntimeException("Parent is null!");
}
JSONObject jsonObject = JSONConverter.convert(parent, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.OBJECT, succinct, dateTimeFormat);
return jsonObject;
}
Aggregations