use of org.apache.chemistry.opencmis.commons.impl.json.JSONArray in project copper-cms by PogeyanOSS.
the class NavigationActor method getDescendants.
private JSONArray getDescendants(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 folderId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
BigInteger depth = request.getBigIntegerParameter(QueryGetRequest.PARAM_DEPTH);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
includeAllowableActions = includeAllowableActions == null ? false : includeAllowableActions;
IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
List<ObjectInFolderContainer> descendants = CmisNavigationService.Impl.getDescendants(request.getRepositoryId(), folderId, depth, filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, null, request.getUserObject());
if (descendants == null) {
throw new CmisRuntimeException("Descendants are null!");
}
JSONArray jsonDescendants = new JSONArray();
for (ObjectInFolderContainer descendant : descendants) {
jsonDescendants.add(JSONConverter.convert(descendant, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
}
return jsonDescendants;
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONArray in project copper-cms by PogeyanOSS.
the class JsonReport method printGroupResults.
private void printGroupResults(CmisTestGroup group, JSONArray jsonGroups) throws IOException {
if (!group.isEnabled()) {
return;
}
JSONObject jsonGroup = new JSONObject();
jsonGroups.add(jsonGroup);
jsonGroup.put("name", group.getName());
if (group.getTests() != null && !group.getTests().isEmpty()) {
JSONArray jsonTests = new JSONArray();
jsonGroup.put("tests", jsonTests);
for (CmisTest test : group.getTests()) {
printTestResults(test, jsonTests);
}
}
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONArray in project copper-cms by PogeyanOSS.
the class JsonReport method printTestResults.
private void printTestResults(CmisTest test, JSONArray jsonTests) throws IOException {
if (!test.isEnabled()) {
return;
}
JSONObject jsonTest = new JSONObject();
jsonTests.add(jsonTest);
jsonTest.put("name", test.getName());
jsonTest.put("time", test.getTime());
if (test.getResults() != null && !test.getResults().isEmpty()) {
JSONArray jsonResults = new JSONArray();
jsonTest.put("results", jsonResults);
for (CmisTestResult result : test.getResults()) {
printResult(result, jsonResults);
}
}
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONArray in project copper-cms by PogeyanOSS.
the class JsonReport method printResult.
private void printResult(CmisTestResult result, JSONArray results) throws IOException {
JSONObject jsonResult = new JSONObject();
results.add(jsonResult);
jsonResult.put("status", result.getStatus().toString());
jsonResult.put("message", result.getMessage());
if (result.getStackTrace() != null && result.getStackTrace().length > 0) {
jsonResult.put("file", result.getStackTrace()[0].getFileName() + ":" + result.getStackTrace()[0].getLineNumber());
}
if (result.getStatus() == CmisTestResultStatus.UNEXPECTED_EXCEPTION && result.getException() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
result.getException().printStackTrace(pw);
jsonResult.put("stacktrace", sw.toString());
if (result.getException() instanceof CmisBaseException) {
CmisBaseException cbe = (CmisBaseException) result.getException();
if (cbe.getErrorContent() != null) {
jsonResult.put("errorcontent", cbe.getErrorContent());
}
}
}
if (result.getException() != null) {
jsonResult.put("exception", result.getException().getMessage());
}
if (result.getRequest() != null) {
jsonResult.put("request", result.getRequest());
}
if (result.getRequest() != null) {
jsonResult.put("response", result.getResponse());
}
if (!result.getChildren().isEmpty()) {
JSONArray nextLevel = new JSONArray();
jsonResult.put("results", nextLevel);
for (CmisTestResult child : result.getChildren()) {
printResult(child, nextLevel);
}
}
}
use of org.apache.chemistry.opencmis.commons.impl.json.JSONArray in project copper-cms by PogeyanOSS.
the class JsonReport method createReport.
@Override
public void createReport(Map<String, String> parameters, List<CmisTestGroup> groups, Writer writer) throws IOException {
JSONObject jsonReport = new JSONObject();
JSONObject jsonParameters = new JSONObject();
jsonReport.put("parameters", jsonParameters);
if (parameters != null) {
for (Map.Entry<String, String> p : (new TreeMap<String, String>(parameters)).entrySet()) {
jsonParameters.put(p.getKey(), p.getValue());
}
}
if (groups != null) {
JSONArray jsonGroups = new JSONArray();
jsonReport.put("groups", jsonGroups);
for (CmisTestGroup group : groups) {
printGroupResults(group, jsonGroups);
}
}
jsonReport.writeJSONString(writer);
writer.flush();
}
Aggregations