From 594edc8cdb39fc95836112c20364f07ce2910c89 Mon Sep 17 00:00:00 2001 From: Sanjay Dalal Date: Thu, 26 Mar 2009 19:06:38 +0000 Subject: [PATCH] CSPACE-30 hello.xsd schema changed (made it flat) to accommodate requirements of nuxeo repository and rest apis. HelloWorldDocService renamed to HelloWorldNuxeo Service. Added support for create, update and delete in addition to list. --- .../hello/client/PersonNuxeoClient.java | 93 +++++++++++++++++++ .../hello/client/PersonNuxeoProxy.java | 42 +++++++++ 2 files changed, 135 insertions(+) create mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoClient.java create mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoProxy.java diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoClient.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoClient.java new file mode 100644 index 000000000..cc99f11ee --- /dev/null +++ b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoClient.java @@ -0,0 +1,93 @@ +package org.collectionspace.hello.client; + +import javax.ws.rs.core.Response; + +import org.collectionspace.hello.PersonNuxeo; +import org.collectionspace.hello.People; +import org.jboss.resteasy.client.ProxyFactory; +import org.jboss.resteasy.plugins.providers.RegisterBuiltin; +import org.jboss.resteasy.client.ClientResponse; +import org.jboss.resteasy.spi.ResteasyProviderFactory; + +/** + * A PersonNuxeoClient. + + * @version $Revision:$ + */ +public class PersonNuxeoClient { + + /** + * + */ + private static final PersonNuxeoClient instance = new PersonNuxeoClient(); + /** + * + */ + private PersonNuxeoProxy personProxy; + + /** + * + * Create a new PersonNuxeoClient. + * + */ + private PersonNuxeoClient() { + ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance(); + RegisterBuiltin.register(factory); + personProxy = ProxyFactory.create(PersonNuxeoProxy.class, "http://localhost:8080/helloworld/cspace-nuxeo"); + } + + /** + * FIXME Comment this + * + * @return + */ + public static PersonNuxeoClient getInstance() { + return instance; + } + + /** + * @param id + * @return + * @see org.collectionspace.hello.client.PersonNuxeoProxy#getPerson() + */ + public ClientResponse getPeople() { + return personProxy.getPeople(); + } + + /** + * @param id + * @return + * @see org.collectionspace.hello.client.PersonNuxeoProxy#getPerson(java.lang.String) + */ + public ClientResponse getPerson(String id) { + return personProxy.getPerson(id); + } + + /** + * @param person + * @return + * @see org.collectionspace.hello.client.PersonNuxeoProxy#createPerson(org.collectionspace.hello.PersonNuxeo) + */ + public ClientResponse createPerson(PersonNuxeo person) { + return personProxy.createPerson(person); + } + + /** + * @param id + * @param person + * @return + * @see org.collectionspace.hello.client.PersonNuxeoProxy#updatePerson(java.lang.Long, org.collectionspace.hello.PersonNuxeo) + */ + public ClientResponse updatePerson(String id, PersonNuxeo person) { + return personProxy.updatePerson(id, person); + } + + /** + * @param id + * @return + * @see org.collectionspace.hello.client.PersonNuxeoProxy#deletePerson(java.lang.Long) + */ + public ClientResponse deletePerson(String id) { + return personProxy.deletePerson(id); + } +} diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoProxy.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoProxy.java new file mode 100644 index 000000000..53265de84 --- /dev/null +++ b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/PersonNuxeoProxy.java @@ -0,0 +1,42 @@ +package org.collectionspace.hello.client; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import org.collectionspace.hello.PersonNuxeo; +import org.collectionspace.hello.People; +import org.jboss.resteasy.client.ClientResponse; + +/** + * @version $Revision:$ + */ +@Path("/persons/") +@Produces({"application/xml"}) +@Consumes({"application/xml"}) +public interface PersonNuxeoProxy { + + @GET + ClientResponse getPeople(); + + @GET + @Path("/{id}") + ClientResponse getPerson(@PathParam("id") String id); + + @POST + ClientResponse createPerson(PersonNuxeo so); + + @PUT + @Path("/{id}") + ClientResponse updatePerson(@PathParam("id") String id, PersonNuxeo so); + + @DELETE + @Path("/{id}") + ClientResponse deletePerson(@PathParam("id") String id); +} \ No newline at end of file -- 2.47.3