You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/01/13 17:38:09 UTC
svn commit: r1432653 - in
/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl:
JSONConstants.java JSONConverter.java
Author: fmui
Date: Sun Jan 13 16:38:09 2013
New Revision: 1432653
URL: http://svn.apache.org/viewvc?rev=1432653&view=rev
Log:
CMIS 1.1: added extension features to JSON converter
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java?rev=1432653&r1=1432652&r2=1432653&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConstants.java Sun Jan 13 16:38:09 2013
@@ -50,6 +50,7 @@ public final class JSONConstants {
public static final String JSON_REPINFO_CHANGES_ON_TYPE = "changesOnType";
public static final String JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS = "principalIdAnonymous";
public static final String JSON_REPINFO_PRINCIPAL_ID_ANYONE = "principalIdAnyone";
+ public static final String JSON_REPINFO_EXTENDED_FEATURES = "extendedFeatures";
public static final Set<String> REPINFO_KEYS = new HashSet<String>();
static {
@@ -71,6 +72,7 @@ public final class JSONConstants {
REPINFO_KEYS.add(JSON_REPINFO_CHANGES_ON_TYPE);
REPINFO_KEYS.add(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS);
REPINFO_KEYS.add(JSON_REPINFO_PRINCIPAL_ID_ANYONE);
+ REPINFO_KEYS.add(JSON_REPINFO_EXTENDED_FEATURES);
}
public static final String JSON_CAP_CONTENT_STREAM_UPDATES = "capabilityContentStreamUpdatability";
@@ -178,6 +180,23 @@ public final class JSONConstants {
ACLCAP_MAPPING_KEYS.add(JSON_ACLCAP_MAPPING_PERMISSION);
}
+ public static final String JSON_FEATURE_ID = "id";
+ public static final String JSON_FEATURE_URL = "url";
+ public static final String JSON_FEATURE_COMMON_NAME = "commonName";
+ public static final String JSON_FEATURE_VERSION_LABEL = "versionLabel";
+ public static final String JSON_FEATURE_DESCRIPTION = "description";
+ public static final String JSON_FEATURE_DATA = "featureData";
+
+ public static final Set<String> FEATURE_KEYS = new HashSet<String>();
+ static {
+ FEATURE_KEYS.add(JSON_FEATURE_ID);
+ FEATURE_KEYS.add(JSON_FEATURE_URL);
+ FEATURE_KEYS.add(JSON_FEATURE_COMMON_NAME);
+ FEATURE_KEYS.add(JSON_FEATURE_VERSION_LABEL);
+ FEATURE_KEYS.add(JSON_FEATURE_DESCRIPTION);
+ FEATURE_KEYS.add(JSON_FEATURE_DATA);
+ }
+
public static final String JSON_OBJECT_PROPERTIES = "properties";
public static final String JSON_OBJECT_SUCCINCT_PROPERTIES = "succinctProperties";
public static final String JSON_OBJECT_PROPERTIES_EXTENSION = "propertiesExtension";
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java?rev=1432653&r1=1432652&r2=1432653&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java Sun Jan 13 16:38:09 2013
@@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -42,6 +43,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
import org.apache.chemistry.opencmis.commons.data.CreatablePropertyTypes;
+import org.apache.chemistry.opencmis.commons.data.ExtensionFeature;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.FailedToDeleteData;
import org.apache.chemistry.opencmis.commons.data.NewTypeSettableAttributes;
@@ -115,6 +117,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.CreatablePropertyTypesImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionFeatureImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FailedToDeleteDataImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ItemTypeDefinitionImpl;
@@ -204,6 +207,32 @@ public final class JSONConverter {
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous(), result);
setIfNotNull(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone(), result);
+ if (repositoryInfo.getExtensionFeatures() != null && !repositoryInfo.getExtensionFeatures().isEmpty()) {
+ JSONArray extendedFeatures = new JSONArray();
+
+ for (ExtensionFeature feature : repositoryInfo.getExtensionFeatures()) {
+ JSONObject jsonFeature = new JSONObject();
+
+ setIfNotNull(JSON_FEATURE_ID, feature.getId(), jsonFeature);
+ setIfNotNull(JSON_FEATURE_URL, feature.getUrl(), jsonFeature);
+ setIfNotNull(JSON_FEATURE_COMMON_NAME, feature.getCommonName(), jsonFeature);
+ setIfNotNull(JSON_FEATURE_VERSION_LABEL, feature.getVersionLabel(), jsonFeature);
+ setIfNotNull(JSON_FEATURE_DESCRIPTION, feature.getDescription(), jsonFeature);
+
+ if (feature.getFeatureData() != null && !feature.getFeatureData().isEmpty()) {
+ JSONObject data = new JSONObject();
+ data.putAll(feature.getFeatureData());
+ jsonFeature.put(JSON_FEATURE_DATA, data);
+ }
+
+ convertExtension(feature, jsonFeature);
+
+ extendedFeatures.add(jsonFeature);
+ }
+
+ result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
+ }
+
result.put(JSON_REPINFO_REPOSITORY_URL, repositoryUrl);
result.put(JSON_REPINFO_ROOT_FOLDER_URL, rootUrl);
@@ -390,6 +419,42 @@ public final class JSONConverter {
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);