public static JSONObject convert(final RepositoryCapabilities capabilities) {
if (capabilities == null) {
return null;
}
JSONObject result = new JSONObject();
result.put(JSON_CAP_CONTENT_STREAM_UPDATABILITY,
getJSONEnumValue(capabilities.getContentStreamUpdatesCapability()));
result.put(JSON_CAP_CHANGES, getJSONEnumValue(capabilities.getChangesCapability()));
result.put(JSON_CAP_RENDITIONS, getJSONEnumValue(capabilities.getRenditionsCapability()));
result.put(JSON_CAP_GET_DESCENDANTS, capabilities.isGetDescendantsSupported());
result.put(JSON_CAP_GET_FOLDER_TREE, capabilities.isGetFolderTreeSupported());
result.put(JSON_CAP_MULTIFILING, capabilities.isMultifilingSupported());
result.put(JSON_CAP_UNFILING, capabilities.isUnfilingSupported());
result.put(JSON_CAP_VERSION_SPECIFIC_FILING, capabilities.isVersionSpecificFilingSupported());
result.put(JSON_CAP_PWC_SEARCHABLE, capabilities.isPwcSearchableSupported());
result.put(JSON_CAP_PWC_UPDATABLE, capabilities.isPwcUpdatableSupported());
result.put(JSON_CAP_ALL_VERSIONS_SEARCHABLE, capabilities.isAllVersionsSearchableSupported());
result.put(JSON_CAP_ORDER_BY, getJSONEnumValue(capabilities.getOrderByCapability()));
result.put(JSON_CAP_QUERY, getJSONEnumValue(capabilities.getQueryCapability()));
result.put(JSON_CAP_JOIN, getJSONEnumValue(capabilities.getJoinCapability()));
result.put(JSON_CAP_ACL, getJSONEnumValue(capabilities.getAclCapability()));
if (capabilities.getCreatablePropertyTypes() != null) {
CreatablePropertyTypes creatablePropertyTypes = capabilities.getCreatablePropertyTypes();
JSONObject creatablePropertyTypesJson = new JSONObject();
if (creatablePropertyTypes.canCreate() != null) {
JSONArray canCreate = new JSONArray();
for (PropertyType propType : creatablePropertyTypes.canCreate()) {
if (propType != null) {
canCreate.add(propType.value());
}
}
creatablePropertyTypesJson.put(JSON_CAP_CREATABLE_PROPERTY_TYPES_CANCREATE, canCreate);
}
convertExtension(creatablePropertyTypes, creatablePropertyTypesJson);
result.put(JSON_CAP_CREATABLE_PROPERTY_TYPES, creatablePropertyTypesJson);
}
if (capabilities.getNewTypeSettableAttributes() != null) {
NewTypeSettableAttributes newTypeSettableAttributes = capabilities.getNewTypeSettableAttributes();
JSONObject newTypeSettableAttributesJson = new JSONObject();
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_ID,
newTypeSettableAttributes.canSetId());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAME,
newTypeSettableAttributes.canSetLocalName());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_LOCALNAMESPACE,
newTypeSettableAttributes.canSetLocalNamespace());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DISPLAYNAME,
newTypeSettableAttributes.canSetDisplayName());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYNAME,
newTypeSettableAttributes.canSetQueryName());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_DESCRIPTION,
newTypeSettableAttributes.canSetDescription());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CREATEABLE,
newTypeSettableAttributes.canSetCreatable());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FILEABLE,
newTypeSettableAttributes.canSetFileable());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_QUERYABLE,
newTypeSettableAttributes.canSetQueryable());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_FULLTEXTINDEXED,
newTypeSettableAttributes.canSetFulltextIndexed());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_INCLUDEDINSUPERTYTPEQUERY,
newTypeSettableAttributes.canSetIncludedInSupertypeQuery());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEPOLICY,
newTypeSettableAttributes.canSetControllablePolicy());
newTypeSettableAttributesJson.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES_CONTROLABLEACL,
newTypeSettableAttributes.canSetControllableAcl());
convertExtension(newTypeSettableAttributes, newTypeSettableAttributesJson);
result.put(JSON_CAP_NEW_TYPE_SETTABLE_ATTRIBUTES, newTypeSettableAttributesJson);