use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class RepositoryActor method getTypeChildren.
private JSONObject getTypeChildren(QueryGetRequest request) throws IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeId = request.getParameter(QueryGetRequest.PARAM_TYPE_ID);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
boolean includePropertyDefinitions = request.getBooleanParameter(QueryGetRequest.PARAM_PROPERTY_DEFINITIONS, false);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
TypeDefinitionList typeList = CmisTypeServices.Impl.getTypeChildren(request.getRepositoryId(), typeId, includePropertyDefinitions, maxItems, skipCount, null);
JSONObject jsonTypeList = JSONConverter.convert(typeList, dateTimeFormat);
return jsonTypeList;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class RepositoryActor method createType.
private JSONObject createType(PostRequest request) throws IllegalArgumentException, CmisInvalidArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeStr = request.getParameter(QueryGetRequest.CONTROL_TYPE);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
if (typeStr == null) {
throw new CmisInvalidArgumentException("Type definition missing!");
}
// convert type definition
JSONParser parser = new JSONParser();
Object typeJson = null;
try {
typeJson = parser.parse(typeStr);
} catch (JSONParseException e) {
LOG.error("JSON Parser error: {}", ExceptionUtils.getStackTrace(e));
}
if (!(typeJson instanceof Map)) {
throw new CmisInvalidArgumentException("Invalid type definition!");
}
@SuppressWarnings("unchecked") TypeDefinition typeIn = JSONConverter.convertTypeDefinition((Map<String, Object>) typeJson);
TypeDefinition typeOut = CmisTypeServices.Impl.createType(request.getRepositoryId(), typeIn, null, request.getUserName());
JSONObject jsonType = JSONConverter.convert(typeOut, dateTimeFormat);
return jsonType;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject in project copper-cms by PogeyanOSS.
the class RepositoryActor method updateType.
private JSONObject updateType(PostRequest request) throws CmisInvalidArgumentException, IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "post")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String typeStr = request.getParameter(QueryGetRequest.CONTROL_TYPE);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
if (typeStr == null) {
throw new CmisInvalidArgumentException("Type definition missing!");
}
// convert type definition
JSONParser parser = new JSONParser();
Object typeJson = null;
try {
typeJson = parser.parse(typeStr);
} catch (JSONParseException e) {
LOG.error("JSON parse exception: {}", ExceptionUtils.getStackTrace(e));
}
if (!(typeJson instanceof Map)) {
throw new CmisInvalidArgumentException("Invalid type definition!");
}
@SuppressWarnings("unchecked") TypeDefinition typeIn = JSONConverter.convertTypeDefinition((Map<String, Object>) typeJson);
TypeDefinition typeOut = CmisTypeServices.Impl.updateType(request.getRepositoryId(), typeIn, null);
JSONObject jsonType = JSONConverter.convert(typeOut, dateTimeFormat);
return jsonType;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONObject 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;
}
Aggregations