chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r786580 - in /incubator/chemistry/trunk/chemistry: chemistry-atompub-server/ chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/ chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/ chemi...
Date Fri, 19 Jun 2009 16:56:39 GMT
Author: fguillaume
Date: Fri Jun 19 16:56:38 2009
New Revision: 786580

URL: http://svn.apache.org/viewvc?rev=786580&view=rev
Log:
Added start of JAX-RS bindings for the AtomPub server

Added:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java
      - copied, changed from r785598, incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServlet.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
  (contents, props changed)
      - copied, changed from r785598, incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubServer.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
  (with props)
Removed:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServlet.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubServer.java
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
    incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
    incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
    incubator/chemistry/trunk/chemistry/chemistry-ws/pom.xml

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/pom.xml?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/pom.xml Fri Jun 19 16:56:38
2009
@@ -47,6 +47,10 @@
       <groupId>org.apache.abdera</groupId>
       <artifactId>abdera-client</artifactId>
     </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>jsr311-api</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>org.apache.chemistry</groupId>
@@ -74,6 +78,11 @@
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISProvider.java
Fri Jun 19 16:56:38 2009
@@ -148,12 +148,12 @@
     }
 
     @Override
-    protected WorkspaceManager getWorkspaceManager(RequestContext request) {
+    public WorkspaceManager getWorkspaceManager(RequestContext request) {
         return workspaceManager;
     }
 
     @Override
-    protected ResponseContext getServiceDocument(final RequestContext request) {
+    public ResponseContext getServiceDocument(final RequestContext request) {
         CMISServiceResponse response = new CMISServiceResponse(this, request);
         response.setStatus(200);
         response.setContentType(Constants.APP_MEDIA_TYPE);

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,139 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     Bogdan Stefanescu, Nuxeo
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.server.jaxrs;
+
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.abdera.protocol.server.CollectionAdapter;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.ServiceManager;
+import org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter;
+import org.apache.abdera.protocol.server.servlet.ServletRequestContext;
+import org.apache.chemistry.Repository;
+import org.apache.chemistry.atompub.server.CMISProvider;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A JAX-RS Resource that dispatches to the underlying Abdera
+ * {@link CMISProvider}.
+ */
+public class AbderaResource {
+
+    private static final Log log = LogFactory.getLog(AbderaResource.class);
+
+    protected CMISProvider provider;
+
+    @Context
+    protected HttpServletRequest httpRequest;
+
+    // TODO inject repository somehow
+    public static Repository repository;
+
+    public AbderaResource() throws Exception {
+        try {
+            provider = new CMISProvider(repository);
+            provider.init(ServiceManager.getAbdera(),
+                    new HashMap<String, String>());
+        } catch (Exception e) {
+            log.error(e, e);
+            throw e;
+        }
+    }
+
+    protected ServletRequestContext getRequestContext() {
+        return new ServletRequestContext(provider, httpRequest);
+    }
+
+    protected CollectionAdapter getAbderaCollectionAdapter(
+            RequestContext requestContext) {
+        return provider.getWorkspaceManager(requestContext).getCollectionAdapter(
+                requestContext);
+    }
+
+    protected Response getAbderaFeed() {
+        RequestContext requestContext = getRequestContext();
+        CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
+        return Response.ok(adapter.getFeed(requestContext)).build();
+    }
+
+    protected Response getAbderaEntry() {
+        RequestContext requestContext = getRequestContext();
+        CollectionAdapter adapter = getAbderaCollectionAdapter(requestContext);
+        return Response.ok(adapter.getEntry(requestContext)).build();
+    }
+
+    @GET
+    @Produces("application/atomsvc+xml")
+    @Path("repository")
+    public Response doGetRepository(@Context HttpServletRequest httpRequest) {
+        RequestContext requestContext = getRequestContext();
+        ResponseContext responseContext = provider.getServiceDocument(requestContext);
+        return Response.ok(responseContext).build();
+    }
+
+    @GET
+    @Produces("application/atom+xml;type=feed")
+    @Path("types")
+    public Response doGetTypes() {
+        return getAbderaFeed();
+    }
+
+    @GET
+    @Produces("application/atom+xml;type=feed")
+    @Path("children/{objectid}")
+    public Response doGetChildren() {
+        // objectid decoded by Abdera getCollectionAdapter
+        return getAbderaFeed();
+    }
+
+    @GET
+    @Produces("application/atom+xml;type=entry")
+    @Path("object/{objectid}")
+    public Response doGetObject() {
+        // objectid decoded by Abdera getCollectionAdapter
+        return getAbderaEntry();
+    }
+
+    @GET
+    @Path("file/{objectid}")
+    public Response doGetFile() {
+        // objectid decoded by Abdera getCollectionAdapter
+        RequestContext requestContext = getRequestContext();
+        AbstractCollectionAdapter adapter = (AbstractCollectionAdapter) getAbderaCollectionAdapter(requestContext);
+        ResponseContext responseContext = adapter.getMedia(requestContext);
+        String contentType = responseContext.getHeader("Content-Type");
+        return Response.ok(responseContext).type(contentType).build();
+    }
+
+    // @PUT
+    // @Path("object/{objectid}}")
+    // @Consumes("application/atom+xml;type=entry")
+    // public Response doPut(@PathParam("objectid") String objectid) {
+    // return AbderaProvider.putEntry(ctx, getCollectionAdapter());
+    // }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResource.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,41 @@
+package org.apache.chemistry.atompub.server.jaxrs;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.abdera.protocol.server.ResponseContext;
+
+/**
+ * A JAX-RS MessageBodyWriter that knows how to write an Abdera ResponseContext.
+ */
+@Provider
+public class AbderaResponseProvider implements
+        MessageBodyWriter<ResponseContext> {
+
+    public long getSize(ResponseContext responseContext, Class<?> type,
+            Type genericType, Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return ResponseContext.class.isAssignableFrom(type);
+    }
+
+    public void writeTo(ResponseContext responseContext, Class<?> type,
+            Type genericType, Annotation[] annotations, MediaType mediaType,
+            MultivaluedMap<String, Object> httpHeaders,
+            OutputStream entityStream) throws IOException,
+            WebApplicationException {
+        responseContext.writeTo(entityStream);
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/AbderaResponseProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     Bogdan Stefanescu, Nuxeo
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.server.jaxrs;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+/**
+ * A JAX-RS Application registering the relevant classes.
+ * <p>
+ * This is registered through implementation mechanism depending on the JAX-RS
+ * implementation.
+ * <p>
+ * For CXF, a CXFNonSpringJaxrsServlet servlet must be registered with this
+ * class as value of parameter javax.ws.rs.Application.
+ */
+public class CMISApplication extends Application {
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Set<Class<?>> getClasses() {
+        return new HashSet<Class<?>>(Arrays.asList( //
+        AbderaResource.class //
+        ));
+    }
+
+    /*
+     * CXFNonSpringJaxrsServlet expects Providers only as singletons...
+     */
+    @Override
+    public Set<Object> getSingletons() {
+        return new HashSet<Object>(Arrays.asList( //
+        new AbderaResponseProvider() //
+        ));
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/jaxrs/CMISApplication.java
------------------------------------------------------------------------------
    svn:keywords = Id

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java
(from r785598, incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServlet.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServlet.java&r1=785598&r2=786580&rev=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISServlet.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java
Fri Jun 19 16:56:38 2009
@@ -14,7 +14,7 @@
  * Authors:
  *     Florent Guillaume, Nuxeo
  */
-package org.apache.chemistry.atompub.server;
+package org.apache.chemistry.atompub.server.servlet;
 
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -28,6 +28,7 @@
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.RepositoryFactory;
+import org.apache.chemistry.atompub.server.CMISProvider;
 
 public class CMISServlet extends AbderaServlet {
 

Copied: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
(from r785598, incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubServer.java)
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java?p2=incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java&p1=incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubServer.java&r1=785598&r2=786580&rev=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubServer.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
Fri Jun 19 16:56:38 2009
@@ -19,8 +19,6 @@
 import java.io.IOException;
 import java.util.Arrays;
 
-import javax.servlet.Servlet;
-
 import junit.framework.TestCase;
 
 import org.apache.abdera.model.Element;
@@ -48,12 +46,10 @@
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
 
-public class TestAtomPubServer extends TestCase {
+public abstract class AtomPubServerTestCase extends TestCase {
 
-    private static final String TEST_FILE_CONTENT = "This is a test file.\nTesting, testing...\n";
+    public static final String TEST_FILE_CONTENT = "This is a test file.\nTesting, testing...\n";
 
     protected static final AbderaClient client = new AbderaClient();
 
@@ -80,14 +76,7 @@
         stopServer();
     }
 
-    public void startServer() throws Exception {
-        server = new Server(PORT);
-        Servlet servlet = new CMISServlet(repository);
-        ServletHolder servletHolder = new ServletHolder(servlet);
-        Context context = new Context(server, SERVLET_PATH, Context.SESSIONS);
-        context.addServlet(servletHolder, "/*");
-        server.start();
-    }
+    public abstract void startServer() throws Exception;
 
     public void stopServer() throws Exception {
         server.stop();

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/AtomPubServerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.server;
+
+import javax.servlet.Servlet;
+
+import org.apache.chemistry.atompub.server.servlet.CMISServlet;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * Test that uses the Abdera Servlet subclass {@link CMISServlet}.
+ */
+public class TestAtomPubAbderaServlet extends AtomPubServerTestCase {
+
+    @Override
+    public void startServer() throws Exception {
+        server = new Server(PORT);
+        Servlet servlet = new CMISServlet(repository);
+        ServletHolder servletHolder = new ServletHolder(servlet);
+        Context context = new Context(server, SERVLET_PATH, Context.SESSIONS);
+        context.addServlet(servletHolder, "/*");
+        server.start();
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubAbderaServlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed 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.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry.atompub.server;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.chemistry.atompub.server.jaxrs.AbderaResource;
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.IOUtils;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+/**
+ * Test that uses a JAX-RS Application (itself wrapping our Abdera {@link CMIS).
+ */
+public class TestAtomPubJaxrs extends AtomPubServerTestCase {
+
+    private File tmpDir;
+
+    @Override
+    public void startServer() throws Exception {
+        AbderaResource.repository = repository; // TODO inject differently
+        server = new Server(PORT);
+        server.setHandler(new WebAppContext(server, makeWar(), SERVLET_PATH));
+        server.start();
+    }
+
+    public String makeWar() throws IOException {
+        tmpDir = makeTmpDir();
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        InputStream is = cl.getResourceAsStream("jaxrs/web.xml");
+        File war = new File(tmpDir, "war");
+        File webinf = new File(war, "WEB-INF");
+        webinf.mkdirs();
+        File web = new File(webinf, "web.xml");
+        OutputStream os = new FileOutputStream(web);
+        IOUtils.copy(is, os);
+        return war.getAbsolutePath();
+    }
+
+    @Override
+    public void stopServer() throws Exception {
+        try {
+            super.stopServer();
+        } finally {
+            FileUtils.removeDir(tmpDir);
+        }
+    }
+
+    public static File makeTmpDir() throws IOException {
+        File tmpDir = File.createTempFile("test-chemistry-", null);
+        tmpDir.delete();
+        tmpDir.mkdir();
+        return tmpDir;
+    }
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/java/org/apache/chemistry/atompub/server/TestAtomPubJaxrs.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml?rev=786580&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
Fri Jun 19 16:56:38 2009
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+  "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+  <servlet>
+    <servlet-name>cxfjaxrs</servlet-name>
+    <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+    <init-param>
+      <param-name>javax.ws.rs.Application</param-name>
+      <param-value>org.apache.chemistry.atompub.server.jaxrs.CMISApplication</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>cxfjaxrs</servlet-name>
+    <url-pattern>/*</url-pattern> <!-- context defined in code -->
+  </servlet-mapping>
+</web-app>

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/test/resources/jaxrs/web.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-parent/pom.xml Fri Jun 19 16:56:38 2009
@@ -28,7 +28,20 @@
   <name>Chemistry Parent POM</name>
   <packaging>pom</packaging>
 
+  <properties>
+    <cxf.version>2.2.2</cxf.version>
+  </properties>
+
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.cxf</groupId>
+          <artifactId>cxf-codegen-plugin</artifactId>
+          <version>${cxf.version}</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
       <!-- Use Java 1.5 everywhere -->
       <plugin>
@@ -123,6 +136,16 @@
         <artifactId>wstx-asl</artifactId>
         <version>3.2.1</version>
       </dependency>
+      <dependency>
+        <groupId>javax.ws.rs</groupId>
+        <artifactId>jsr311-api</artifactId>
+        <version>1.0</version>
+      </dependency>
+      <dependency>
+	<groupId>org.apache.cxf</groupId>
+	<artifactId>cxf-rt-frontend-jaxrs</artifactId>
+	<version>${cxf.version}</version>
+      </dependency>
 
       <dependency>
         <groupId>junit</groupId>

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/main/java/org/apache/chemistry/test/MainServlet.java
Fri Jun 19 16:56:38 2009
@@ -19,7 +19,7 @@
 import javax.servlet.Servlet;
 
 import org.apache.chemistry.Repository;
-import org.apache.chemistry.atompub.server.CMISServlet;
+import org.apache.chemistry.atompub.server.servlet.CMISServlet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.Connector;

Modified: incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-tests/src/test/java/org/apache/chemistry/test/TestAtomPubClientServer.java
Fri Jun 19 16:56:38 2009
@@ -21,7 +21,7 @@
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.atompub.client.ContentManager;
 import org.apache.chemistry.atompub.client.connector.APPContentManager;
-import org.apache.chemistry.atompub.server.CMISServlet;
+import org.apache.chemistry.atompub.server.servlet.CMISServlet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.Connector;

Modified: incubator/chemistry/trunk/chemistry/chemistry-ws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-ws/pom.xml?rev=786580&r1=786579&r2=786580&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-ws/pom.xml (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-ws/pom.xml Fri Jun 19 16:56:38 2009
@@ -28,10 +28,6 @@
   <artifactId>chemistry-ws</artifactId>
   <name>Chemistry WebServices</name>
 
-  <properties>
-    <cxf.version>2.2.1</cxf.version>
-  </properties>
-
   <dependencies>
     <dependency>
       <groupId>org.apache.chemistry</groupId>
@@ -64,7 +60,6 @@
       <plugin>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-codegen-plugin</artifactId>
-        <version>${cxf.version}</version>
         <executions>
           <execution>
             <id>generate-sources</id>



Mime
View raw message