Author: bcarothers
Date: 2009-05-11 13:25:19 -0400 (Mon, 11 May 2009)
New Revision: 900
Added:
trunk/extensions/dna-web-jcr-rest/
trunk/extensions/dna-web-jcr-rest/.classpath
trunk/extensions/dna-web-jcr-rest/.project
trunk/extensions/dna-web-jcr-rest/pom.xml
trunk/extensions/dna-web-jcr-rest/src/
trunk/extensions/dna-web-jcr-rest/src/main/
trunk/extensions/dna-web-jcr-rest/src/main/java/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
trunk/extensions/dna-web-jcr-rest/src/main/resources/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/
trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
trunk/extensions/dna-web-jcr-rest/src/test/
trunk/extensions/dna-web-jcr-rest/src/test/java/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
Log:
Adding patch to create the web project for RESTful services along with Maven integration
for automatic deployment and in-container unit testing.
Added: trunk/extensions/dna-web-jcr-rest/.classpath
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.classpath (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/.classpath 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: trunk/extensions/dna-web-jcr-rest/.project
===================================================================
--- trunk/extensions/dna-web-jcr-rest/.project (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/.project 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-web-jcr-rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: trunk/extensions/dna-web-jcr-rest/pom.xml
===================================================================
--- trunk/extensions/dna-web-jcr-rest/pom.xml (rev 0)
+++ trunk/extensions/dna-web-jcr-rest/pom.xml 2009-05-11 17:25:19 UTC (rev 900)
@@ -0,0 +1,98 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>dna</artifactId>
+ <groupId>org.jboss.dna</groupId>
+ <version>0.5-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-web-jcr-rest</artifactId>
+ <packaging>war</packaging>
+ <name>JBoss DNA JCR REST Servlet</name>
+ <description>JBoss DNA servlet that provides RESTful access to JCR
items</description>
+ <
url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>1.1-RC2</version>
+ </dependency>
+
+ <!--
+ Java Content Repository API
+ -->
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+
+ <!-- TESTING DEPENDENCIES -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>4.4</version>
+ <scope>integration-test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-client</artifactId>
+ <version>1.0-beta-8</version>
+ <scope>integration-test</scope>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <finalName>resources</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ </configuration>
+ </plugin>
+ <!--
+ Override the default Surefire behavior to run during
+ integration-test phase
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Property changes on: trunk/extensions/dna-web-jcr-rest/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
===================================================================
---
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
(rev 0)
+++
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java 2009-05-11
17:25:19 UTC (rev 900)
@@ -0,0 +1,47 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import java.util.Collections;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+
+/**
+ * Implementation of the JAX-RS {@code Application} class to identify all JAX-RS
providers and classes in the application.
+ *
+ * @see Application
+ */
+public class JcrApplication extends Application {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Application#getClasses()
+ */
+ @Override
+ public Set<Class<?>> getClasses() {
+ return Collections.<Class<?>>singleton(JcrResources.class);
+ }
+
+}
Property changes on:
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
---
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
(rev 0)
+++
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-05-11
17:25:19 UTC (rev 900)
@@ -0,0 +1,120 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+/**
+ * RESTEasy handler to provide the JCR resources at the URIs below. Please note that
these URIs assume a context of {@code
+ * /resources} for the web application.
+ * <table border="1">
+ * <tr>
+ * <th>URI Pattern</th>
+ * <th>Description</th>
+ * <th>Supported Methods</th>
+ * </tr>
+ * <tr>
+ * <td>/resources</td>
+ * <td>returns a list of accessible repositories</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/repositories</td>
+ * <td>returns a list of accessible repositories</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}</td>
+ * <td>returns a list of accessible workspaces within that repository</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/workspaces</td>
+ * <td>returns a list of accessible workspaces within that repository</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}</td>
+ * <td>returns a list of operations within the workspace</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/item/{path}</td>
+ * <td>accesses the node at the path</td>
+ * <td>ALL</td>
+ * </tr>
+ * <tr>
+ *
<td>/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}</td>
+ * <td>accesses the named property at the path</td>
+ * <td>ALL (except PUT)</td>
+ * </tr>
+ * <tr>
+ *
<td>/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}</td>
+ * <td>adds the value from the body to the named property at the path</td>
+ * <td>PUT</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/uuid/{uuid}</td>
+ * <td>accesses the node with the given UUID</td>
+ * <td>ALL</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/lock/{path}</td>
+ * <td>locks the node at the path</td>
+ * <td>GET</td>
+ * </tr>
+ * <tr>
+ * <td>/resources/{repositoryName}/{workspaceName}/lock/{path}</td>
+ * <td>unlocks the node at the path</td>
+ * <td>PUT</td>
+ * </tr>
+ * </table>
+ */
+@Path( "/" )
+public class JcrResources {
+
+ /**
+ * Returns the list of JCR repositories available on this server
+ * @return the list of JCR repositories available on this server
+ */
+ @GET
+ @Path( "/repositories" )
+ public String repositories() {
+ return "Hello, DNA!";
+ }
+
+ /**
+ * Returns the list of workspaces available to this user within the named
repository.
+ * @param repositoryName the name of the repository
+ * @return the list of workspaces available to this user within the named
repository.
+ */
+ @GET
+ @Path( "/{repositoryName}/workspaces" )
+ public String workspaces( @PathParam( "repositoryName" ) String
repositoryName ) {
+ return repositoryName;
+ }
+
+}
Property changes on:
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++ trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml 2009-05-11 17:25:19
UTC (rev 900)
@@ -0,0 +1,54 @@
+<?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">
+<!--
+ JBoss DNA (
http://www.jboss.org/dna)
+ See the COPYRIGHT.txt file distributed with this work for information
+ regarding copyright ownership. Some portions may be licensed
+ to Red Hat, Inc. under one or more contributor license agreements.
+ See the AUTHORS.txt file in the distribution for a full listing of
+ individual contributors.
+
+ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ is licensed to you under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ JBoss DNA is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+ -->
+<web-app>
+ <display-name>JBoss DNA JCR RESTful Interface</display-name>
+
+ <context-param>
+ <param-name>javax.ws.rs.core.Application</param-name>
+ <param-value>org.jboss.dna.web.jcr.rest.JcrApplication</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>
+ org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+ </listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>
+ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
Property changes on: trunk/extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
===================================================================
---
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
(rev 0)
+++
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-05-11
17:25:19 UTC (rev 900)
@@ -0,0 +1,75 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JcrResourcesTest {
+
+ private static final String SERVER_URL =
"http://localhost:8080/resources";
+
+ private ClientRequest request;
+ private ClientResponse<?> response;
+
+ private ClientRequest requestFor(String path) {
+ return new ClientRequest(SERVER_URL + path);
+ }
+
+ @Ignore
+ @Test
+ public void shouldServeContentAtRoot() throws Exception {
+ request = requestFor("/");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+
+ }
+
+ @Test
+ public void shouldServeListOfRepositories() throws Exception {
+ request = requestFor("/repositories");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+
+ }
+
+ @Test
+ public void shouldServeListOfWorkspaces() throws Exception {
+ String validRepositoryName = "foo"; // Stub this for now
+ request = requestFor("/" + validRepositoryName +
"/workspaces");
+
+ response = request.get();
+
+ assertThat(response.getStatus(), is(200));
+ }
+
+}
Property changes on:
trunk/extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF