You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/11/05 18:25:30 UTC

svn commit: r1031674 - in /incubator/chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/ chemistry-opencmis-commons/chemistry-opencmis-commons-api...

Author: fguillaume
Date: Fri Nov  5 17:25:30 2010
New Revision: 1031674

URL: http://svn.apache.org/viewvc?rev=1031674&view=rev
Log:
Make CallContext map more generic (holds Objects)

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java Fri Nov  5 17:25:30 2010
@@ -93,7 +93,7 @@ public abstract class AbstractLocalServi
      */
     static class LocalCallContext implements CallContext {
 
-        private Map<String, String> contextMap = new HashMap<String, String>();
+        private Map<String, Object> contextMap = new HashMap<String, Object>();
 
         public LocalCallContext(String repositoryId, String user, String password) {
             contextMap.put(REPOSITORY_ID, repositoryId);
@@ -105,20 +105,20 @@ public abstract class AbstractLocalServi
             return BINDING_LOCAL;
         }
 
-        public String get(String key) {
+        public Object get(String key) {
             return contextMap.get(key);
         }
 
         public String getRepositoryId() {
-            return get(REPOSITORY_ID);
+            return (String) get(REPOSITORY_ID);
         }
 
         public String getUsername() {
-            return get(USERNAME);
+            return (String) get(USERNAME);
         }
 
         public String getPassword() {
-            return get(PASSWORD);
+            return (String) get(PASSWORD);
         }
 
         public String getLocale() {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java Fri Nov  5 17:25:30 2010
@@ -35,6 +35,8 @@ public interface CallContext {
     String OFFSET = "offset";
     String LENGTH = "length";
 
+    String SERVLET_CONTEXT = "servletContext";
+
     /**
      * Returns the binding. Usually it returns
      * {@link CallContext#BINDING_ATOMPUB},
@@ -50,12 +52,12 @@ public interface CallContext {
 
     /**
      * Returns context data by key.
-     * 
+     *
      * @param key
      *            the key
      * @return the data if the key is valid, <code>null</code> otherwise
      */
-    String get(String key);
+    Object get(String key);
 
     /**
      * Returns the repository id.

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java Fri Nov  5 17:25:30 2010
@@ -30,7 +30,7 @@ public class CallContextImpl implements 
 
     private String binding;
     private boolean objectInfoRequired;
-    private Map<String, String> parameter = new HashMap<String, String>();
+    private Map<String, Object> parameter = new HashMap<String, Object>();
 
     public CallContextImpl(String binding, String repositoryId, boolean objectInfoRequired) {
         this.binding = binding;
@@ -46,37 +46,37 @@ public class CallContextImpl implements 
         return objectInfoRequired;
     }
 
-    public String get(String key) {
+    public Object get(String key) {
         return parameter.get(key);
     }
 
     public String getRepositoryId() {
-        return get(REPOSITORY_ID);
+        return (String) get(REPOSITORY_ID);
     }
 
     public String getUsername() {
-        return get(USERNAME);
+        return (String) get(USERNAME);
     }
 
     public String getPassword() {
-        return get(PASSWORD);
+        return (String) get(PASSWORD);
     }
 
     public String getLocale() {
-        return get(LOCALE);
+        return (String) get(LOCALE);
     }
 
     /**
      * Adds a parameter.
      */
-    public void put(String key, String value) {
+    public void put(String key, Object value) {
         parameter.put(key, value);
     }
 
     /**
      * Removes a parameter.
      */
-    public String remove(String key) {
+    public Object remove(String key) {
         return parameter.remove(key);
     }
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java Fri Nov  5 17:25:30 2010
@@ -158,7 +158,8 @@ public class CmisAtomPubServlet extends 
         // create a context object, dispatch and handle exceptions
         CallContext context = null;
         try {
-            context = HttpUtils.createContext(request, CallContext.BINDING_ATOMPUB, callContextHandler);
+            context = HttpUtils.createContext(request, getServletContext(),
+                    CallContext.BINDING_ATOMPUB, callContextHandler);
             dispatch(context, request, response);
         } catch (Exception e) {
             if (e instanceof CmisPermissionDeniedException) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Fri Nov  5 17:25:30 2010
@@ -389,13 +389,13 @@ public final class ObjectService {
         String streamId = getStringParameter(request, Constants.PARAM_STREAM_ID);
 
         BigInteger offset = null;
-        String offsetStr = context.get(CallContext.OFFSET);
+        String offsetStr = (String) context.get(CallContext.OFFSET);
         if (offsetStr != null) {
             offset = new BigInteger(offsetStr);
         }
 
         BigInteger length = null;
-        String lengthStr = context.get(CallContext.LENGTH);
+        String lengthStr = (String) context.get(CallContext.LENGTH);
         if (lengthStr != null) {
             length = new BigInteger(offsetStr);
         }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java Fri Nov  5 17:25:30 2010
@@ -88,6 +88,10 @@ public abstract class AbstractService {
             }
         }
 
+        ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
+                MessageContext.SERVLET_CONTEXT);
+        context.put(CallContext.SERVLET_CONTEXT, servletContext);
+
         return context;
     }
 

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java Fri Nov  5 17:25:30 2010
@@ -22,7 +22,9 @@ import java.lang.reflect.Method;
 import java.math.BigInteger;
 import java.util.Map;
 
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.handler.MessageContext;
 
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
@@ -37,7 +39,8 @@ public class HttpUtils {
     /**
      * Creates a {@link CallContext} object from a servlet request.
      */
-    public static CallContext createContext(HttpServletRequest request, String binding,
+    public static CallContext createContext(HttpServletRequest request,
+            ServletContext servletContext, String binding,
             CallContextHandler callContextHandler) {
         String[] pathFragments = splitPath(request);
 
@@ -58,6 +61,9 @@ public class HttpUtils {
             }
         }
 
+        // servlet context
+        context.put(CallContext.SERVLET_CONTEXT, servletContext);
+
         // decode range
         String rangeHeader = request.getHeader("Range");
         if (rangeHeader != null) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java?rev=1031674&r1=1031673&r2=1031674&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java Fri Nov  5 17:25:30 2010
@@ -27,7 +27,7 @@ import java.util.Map;
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 
 public class DummyCallContext implements CallContext {
-    private Map<String, String> fParameter = new HashMap<String, String>();
+    private Map<String, Object> fParameter = new HashMap<String, Object>();
 
     public DummyCallContext() {
         fParameter.put(USERNAME, "TestUser");
@@ -39,7 +39,7 @@ public class DummyCallContext implements
         return false;
     }
 
-    public String get(String key) {
+    public Object get(String key) {
         return fParameter.get(key);
     }
 
@@ -48,19 +48,19 @@ public class DummyCallContext implements
     }
 
     public String getRepositoryId() {
-        return get(REPOSITORY_ID);
+        return (String) get(REPOSITORY_ID);
     }
 
     public String getLocale() {
-        return get(LOCALE);
+        return (String) get(LOCALE);
     }
 
     public String getPassword() {
-        return get(PASSWORD);
+        return (String) get(PASSWORD);
     }
 
     public String getUsername() {
-        return get(USERNAME);
+        return (String) get(USERNAME);
     }
 
     public void put(String key, String value) {