chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1492640 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/ja...
Date Thu, 13 Jun 2013 12:18:29 GMT
Author: fmui
Date: Thu Jun 13 12:18:28 2013
New Revision: 1492640

URL: http://svn.apache.org/r1492640
Log:
OpenCMIS client: added session parameter to force the CMIS version to use (workaround for
non-compliant servers)

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java
    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/webservices/AbstractWebServicesService.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/RepositoryServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.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/impl/CmisBindingImpl.java?rev=1492640&r1=1492639&r2=1492640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingImpl.java
Thu Jun 13 12:18:28 2013
@@ -25,6 +25,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
 import org.apache.chemistry.opencmis.client.bindings.spi.SessionAwareAuthenticationProvider;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
 import org.apache.chemistry.opencmis.commons.spi.AclService;
@@ -126,6 +127,16 @@ public class CmisBindingImpl implements 
             }
         }
 
+        // force CMIS version
+        String forceCmisVersion = sessionParameters.get(SessionParameter.FORCE_CMIS_VERSION);
+        if (forceCmisVersion != null) {
+            try {
+                session.put(CmisBindingsHelper.FORCE_CMIS_VERSION, CmisVersion.fromValue(forceCmisVersion));
+            } catch (IllegalArgumentException e) {
+                throw new IllegalArgumentException("Invalid CMIS version value: " + forceCmisVersion);
+            }
+        }
+
         // set up caches
         clearAllCaches();
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.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/impl/CmisBindingsHelper.java?rev=1492640&r1=1492639&r2=1492640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/impl/CmisBindingsHelper.java
Thu Jun 13 12:18:28 2013
@@ -24,6 +24,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpInvoker;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
@@ -41,6 +42,7 @@ public final class CmisBindingsHelper {
     public static final String HTTP_INVOKER_OBJECT = "org.apache.chemistry.opencmis.binding.httpinvoker.object";
     public static final String AUTHENTICATION_PROVIDER_OBJECT = "org.apache.chemistry.opencmis.binding.auth.object";
     public static final String ACCEPT_LANGUAGE = "org.apache.chemistry.opencmis.binding.acceptLanguage";
+    public static final String FORCE_CMIS_VERSION = "org.apache.chemistry.opencmis.cmisversion";
 
     /**
      * Private constructor.
@@ -131,6 +133,13 @@ public final class CmisBindingsHelper {
     }
 
     /**
+     * Returns a CMIS version if the user set one, <code>null</code> otherwise.
+     */
+    public static CmisVersion getForcedCmisVersion(BindingSession session) {
+        return (CmisVersion) session.get(FORCE_CMIS_VERSION);
+    }
+
+    /**
      * Returns the authentication provider from the session or <code>null</code>
      * if no authentication provider is set.
      */

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=1492640&r1=1492639&r2=1492640&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 Jun 13 12:18:28 2013
@@ -140,6 +140,10 @@ public abstract class AbstractAtomPubSer
      * Return the CMIS version of the given repository.
      */
     protected CmisVersion getCmisVersion(String repositoryId) {
+        if (CmisBindingsHelper.getForcedCmisVersion(session) != null) {
+            return CmisBindingsHelper.getForcedCmisVersion(session);
+        }
+
         RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session);
         RepositoryInfo info = cache.get(repositoryId);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.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/webservices/AbstractWebServicesService.java?rev=1492640&r1=1492639&r2=1492640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
Thu Jun 13 12:18:28 2013
@@ -150,6 +150,10 @@ public abstract class AbstractWebService
      * Return the CMIS version of the given repository.
      */
     protected CmisVersion getCmisVersion(String repositoryId) {
+        if (CmisBindingsHelper.getForcedCmisVersion(session) != null) {
+            return CmisBindingsHelper.getForcedCmisVersion(session);
+        }
+
         RepositoryInfoCache cache = CmisBindingsHelper.getRepositoryInfoCache(session);
         RepositoryInfo info = cache.get(repositoryId);
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/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/webservices/RepositoryServiceImpl.java?rev=1492640&r1=1492639&r2=1492640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/RepositoryServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/RepositoryServiceImpl.java
Thu Jun 13 12:18:28 2013
@@ -27,6 +27,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
 import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
@@ -60,14 +61,30 @@ public class RepositoryServiceImpl exten
     }
 
     public List<RepositoryInfo> getRepositoryInfos(ExtensionsData extension) {
-        RepositoryServicePort port = portProvider.getRepositoryServicePort(CmisVersion.CMIS_1_1,
"getRepositories");
+        CmisVersion cmisVersion = CmisBindingsHelper.getForcedCmisVersion(getSession());
+        if (cmisVersion == null) {
+            cmisVersion = CmisVersion.CMIS_1_1;
+        }
 
-        List<RepositoryInfo> infos = null;
+        RepositoryServicePort port = portProvider.getRepositoryServicePort(cmisVersion, "getRepositories");
+
+        List<CmisRepositoryEntryType> entries = null;
         try {
             // get the list of repositories
-            List<CmisRepositoryEntryType> entries = port.getRepositories(convert(extension));
+            entries = port.getRepositories(convert(extension));
+        } catch (CmisException e) {
+            throw convertException(e);
+        } catch (Exception e) {
+            throw new CmisRuntimeException("Error: " + e.getMessage(), e);
+        } finally {
+            portProvider.endCall(port);
+        }
 
-            if (entries != null) {
+        List<RepositoryInfo> infos = null;
+        if (entries != null) {
+            port = portProvider.getRepositoryServicePort(cmisVersion, "getRepositoryInfo");
+
+            try {
                 infos = new ArrayList<RepositoryInfo>();
 
                 // iterate through the list and fetch repository infos
@@ -75,20 +92,25 @@ public class RepositoryServiceImpl exten
                     CmisRepositoryInfoType info = port.getRepositoryInfo(entry.getRepositoryId(),
null);
                     infos.add(convert(info));
                 }
+            } catch (CmisException e) {
+                throw convertException(e);
+            } catch (Exception e) {
+                throw new CmisRuntimeException("Error: " + e.getMessage(), e);
+            } finally {
+                portProvider.endCall(port);
             }
-        } catch (CmisException e) {
-            throw convertException(e);
-        } catch (Exception e) {
-            throw new CmisRuntimeException("Error: " + e.getMessage(), e);
-        } finally {
-            portProvider.endCall(port);
         }
 
         return infos;
     }
 
     public RepositoryInfo getRepositoryInfo(String repositoryId, ExtensionsData extension)
{
-        RepositoryServicePort port = portProvider.getRepositoryServicePort(CmisVersion.CMIS_1_1,
"getRepositoryInfo");
+        CmisVersion cmisVersion = CmisBindingsHelper.getForcedCmisVersion(getSession());
+        if (cmisVersion == null) {
+            cmisVersion = CmisVersion.CMIS_1_1;
+        }
+
+        RepositoryServicePort port = portProvider.getRepositoryServicePort(cmisVersion, "getRepositoryInfo");
 
         try {
             return convert(port.getRepositoryInfo(repositoryId, convert(extension)));

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.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/SessionParameter.java?rev=1492640&r1=1492639&r2=1492640&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
Thu Jun 13 12:18:28 2013
@@ -138,7 +138,8 @@ package org.apache.chemistry.opencmis.co
  * <td>AtomPub, Web Services, Browser</td>
  * <td>class name</td>
  * <td>no</td>
- * <td>org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker</td>
+ * <td>org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker
+ * </td>
  * </tr>
  * <tr>
  * <td>{@link #COMPRESSION}</td>
@@ -507,6 +508,12 @@ public final class SessionParameter {
     /** Class name of the binding class. */
     public static final String BINDING_SPI_CLASS = "org.apache.chemistry.opencmis.binding.spi.classname";
 
+    /**
+     * Forces OpenCMIS to use the specified CMIS version and ignore the CMIS
+     * version reported by the repository.
+     */
+    public static final String FORCE_CMIS_VERSION = "org.apache.chemistry.opencmis.cmisversion";
+
     /** URL of the AtomPub service document. */
     public static final String ATOMPUB_URL = "org.apache.chemistry.opencmis.binding.atompub.url";
 



Mime
View raw message