Return-Path: Delivered-To: apmail-incubator-chemistry-commits-archive@minotaur.apache.org Received: (qmail 28766 invoked from network); 19 Jun 2009 16:56:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Jun 2009 16:56:56 -0000 Received: (qmail 72123 invoked by uid 500); 19 Jun 2009 16:57:07 -0000 Delivered-To: apmail-incubator-chemistry-commits-archive@incubator.apache.org Received: (qmail 72101 invoked by uid 500); 19 Jun 2009 16:57:07 -0000 Mailing-List: contact chemistry-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: chemistry-dev@incubator.apache.org Delivered-To: mailing list chemistry-commits@incubator.apache.org Received: (qmail 72091 invoked by uid 99); 19 Jun 2009 16:57:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2009 16:57:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2009 16:57:01 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7238E2388877; Fri, 19 Jun 2009 16:56:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: chemistry-commits@incubator.apache.org From: fguillaume@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090619165640.7238E2388877@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ org.apache.abdera abdera-client + + javax.ws.rs + jsr311-api + org.apache.chemistry @@ -74,6 +78,11 @@ slf4j-log4j12 test + + org.apache.cxf + cxf-rt-frontend-jaxrs + test + 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()); + } 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 { + + 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 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. + *

+ * This is registered through implementation mechanism depending on the JAX-RS + * implementation. + *

+ * 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> getClasses() { + return new HashSet>(Arrays.asList( // + AbderaResource.class // + )); + } + + /* + * CXFNonSpringJaxrsServlet expects Providers only as singletons... + */ + @Override + public Set getSingletons() { + return new HashSet(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 @@ + + + + + cxfjaxrs + org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet + + javax.ws.rs.Application + org.apache.chemistry.atompub.server.jaxrs.CMISApplication + + 1 + + + + cxfjaxrs + /* + + 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 @@ Chemistry Parent POM pom + + 2.2.2 + + + + + + org.apache.cxf + cxf-codegen-plugin + ${cxf.version} + + + @@ -123,6 +136,16 @@ wstx-asl 3.2.1 + + javax.ws.rs + jsr311-api + 1.0 + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + junit 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 @@ chemistry-ws Chemistry WebServices - - 2.2.1 - - org.apache.chemistry @@ -64,7 +60,6 @@ org.apache.cxf cxf-codegen-plugin - ${cxf.version} generate-sources