public static JSONObject convert(RepositoryInfo repositoryInfo, HttpServletRequest request) {
if (repositoryInfo == null) {
return null;
}
JSONObject result = new JSONObject();
result.put(REPINFO_ID, repositoryInfo.getId());
result.put(REPINFO_NAME, repositoryInfo.getName());
result.put(REPINFO_DESCRIPTION, repositoryInfo.getDescription());
result.put(REPINFO_VENDOR, repositoryInfo.getVendorName());
result.put(REPINFO_PRODUCT, repositoryInfo.getProductName());
result.put(REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
result.put(REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
result.put(REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
result.put(REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()));
result.put(REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
result.put(REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
result.put(REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri());
result.put(REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete());
if (repositoryInfo.getChangesOnType() != null) {
JSONArray changesOnType = new JSONArray();
for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
changesOnType.add(getJSONStringValue(type));
}
result.put(REPINFO_CHANGES_ON_TYPE, changesOnType);
}
result.put(REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
result.put(REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
result.put(REPINFO_REPOSITORY_URL, BrowserBindingUtils.compileRepositoryUrl(request, repositoryInfo.getId())
.toString());
result.put(REPINFO_ROOT_FOLDER_URL, BrowserBindingUtils.compileRootUrl(request, repositoryInfo.getId())
.toString());
return result;
}