public static JSONObject convert(RepositoryInfo repositoryInfo, String repositoryUrl, String rootUrl) {
if (repositoryInfo == null) {
return null;
}
JSONObject result = new JSONObject();
result.put(JSON_REPINFO_ID, repositoryInfo.getId());
result.put(JSON_REPINFO_NAME, repositoryInfo.getName());
result.put(JSON_REPINFO_DESCRIPTION, repositoryInfo.getDescription());
result.put(JSON_REPINFO_VENDOR, repositoryInfo.getVendorName());
result.put(JSON_REPINFO_PRODUCT, repositoryInfo.getProductName());
result.put(JSON_REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
result.put(JSON_REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
result.put(JSON_REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
setIfNotNull(JSON_REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()), result);
result.put(JSON_REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
result.put(JSON_REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
setIfNotNull(JSON_REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri(), result);
setIfNotNull(JSON_REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete(), result);
JSONArray changesOnType = new JSONArray();
if (repositoryInfo.getChangesOnType() != null) {
for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
changesOnType.add(getJSONStringValue(type.value()));
}
}
result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous(), result);
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone(), result);
result.put(JSON_REPINFO_REPOSITORY_URL, repositoryUrl);
result.put(JSON_REPINFO_ROOT_FOLDER_URL, rootUrl);
convertExtension(repositoryInfo, result);
return result;
}