chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1225607 [1/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-client/chemistry-opencmis-client-binding...
Date Thu, 29 Dec 2011 17:57:30 GMT
Author: fmui
Date: Thu Dec 29 17:57:29 2011
New Revision: 1225607

URL: http://svn.apache.org/viewvc?rev=1225607&view=rev
Log:
More browser binding code

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryInfoBrowserBindingImpl.java   (with props)
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryUrlCache.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java
    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
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AclCapabilitiesDataImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AbstractAtomPubService.java Thu Dec 29 17:57:29 2011
@@ -235,7 +235,7 @@ public abstract class AbstractAtomPubSer
         case 3:
             throw new CmisNotSupportedException("No link with matching media type!");
         case 4:
-            throw new CmisRuntimeException("Nothing wrong! Either this is a bug or threading issue.");
+            throw new CmisRuntimeException("Nothing wrong! Either this is a bug or a threading issue.");
         default:
             throw new CmisRuntimeException("Unknown error!");
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java Thu Dec 29 17:57:29 2011
@@ -21,14 +21,16 @@ package org.apache.chemistry.opencmis.cl
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.client.bindings.spi.LinkAccess;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpUtils;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
@@ -50,8 +52,9 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.impl.JSONConstants;
 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
-import org.json.simple.JSONArray;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoBrowserBindingImpl;
 import org.json.simple.JSONObject;
+import org.json.simple.parser.ContainerFactory;
 import org.json.simple.parser.JSONParser;
 
 /**
@@ -59,6 +62,18 @@ import org.json.simple.parser.JSONParser
  */
 public abstract class AbstractBrowserBindingService implements LinkAccess {
 
+    protected static final ContainerFactory SIMPLE_CONTAINER_FACTORY = new ContainerFactory() {
+        @SuppressWarnings("rawtypes")
+        public Map createObjectContainer() {
+            return new LinkedHashMap();
+        }
+
+        @SuppressWarnings("rawtypes")
+        public List creatArrayContainer() {
+            return new ArrayList();
+        }
+    };
+
     private BindingSession session;
 
     /**
@@ -78,7 +93,7 @@ public abstract class AbstractBrowserBin
     /**
      * Returns the service URL of this session.
      */
-    protected String getServiceURL() {
+    protected String getServiceUrl() {
         Object url = session.get(SessionParameter.BROWSER_URL);
         if (url instanceof String) {
             return (String) url;
@@ -87,6 +102,21 @@ public abstract class AbstractBrowserBin
         return null;
     }
 
+    protected UrlBuilder getRepositoryUrl(String repositoryId, String selector) {
+        UrlBuilder result = getRepositoryUrlCache().getRepositoryUrl(repositoryId, selector);
+
+        if (result == null) {
+            getRepositoriesInternal(repositoryId);
+            result = getRepositoryUrlCache().getRepositoryUrl(repositoryId, selector);
+        }
+
+        if (result == null) {
+            throw new CmisObjectNotFoundException("Unknown repository!");
+        }
+
+        return result;
+    }
+
     // ---- exceptions ----
 
     /**
@@ -164,16 +194,44 @@ public abstract class AbstractBrowserBin
     /**
      * Parses an input stream.
      */
-    protected Object parse(InputStream stream, String charset) {
+    @SuppressWarnings("unchecked")
+    protected Map<String, Object> parse(InputStream stream, String charset) {
+        Object obj = parse(stream, charset, SIMPLE_CONTAINER_FACTORY);
+
+        if (obj instanceof Map) {
+            return (Map<String, Object>) obj;
+        }
+
+        throw new CmisConnectionException("Unexpected object!");
+    }
+
+    /**
+     * Parses an input stream.
+     */
+    protected Object parse(InputStream stream, String charset, ContainerFactory containerFactory) {
+
+        InputStreamReader reader = null;
+
         Object obj = null;
         try {
+            reader = new InputStreamReader(stream, charset);
             JSONParser parser = new JSONParser();
-            obj = parser.parse(new InputStreamReader(stream, charset));
+            obj = parser.parse(reader, containerFactory);
         } catch (Exception e) {
             throw new CmisConnectionException("Parsing exception!", e);
         } finally {
             try {
-                stream.close();
+                char[] buffer = new char[4096];
+                while (reader.read(buffer) > -1) {
+                }
+            } catch (Exception e) {
+            }
+            try {
+                if (reader == null) {
+                    stream.close();
+                } else {
+                    reader.close();
+                }
             } catch (Exception e) {
             }
         }
@@ -219,7 +277,7 @@ public abstract class AbstractBrowserBin
      * Returns the repository URL cache or creates a new cache if it doesn't
      * exist.
      */
-    protected RepositoryUrlCache geRepositoryUrlCache() {
+    protected RepositoryUrlCache getRepositoryUrlCache() {
         RepositoryUrlCache repositoryUrlCache = (RepositoryUrlCache) getSession().get(
                 SpiSessionParameter.REPOSITORY_URL_CACHE);
         if (repositoryUrlCache == null) {
@@ -234,32 +292,68 @@ public abstract class AbstractBrowserBin
      * Retrieves the the repository info objects.
      */
     protected List<RepositoryInfo> getRepositoriesInternal(String repositoryId) {
-        // retrieve service doc
-        UrlBuilder url = new UrlBuilder(getServiceURL());
-        url.addParameter(Constants.PARAM_REPOSITORY_ID, repositoryId);
+
+        UrlBuilder url = null;
+
+        if (repositoryId == null) {
+            // no repository id provided -> get all
+            url = new UrlBuilder(getServiceUrl());
+        } else {
+            // use URL of the specified repository
+            url = getRepositoryUrlCache().getRepositoryUrl(repositoryId, Constants.SELECTOR_REPOSITORY_INFO);
+            if (url == null) {
+                // repository infos haven't been fetched yet -> get them all
+                url = new UrlBuilder(getServiceUrl());
+            }
+        }
 
         // read and parse
         HttpUtils.Response resp = read(url);
+        Map<String, Object> json = parse(resp.getStream(), resp.getCharset());
 
-        Object json = parse(resp.getStream(), resp.getCharset());
+        List<RepositoryInfo> repInfos = new ArrayList<RepositoryInfo>();
 
-        if (json instanceof JSONObject) {
-            return Collections.singletonList(JSONConverter.convertRepositoryInfo((JSONObject) json));
-        }
+        for (Object jri : json.values()) {
+            if (jri instanceof Map) {
+                @SuppressWarnings("unchecked")
+                RepositoryInfo ri = JSONConverter.convertRepositoryInfo((Map<String, Object>) jri);
+                String id = ri.getId();
 
-        if (json instanceof JSONArray) {
-            List<RepositoryInfo> repInfos = new ArrayList<RepositoryInfo>();
+                if (ri instanceof RepositoryInfoBrowserBindingImpl) {
+                    String repositoryUrl = ((RepositoryInfoBrowserBindingImpl) ri).getRepositoryUrl();
+                    String rootUrl = ((RepositoryInfoBrowserBindingImpl) ri).getRootUrl();
 
-            for (Object ri : ((JSONArray) json)) {
-                if (ri instanceof JSONObject) {
-                    repInfos.add(JSONConverter.convertRepositoryInfo((JSONObject) json));
+                    if (id == null || repositoryUrl == null || rootUrl == null) {
+                        throw new CmisConnectionException("Found invalid Repository Info! (id: " + id + ")");
+                    }
+
+                    getRepositoryUrlCache().addRepository(id, repositoryUrl, rootUrl);
                 }
-            }
 
-            return repInfos;
+                if (repositoryId == null || repositoryId.equals(id)) {
+                    repInfos.add(ri);
+                }
+            } else {
+                throw new CmisConnectionException("Found invalid Repository Info!");
+            }
         }
 
-        throw new CmisConnectionException("Repository Infos could not be read!");
+        return repInfos;
+    }
+
+    /**
+     * Retrieves a type definition.
+     */
+    protected TypeDefinition getTypeDefinitionInternal(String repositoryId, String typeId) {
+        // build URL
+        UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_TYPE_DEFINITION);
+        url.addParameter(Constants.PARAM_TYPE_ID, typeId);
+
+        // read and parse
+        HttpUtils.Response resp = read(url);
+        Map<String, Object> json = parse(resp.getStream(), resp.getCharset());
+
+        return JSONConverter.convertTypeDefinition(json);
     }
 
     // ---- LinkAccess interface ----
@@ -270,7 +364,7 @@ public abstract class AbstractBrowserBin
     }
 
     public String loadContentLink(String repositoryId, String documentId) {
-        UrlBuilder result = geRepositoryUrlCache().getObjectUrl(repositoryId, documentId, Constants.SELECTOR_CONTENT);
+        UrlBuilder result = getRepositoryUrlCache().getObjectUrl(repositoryId, documentId, Constants.SELECTOR_CONTENT);
         return result == null ? null : result.toString();
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryServiceImpl.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryServiceImpl.java Thu Dec 29 17:57:29 2011
@@ -63,6 +63,10 @@ public class RepositoryServiceImpl exten
         throw new CmisObjectNotFoundException("Repository not found!");
     }
 
+    public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
+        return getTypeDefinitionInternal(repositoryId, typeId);
+    }
+
     public TypeDefinitionList getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions,
             BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
         // TODO Auto-generated method stub
@@ -74,9 +78,4 @@ public class RepositoryServiceImpl exten
         // TODO Auto-generated method stub
         return null;
     }
-
-    public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) {
-        // TODO Auto-generated method stub
-        return null;
-    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryUrlCache.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryUrlCache.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryUrlCache.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/RepositoryUrlCache.java Thu Dec 29 17:57:29 2011
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 
 /**
@@ -30,7 +31,6 @@ import org.apache.chemistry.opencmis.com
  */
 public class RepositoryUrlCache implements Serializable {
 
-    public static final String CMIS_SELECTOR = "cmisselector";
     public static final String OBJECT_ID = "objectId";
 
     private static final long serialVersionUID = 1L;
@@ -49,6 +49,10 @@ public class RepositoryUrlCache implemen
      * Adds the URLs of a repository to the cache.
      */
     public void addRepository(String repositoryId, String repositoryUrl, String rootUrl) {
+        if (repositoryId == null || repositoryUrl == null || rootUrl == null) {
+            throw new IllegalArgumentException("Repository Id or Repository URL or Root URL is not set!");
+        }
+
         lock.writeLock().lock();
         try {
             repositoryUrls.put(repositoryId, repositoryUrl);
@@ -96,7 +100,7 @@ public class RepositoryUrlCache implemen
     }
 
     /**
-     * Return the repository URL.
+     * Returns the repository URL.
      */
     public UrlBuilder getRepositoryUrl(String repositoryId) {
         String base = getRepositoryBaseUrl(repositoryId);
@@ -108,7 +112,7 @@ public class RepositoryUrlCache implemen
     }
 
     /**
-     * Return the repository URL with the given selector.
+     * Returns the repository URL with the given selector.
      */
     public UrlBuilder getRepositoryUrl(String repositoryId, String selector) {
         UrlBuilder result = getRepositoryUrl(repositoryId);
@@ -116,13 +120,13 @@ public class RepositoryUrlCache implemen
             return null;
         }
 
-        result.addParameter(CMIS_SELECTOR, selector);
+        result.addParameter(Constants.PARAM_SELECTOR, selector);
 
         return result;
     }
 
     /**
-     * Return an object URL with the given selector.
+     * Returns an object URL with the given selector.
      */
     public UrlBuilder getObjectUrl(String repositoryId, String objectId) {
         String root = getRootUrl(repositoryId);
@@ -137,7 +141,7 @@ public class RepositoryUrlCache implemen
     }
 
     /**
-     * Return an object URL with the given selector.
+     * Returns an object URL with the given selector.
      */
     public UrlBuilder getObjectUrl(String repositoryId, String objectId, String selector) {
         UrlBuilder result = getObjectUrl(repositoryId, objectId);
@@ -145,7 +149,7 @@ public class RepositoryUrlCache implemen
             return null;
         }
 
-        result.addParameter(CMIS_SELECTOR, selector);
+        result.addParameter(Constants.PARAM_SELECTOR, selector);
 
         return result;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.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/Constants.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Constants.java Thu Dec 29 17:57:29 2011
@@ -95,6 +95,7 @@ public final class Constants {
 
     // browser binding selectors
     public static final String SELECTOR_LAST_RESULT = "lastResult";
+    public static final String SELECTOR_REPOSITORY_INFO = "repositoryInfo";
     public static final String SELECTOR_TYPE_CHILDREN = "typeChildren";
     public static final String SELECTOR_TYPE_DESCENDANTS = "typeDescendants";
     public static final String SELECTOR_TYPE_DEFINITION = "typeDefinition";
@@ -184,6 +185,11 @@ public final class Constants {
     public static final String PARAM_ACL_PROPAGATION = "ACLPropagation";
     public static final String PARAM_SOURCE_ID = "sourceId";
 
+    public static final String PARAM_SELECTOR = "cmisselector";
+    public static final String PARAM_TRANSACTION = "transaction";
+    public static final String PARAM_CLIENT_TOKEN = "clientToken";
+    public static final String PARAM_SUPPRESS_RESPONSE_CODES = "suppressResponseCodes";
+
     // rendition filter
     public static final String RENDITION_NONE = "cmis:none";
 }

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=1225607&r1=1225606&r2=1225607&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 Thu Dec 29 17:57:29 2011
@@ -18,6 +18,9 @@
  */
 package org.apache.chemistry.opencmis.commons.impl;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * JSON object constants.
  */
@@ -27,24 +30,46 @@ public class JSONConstants {
     public static final String ERROR_MESSAGE = "message";
     public static final String ERROR_STACKTRACE = "stacktrace";
 
-    public static final String REPINFO_ID = "repositoryId";
-    public static final String REPINFO_NAME = "repositoryName";
-    public static final String REPINFO_DESCRIPTION = "repositoryDescription";
-    public static final String REPINFO_VENDOR = "vendorName";
-    public static final String REPINFO_PRODUCT = "productName";
-    public static final String REPINFO_PRODUCT_VERSION = "productVersion";
-    public static final String REPINFO_ROOT_FOLDER_ID = "rootFolderId";
-    public static final String REPINFO_REPOSITORY_URL = "repositoryUrl";
-    public static final String REPINFO_ROOT_FOLDER_URL = "rootFolderUrl";
-    public static final String REPINFO_CAPABILITIES = "capabilities";
-    public static final String REPINFO_ACL_CAPABILITIES = "aclCapabilities";
-    public static final String REPINFO_CHANGE_LOCK_TOKEN = "latestChangeLogToken";
-    public static final String REPINFO_CMIS_VERSION_SUPPORTED = "cmisVersionSupported";
-    public static final String REPINFO_THIN_CLIENT_URI = "thinClientURI";
-    public static final String REPINFO_CHANGES_INCOMPLETE = "changesIncomplete";
-    public static final String REPINFO_CHANGES_ON_TYPE = "changesOnType";
-    public static final String REPINFO_PRINCIPAL_ID_ANONYMOUS = "principalIdAnonymous";
-    public static final String REPINFO_PRINCIPAL_ID_ANYONE = "principalIdAnyone";
+    public static final String JSON_REPINFO_ID = "repositoryId";
+    public static final String JSON_REPINFO_NAME = "repositoryName";
+    public static final String JSON_REPINFO_DESCRIPTION = "repositoryDescription";
+    public static final String JSON_REPINFO_VENDOR = "vendorName";
+    public static final String JSON_REPINFO_PRODUCT = "productName";
+    public static final String JSON_REPINFO_PRODUCT_VERSION = "productVersion";
+    public static final String JSON_REPINFO_ROOT_FOLDER_ID = "rootFolderId";
+    public static final String JSON_REPINFO_REPOSITORY_URL = "repositoryUrl";
+    public static final String JSON_REPINFO_ROOT_FOLDER_URL = "rootFolderUrl";
+    public static final String JSON_REPINFO_CAPABILITIES = "capabilities";
+    public static final String JSON_REPINFO_ACL_CAPABILITIES = "aclCapabilities";
+    public static final String JSON_REPINFO_CHANGE_LOCK_TOKEN = "latestChangeLogToken";
+    public static final String JSON_REPINFO_CMIS_VERSION_SUPPORTED = "cmisVersionSupported";
+    public static final String JSON_REPINFO_THIN_CLIENT_URI = "thinClientURI";
+    public static final String JSON_REPINFO_CHANGES_INCOMPLETE = "changesIncomplete";
+    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 Set<String> REPINFO_KEYS = new HashSet<String>();
+    static {
+        REPINFO_KEYS.add(JSON_REPINFO_ID);
+        REPINFO_KEYS.add(JSON_REPINFO_NAME);
+        REPINFO_KEYS.add(JSON_REPINFO_DESCRIPTION);
+        REPINFO_KEYS.add(JSON_REPINFO_VENDOR);
+        REPINFO_KEYS.add(JSON_REPINFO_PRODUCT);
+        REPINFO_KEYS.add(JSON_REPINFO_PRODUCT_VERSION);
+        REPINFO_KEYS.add(JSON_REPINFO_ROOT_FOLDER_ID);
+        REPINFO_KEYS.add(JSON_REPINFO_REPOSITORY_URL);
+        REPINFO_KEYS.add(JSON_REPINFO_ROOT_FOLDER_URL);
+        REPINFO_KEYS.add(JSON_REPINFO_CAPABILITIES);
+        REPINFO_KEYS.add(JSON_REPINFO_ACL_CAPABILITIES);
+        REPINFO_KEYS.add(JSON_REPINFO_CHANGE_LOCK_TOKEN);
+        REPINFO_KEYS.add(JSON_REPINFO_CMIS_VERSION_SUPPORTED);
+        REPINFO_KEYS.add(JSON_REPINFO_THIN_CLIENT_URI);
+        REPINFO_KEYS.add(JSON_REPINFO_CHANGES_INCOMPLETE);
+        REPINFO_KEYS.add(JSON_REPINFO_CHANGES_ON_TYPE);
+        REPINFO_KEYS.add(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS);
+        REPINFO_KEYS.add(JSON_REPINFO_PRINCIPAL_ID_ANYONE);
+    }
 
     public static final String JSON_CAP_CONTENT_STREAM_UPDATES = "capabilityContentStreamUpdatability";
     public static final String JSON_CAP_CHANGES = "capabilityChanges";
@@ -61,17 +86,55 @@ public class JSONConstants {
     public static final String JSON_CAP_JOIN = "capabilityJoin";
     public static final String JSON_CAP_ACL = "capabilityACL";
 
+    public static final Set<String> CAP_KEYS = new HashSet<String>();
+    static {
+        CAP_KEYS.add(JSON_CAP_CONTENT_STREAM_UPDATES);
+        CAP_KEYS.add(JSON_CAP_CHANGES);
+        CAP_KEYS.add(JSON_CAP_RENDITIONS);
+        CAP_KEYS.add(JSON_CAP_GET_DESCENDANTS);
+        CAP_KEYS.add(JSON_CAP_GET_FOLDER_TREE);
+        CAP_KEYS.add(JSON_CAP_MULTIFILING);
+        CAP_KEYS.add(JSON_CAP_UNFILING);
+        CAP_KEYS.add(JSON_CAP_VERSION_SPECIFIC_FILING);
+        CAP_KEYS.add(JSON_CAP_PWC_SEARCHABLE);
+        CAP_KEYS.add(JSON_CAP_PWC_UPDATABLE);
+        CAP_KEYS.add(JSON_CAP_ALL_VERSIONS_SEARCHABLE);
+        CAP_KEYS.add(JSON_CAP_QUERY);
+        CAP_KEYS.add(JSON_CAP_JOIN);
+        CAP_KEYS.add(JSON_CAP_ACL);
+    }
+
     public static final String JSON_ACLCAP_SUPPORTED_PERMISSIONS = "supportedPermissions";
     public static final String JSON_ACLCAP_ACL_PROPAGATION = "propagation";
     public static final String JSON_ACLCAP_PERMISSIONS = "permissions";
     public static final String JSON_ACLCAP_PERMISSION_MAPPING = "permissionMapping";
 
+    public static final Set<String> ACLCAP_KEYS = new HashSet<String>();
+    static {
+        ACLCAP_KEYS.add(JSON_ACLCAP_SUPPORTED_PERMISSIONS);
+        ACLCAP_KEYS.add(JSON_ACLCAP_ACL_PROPAGATION);
+        ACLCAP_KEYS.add(JSON_ACLCAP_PERMISSIONS);
+        ACLCAP_KEYS.add(JSON_ACLCAP_PERMISSION_MAPPING);
+    }
+
     public static final String JSON_ACLCAP_PERMISSION_PERMISSION = "permission";
     public static final String JSON_ACLCAP_PERMISSION_DESCRIPTION = "description";
 
+    public static final Set<String> ACLCAP_PERMISSION_KEYS = new HashSet<String>();
+    static {
+        ACLCAP_PERMISSION_KEYS.add(JSON_ACLCAP_PERMISSION_PERMISSION);
+        ACLCAP_PERMISSION_KEYS.add(JSON_ACLCAP_PERMISSION_DESCRIPTION);
+    }
+
     public static final String JSON_ACLCAP_MAPPING_KEY = "key";
     public static final String JSON_ACLCAP_MAPPING_PERMISSION = "permission";
 
+    public static final Set<String> ACLCAP_MAPPING_KEYS = new HashSet<String>();
+    static {
+        ACLCAP_MAPPING_KEYS.add(JSON_ACLCAP_MAPPING_KEY);
+        ACLCAP_MAPPING_KEYS.add(JSON_ACLCAP_MAPPING_PERMISSION);
+    }
+
     public static final String JSON_OBJECT_PROPERTIES = "properties";
     public static final String JSON_OBJECT_ALLOWABLE_ACTIONS = "allowableActions";
     public static final String JSON_OBJECT_RELATIONSHIPS = "relationships";
@@ -148,6 +211,30 @@ public class JSONConstants {
     public static final String JSON_TYPE_ALLOWED_SOURCE_TYPES = "allowedSourceTypes"; // relationship
     public static final String JSON_TYPE_ALLOWED_TARGET_TYPES = "allowedTargetTypes"; // relationship
 
+    public static final Set<String> TYPE_KEYS = new HashSet<String>();
+    static {
+        TYPE_KEYS.add(JSON_TYPE_ID);
+        TYPE_KEYS.add(JSON_TYPE_LOCALNAME);
+        TYPE_KEYS.add(JSON_TYPE_LOCALNAMESPACE);
+        TYPE_KEYS.add(JSON_TYPE_DISPLAYNAME);
+        TYPE_KEYS.add(JSON_TYPE_QUERYNAME);
+        TYPE_KEYS.add(JSON_TYPE_DESCRIPTION);
+        TYPE_KEYS.add(JSON_TYPE_BASE_ID);
+        TYPE_KEYS.add(JSON_TYPE_PARENT_ID);
+        TYPE_KEYS.add(JSON_TYPE_CREATABLE);
+        TYPE_KEYS.add(JSON_TYPE_FILEABLE);
+        TYPE_KEYS.add(JSON_TYPE_QUERYABLE);
+        TYPE_KEYS.add(JSON_TYPE_FULLTEXT_INDEXED);
+        TYPE_KEYS.add(JSON_TYPE_INCLUDE_IN_SUPERTYPE_QUERY);
+        TYPE_KEYS.add(JSON_TYPE_CONTROLABLE_POLICY);
+        TYPE_KEYS.add(JSON_TYPE_CONTROLABLE_ACL);
+        TYPE_KEYS.add(JSON_TYPE_PROPERTY_DEFINITIONS);
+        TYPE_KEYS.add(JSON_TYPE_VERSIONABLE);
+        TYPE_KEYS.add(JSON_TYPE_CONTENTSTREAM_ALLOWED);
+        TYPE_KEYS.add(JSON_TYPE_ALLOWED_SOURCE_TYPES);
+        TYPE_KEYS.add(JSON_TYPE_ALLOWED_TARGET_TYPES);
+    }
+
     public static final String JSON_PROPERTYTYPE_ID = "id";
     public static final String JSON_PROPERTYTYPE_LOCALNAME = "localName";
     public static final String JSON_PROPERTYTYPE_LOCALNAMESPACE = "localNamespace";

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=1225607&r1=1225606&r2=1225607&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 Thu Dec 29 17:57:29 2011
@@ -20,8 +20,12 @@ package org.apache.chemistry.opencmis.co
 
 import static org.apache.chemistry.opencmis.commons.impl.JSONConstants.*;
 
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.GregorianCalendar;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.chemistry.opencmis.commons.data.Ace;
@@ -29,6 +33,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.AclCapabilities;
 import org.apache.chemistry.opencmis.commons.data.AllowableActions;
 import org.apache.chemistry.opencmis.commons.data.ChangeEventInfo;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
@@ -56,11 +62,33 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
+import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityChanges;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
+import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
 import org.apache.chemistry.opencmis.commons.enums.Cardinality;
+import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
 import org.apache.chemistry.opencmis.commons.enums.PropertyType;
-import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;
+import org.apache.chemistry.opencmis.commons.enums.SupportedPermissions;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyDefinition;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.AclCapabilitiesDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.DocumentTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.FolderTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionDefinitionDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PermissionMappingDataImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PolicyTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RelationshipTypeDefinitionImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryCapabilitiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoBrowserBindingImpl;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 
@@ -86,35 +114,35 @@ public class JSONConverter {
 
         JSONObject result = new JSONObject();
 
-        result.put(REPINFO_ID, repositoryInfo.getId());
-        result.put(REPINFO_NAME, repositoryInfo.getName());
-        result.put(REPINFO_DESCRIPTION, repositoryInfo.getDescription());
-        result.put(REPINFO_VENDOR, repositoryInfo.getVendorName());
-        result.put(REPINFO_PRODUCT, repositoryInfo.getProductName());
-        result.put(REPINFO_PRODUCT_VERSION, repositoryInfo.getProductVersion());
-        result.put(REPINFO_ROOT_FOLDER_ID, repositoryInfo.getRootFolderId());
-        result.put(REPINFO_CAPABILITIES, convert(repositoryInfo.getCapabilities()));
-        result.put(REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()));
-        result.put(REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
-        result.put(REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
-        result.put(REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri());
-        result.put(REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete());
+        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()));
+        result.put(JSON_REPINFO_ACL_CAPABILITIES, convert(repositoryInfo.getAclCapabilities()));
+        result.put(JSON_REPINFO_CHANGE_LOCK_TOKEN, repositoryInfo.getLatestChangeLogToken());
+        result.put(JSON_REPINFO_CMIS_VERSION_SUPPORTED, repositoryInfo.getCmisVersionSupported());
+        result.put(JSON_REPINFO_THIN_CLIENT_URI, repositoryInfo.getThinClientUri());
+        result.put(JSON_REPINFO_CHANGES_INCOMPLETE, repositoryInfo.getChangesIncomplete());
 
         if (repositoryInfo.getChangesOnType() != null) {
             JSONArray changesOnType = new JSONArray();
 
             for (BaseTypeId type : repositoryInfo.getChangesOnType()) {
-                changesOnType.add(getJSONStringValue(type));
+                changesOnType.add(getJSONStringValue(type.value()));
             }
 
-            result.put(REPINFO_CHANGES_ON_TYPE, changesOnType);
+            result.put(JSON_REPINFO_CHANGES_ON_TYPE, changesOnType);
         }
 
-        result.put(REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
-        result.put(REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
+        result.put(JSON_REPINFO_PRINCIPAL_ID_ANONYMOUS, repositoryInfo.getPrincipalIdAnonymous());
+        result.put(JSON_REPINFO_PRINCIPAL_ID_ANYONE, repositoryInfo.getPrincipalIdAnyone());
 
-        result.put(REPINFO_REPOSITORY_URL, repositoryUrl);
-        result.put(REPINFO_ROOT_FOLDER_URL, rootUrl);
+        result.put(JSON_REPINFO_REPOSITORY_URL, repositoryUrl);
+        result.put(JSON_REPINFO_ROOT_FOLDER_URL, rootUrl);
 
         return result;
     }
@@ -205,20 +233,261 @@ public class JSONConverter {
         return result;
     }
 
-    public static RepositoryInfo convertRepositoryInfo(JSONObject json) {
+    @SuppressWarnings("unchecked")
+    public static RepositoryInfo convertRepositoryInfo(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));
+
+        Object capabilities = json.get(JSON_REPINFO_CAPABILITIES);
+        if (capabilities instanceof Map) {
+            result.setCapabilities(convertRepositoryCapabilities((Map<String, Object>) capabilities));
+        }
+
+        Object aclCapabilities = json.get(JSON_REPINFO_ACL_CAPABILITIES);
+        if (aclCapabilities instanceof Map) {
+            result.setAclCapabilities(convertAclCapabilities((Map<String, Object>) aclCapabilities));
+        }
+
+        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));
+
+        Object changesOnType = json.get(JSON_REPINFO_CHANGES_ON_TYPE);
+        if (changesOnType instanceof List) {
+            List<BaseTypeId> types = new ArrayList<BaseTypeId>();
+            for (Object type : ((List<Object>) 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));
+
+        // handle extensions
+        convertExtension(json, result, REPINFO_KEYS);
+
+        return result;
+    }
+
+    public static RepositoryCapabilities convertRepositoryCapabilities(Map<String, Object> json) {
         if (json == null) {
             return null;
         }
 
-        RepositoryInfoImpl result = new RepositoryInfoImpl();
+        RepositoryCapabilitiesImpl result = new RepositoryCapabilitiesImpl();
+
+        result.setCapabilityContentStreamUpdates(getEnum(json, JSON_CAP_CONTENT_STREAM_UPDATES,
+                CapabilityContentStreamUpdates.class));
+        result.setCapabilityChanges(getEnum(json, JSON_CAP_CHANGES, CapabilityChanges.class));
+        result.setCapabilityRendition(getEnum(json, JSON_CAP_RENDITIONS, CapabilityRenditions.class));
+        result.setSupportsGetDescendants(getBoolean(json, JSON_CAP_GET_DESCENDANTS));
+        result.setSupportsGetFolderTree(getBoolean(json, JSON_CAP_GET_FOLDER_TREE));
+        result.setSupportsMultifiling(getBoolean(json, JSON_CAP_MULTIFILING));
+        result.setSupportsUnfiling(getBoolean(json, JSON_CAP_UNFILING));
+        result.setSupportsVersionSpecificFiling(getBoolean(json, JSON_CAP_VERSION_SPECIFIC_FILING));
+        result.setIsPwcSearchable(getBoolean(json, JSON_CAP_PWC_SEARCHABLE));
+        result.setIsPwcUpdatable(getBoolean(json, JSON_CAP_PWC_UPDATABLE));
+        result.setAllVersionsSearchable(getBoolean(json, JSON_CAP_ALL_VERSIONS_SEARCHABLE));
+        result.setCapabilityQuery(getEnum(json, JSON_CAP_QUERY, CapabilityQuery.class));
+        result.setCapabilityJoin(getEnum(json, JSON_CAP_JOIN, CapabilityJoin.class));
+        result.setCapabilityAcl(getEnum(json, JSON_CAP_ACL, CapabilityAcl.class));
+
+        // handle extensions
+        convertExtension(json, result, CAP_KEYS);
+
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static AclCapabilities convertAclCapabilities(Map<String, Object> json) {
+        if (json == null) {
+            return null;
+        }
+
+        AclCapabilitiesDataImpl result = new AclCapabilitiesDataImpl();
+
+        result.setSupportedPermissions(getEnum(json, JSON_ACLCAP_SUPPORTED_PERMISSIONS, SupportedPermissions.class));
+        result.setAclPropagation(getEnum(json, JSON_ACLCAP_ACL_PROPAGATION, AclPropagation.class));
+
+        Object permissions = json.get(JSON_ACLCAP_PERMISSIONS);
+        if (permissions instanceof List) {
+            List<PermissionDefinition> permissionDefinitionList = new ArrayList<PermissionDefinition>();
+
+            for (Object permission : (List<Object>) permissions) {
+                if (permission instanceof Map) {
+                    PermissionDefinitionDataImpl permDef = new PermissionDefinitionDataImpl();
+
+                    permDef.setPermission(getString((Map<String, Object>) permission, JSON_ACLCAP_PERMISSION_PERMISSION));
+                    permDef.setDescription(getString((Map<String, Object>) permission,
+                            JSON_ACLCAP_PERMISSION_DESCRIPTION));
+
+                    convertExtension((Map<String, Object>) permission, permDef, ACLCAP_PERMISSION_KEYS);
+
+                    permissionDefinitionList.add(permDef);
+                }
+            }
+
+            result.setPermissionDefinitionData(permissionDefinitionList);
+        }
+
+        Object permissionMapping = json.get(JSON_ACLCAP_PERMISSION_MAPPING);
+        if (permissionMapping instanceof List) {
+            Map<String, PermissionMapping> permMap = new HashMap<String, PermissionMapping>();
+
+            for (Object permission : (List<Object>) permissionMapping) {
+                if (permission instanceof Map) {
+                    PermissionMappingDataImpl mapping = new PermissionMappingDataImpl();
+
+                    String key = getString((Map<String, Object>) permission, JSON_ACLCAP_MAPPING_KEY);
+                    mapping.setKey(key);
+
+                    Object perms = ((Map<String, Object>) permission).get(JSON_ACLCAP_MAPPING_PERMISSION);
+                    if (perms instanceof List) {
+                        List<String> permList = new ArrayList<String>();
+
+                        for (Object perm : (List<Object>) perms) {
+                            if (perm != null) {
+                                permList.add(perm.toString());
+                            }
+                        }
+
+                        mapping.setPermissions(permList);
+                    }
+
+                    convertExtension((Map<String, Object>) permission, mapping, ACLCAP_MAPPING_KEYS);
+
+                    permMap.put(key, mapping);
+                }
+            }
+
+            result.setPermissionMappingData(permMap);
+        }
+
+        // handle extensions
+        convertExtension(json, result, ACLCAP_KEYS);
+
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static TypeDefinition convertTypeDefinition(Map<String, Object> json) {
+        if (json == null) {
+            return null;
+        }
+
+        AbstractTypeDefinition result = null;
+
+        String id = getString(json, JSON_TYPE_ID);
+
+        // find base type
+        BaseTypeId baseType = getEnum(json, JSON_TYPE_BASE_ID, BaseTypeId.class);
+        if (baseType == null) {
+            throw new CmisConnectionException("Invalid base type! Type defintion: " + id);
+        }
+
+        switch (baseType) {
+        case CMIS_FOLDER:
+            result = new FolderTypeDefinitionImpl();
+            break;
+        case CMIS_DOCUMENT:
+            result = new DocumentTypeDefinitionImpl();
+
+            ((DocumentTypeDefinitionImpl) result).setContentStreamAllowed(getEnum(json,
+                    JSON_TYPE_CONTENTSTREAM_ALLOWED, ContentStreamAllowed.class));
+            ((DocumentTypeDefinitionImpl) result).setIsVersionable(getBoolean(json, JSON_TYPE_VERSIONABLE));
+
+            break;
+        case CMIS_RELATIONSHIP:
+            result = new RelationshipTypeDefinitionImpl();
+
+            Object allowedSourceTypes = json.get(JSON_TYPE_ALLOWED_SOURCE_TYPES);
+            if (allowedSourceTypes instanceof List) {
+                List<String> types = new ArrayList<String>();
+                for (Object type : ((List<Object>) allowedSourceTypes)) {
+                    if (type != null) {
+                        types.add(type.toString());
+                    }
+                }
+
+                ((RelationshipTypeDefinitionImpl) result).setAllowedSourceTypes(types);
+            }
+
+            Object allowedTargetTypes = json.get(JSON_TYPE_ALLOWED_TARGET_TYPES);
+            if (allowedTargetTypes instanceof List) {
+                List<String> types = new ArrayList<String>();
+                for (Object type : ((List<Object>) allowedTargetTypes)) {
+                    if (type != null) {
+                        types.add(type.toString());
+                    }
+                }
+
+                ((RelationshipTypeDefinitionImpl) result).setAllowedTargetTypes(types);
+            }
+
+            break;
+        case CMIS_POLICY:
+            result = new PolicyTypeDefinitionImpl();
+            break;
+        default:
+            throw new CmisRuntimeException("Type '" + id + "' does not match a base type!");
+        }
+
+        result.setBaseTypeId(baseType);
+        result.setDescription(getString(json, JSON_TYPE_DESCRIPTION));
+        result.setDisplayName(getString(json, JSON_TYPE_DISPLAYNAME));
+        result.setId(id);
+        result.setIsControllableAcl(getBoolean(json, JSON_TYPE_CONTROLABLE_ACL));
+        result.setIsControllablePolicy(getBoolean(json, JSON_TYPE_CONTROLABLE_POLICY));
+        result.setIsCreatable(getBoolean(json, JSON_TYPE_CREATABLE));
+        result.setIsFileable(getBoolean(json, JSON_TYPE_FILEABLE));
+        result.setIsFulltextIndexed(getBoolean(json, JSON_TYPE_FULLTEXT_INDEXED));
+        result.setIsIncludedInSupertypeQuery(getBoolean(json, JSON_TYPE_INCLUDE_IN_SUPERTYPE_QUERY));
+        result.setIsQueryable(getBoolean(json, JSON_TYPE_QUERYABLE));
+        result.setLocalName(getString(json, JSON_TYPE_LOCALNAME));
+        result.setLocalNamespace(getString(json, JSON_TYPE_LOCALNAMESPACE));
+        result.setParentTypeId(getString(json, JSON_TYPE_PARENT_ID));
+        result.setQueryName(getString(json, JSON_TYPE_QUERYNAME));
+
+        Object propertyDefinitions = json.get(JSON_TYPE_PROPERTY_DEFINITIONS);
+        if (propertyDefinitions instanceof Map) {
+            for (Object propDef : ((Map<String, Object>) propertyDefinitions).values()) {
+                if (propDef instanceof Map) {
+                    result.addPropertyDefinition(convertPropertyDefinition((Map<String, Object>) propDef));
+                }
+            }
+        }
+
+        // handle extensions
+        convertExtension(json, result, TYPE_KEYS);
+
+        return result;
+    }
 
-        result.setId(getString(json, REPINFO_ID));
-        result.setName(getString(json, REPINFO_NAME));
-        result.setDescription(getString(json, REPINFO_DESCRIPTION));
-        result.setProductName(getString(json, REPINFO_PRODUCT));
-        result.setProductVersion(getString(json, REPINFO_PRODUCT_VERSION));
-        result.setRootFolder(getString(json, REPINFO_ROOT_FOLDER_ID));
+    public static PropertyDefinition<?> convertPropertyDefinition(Map<String, Object> json) {
+        if (json == null) {
+            return null;
+        }
 
+        AbstractPropertyDefinition<?> result = null;
+        
         // TODO
 
         return result;
@@ -715,6 +984,91 @@ public class JSONConverter {
 
     // -----------------------------------------------------------------
 
+    @SuppressWarnings("unchecked")
+    public static void convertExtension(Map<String, Object> source, ExtensionsData target, Set<String> cmisKeys) {
+        if (source == null) {
+            return;
+        }
+
+        List<CmisExtensionElement> extensions = null;
+
+        for (Map.Entry<String, Object> element : source.entrySet()) {
+            if (cmisKeys.contains(element.getKey())) {
+                continue;
+            }
+
+            if (extensions == null) {
+                extensions = new ArrayList<CmisExtensionElement>();
+            }
+
+            if (element.getValue() instanceof Map) {
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null,
+                        convertExtension((Map<String, Object>) element.getValue())));
+            } else if (element.getValue() instanceof List) {
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null,
+                        convertExtension((List<Object>) element.getValue())));
+            } else {
+                String value = (element.getValue() == null ? null : element.getValue().toString());
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null, value));
+            }
+        }
+
+        target.setExtensions(extensions);
+    }
+
+    @SuppressWarnings("unchecked")
+    public static List<CmisExtensionElement> convertExtension(Map<String, Object> map) {
+        if (map == null) {
+            return null;
+        }
+
+        List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+        for (Map.Entry<String, Object> element : map.entrySet()) {
+            if (element.getValue() instanceof Map) {
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null,
+                        convertExtension((Map<String, Object>) element.getValue())));
+            } else if (element.getValue() instanceof List) {
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null,
+                        convertExtension((List<Object>) element.getValue())));
+            } else {
+                String value = (element.getValue() == null ? null : element.getValue().toString());
+                extensions.add(new CmisExtensionElementImpl(null, element.getKey(), null, value));
+            }
+        }
+
+        return extensions;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static List<CmisExtensionElement> convertExtension(List<Object> list) {
+        if (list == null) {
+            return null;
+        }
+
+        List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
+
+        int i = 0;
+        for (Object element : list) {
+            if (element instanceof Map) {
+                extensions.add(new CmisExtensionElementImpl(null, "" + i, null,
+                        convertExtension((Map<String, Object>) element)));
+            } else if (element instanceof List) {
+                extensions.add(new CmisExtensionElementImpl(null, "" + i, null,
+                        convertExtension((List<Object>) element)));
+            } else {
+                String value = (element == null ? null : element.toString());
+                extensions.add(new CmisExtensionElementImpl(null, "" + i, null, value));
+            }
+
+            i++;
+        }
+
+        return extensions;
+    }
+
+    // -----------------------------------------------------------------
+
     public static String getJSONStringValue(Object obj) {
         if (obj == null) {
             return null;
@@ -765,8 +1119,37 @@ public class JSONConverter {
         return null;
     }
 
-    public static String getString(JSONObject json, String key) {
+    public static String getString(@SuppressWarnings("rawtypes") Map json, String key) {
         Object obj = json.get(key);
         return obj == null ? null : obj.toString();
     }
+
+    public static Boolean getBoolean(@SuppressWarnings("rawtypes") Map json, String key) {
+        Object obj = json.get(key);
+
+        if (obj instanceof Boolean) {
+            return (Boolean) obj;
+        }
+
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <T extends Enum<T>> T getEnum(@SuppressWarnings("rawtypes") Map json, String key, Class<T> clazz) {
+        String value = getString(json, key);
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            Method m = clazz.getMethod("fromValue", String.class);
+            return (T) m.invoke(null, value);
+        } catch (Exception e) {
+            if (e instanceof IllegalArgumentException) {
+                return null;
+            } else {
+                throw new CmisRuntimeException("Could not parse enum value!", e);
+            }
+        }
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AclCapabilitiesDataImpl.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/dataobjects/AclCapabilitiesDataImpl.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AclCapabilitiesDataImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/AclCapabilitiesDataImpl.java Thu Dec 29 17:57:29 2011
@@ -28,54 +28,33 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.SupportedPermissions;
 
 /**
- * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- * 
+ * AclCapabilities Implementation.
  */
 public class AclCapabilitiesDataImpl extends AbstractExtensionData implements AclCapabilities {
 
     private static final long serialVersionUID = 1L;
 
-    private SupportedPermissions fSupportedPermissions;
-    private AclPropagation fACLPropagation;
+    private SupportedPermissions supportedPermissions;
+    private AclPropagation aclPropagation;
     private Map<String, PermissionMapping> permissionMapping;
-    private List<PermissionDefinition> fPermissionDefinitionList;
+    private List<PermissionDefinition> permissionDefinitionList;
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.client.provider.ACLCapabilitiesData#getACLPropagation
-     * ()
-     */
     public SupportedPermissions getSupportedPermissions() {
-        return fSupportedPermissions;
+        return supportedPermissions;
     }
 
     public void setSupportedPermissions(SupportedPermissions supportedPermissions) {
-        fSupportedPermissions = supportedPermissions;
+        this.supportedPermissions = supportedPermissions;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.client.provider.ACLCapabilitiesData#getACLPropagation
-     * ()
-     */
     public AclPropagation getAclPropagation() {
-        return fACLPropagation;
+        return aclPropagation;
     }
 
     public void setAclPropagation(AclPropagation aclPropagation) {
-        fACLPropagation = aclPropagation;
+        this.aclPropagation = aclPropagation;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.ACLCapabilitiesData#
-     * getPermissionMappingData()
-     */
     public Map<String, PermissionMapping> getPermissionMapping() {
         return permissionMapping;
     }
@@ -84,28 +63,17 @@ public class AclCapabilitiesDataImpl ext
         this.permissionMapping = permissionMapping;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.ACLCapabilitiesData#
-     * getPermissionDefinitionData()
-     */
     public List<PermissionDefinition> getPermissions() {
-        return fPermissionDefinitionList;
+        return permissionDefinitionList;
     }
 
     public void setPermissionDefinitionData(List<PermissionDefinition> permissionDefinitionList) {
-        fPermissionDefinitionList = permissionDefinitionList;
+        this.permissionDefinitionList = permissionDefinitionList;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
-        return "ACL Capabilities [ACL propagation=" + fACLPropagation + ", permission definition list="
-                + fPermissionDefinitionList + ", permission mappings=" + permissionMapping + "]" + super.toString();
+        return "ACL Capabilities [ACL propagation=" + aclPropagation + ", permission definition list="
+                + permissionDefinitionList + ", permission mappings=" + permissionMapping + "]" + super.toString();
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.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/dataobjects/RepositoryCapabilitiesImpl.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryCapabilitiesImpl.java Thu Dec 29 17:57:29 2011
@@ -27,27 +27,26 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
 
 /**
- * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
- * 
+ * RepositoryCapabilities Implementation.
  */
 public class RepositoryCapabilitiesImpl extends AbstractExtensionData implements RepositoryCapabilities {
 
     private static final long serialVersionUID = 1L;
 
-    private Boolean fAllVersionsSearchable;
-    private CapabilityAcl fCapabilityAcl;
-    private CapabilityChanges fCapabilityChanges;
-    private CapabilityContentStreamUpdates fCapabilityContentStreamUpdates;
-    private CapabilityJoin fCapabilityJoin;
-    private CapabilityQuery fCapabilityQuery;
-    private CapabilityRenditions fCapabilityRendition;
-    private Boolean fIsPwcSearchable;
-    private Boolean fIsPwcUpdatable;
-    private Boolean fSupportsGetDescendants;
-    private Boolean fSupportsGetFolderTree;
-    private Boolean fSupportsMultifiling;
-    private Boolean fSupportsUnfiling;
-    private Boolean fSupportsVersionSpecificFiling;
+    private Boolean allVersionsSearchable;
+    private CapabilityAcl capabilityAcl;
+    private CapabilityChanges capabilityChanges;
+    private CapabilityContentStreamUpdates capabilityContentStreamUpdates;
+    private CapabilityJoin capabilityJoin;
+    private CapabilityQuery capabilityQuery;
+    private CapabilityRenditions capabilityRendition;
+    private Boolean isPwcSearchable;
+    private Boolean isPwcUpdatable;
+    private Boolean supportsGetDescendants;
+    private Boolean supportsGetFolderTree;
+    private Boolean supportsMultifiling;
+    private Boolean supportsUnfiling;
+    private Boolean supportsVersionSpecificFiling;
 
     /**
      * Constructor.
@@ -55,218 +54,127 @@ public class RepositoryCapabilitiesImpl 
     public RepositoryCapabilitiesImpl() {
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * allVersionsSearchable()
-     */
     public Boolean isAllVersionsSearchableSupported() {
-        return fAllVersionsSearchable;
+        return allVersionsSearchable;
     }
 
     public void setAllVersionsSearchable(Boolean allVersionsSearchable) {
-        fAllVersionsSearchable = allVersionsSearchable;
+        this.allVersionsSearchable = allVersionsSearchable;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityACL()
-     */
     public CapabilityAcl getAclCapability() {
-        return fCapabilityAcl;
+        return capabilityAcl;
     }
 
     public void setCapabilityAcl(CapabilityAcl capabilityAcl) {
-        fCapabilityAcl = capabilityAcl;
+        this.capabilityAcl = capabilityAcl;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityChanges()
-     */
     public CapabilityChanges getChangesCapability() {
-        return fCapabilityChanges;
+        return capabilityChanges;
     }
 
     public void setCapabilityChanges(CapabilityChanges capabilityChanges) {
-        fCapabilityChanges = capabilityChanges;
+        this.capabilityChanges = capabilityChanges;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityContentStreamUpdatability ()
-     */
     public CapabilityContentStreamUpdates getContentStreamUpdatesCapability() {
-        return fCapabilityContentStreamUpdates;
+        return capabilityContentStreamUpdates;
     }
 
     public void setCapabilityContentStreamUpdates(CapabilityContentStreamUpdates capabilityContentStreamUpdates) {
-        fCapabilityContentStreamUpdates = capabilityContentStreamUpdates;
+        this.capabilityContentStreamUpdates = capabilityContentStreamUpdates;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityJoin()
-     */
     public CapabilityJoin getJoinCapability() {
-        return fCapabilityJoin;
+        return capabilityJoin;
     }
 
     public void setCapabilityJoin(CapabilityJoin capabilityJoin) {
-        fCapabilityJoin = capabilityJoin;
+        this.capabilityJoin = capabilityJoin;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityQuery()
-     */
     public CapabilityQuery getQueryCapability() {
-        return fCapabilityQuery;
+        return capabilityQuery;
     }
 
     public void setCapabilityQuery(CapabilityQuery capabilityQuery) {
-        fCapabilityQuery = capabilityQuery;
+        this.capabilityQuery = capabilityQuery;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * getCapabilityRenditions()
-     */
     public CapabilityRenditions getRenditionsCapability() {
-        return fCapabilityRendition;
+        return capabilityRendition;
     }
 
     public void setCapabilityRendition(CapabilityRenditions capabilityRendition) {
-        fCapabilityRendition = capabilityRendition;
+        this.capabilityRendition = capabilityRendition;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * isPwcSearchable()
-     */
     public Boolean isPwcSearchableSupported() {
-        return fIsPwcSearchable;
+        return isPwcSearchable;
     }
 
     public void setIsPwcSearchable(Boolean isPwcSearchable) {
-        fIsPwcSearchable = isPwcSearchable;
+        this.isPwcSearchable = isPwcSearchable;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.opencmis.client.provider.RepositoryCapabilitiesData#isPwcUpdatable
-     * ()
-     */
     public Boolean isPwcUpdatableSupported() {
-        return fIsPwcUpdatable;
+        return isPwcUpdatable;
     }
 
     public void setIsPwcUpdatable(Boolean isPwcUpdatable) {
-        fIsPwcUpdatable = isPwcUpdatable;
+        this.isPwcUpdatable = isPwcUpdatable;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * supportsGetDescendants()
-     */
     public Boolean isGetDescendantsSupported() {
-        return fSupportsGetDescendants;
+        return supportsGetDescendants;
     }
 
     public void setSupportsGetDescendants(Boolean supportsGetDescendants) {
-        fSupportsGetDescendants = supportsGetDescendants;
+        this.supportsGetDescendants = supportsGetDescendants;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * supportsGetFolderTree()
-     */
     public Boolean isGetFolderTreeSupported() {
-        return fSupportsGetFolderTree;
+        return supportsGetFolderTree;
     }
 
     public void setSupportsGetFolderTree(Boolean supportsGetFolderTree) {
-        fSupportsGetFolderTree = supportsGetFolderTree;
+        this.supportsGetFolderTree = supportsGetFolderTree;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * supportsMultifiling()
-     */
     public Boolean isMultifilingSupported() {
-        return fSupportsMultifiling;
+        return supportsMultifiling;
     }
 
     public void setSupportsMultifiling(Boolean supportsMultifiling) {
-        fSupportsMultifiling = supportsMultifiling;
+        this.supportsMultifiling = supportsMultifiling;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * supportsUnfiling()
-     */
     public Boolean isUnfilingSupported() {
-        return fSupportsUnfiling;
+        return supportsUnfiling;
     }
 
     public void setSupportsUnfiling(Boolean supportsUnfiling) {
-        fSupportsUnfiling = supportsUnfiling;
+        this.supportsUnfiling = supportsUnfiling;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeorg.apache.opencmis.client.provider.RepositoryCapabilitiesData#
-     * supportsVersionSpecificFiling()
-     */
     public Boolean isVersionSpecificFilingSupported() {
-        return fSupportsVersionSpecificFiling;
+        return supportsVersionSpecificFiling;
     }
 
     public void setSupportsVersionSpecificFiling(Boolean supportsVersionSpecificFiling) {
-        fSupportsVersionSpecificFiling = supportsVersionSpecificFiling;
+        this.supportsVersionSpecificFiling = supportsVersionSpecificFiling;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
-        return "Repository Capabilities [all versions searchable=" + fAllVersionsSearchable + ", capability ACL="
-                + fCapabilityAcl + ", capability changes=" + fCapabilityChanges
-                + ", capability content stream updates=" + fCapabilityContentStreamUpdates + ", capability join="
-                + fCapabilityJoin + ", capability query=" + fCapabilityQuery + ", capability rendition="
-                + fCapabilityRendition + ", is PWC searchable=" + fIsPwcSearchable + ", is PWC updatable="
-                + fIsPwcUpdatable + ", supports GetDescendants=" + fSupportsGetDescendants
-                + ", supports GetFolderTree=" + fSupportsGetFolderTree + ", supports multifiling="
-                + fSupportsMultifiling + ", supports unfiling=" + fSupportsUnfiling
-                + ", supports version specific filing=" + fSupportsVersionSpecificFiling + "]" + super.toString();
+        return "Repository Capabilities [all versions searchable=" + allVersionsSearchable + ", capability ACL="
+                + capabilityAcl + ", capability changes=" + capabilityChanges + ", capability content stream updates="
+                + capabilityContentStreamUpdates + ", capability join=" + capabilityJoin + ", capability query="
+                + capabilityQuery + ", capability rendition=" + capabilityRendition + ", is PWC searchable="
+                + isPwcSearchable + ", is PWC updatable=" + isPwcUpdatable + ", supports GetDescendants="
+                + supportsGetDescendants + ", supports GetFolderTree=" + supportsGetFolderTree
+                + ", supports multifiling=" + supportsMultifiling + ", supports unfiling=" + supportsUnfiling
+                + ", supports version specific filing=" + supportsVersionSpecificFiling + "]" + super.toString();
     }
 }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryInfoBrowserBindingImpl.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/dataobjects/RepositoryInfoBrowserBindingImpl.java?rev=1225607&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryInfoBrowserBindingImpl.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryInfoBrowserBindingImpl.java Thu Dec 29 17:57:29 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.impl.dataobjects;
+
+/**
+ * Repository info data implementation including browser binding specific data.
+ */
+public class RepositoryInfoBrowserBindingImpl extends RepositoryInfoImpl {
+
+    private static final long serialVersionUID = 1L;
+
+    private String repositoryUrl;
+    private String rootUrl;
+
+    public String getRepositoryUrl() {
+        return repositoryUrl;
+    }
+
+    public void setRepositoryUrl(String repositoryUrl) {
+        this.repositoryUrl = repositoryUrl;
+    }
+
+    public String getRootUrl() {
+        return rootUrl;
+    }
+
+    public void setRootUrl(String rootUrl) {
+        this.rootUrl = rootUrl;
+    }
+}

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/RepositoryInfoBrowserBindingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.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/BrowserBindingUtils.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java Thu Dec 29 17:57:29 2011
@@ -45,6 +45,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.Base64;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.TypeCache;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlEntryImpl;
@@ -73,11 +74,6 @@ public class BrowserBindingUtils {
 
     public static final String ROOT_PATH_FRAGMENT = "root";
 
-    public static final String PARAM_SELECTOR = "selector";
-    public static final String PARAM_TRANSACTION = "transaction";
-    public static final String PARAM_CLIENT_TOKEN = "clientToken";
-    public static final String PARAM_SUPPRESS_RESPONSE_CODES = "suppressResponseCodes";
-
     public static final String CONTROL_CMISACTION = "cmisaction";
     public static final String CONTROL_TRANSACTION = "transaction";
     public static final String CONTROL_OBJECT_ID = "objectid";
@@ -468,7 +464,7 @@ public class BrowserBindingUtils {
         response.setContentType(JSON_MIME_TYPE);
         response.setCharacterEncoding("UTF-8");
 
-        String clientToken = getStringParameter(request, PARAM_CLIENT_TOKEN);
+        String clientToken = getStringParameter(request, Constants.PARAM_CLIENT_TOKEN);
         if (clientToken != null) {
             if (!clientToken.matches("[A-Za-z0-9._\\[\\]]*")) {
                 throw new CmisInvalidArgumentException("Invalid clientToken name!");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.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/CmisBrowserBindingServlet.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Thu Dec 29 17:57:29 2011
@@ -54,6 +54,7 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_QUERY;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_RELATIONSHIPS;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_RENDITIONS;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_REPOSITORY_INFO;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_TYPE_CHILDREN;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_TYPE_DEFINITION;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.SELECTOR_TYPE_DESCENDANTS;
@@ -67,8 +68,6 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTROL_OBJECT_ID;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTROL_TRANSACTION;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.JSON_MIME_TYPE;
-import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_SELECTOR;
-import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_SUPPRESS_RESPONSE_CODES;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createCookieValue;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.prepareContext;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.setCookie;
@@ -101,6 +100,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
+import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.CmisService;
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
@@ -147,7 +147,8 @@ public class CmisBrowserBindingServlet e
         rootDispatcher = new Dispatcher();
 
         try {
-            repositoryDispatcher.addResource("", METHOD_GET, RepositoryService.class, "getRepositoryInfo");
+            repositoryDispatcher.addResource(SELECTOR_REPOSITORY_INFO, METHOD_GET, RepositoryService.class,
+                    "getRepositoryInfo");
             repositoryDispatcher
                     .addResource(SELECTOR_LAST_RESULT, METHOD_GET, RepositoryService.class, "getLastResult");
             repositoryDispatcher.addResource(SELECTOR_TYPE_CHILDREN, METHOD_GET, RepositoryService.class,
@@ -291,7 +292,7 @@ public class CmisBrowserBindingServlet e
             boolean methodFound = false;
 
             if (METHOD_GET.equals(method)) {
-                String selector = getStringParameter(request, PARAM_SELECTOR);
+                String selector = getStringParameter(request, Constants.PARAM_SELECTOR);
                 String objectId = getStringParameter(request, PARAM_OBJECT_ID);
 
                 // add object id and object base type id to context
@@ -416,7 +417,7 @@ public class CmisBrowserBindingServlet e
             LOG.error(ex.getMessage(), ex);
         }
 
-        if (getBooleanParameter(request, PARAM_SUPPRESS_RESPONSE_CODES, false)) {
+        if (getBooleanParameter(request, Constants.PARAM_SUPPRESS_RESPONSE_CODES, false)) {
             statusCode = HttpServletResponse.SC_OK;
         }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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/ObjectService.java?rev=1225607&r1=1225606&r2=1225607&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Thu Dec 29 17:57:29 2011
@@ -30,13 +30,13 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_SOURCE_ID;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_STREAM_ID;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_TARGET_FOLDER_ID;
+import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_TRANSACTION;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_VERSIONIG_STATE;
 import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.RESOURCE_CONTENT;
 import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileBaseUrl;
 import static org.apache.chemistry.opencmis.server.impl.atompub.AtomPubUtils.compileUrl;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_OBJECT_ID;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_OBJECT_TYPE_ID;
-import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.PARAM_TRANSACTION;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createAddAcl;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createContentStream;
 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.createCookieValue;



Mime
View raw message