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 2014/06/17 16:00:30 UTC

svn commit: r1603174 - in /chemistry/opencmis/trunk: chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chem...

Author: fmui
Date: Tue Jun 17 14:00:29 2014
New Revision: 1603174

URL: http://svn.apache.org/r1603174
Log:
CMIS-815: added ExtensionFeature to repository info

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java   (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/RepositoryInfoConverterTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java?rev=1603174&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java Tue Jun 17 14:00:29 2014
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.commons;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.ExtensionFeature;
+
+public final class ExtensionFeatures {
+
+    public static final ExtensionFeature EXTENDED_DATETIME_FORMAT = new ExtensionFeature() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String getId() {
+            return "http://docs.oasis-open.org/ns/cmis/extension/datetimeformat";
+        }
+
+        @Override
+        public String getUrl() {
+            return "https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis";
+        }
+
+        @Override
+        public String getCommonName() {
+            return "Browser Binding DateTime Format";
+        }
+
+        @Override
+        public String getVersionLabel() {
+            return "1.0";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Adds an additional DateTime format for the Browser Binding.";
+        }
+
+        @Override
+        public Map<String, String> getFeatureData() {
+            return null;
+        }
+
+        @Override
+        public void setExtensions(List<CmisExtensionElement> extensions) {
+        }
+
+        @Override
+        public List<CmisExtensionElement> getExtensions() {
+            return null;
+        }
+    };
+
+    public static final ExtensionFeature CONTENT_STREAM_HASH = new ExtensionFeature() {
+        private static final long serialVersionUID = 1L;
+
+        @Override
+        public String getId() {
+            return "http://docs.oasis-open.org/ns/cmis/extension/contentstreamhash";
+        }
+
+        @Override
+        public String getUrl() {
+            return "https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=cmis";
+        }
+
+        @Override
+        public String getCommonName() {
+            return "Content Stream Hash";
+        }
+
+        @Override
+        public String getVersionLabel() {
+            return "1.0";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Adds the property cmis:contentStreamHash, which represents the hash of the document content.";
+        }
+
+        @Override
+        public Map<String, String> getFeatureData() {
+            return null;
+        }
+
+        @Override
+        public void setExtensions(List<CmisExtensionElement> extensions) {
+        }
+
+        @Override
+        public List<CmisExtensionElement> getExtensions() {
+            return null;
+        }
+    };
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/ExtensionFeatures.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1603174&r1=1603173&r2=1603174&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 Tue Jun 17 14:00:29 2014
@@ -34,6 +34,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
 
+import org.apache.chemistry.opencmis.commons.ExtensionFeatures;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.data.Ace;
 import org.apache.chemistry.opencmis.commons.data.Acl;
@@ -187,7 +188,7 @@ public final class JSONConverter {
      * Converts a repository info object.
      */
     public static JSONObject convert(final RepositoryInfo repositoryInfo, final String repositoryUrl,
-            final String rootUrl) {
+            final String rootUrl, final boolean addExtendedDatetimeExtensionFeature) {
         if (repositoryInfo == null) {
             return null;
         }
@@ -225,26 +226,20 @@ public final class JSONConverter {
             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);
-                }
+                extendedFeatures.add(convert(feature));
+            }
 
-                convertExtension(feature, jsonFeature);
+            result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
+        }
 
-                extendedFeatures.add(jsonFeature);
+        if (addExtendedDatetimeExtensionFeature) {
+            JSONArray extendedFeatures = (JSONArray) result.get(JSON_REPINFO_EXTENDED_FEATURES);
+            if (extendedFeatures == null) {
+                extendedFeatures = new JSONArray();
+                result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
             }
 
-            result.put(JSON_REPINFO_EXTENDED_FEATURES, extendedFeatures);
+            extendedFeatures.add(convert(ExtensionFeatures.EXTENDED_DATETIME_FORMAT));
         }
 
         result.put(JSON_REPINFO_REPOSITORY_URL, repositoryUrl);
@@ -255,6 +250,30 @@ public final class JSONConverter {
         return result;
     }
 
+    private static JSONObject convert(final ExtensionFeature feature) {
+        if (feature == null) {
+            return null;
+        }
+
+        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);
+
+        return jsonFeature;
+    }
+
     /**
      * Converts a capabilities object.
      */

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/RepositoryInfoConverterTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/RepositoryInfoConverterTest.java?rev=1603174&r1=1603173&r2=1603174&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/RepositoryInfoConverterTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/xml/RepositoryInfoConverterTest.java Tue Jun 17 14:00:29 2014
@@ -299,7 +299,7 @@ public class RepositoryInfoConverterTest
     protected void assertJsonRepositoryInfo11(RepositoryInfo repInfo) throws Exception {
         StringWriter sw = new StringWriter();
 
-        JSONConverter.convert(repInfo, null, null).writeJSONString(sw);
+        JSONConverter.convert(repInfo, null, null, false).writeJSONString(sw);
 
         Object json = (new JSONParser()).parse(sw.toString());
         assertTrue(json instanceof Map<?, ?>);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java?rev=1603174&r1=1603173&r2=1603174&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/RepositoryService.java Tue Jun 17 14:00:29 2014
@@ -76,7 +76,7 @@ public class RepositoryService {
                 String repositoryUrl = compileRepositoryUrl(request, ri.getId()).toString();
                 String rootUrl = compileRootUrl(request, ri.getId()).toString();
 
-                result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl));
+                result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl, true));
             }
 
             response.setStatus(HttpServletResponse.SC_OK);
@@ -103,7 +103,7 @@ public class RepositoryService {
             String rootUrl = compileRootUrl(request, ri.getId()).toString();
 
             JSONObject result = new JSONObject();
-            result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl));
+            result.put(ri.getId(), JSONConverter.convert(ri, repositoryUrl, rootUrl, true));
 
             response.setStatus(HttpServletResponse.SC_OK);
             writeJSON(result, request, response);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java?rev=1603174&r1=1603173&r2=1603174&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/RepositoryInfoFrame.java Tue Jun 17 14:00:29 2014
@@ -20,6 +20,7 @@ package org.apache.chemistry.opencmis.wo
 
 import java.awt.Dimension;
 import java.util.List;
+import java.util.Map;
 
 import javax.swing.JFrame;
 import javax.swing.JScrollPane;
@@ -31,6 +32,7 @@ import javax.swing.tree.TreeSelectionMod
 
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.ExtensionFeature;
 import org.apache.chemistry.opencmis.commons.data.PermissionMapping;
 import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
@@ -245,6 +247,53 @@ public class RepositoryInfoFrame extends
                 }
             }
 
+            if (repInfo.getExtensionFeatures() != null && !repInfo.getExtensionFeatures().isEmpty()) {
+                JTree extensionFeaturesTree = new JTree();
+                extensionFeaturesTree.setRootVisible(false);
+                extensionFeaturesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+                DefaultMutableTreeNode extFeatRootNode = new DefaultMutableTreeNode("Extensions");
+
+                for (ExtensionFeature ef : repInfo.getExtensionFeatures()) {
+                    String efId = ef.getId();
+                    if (efId == null) {
+                        efId = "???";
+                    }
+
+                    DefaultMutableTreeNode efNode = new DefaultMutableTreeNode(efId);
+                    extFeatRootNode.add(efNode);
+
+                    if (ef.getCommonName() != null) {
+                        efNode.add(new DefaultMutableTreeNode("Common Name: " + ef.getCommonName()));
+                    }
+
+                    if (ef.getVersionLabel() != null) {
+                        efNode.add(new DefaultMutableTreeNode("Version Label: " + ef.getVersionLabel()));
+                    }
+
+                    if (ef.getDescription() != null) {
+                        efNode.add(new DefaultMutableTreeNode("Description: " + ef.getDescription()));
+                    }
+
+                    if (ef.getUrl() != null) {
+                        efNode.add(new DefaultMutableTreeNode("URL: " + ef.getUrl()));
+                    }
+
+                    if (ef.getFeatureData() != null && !ef.getFeatureData().isEmpty()) {
+                        DefaultMutableTreeNode dataNode = new DefaultMutableTreeNode("Feature Data");
+                        efNode.add(dataNode);
+
+                        for (Map.Entry<String, String> e : ef.getFeatureData().entrySet()) {
+                            dataNode.add(new DefaultMutableTreeNode(e.getKey() + ": " + e.getValue()));
+                        }
+                    }
+                }
+
+                extensionFeaturesTree.setModel(new DefaultTreeModel(extFeatRootNode));
+
+                addComponent("Extension Features:", new JScrollPane(extensionFeaturesTree));
+            }
+
             if (repInfo.getExtensions() != null && !repInfo.getExtensions().isEmpty()) {
                 JTree extensionsTree = new JTree();
                 extensionsTree.setRootVisible(false);