Index: extensions/dna-web-jcr-rest/.classpath =================================================================== --- extensions/dna-web-jcr-rest/.classpath (revision 0) +++ extensions/dna-web-jcr-rest/.classpath (revision 0) @@ -0,0 +1,9 @@ + + + + + + + + + Index: extensions/dna-web-jcr-rest/.project =================================================================== --- extensions/dna-web-jcr-rest/.project (revision 0) +++ extensions/dna-web-jcr-rest/.project (revision 0) @@ -0,0 +1,23 @@ + + + dna-web-jcr-rest + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + Index: extensions/dna-web-jcr-rest/pom.xml =================================================================== --- extensions/dna-web-jcr-rest/pom.xml (revision 0) +++ extensions/dna-web-jcr-rest/pom.xml (revision 0) @@ -0,0 +1,98 @@ + + 4.0.0 + + dna + org.jboss.dna + 0.5-SNAPSHOT + ../.. + + org.jboss.dna + dna-web-jcr-rest + war + JBoss DNA JCR REST Servlet + JBoss DNA servlet that provides RESTful access to JCR items + http://labs.jboss.org/dna + + + org.jboss.resteasy + resteasy-jaxrs + 1.1-RC2 + + + + + javax.jcr + jcr + + + + + junit + junit-dep + 4.4 + integration-test + + + org.jboss.resteasy + resteasy-client + 1.0-beta-8 + integration-test + + + + + resources + + + org.codehaus.cargo + cargo-maven2-plugin + + + start-container + pre-integration-test + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + surefire-it + integration-test + + test + + + false + + + + + + + + Property changes on: extensions\dna-web-jcr-rest\pom.xml ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java (revision 0) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrApplication.java (revision 0) @@ -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> getClasses() { + return Collections.>singleton(JcrResources.class); + } + +} Property changes on: extensions\dna-web-jcr-rest\src\main\java\org\jboss\dna\web\jcr\rest\JcrApplication.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java =================================================================== --- extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java (revision 0) +++ extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java (revision 0) @@ -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. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
URI PatternDescriptionSupported Methods
/resourcesreturns a list of accessible repositoriesGET
/resources/repositoriesreturns a list of accessible repositoriesGET
/resources/{repositoryName}returns a list of accessible workspaces within that repositoryGET
/resources/{repositoryName}/workspacesreturns a list of accessible workspaces within that repositoryGET
/resources/{repositoryName}/{workspaceName}returns a list of operations within the workspaceGET
/resources/{repositoryName}/{workspaceName}/item/{path}accesses the node at the pathALL
/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}accesses the named property at the pathALL (except PUT)
/resources/{repositoryName}/{workspaceName}/item/{path}/@{propertyName}adds the value from the body to the named property at the pathPUT
/resources/{repositoryName}/{workspaceName}/uuid/{uuid}accesses the node with the given UUIDALL
/resources/{repositoryName}/{workspaceName}/lock/{path}locks the node at the pathGET
/resources/{repositoryName}/{workspaceName}/lock/{path}unlocks the node at the pathPUT
+ */ +@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: extensions\dna-web-jcr-rest\src\main\java\org\jboss\dna\web\jcr\rest\JcrResources.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml =================================================================== --- extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml (revision 0) +++ extensions/dna-web-jcr-rest/src/main/webapp/WEB-INF/web.xml (revision 0) @@ -0,0 +1,54 @@ + + + + + JBoss DNA JCR RESTful Interface + + + javax.ws.rs.core.Application + org.jboss.dna.web.jcr.rest.JcrApplication + + + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + + + + Resteasy + + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher + + + + + Resteasy + /* + + + \ No newline at end of file Property changes on: extensions\dna-web-jcr-rest\src\main\webapp\WEB-INF\web.xml ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java =================================================================== --- extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java (revision 0) +++ extensions/dna-web-jcr-rest/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java (revision 0) @@ -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: extensions\dna-web-jcr-rest\src\test\java\org\jboss\dna\web\jcr\rest\JcrResourcesTest.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF