public static RepositoryInfo convertRepositoryInfo(final Map<String, Object> json) {
if (json == null) {
return null;
}
RepositoryInfoBrowserBindingImpl result = new RepositoryInfoBrowserBindingImpl();
result.setId(getString(json, JSON_REPINFO_ID));
result.setName(getString(json, JSON_REPINFO_NAME));
result.setDescription(getString(json, JSON_REPINFO_DESCRIPTION));
result.setVendorName(getString(json, JSON_REPINFO_VENDOR));
result.setProductName(getString(json, JSON_REPINFO_PRODUCT));
result.setProductVersion(getString(json, JSON_REPINFO_PRODUCT_VERSION));
result.setRootFolder(getString(json, JSON_REPINFO_ROOT_FOLDER_ID));
result.setRepositoryUrl(getString(json, JSON_REPINFO_REPOSITORY_URL));
result.setRootUrl(getString(json, JSON_REPINFO_ROOT_FOLDER_URL));
result.setCapabilities(convertRepositoryCapabilities(getMap(json.get(JSON_REPINFO_CAPABILITIES))));
result.setAclCapabilities(convertAclCapabilities(getMap(json.get(JSON_REPINFO_ACL_CAPABILITIES))));
result.setLatestChangeLogToken(getString(json, JSON_REPINFO_CHANGE_LOCK_TOKEN));
result.setCmisVersionSupported(getString(json, JSON_REPINFO_CMIS_VERSION_SUPPORTED));
result.setThinClientUri(getString(json, JSON_REPINFO_THIN_CLIENT_URI));
result.setChangesIncomplete(getBoolean(json, JSON_REPINFO_CHANGES_INCOMPLETE));
List<Object> changesOnType = getList(json.get(JSON_REPINFO_CHANGES_ON_TYPE));
List<BaseTypeId> types = new ArrayList<BaseTypeId>();
if (changesOnType != null) {
for (Object type : changesOnType) {
if (type != null) {
types.add(BaseTypeId.fromValue(type.toString()));
}
}
}
result.setChangesOnType(types);
result.setPrincipalAnonymous(getString(json, JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS));
result.setPrincipalAnyone(getString(json, JSON_REPINFO_PRINCIPAL_ID_ANYONE));
List<Object> extendedFeatures = getList(json.get(JSON_REPINFO_EXTENDED_FEATURES));
if (extendedFeatures != null) {
List<ExtensionFeature> features = new ArrayList<ExtensionFeature>();
for (Object extendedFeature : extendedFeatures) {
Map<String, Object> jsonFeature = getMap(extendedFeature);
ExtensionFeatureImpl feature = new ExtensionFeatureImpl();
feature.setId(getString(jsonFeature, JSON_FEATURE_ID));
feature.setUrl(getString(jsonFeature, JSON_FEATURE_URL));
feature.setCommonName(getString(jsonFeature, JSON_FEATURE_COMMON_NAME));
feature.setVersionLabel(getString(jsonFeature, JSON_FEATURE_VERSION_LABEL));
feature.setDescription(getString(jsonFeature, JSON_FEATURE_DESCRIPTION));
Map<String, Object> data = getMap(jsonFeature.get(JSON_FEATURE_DATA));
if (data != null) {
LinkedHashMap<String, String> dataMap = new LinkedHashMap<String, String>();
for (Map.Entry<String, Object> e : data.entrySet()) {
dataMap.put(e.getKey(), (e.getValue() == null ? null : e.getValue().toString()));
}
if (!dataMap.isEmpty()) {
feature.setFeatureData(dataMap);
}
}
convertExtension(jsonFeature, feature, FEATURE_KEYS);
features.add(feature);
}
if (!features.isEmpty()) {
result.setExtensionFeature(features);
}
}
// handle extensions
convertExtension(json, result, REPINFO_KEYS);