chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1428938 - in /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main: java/org/apache/chemistry/opencmis/server/impl/atompub/ java/org/apache/chemistry/opencmis/server/impl/webservices/ webapp/WEB-INF/
Date Fri, 04 Jan 2013 15:53:51 GMT
Author: fmui
Date: Fri Jan  4 15:53:51 2013
New Revision: 1428938

URL: http://svn.apache.org/viewvc?rev=1428938&view=rev
Log:
Server: prepared Web Services and AtomPub binding servlets for CMIS 1.1

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1428938&r1=1428937&r2=1428938&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
Fri Jan  4 15:53:51 2013
@@ -88,12 +88,14 @@ import org.slf4j.LoggerFactory;
 public class CmisAtomPubServlet extends HttpServlet {
 
     public static final String PARAM_CALL_CONTEXT_HANDLER = "callContextHandler";
-    public static final String PARAM_TRUSTED_PROXIES = "trustedProxies";
+    public static final String PARAM_CMIS_VERSION = "cmisVersion";
 
     private static final Logger LOG = LoggerFactory.getLogger(CmisAtomPubServlet.class.getName());
 
     private static final long serialVersionUID = 1L;
 
+    private CmisVersion cmisVersion;
+
     private File tempDir;
     private int memoryThreshold;
     private long maxContentSize;
@@ -117,6 +119,24 @@ public class CmisAtomPubServlet extends 
             }
         }
 
+        // get CMIS version
+        String cmisVersionStr = config.getInitParameter(PARAM_CMIS_VERSION);
+        if (cmisVersionStr != null) {
+            try {
+                cmisVersion = CmisVersion.fromValue(cmisVersionStr);
+
+                // !!! As long as CMIS 1.1 is not implemented, we have to set
+                // the CMIS version to 1.0 !!!
+                cmisVersion = CmisVersion.CMIS_1_0;
+            } catch (IllegalArgumentException e) {
+                LOG.warn("CMIS version is invalid! Setting it to CMIS 1.0.");
+                cmisVersion = CmisVersion.CMIS_1_0;
+            }
+        } else {
+            LOG.warn("CMIS version is not defined! Setting it to CMIS 1.0.");
+            cmisVersion = CmisVersion.CMIS_1_0;
+        }
+
         // get memory threshold and temp directory
         CmisServiceFactory factory = (CmisServiceFactory) config.getServletContext().getAttribute(
                 CmisRepositoryContextListener.SERVICES_FACTORY);
@@ -188,7 +208,7 @@ public class CmisAtomPubServlet extends 
         CallContext context = null;
         try {
             context = HttpUtils.createContext(qsRequest, response, getServletContext(), CallContext.BINDING_ATOMPUB,
-                    CmisVersion.CMIS_1_0, callContextHandler, tempDir, memoryThreshold, maxContentSize,
encrypt);
+                    cmisVersion, callContextHandler, tempDir, memoryThreshold, maxContentSize,
encrypt);
             dispatch(context, qsRequest, response);
         } catch (Exception e) {
             if (e instanceof CmisPermissionDeniedException) {

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1428938&r1=1428937&r2=1428938&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
Fri Jan  4 15:53:51 2013
@@ -91,7 +91,8 @@ public abstract class AbstractService {
     protected CallContext createContext(WebServiceContext wsContext, CmisServiceFactory factory,
String repositoryId) {
         CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId,
false);
 
-        context.put(CallContext.CMIS_VERSION, CmisVersion.CMIS_1_0);
+        ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
+                MessageContext.SERVLET_CONTEXT);
 
         MessageContext mc = wsContext.getMessageContext();
         Map<String, String> callContextMap = (Map<String, String>) mc.get(CALL_CONTEXT_MAP);
@@ -101,8 +102,9 @@ public abstract class AbstractService {
             }
         }
 
-        ServletContext servletContext = (ServletContext) wsContext.getMessageContext().get(
-                MessageContext.SERVLET_CONTEXT);
+        CmisVersion cmisVersion = (CmisVersion) servletContext.getAttribute(CmisWebServicesServlet.CMIS_VERSION);
+        context.put(CallContext.CMIS_VERSION, cmisVersion);
+
         context.put(CallContext.SERVLET_CONTEXT, servletContext);
 
         HttpServletRequest request = (HttpServletRequest) wsContext.getMessageContext().get(

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.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/webservices/CmisWebServicesServlet.java?rev=1428938&r1=1428937&r2=1428938&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
Fri Jan  4 15:53:51 2013
@@ -19,11 +19,15 @@
 package org.apache.chemistry.opencmis.server.impl.webservices;
 
 import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
 import javax.xml.ws.WebServiceFeature;
 
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
 import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.sun.xml.ws.api.WSFeatureList;
 import com.sun.xml.ws.developer.StreamingAttachmentFeature;
@@ -32,8 +36,43 @@ import com.sun.xml.ws.transport.http.ser
 import com.sun.xml.ws.transport.http.servlet.WSServletDelegate;
 
 public class CmisWebServicesServlet extends WSServlet {
+
+    public static final String PARAM_CMIS_VERSION = "cmisVersion";
+
+    public static final String CMIS_VERSION = "org.apache.chemistry.opencmis.cmisVersion";
+
+    private static final Logger LOG = LoggerFactory.getLogger(CmisWebServicesServlet.class.getName());
+
     private static final long serialVersionUID = 1L;
 
+    private CmisVersion cmisVersion;
+
+    @Override
+    public void init(ServletConfig config) throws ServletException {
+
+        // get CMIS version
+        String cmisVersionStr = config.getInitParameter(PARAM_CMIS_VERSION);
+        if (cmisVersionStr != null) {
+            try {
+                cmisVersion = CmisVersion.fromValue(cmisVersionStr);
+
+                // !!! As long as CMIS 1.1 is not implemented, we have to set
+                // the CMIS version to 1.0 !!!
+                cmisVersion = CmisVersion.CMIS_1_0;
+            } catch (IllegalArgumentException e) {
+                LOG.warn("CMIS version is invalid! Setting it to CMIS 1.0.");
+                cmisVersion = CmisVersion.CMIS_1_0;
+            }
+        } else {
+            LOG.warn("CMIS version is not defined! Setting it to CMIS 1.0.");
+            cmisVersion = CmisVersion.CMIS_1_0;
+        }
+
+        config.getServletContext().setAttribute(CMIS_VERSION, cmisVersion);
+
+        super.init(config);
+    }
+
     @Override
     protected WSServletDelegate getDelegate(ServletConfig servletConfig) {
         WSServletDelegate delegate = super.getDelegate(servletConfig);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml?rev=1428938&r1=1428937&r2=1428938&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/webapp/WEB-INF/web.xml
Fri Jan  4 15:53:51 2013
@@ -98,18 +98,50 @@
 	-->
 
 	<servlet>
-		<servlet-name>cmisws</servlet-name>
+		<servlet-name>cmisws10</servlet-name>
 		<servlet-class>org.apache.chemistry.opencmis.server.impl.webservices.CmisWebServicesServlet</servlet-class>
+		<init-param>
+			<param-name>cmisVersion</param-name>
+			<param-value>1.0</param-value>
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+	
+	<servlet>
+		<servlet-name>cmisws11</servlet-name>
+		<servlet-class>org.apache.chemistry.opencmis.server.impl.webservices.CmisWebServicesServlet</servlet-class>
+		<init-param>
+			<param-name>cmisVersion</param-name>
+			<param-value>1.1</param-value>
+		</init-param>
 		<load-on-startup>1</load-on-startup>
 	</servlet>
 
 	<servlet>
-		<servlet-name>cmisatom</servlet-name>
+		<servlet-name>cmisatom10</servlet-name>
+		<servlet-class>org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet</servlet-class>
+		<init-param>
+			<param-name>callContextHandler</param-name>
+			<param-value>org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler</param-value>
+		</init-param>
+		<init-param>
+			<param-name>cmisVersion</param-name>
+			<param-value>1.0</param-value>
+		</init-param>
+		<load-on-startup>2</load-on-startup>
+	</servlet>
+
+	<servlet>
+		<servlet-name>cmisatom11</servlet-name>
 		<servlet-class>org.apache.chemistry.opencmis.server.impl.atompub.CmisAtomPubServlet</servlet-class>
 		<init-param>
 			<param-name>callContextHandler</param-name>
 			<param-value>org.apache.chemistry.opencmis.server.shared.BasicAuthCallContextHandler</param-value>
 		</init-param>
+		<init-param>
+			<param-name>cmisVersion</param-name>
+			<param-value>1.1</param-value>
+		</init-param>
 		<load-on-startup>2</load-on-startup>
 	</servlet>
 	
@@ -124,14 +156,24 @@
 	</servlet>
 
 	<servlet-mapping>
-		<servlet-name>cmisws</servlet-name>
+		<servlet-name>cmisws10</servlet-name>
 		<url-pattern>/services/*</url-pattern>
 	</servlet-mapping>
 
 	<servlet-mapping>
-		<servlet-name>cmisatom</servlet-name>
+		<servlet-name>cmisws11</servlet-name>
+		<url-pattern>/services11/*</url-pattern>
+	</servlet-mapping>
+
+	<servlet-mapping>
+		<servlet-name>cmisatom10</servlet-name>
 		<url-pattern>/atom/*</url-pattern>
 	</servlet-mapping>
+	
+	<servlet-mapping>
+		<servlet-name>cmisatom11</servlet-name>
+		<url-pattern>/atom11/*</url-pattern>
+	</servlet-mapping>
 
 	<servlet-mapping>
 		<servlet-name>cmisbrowser</servlet-name>



Mime
View raw message