chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1500288 - in /chemistry/opencmis/trunk: ./ chemistry-opencmis-client/chemistry-opencmis-client-bindings/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservic...
Date Sat, 06 Jul 2013 14:53:20 GMT
Author: fmui
Date: Sat Jul  6 14:53:19 2013
New Revision: 1500288

URL: http://svn.apache.org/r1500288
Log:
OpenCMIS client: added experimental Axis2 support

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/Axis2PortProvider.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CmisWebServicesSpi.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-assembly.xml
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-cxf-assembly.xml
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-mac-assembly.xml
    chemistry/opencmis/trunk/pom.xml

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/pom.xml?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/pom.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/pom.xml
Sat Jul  6 14:53:19 2013
@@ -112,7 +112,13 @@
             <artifactId>cxf-rt-transports-http</artifactId>
             <version>${cxf.version}</version>
             <scope>provided</scope>
-        </dependency> 
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-kernel</artifactId>
+            <version>${axis2.version}</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
     
 </project>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.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/AbstractPortProvider.java?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
Sat Jul  6 14:53:19 2013
@@ -178,7 +178,9 @@ public abstract class AbstractPortProvid
         private SoftReference<Service> serviceObject;
         private final URL endpointUrl;
 
-        public CmisServiceHolder(final CmisWebSerivcesService service, final URL endpointUrl)
throws NoSuchMethodException, SecurityException, InstantiationException, InvocationTargetException,
IllegalAccessException {
+        public CmisServiceHolder(final CmisWebSerivcesService service, final URL endpointUrl)
+                throws NoSuchMethodException, SecurityException, InstantiationException,
InvocationTargetException,
+                IllegalAccessException {
             this.service = service;
             this.endpointUrl = endpointUrl;
             this.serviceObject = new SoftReference<Service>(createServiceObject());
@@ -488,19 +490,22 @@ public abstract class AbstractPortProvid
             return new CmisServiceHolder(service, endpointUrl);
         } catch (CmisBaseException ce) {
             throw ce;
+        } catch (HTTPException he) {
+            String message = "Cannot connect to Web Services [" + service.getServiceName()
+ "]: " + he.getMessage();
+            if (he.getStatusCode() == 401) {
+                throw new CmisUnauthorizedException(message, he);
+            } else if (he.getStatusCode() == 407) {
+                throw new CmisProxyAuthenticationException(message, he);
+            } else {
+                throw new CmisConnectionException(message, he);
+            }
+        } catch (InvocationTargetException ite) {
+            String message = "Cannot initalize Web Services service object [" + service.getServiceName()
+ "]: "
+                    + ite.getCause().getMessage();
+            throw new CmisConnectionException(message, ite);
         } catch (Exception e) {
             String message = "Cannot initalize Web Services service object [" + service.getServiceName()
+ "]: "
                     + e.getMessage();
-
-            if (e instanceof HTTPException) {
-                HTTPException he = (HTTPException) e;
-                if (he.getStatusCode() == 401) {
-                    throw new CmisUnauthorizedException(message, e);
-                } else if (he.getStatusCode() == 407) {
-                    throw new CmisProxyAuthenticationException(message, e);
-                }
-            }
-
             throw new CmisConnectionException(message, e);
         }
     }

Added: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/Axis2PortProvider.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/Axis2PortProvider.java?rev=1500288&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/Axis2PortProvider.java
(added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/Axis2PortProvider.java
Sat Jul  6 14:53:19 2013
@@ -0,0 +1,131 @@
+/*
+ * 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.client.bindings.spi.webservices;
+
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.client.Stub;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
+import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+/**
+ * Axis2 JAX-WS implementation
+ * 
+ * !!! EXPERIMENTAL !!!
+ */
+public class Axis2PortProvider extends AbstractPortProvider {
+    private static final Logger LOG = LoggerFactory.getLogger(Axis2PortProvider.class);
+
+    /**
+     * Creates a port object.
+     */
+    protected BindingProvider createPortObject(CmisServiceHolder serviceHolder) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Creating Web Service port object of " + serviceHolder.getServiceName()
+ "...");
+        }
+
+        try {
+            // create port object
+            BindingProvider portObject = createPortObjectFromServiceHolder(serviceHolder,
new MTOMFeature());
+            ServiceClient serviceClient = ((Stub) portObject)._getServiceClient();
+
+            // add SOAP and HTTP authentication headers
+            AuthenticationProvider authProvider = CmisBindingsHelper.getAuthenticationProvider(getSession());
+            Map<String, List<String>> httpHeaders = null;
+            if (authProvider != null) {
+                // SOAP header
+                Element soapHeader = authProvider.getSOAPHeaders(portObject);
+                if (soapHeader != null) {
+                    TransformerFactory transFactory = TransformerFactory.newInstance();
+                    Transformer transformer = transFactory.newTransformer();
+                    StringWriter headerXml = new StringWriter();
+                    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+                    transformer.transform(new DOMSource(soapHeader), new StreamResult(headerXml));
+
+                    serviceClient.addStringHeader(new QName(soapHeader.getNamespaceURI(),
soapHeader.getLocalName()),
+                            headerXml.toString());
+                    /*
+                     * Map<QName, List<String>> header = new HashMap<QName,
+                     * List<String>>(); header.put(new
+                     * QName(soapHeader.getNamespaceURI(),
+                     * soapHeader.getLocalName()),
+                     * Collections.singletonList(headerXml.toString()));
+                     * portObject.getRequestContext().put(
+                     * "jaxws.binding.soap.headers.outbound", header);
+                     */
+                }
+
+                // HTTP header
+                String url = (serviceHolder.getEndpointUrl() != null ? serviceHolder.getEndpointUrl().toString()
+                        : serviceHolder.getServiceObject().getWSDLDocumentLocation().toString());
+                httpHeaders = authProvider.getHTTPHeaders(url);
+
+                // TODO: set SSL Factory
+
+                // TODO: set Hostname Verifier
+            }
+
+            // set HTTP headers
+            setHTTPHeaders(portObject, httpHeaders);
+
+            // set endpoint URL
+            setEndpointUrl(portObject, serviceHolder.getEndpointUrl());
+
+            // HTTP settings
+            serviceClient.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true");
+
+            // timeouts
+            int connectTimeout = getSession().get(SessionParameter.CONNECT_TIMEOUT, -1);
+            if (connectTimeout >= 0) {
+                serviceClient.getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT,
+                        Integer.valueOf(connectTimeout));
+            }
+
+            int readTimeout = getSession().get(SessionParameter.READ_TIMEOUT, -1);
+            if (readTimeout >= 0) {
+                serviceClient.getOptions().setProperty(HTTPConstants.SO_TIMEOUT, Integer.valueOf(readTimeout));
+            }
+
+            return portObject;
+        } catch (CmisBaseException ce) {
+            throw ce;
+        } catch (Exception e) {
+            throw new CmisConnectionException("Cannot initalize Web Services port object:
" + e.getMessage(), e);
+        }
+    }
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CmisWebServicesSpi.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/CmisWebServicesSpi.java?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CmisWebServicesSpi.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CmisWebServicesSpi.java
Sat Jul  6 14:53:19 2013
@@ -44,6 +44,7 @@ public class CmisWebServicesSpi implemen
     public static final String JAXWS_IMPL_JRE = "sunjre";
     public static final String JAXWS_IMPL_CXF = "cxf";
     public static final String JAXWS_IMPL_WEBSPHERE = "websphere";
+    public static final String JAXWS_IMPL_AXIS2 = "axis2";
 
     private static final Logger LOG = LoggerFactory.getLogger(CmisWebServicesSpi.class);
 
@@ -83,6 +84,8 @@ public class CmisWebServicesSpi implemen
                 portProvider = new CXFPortProvider();
             } else if (JAXWS_IMPL_WEBSPHERE.equals(jaxwsImpl)) {
                 portProvider = new WebSpherePortProvider();
+            } else if (JAXWS_IMPL_AXIS2.equals(jaxwsImpl)) {
+                portProvider = new Axis2PortProvider();
             } else {
                 throw new CmisRuntimeException("Unknown JAX-WS implementation specified!");
             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-assembly.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-assembly.xml?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-assembly.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-assembly.xml
Sat Jul  6 14:53:19 2013
@@ -66,8 +66,9 @@
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
                 <exclude>com.sun.xml.ws:jaxws-rt</exclude>
-                <exclude>org.apache.cxf:cxf-rt-frontend-jaxws</exclude>
-                <exclude>org.apache.cxf:cxf-rt-transports-http</exclude>
+                <exclude>wsdl4j</exclude>
+                <exclude>org.apache.cxf</exclude>
+                <exclude>org.apache.axis2</exclude>
                 <exclude>org.apache:apache-jar-resource-bundle</exclude>
             </excludes>
         </dependencySet>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-cxf-assembly.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-cxf-assembly.xml?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-cxf-assembly.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-cxf-assembly.xml
Sat Jul  6 14:53:19 2013
@@ -68,6 +68,7 @@
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
                 <exclude>com.sun.xml.ws:jaxws-rt</exclude>
+                <exclude>org.apache.axis2</exclude>
                 <exclude>org.apache:apache-jar-resource-bundle</exclude>
             </excludes>
         </dependencySet>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-mac-assembly.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-mac-assembly.xml?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-mac-assembly.xml
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/assembly/workbench-mac-assembly.xml
Sat Jul  6 14:53:19 2013
@@ -76,8 +76,9 @@
             <useTransitiveFiltering>true</useTransitiveFiltering>
             <excludes>
                 <exclude>com.sun.xml.ws:jaxws-rt</exclude>
-                <exclude>org.apache.cxf:cxf-rt-frontend-jaxws</exclude>
-                <exclude>org.apache.cxf:cxf-rt-transports-http</exclude>
+                <exclude>wsdl4j</exclude>
+                <exclude>org.apache.cxf</exclude>
+                <exclude>org.apache.axis2</exclude>
                 <exclude>org.apache:apache-jar-resource-bundle</exclude>
             </excludes>
         </dependencySet>

Modified: chemistry/opencmis/trunk/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/pom.xml?rev=1500288&r1=1500287&r2=1500288&view=diff
==============================================================================
--- chemistry/opencmis/trunk/pom.xml (original)
+++ chemistry/opencmis/trunk/pom.xml Sat Jul  6 14:53:19 2013
@@ -235,6 +235,7 @@
         <slf4j.version>1.7.5</slf4j.version>
         <log4j.version>1.2.17</log4j.version>
         <cxf.version>2.7.4</cxf.version>
+        <axis2.version>1.6.2</axis2.version>
     </properties>
 
     <build>



Mime
View raw message