use of org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser 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.parser.JSONParser 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;
}
Aggregations