From a21de0da58089992122aa037a4a5c642195803fc Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Wed, 14 Dec 2011 23:20:10 +0000 Subject: [PATCH] CSPACE-4737: Remove obsolete "Hello, world!" directory from services trunk. --- HelloWorld/HelloWorldClient/.classpath | 11 - HelloWorld/HelloWorldClient/.project | 23 -- .../.settings/org.maven.ide.eclipse.prefs | 8 - .../HelloWorldClient/nb-configuration.xml | 20 - HelloWorld/HelloWorldClient/nbactions.xml | 17 - HelloWorld/HelloWorldClient/pom.xml | 74 ---- .../hello/client/CollectionObjectClient.java | 94 ----- .../hello/client/CollectionObjectProxy.java | 46 --- .../hello/client/CollectionSpaceClient.java | 34 -- .../hello/client/DomainIdentifierClient.java | 65 --- .../hello/client/DomainIdentifierProxy.java | 32 -- .../test/CollectionObjectServiceTest.java | 147 ------- .../test/DomainIdentifierServiceTest.java | 64 --- .../src/test/resources/log4j.xml | 45 --- .../temp-testng-customsuite.xml | 8 - HelloWorld/HelloWorldJaxb/.classpath | 9 - HelloWorld/HelloWorldJaxb/.project | 23 -- .../.settings/org.maven.ide.eclipse.prefs | 8 - .../HelloWorldJaxb/nb-configuration.xml | 20 - HelloWorld/HelloWorldJaxb/pom.xml | 100 ----- .../services/CollectionObjectJAXBSchema.java | 21 - .../CollectionObjectListItemJAXBSchema.java | 7 - .../src/main/resources/hello.xsd | 61 --- HelloWorld/HelloWorldNuxeoService/README.txt | 14 - .../HelloWorldNuxeoService/build.properties | 4 - HelloWorld/HelloWorldNuxeoService/build.xml | 13 - .../nb-configuration.xml | 21 - .../HelloWorldNuxeoService/nbactions.xml | 74 ---- HelloWorld/HelloWorldNuxeoService/pom.xml | 253 ------------ .../services/CollectionObjectResource.java | 373 ------------------ .../services/CollectionSpaceResource.java | 24 -- .../services/DomainIdentifierResource.java | 80 ---- .../services/HelloworldNuxeoApplication.java | 27 -- .../hello/services/PingResource.java | 64 --- .../hello/services/nuxeo/NuxeoCallback.java | 50 --- .../services/nuxeo/NuxeoCallbackHandler.java | 85 ---- .../nuxeo/NuxeoLoginConfiguration.java | 53 --- .../nuxeo/NuxeoLoginContextFactory.java | 48 --- .../hello/services/nuxeo/NuxeoRESTClient.java | 313 --------------- .../PortalSSOAuthenticationProvider.java | 72 ---- .../src/main/resources/jndi.properties | 3 - .../src/main/resources/nuxeo.properties | 2 - .../src/main/webapp/WEB-INF/web.xml | 34 -- HelloWorld/pom.xml | 173 -------- 44 files changed, 2717 deletions(-) delete mode 100644 HelloWorld/HelloWorldClient/.classpath delete mode 100644 HelloWorld/HelloWorldClient/.project delete mode 100644 HelloWorld/HelloWorldClient/.settings/org.maven.ide.eclipse.prefs delete mode 100644 HelloWorld/HelloWorldClient/nb-configuration.xml delete mode 100644 HelloWorld/HelloWorldClient/nbactions.xml delete mode 100644 HelloWorld/HelloWorldClient/pom.xml delete mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java delete mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java delete mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionSpaceClient.java delete mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierClient.java delete mode 100644 HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierProxy.java delete mode 100644 HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/CollectionObjectServiceTest.java delete mode 100644 HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/DomainIdentifierServiceTest.java delete mode 100644 HelloWorld/HelloWorldClient/src/test/resources/log4j.xml delete mode 100644 HelloWorld/HelloWorldClient/temp-testng-customsuite.xml delete mode 100644 HelloWorld/HelloWorldJaxb/.classpath delete mode 100644 HelloWorld/HelloWorldJaxb/.project delete mode 100644 HelloWorld/HelloWorldJaxb/.settings/org.maven.ide.eclipse.prefs delete mode 100644 HelloWorld/HelloWorldJaxb/nb-configuration.xml delete mode 100644 HelloWorld/HelloWorldJaxb/pom.xml delete mode 100644 HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectJAXBSchema.java delete mode 100644 HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectListItemJAXBSchema.java delete mode 100644 HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd delete mode 100644 HelloWorld/HelloWorldNuxeoService/README.txt delete mode 100644 HelloWorld/HelloWorldNuxeoService/build.properties delete mode 100644 HelloWorld/HelloWorldNuxeoService/build.xml delete mode 100644 HelloWorld/HelloWorldNuxeoService/nb-configuration.xml delete mode 100644 HelloWorld/HelloWorldNuxeoService/nbactions.xml delete mode 100644 HelloWorld/HelloWorldNuxeoService/pom.xml delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionSpaceResource.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/DomainIdentifierResource.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java delete mode 100755 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallback.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallbackHandler.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginConfiguration.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginContextFactory.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoRESTClient.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/PortalSSOAuthenticationProvider.java delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/resources/jndi.properties delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/resources/nuxeo.properties delete mode 100644 HelloWorld/HelloWorldNuxeoService/src/main/webapp/WEB-INF/web.xml delete mode 100644 HelloWorld/pom.xml diff --git a/HelloWorld/HelloWorldClient/.classpath b/HelloWorld/HelloWorldClient/.classpath deleted file mode 100644 index 5fc0d1639..000000000 --- a/HelloWorld/HelloWorldClient/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/HelloWorld/HelloWorldClient/.project b/HelloWorld/HelloWorldClient/.project deleted file mode 100644 index f44220ec1..000000000 --- a/HelloWorld/HelloWorldClient/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - javaee-addressbook-client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/HelloWorld/HelloWorldClient/.settings/org.maven.ide.eclipse.prefs b/HelloWorld/HelloWorldClient/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index c6e4123cd..000000000 --- a/HelloWorld/HelloWorldClient/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Thu Feb 26 16:30:28 PST 2009 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -version=1 diff --git a/HelloWorld/HelloWorldClient/nb-configuration.xml b/HelloWorld/HelloWorldClient/nb-configuration.xml deleted file mode 100644 index 6c3fe600b..000000000 --- a/HelloWorld/HelloWorldClient/nb-configuration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - default - 8 - 80 - - diff --git a/HelloWorld/HelloWorldClient/nbactions.xml b/HelloWorld/HelloWorldClient/nbactions.xml deleted file mode 100644 index 047c73d4e..000000000 --- a/HelloWorld/HelloWorldClient/nbactions.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - rebuild - - * - - - clean - install - - - true - - - - diff --git a/HelloWorld/HelloWorldClient/pom.xml b/HelloWorld/HelloWorldClient/pom.xml deleted file mode 100644 index 8aaa841e6..000000000 --- a/HelloWorld/HelloWorldClient/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - helloworld - org.collectionspace.hello.services - 0.1 - - 4.0.0 - org.collectionspace.hello.services - helloworld-client - jar - 0.1 - Helloworld Client - - - org.collectionspace.hello.services - helloworld-jaxb - 0.1 - - - org.testng - testng - 5.6 - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - - - org.jboss.resteasy - resteasy-jaxrs - 1.0.2.GA - - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - 1.0.2.GA - - - org.jboss.resteasy - resteasy-multipart-provider - 1.0.2.GA - - - commons-httpclient - commons-httpclient - - - - - - maven-compiler-plugin - 2.0.2 - - 1.5 - 1.5 - - - - - diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java deleted file mode 100644 index 8fd55ac08..000000000 --- a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.collectionspace.hello.client; - -import javax.ws.rs.core.Response; - -import org.collectionspace.hello.CollectionObject; -import org.collectionspace.hello.CollectionObjectList; - -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 CollectionObjectClient. - - * @version $Revision:$ - */ -public class CollectionObjectClient extends CollectionSpaceClient { - - - /** - * - */ - private static final CollectionObjectClient instance = new CollectionObjectClient(); - /** - * - */ - private CollectionObjectProxy collectionObjectProxy; - - /** - * - * Default constructor for CollectionObjectClient class. - * - */ - private CollectionObjectClient() { - ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance(); - RegisterBuiltin.register(factory); - collectionObjectProxy = ProxyFactory.create(CollectionObjectProxy.class, getURL()); - } - - /** - * FIXME Comment this - * - * @return - */ - public static CollectionObjectClient getInstance() { - return instance; - } - - /** - * @return - * @see org.collectionspace.hello.client.CollectionObjectProxy#getCollectionObject() - */ - public ClientResponse getCollectionObjectList() { - return collectionObjectProxy.getCollectionObjectList(); - } - - /** - * @param csid - * @return - * @see org.collectionspace.hello.client.CollectionObjectProxy#getCollectionObject(java.lang.String) - */ - public ClientResponse getCollectionObject(String csid) { - return collectionObjectProxy.getCollectionObject(csid); - } - - /** - * @param collectionobject - * @return - * @see org.collectionspace.hello.client.CollectionObjectProxy#createCollectionObject(org.collectionspace.hello.CollectionObject) - */ - public ClientResponse createCollectionObject(CollectionObject collectionObject) { - return collectionObjectProxy.createCollectionObject(collectionObject); - } - - /** - * @param csid - * @param collectionobject - * @return - * @see org.collectionspace.hello.client.CollectionObjectProxy#updateCollectionObject(java.lang.Long, org.collectionspace.hello.CollectionObject) - */ - public ClientResponse updateCollectionObject(String csid, CollectionObject collectionObject) { - return collectionObjectProxy.updateCollectionObject(csid, collectionObject); - } - - /** - * @param csid - * @return - * @see org.collectionspace.hello.client.CollectionObjectProxy#deleteCollectionObject(java.lang.Long) - */ - public ClientResponse deleteCollectionObject(String csid) { - return collectionObjectProxy.deleteCollectionObject(csid); - } -} diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java deleted file mode 100644 index 6097fed14..000000000 --- a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java +++ /dev/null @@ -1,46 +0,0 @@ -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.CollectionObject; -import org.collectionspace.hello.CollectionObjectList; -import org.jboss.resteasy.client.ClientResponse; - -/** - * @version $Revision:$ - */ -@Path("/collectionobjects/") -@Produces({"application/xml"}) -@Consumes({"application/xml"}) -public interface CollectionObjectProxy { - - @GET - ClientResponse getCollectionObjectList(); - - //(C)reate - @POST - ClientResponse createCollectionObject(CollectionObject co); - - //(R)ead - @GET - @Path("/{csid}") - ClientResponse getCollectionObject(@PathParam("csid") String csid); - - //(U)pdate - @PUT - @Path("/{csid}") - ClientResponse updateCollectionObject(@PathParam("csid") String csid, CollectionObject co); - - //(D)elete - @DELETE - @Path("/{csid}") - ClientResponse deleteCollectionObject(@PathParam("csid") String csid); -} \ No newline at end of file diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionSpaceClient.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionSpaceClient.java deleted file mode 100644 index 879800e34..000000000 --- a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionSpaceClient.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.collectionspace.hello.client; - -import java.util.*; - -public abstract class CollectionSpaceClient { - static final String URL_PROPERTY = "org.collectionspace.url"; - /* - static final String URL_PROPERTY_SCHEME = "org.collectionspace.url.schme"; - static final String URL_PROPERTY_HOST = "org.collectionspace.url.host"; - static final String URL_PROPERTY_PORT = "org.collectionspace.url.port"; - static final String URL_PROPERTY_CONTEXT = "org.collectionspace.url.context"; - */ - - private static final String SCHEME = "http"; - private static final String HOST = "localhost"; - private static final String PORT = "8080"; - private static final String URI = "/helloworld/cspace-nuxeo"; - private static final String URL = SCHEME + "://" + - HOST + ":" + - PORT + - URI; - private String collectionSpaceURL = null; - - - String getURL() { - String result = collectionSpaceURL; - - if (collectionSpaceURL == null) { - result = collectionSpaceURL = System.getProperty(URL_PROPERTY, URL); - } - - return result; - } -} diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierClient.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierClient.java deleted file mode 100644 index 56061c6ad..000000000 --- a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierClient.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.collectionspace.hello.client; - -import javax.ws.rs.core.Response; - -import org.collectionspace.hello.DomainIdentifier; -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 IdentifierClient. - - * @version $Revision:$ - */ -public class DomainIdentifierClient extends CollectionSpaceClient { - - - /** - * - */ - private static final DomainIdentifierClient instance = new DomainIdentifierClient(); - /** - * - */ - private DomainIdentifierProxy identifierProxy; - - /** - * - * Create a new IdentifierClient. - * - */ - private DomainIdentifierClient() { - ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance(); - RegisterBuiltin.register(factory); - identifierProxy = ProxyFactory.create(DomainIdentifierProxy.class, getURL()); - } - - /** - * FIXME Comment this - * - * @return - */ - public static DomainIdentifierClient getInstance() { - return instance; - } - - /** - * @param id - * @return - * @see org.collectionspace.hello.client.IdentifierProxy#getIdentifier(java.lang.Long) - */ - public ClientResponse getIdentifier(String id) { - return identifierProxy.getIdentifier(id); - } - - /** - * @param identifier - * @return - * @see org.collectionspace.hello.client.IdentifierProxy#createIdentifier(org.collectionspace.hello.client.entity.Identifier) - */ - public ClientResponse createIdentifier(DomainIdentifier identifier) { - return identifierProxy.createIdentifier(identifier); - } -} diff --git a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierProxy.java b/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierProxy.java deleted file mode 100644 index ca4225595..000000000 --- a/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/DomainIdentifierProxy.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.collectionspace.hello.client; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -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.DomainIdentifier; -import org.jboss.resteasy.client.ClientResponse; - -/** - * @version $Revision:$ - */ -@Path("/domainidentifiers/") -@Produces({"application/xml"}) -@Consumes({"application/xml"}) -public interface DomainIdentifierProxy { - - /** - * @param id - * @return - */ - @GET - @Path("/{id}") - ClientResponse getIdentifier(@PathParam("id") String id); - - @POST - ClientResponse createIdentifier(DomainIdentifier so); -} \ No newline at end of file diff --git a/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/CollectionObjectServiceTest.java b/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/CollectionObjectServiceTest.java deleted file mode 100644 index 7887d0077..000000000 --- a/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/CollectionObjectServiceTest.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.collectionspace.hello.client.test; - -import java.util.ArrayList; -import java.util.List; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import org.jboss.resteasy.client.ClientResponse; -import org.testng.Assert; -import org.testng.annotations.Test; - -import org.collectionspace.hello.CollectionObject; -import org.collectionspace.hello.CollectionObjectList; -import org.collectionspace.hello.client.CollectionObjectClient; - -/** - * A CollectionObjectNuxeoServiceTest. - * - * @version $Revision:$ - */ -public class CollectionObjectServiceTest { - - private CollectionObjectClient collectionObjectClient = CollectionObjectClient.getInstance(); - private String updateId = null; - private String deleteId = null; - - @Test - public void createCollectionObject() { - long identifier = this.createIdentifier(); - - CollectionObject collectionObject = createCollectionObject(identifier); - ClientResponse res = collectionObjectClient.createCollectionObject(collectionObject); - Assert.assertEquals(res.getStatus(), Response.Status.CREATED.getStatusCode()); - - //store updateId locally for "update" test - if (updateId == null) - updateId = extractId(res); - else - deleteId = extractId(res); - } - - @Test(dependsOnMethods = {"createCollectionObject"}) - public void updateCollectionObject() { - ClientResponse res = collectionObjectClient.getCollectionObject(updateId); - CollectionObject collectionObject = res.getEntity(); - verbose("Got CollectionObject to update with ID: " + updateId, - collectionObject, CollectionObject.class); - - //collectionObject.setCsid("updated-" + updateId); - collectionObject.setObjectNumber("updated-" + collectionObject.getObjectNumber()); - collectionObject.setObjectName("updated-" + collectionObject.getObjectName()); - - // make call to update service - res = collectionObjectClient.updateCollectionObject(updateId, collectionObject); - - // check the response - CollectionObject updatedCollectionObject = res.getEntity(); - Assert.assertEquals(updatedCollectionObject.getObjectName(), collectionObject.getObjectName()); - verbose("updateCollectionObject: ", updatedCollectionObject, CollectionObject.class); - - return; - } - - @Test(dependsOnMethods = {"createCollectionObject"}) - public void createCollection() { - for (int i = 0; i < 3; i++) { - this.createCollectionObject(); - } - } - - @Test(dependsOnMethods = {"createCollection"}) - public void getCollectionObjectList() { - //the resource method is expected to return at least an empty list - CollectionObjectList coList = collectionObjectClient.getCollectionObjectList().getEntity(); - List coItemList = coList.getCollectionObjectListItem(); - int i = 0; - for(CollectionObjectList.CollectionObjectListItem pli : coItemList) { - verbose("getCollectionObjectList: list-item[" + i + "] csid=" + pli.getCsid()); - verbose("getCollectionObjectList: list-item[" + i + "] objectNumber=" + pli.getObjectNumber()); - verbose("getCollectionObjectList: list-item[" + i + "] URI=" + pli.getUri()); - i++; - } - } - - @Test(dependsOnMethods = {"updateCollectionObject"}) - public void deleteCollectionObject() { - ClientResponse res = collectionObjectClient.deleteCollectionObject(deleteId); - verbose("deleteCollectionObject: csid=" + deleteId); - verbose("deleteCollectionObject: status = " + res.getStatus()); - Assert.assertEquals(res.getStatus(), Response.Status.NO_CONTENT.getStatusCode()); - } - - private CollectionObject createCollectionObject(long identifier) { - CollectionObject collectionObject = createCollectionObject("objectNumber-" + identifier, - "objectName-" + identifier); - - return collectionObject; - } - - private CollectionObject createCollectionObject(String objectNumber, String objectName) { - CollectionObject collectionObject = new CollectionObject(); - - collectionObject.setObjectNumber(objectNumber); - collectionObject.setObjectName(objectName); - - return collectionObject; - } - - private String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - String[] segments = uri.split("/"); - String id = segments[segments.length - 1]; - verbose("id=" + id); - return id; - } - - private void verbose(String msg) { - System.out.println("CollectionObject Test: " + msg); - } - - private void verbose(String msg, Object o, Class clazz) { - try{ - verbose(msg); - JAXBContext jc = JAXBContext.newInstance(clazz); - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(o, System.out); - }catch(Exception e){ - e.printStackTrace(); - } - } - - private void verboseMap(MultivaluedMap map) { - for(Object entry : map.entrySet()){ - MultivaluedMap.Entry mentry = (MultivaluedMap.Entry) entry; - verbose(" name=" + mentry.getKey() + " value=" + mentry.getValue()); - } - } - - private long createIdentifier() { - long identifier = System.currentTimeMillis(); - return identifier; - } -} diff --git a/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/DomainIdentifierServiceTest.java b/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/DomainIdentifierServiceTest.java deleted file mode 100644 index 7b0f54eab..000000000 --- a/HelloWorld/HelloWorldClient/src/test/java/org/collectionspace/hello/client/test/DomainIdentifierServiceTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.collectionspace.hello.client.test; - -import org.collectionspace.hello.client.DomainIdentifierClient; -import java.util.ArrayList; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; -import org.collectionspace.hello.DomainIdentifier; -import org.jboss.resteasy.client.ClientResponse; -import org.testng.Assert; -import org.testng.annotations.Test; - -/** - * A DomainIdentifierServiceTest. - * - * @version $Revision:$ - */ -public class DomainIdentifierServiceTest { - - private DomainIdentifierClient identifierClient = DomainIdentifierClient.getInstance(); - private String id = null; - - @Test - public void createIdentifier() { - DomainIdentifier identifier = new DomainIdentifier(); - identifier.setDsid("org.bnhm"); - ClientResponse res = identifierClient.createIdentifier(identifier); - Assert.assertEquals(res.getStatus(), Response.Status.CREATED.getStatusCode()); - id = extractId(res); - } - - @Test(dependsOnMethods = {"createIdentifier"}) - public void getIdentifier() { - DomainIdentifier i = identifierClient.getIdentifier(id).getEntity(); - verbose("got DomainIdentifier", i); - } - - private String extractId(ClientResponse res) { - MultivaluedMap mvm = res.getMetadata(); - String uri = (String) ((ArrayList) mvm.get("Location")).get(0); - String[] segments = uri.split("/"); - verbose("id=" + segments[segments.length - 1]); - return segments[segments.length - 1]; - } - - private void verbose(String msg) { - System.out.println("DomainIdentifierServiceTest : " + msg); - } - - private void verbose(String msg, DomainIdentifier p) { - try { - verbose(msg); - JAXBContext jc = JAXBContext.newInstance(DomainIdentifier.class); - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(p, System.out); - //m.marshal(new JAXBElement(new QName("uri", "local"), DomainIdentifier.class, p), System.out); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/HelloWorld/HelloWorldClient/src/test/resources/log4j.xml b/HelloWorld/HelloWorldClient/src/test/resources/log4j.xml deleted file mode 100644 index 52121cb83..000000000 --- a/HelloWorld/HelloWorldClient/src/test/resources/log4j.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/HelloWorld/HelloWorldClient/temp-testng-customsuite.xml b/HelloWorld/HelloWorldClient/temp-testng-customsuite.xml deleted file mode 100644 index 9f2480621..000000000 --- a/HelloWorld/HelloWorldClient/temp-testng-customsuite.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/HelloWorld/HelloWorldJaxb/.classpath b/HelloWorld/HelloWorldJaxb/.classpath deleted file mode 100644 index a92b24a87..000000000 --- a/HelloWorld/HelloWorldJaxb/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/HelloWorld/HelloWorldJaxb/.project b/HelloWorld/HelloWorldJaxb/.project deleted file mode 100644 index db1c789f7..000000000 --- a/HelloWorld/HelloWorldJaxb/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - javaee-addressbook-jaxb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/HelloWorld/HelloWorldJaxb/.settings/org.maven.ide.eclipse.prefs b/HelloWorld/HelloWorldJaxb/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index c6e4123cd..000000000 --- a/HelloWorld/HelloWorldJaxb/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Thu Feb 26 16:30:28 PST 2009 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -version=1 diff --git a/HelloWorld/HelloWorldJaxb/nb-configuration.xml b/HelloWorld/HelloWorldJaxb/nb-configuration.xml deleted file mode 100644 index 6c3fe600b..000000000 --- a/HelloWorld/HelloWorldJaxb/nb-configuration.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - default - 8 - 80 - - diff --git a/HelloWorld/HelloWorldJaxb/pom.xml b/HelloWorld/HelloWorldJaxb/pom.xml deleted file mode 100644 index df8339a1b..000000000 --- a/HelloWorld/HelloWorldJaxb/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - helloworld - org.collectionspace.hello.services - 0.1 - - 4.0.0 - org.collectionspace.hello.services - helloworld-jaxb - 0.1 - Helloworld Client JAXB - - - com.sun.xml.bind - jaxb-impl - 2.0.2 - - - org.jvnet.jaxb2-commons - property-listener-injector - 1.0 - - - org.jvnet.jaxb2_commons - runtime - 0.4.1.4 - - - - install - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - - - - generate - - - - - - - javax.activation - activation - 1.1 - - - com.sun.xml.bind - jaxb-impl - 2.1.2 - - - - - -XtoString - -Xinject-listener-code - - - - - - - org.jvnet.jaxb2_commons - - basic - 0.4.1 - - - - org.jvnet.jaxb2-commons - - - property-listener-injector - - 1.0 - - - - - - - - maven-compiler-plugin - 2.0.2 - - 1.5 - 1.5 - - - - - diff --git a/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectJAXBSchema.java b/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectJAXBSchema.java deleted file mode 100644 index 8484bdb15..000000000 --- a/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectJAXBSchema.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * - */ -package org.collectionspace.hello.services; - -/** - * @author remillet - * - */ -public interface CollectionObjectJAXBSchema { - final static String OBJECT_NUMBER = "objectNumber"; - final static String OTHER_NUMBER = "otherNumber"; - final static String BRIEF_DESCRIPTION = "briefDescription"; - final static String COMMENTS = "comments"; - final static String DIST_FEATURES = "distFeatures"; - final static String OBJECT_NAME = "objectName"; - final static String RESPONSIBLE_DEPT = "responsibleDept"; - final static String TITLE = "title"; -} - - diff --git a/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectListItemJAXBSchema.java b/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectListItemJAXBSchema.java deleted file mode 100644 index c3aa8a577..000000000 --- a/HelloWorld/HelloWorldJaxb/src/main/java/org/collectionspace/hello/services/CollectionObjectListItemJAXBSchema.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.collectionspace.hello.services; - -public interface CollectionObjectListItemJAXBSchema { - final static String OBJECT_NUMBER = "objectNumber"; - final static String CSID = "csid"; - final static String URI = "url"; -} diff --git a/HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd b/HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd deleted file mode 100644 index 1593ed41c..000000000 --- a/HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/HelloWorld/HelloWorldNuxeoService/README.txt b/HelloWorld/HelloWorldNuxeoService/README.txt deleted file mode 100644 index b1aa460dd..000000000 --- a/HelloWorld/HelloWorldNuxeoService/README.txt +++ /dev/null @@ -1,14 +0,0 @@ -Helloworld service interfacing with Nuxeo repository through Nuxeo -REST apis. - -System Requirements: -==================== -- Maven 2.0.9 or higher -- Nuxeo CollectionSpace Extensions - -Building the project: -==================== -In root directoy... -1. customize build.properties for your environment -2. mvn clean package -3. ant diff --git a/HelloWorld/HelloWorldNuxeoService/build.properties b/HelloWorld/HelloWorldNuxeoService/build.properties deleted file mode 100644 index 45aaacad2..000000000 --- a/HelloWorld/HelloWorldNuxeoService/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -jboss.dir=/usr/local/jboss-4.2.3.GA -nuxeo.dir=${jboss.dir}/server/default/deploy/nuxeo.ear/system -nuxeo.local.repo.dir=file:///C:/dev/jboss-4.2.3.GA/server/default/deploy/nuxeo.ear/system -nuxeo.local.repo.client.dir=file:///C:/dev/nuxeo/nuxeo-core/nuxeo-core-client/target diff --git a/HelloWorld/HelloWorldNuxeoService/build.xml b/HelloWorld/HelloWorldNuxeoService/build.xml deleted file mode 100644 index b25be4f08..000000000 --- a/HelloWorld/HelloWorldNuxeoService/build.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/HelloWorld/HelloWorldNuxeoService/nb-configuration.xml b/HelloWorld/HelloWorldNuxeoService/nb-configuration.xml deleted file mode 100644 index 3e5cd988f..000000000 --- a/HelloWorld/HelloWorldNuxeoService/nb-configuration.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - default - 8 - 80 - false - - diff --git a/HelloWorld/HelloWorldNuxeoService/nbactions.xml b/HelloWorld/HelloWorldNuxeoService/nbactions.xml deleted file mode 100644 index 9d30c239a..000000000 --- a/HelloWorld/HelloWorldNuxeoService/nbactions.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - test - - * - - - test - - - - build - - * - - - install - - - - clean - - * - - - clean - - - - rebuild - - * - - - clean - install - - - true - - - - run - - war - ear - ejb - - - package - - - - true - - - - debug - - war - ear - ejb - - - package - - - - true - true - - - diff --git a/HelloWorld/HelloWorldNuxeoService/pom.xml b/HelloWorld/HelloWorldNuxeoService/pom.xml deleted file mode 100644 index d0363e486..000000000 --- a/HelloWorld/HelloWorldNuxeoService/pom.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - helloworld - org.collectionspace.hello.services - 0.1 - - 4.0.0 - org.collectionspace.hello.services - helloworld-nuxeo-service - war - 0.1 - Helloworld Nuxeo Service - - - - java.net - http://download.java.net/maven/1 - legacy - - - maven repo - maven repo - http://repo1.maven.org/maven2/ - - - - jboss - jboss repo - http://repository.jboss.org/maven2 - - - mojo - mojo repo - http://svn.codehaus.org/mojo/trunk/mojo/jboss-maven-plugin - - - - cspace.local.nuxeo - ${nuxeo.local.repo.dir} - - - cspace.local.nuxeo.client - ${nuxeo.local.repo.client.dir} - - - public - http://maven.nuxeo.org/public - - - - false - - - - public-snapshot - http://maven.nuxeo.org/public-snapshot - - false - - - - - - - - - - - public - http://maven.nuxeo.org/public - Nuxeo virtual release repository - - - - false - - - - public-snapshot - http://maven.nuxeo.org/public-snapshot - Nuxeo virtual snapshot repository - - false - - - - - - - - - 4.2.3.GA - 3.0 - UTF-8 - 1.5.1 - 0.9.7 - 5.2-SNAPSHOT - 1.11-SNAPSHOT - - - - - - org.collectionspace.hello.services - helloworld-jaxb - 0.1 - - - org.jboss.resteasy - resteasy-jaxrs - 1.0.2.GA - - - tjws - webserver - - - - - org.jboss.resteasy - resteasy-jaxb-provider - 1.0.2.GA - - - org.jboss.resteasy - resteasy-multipart-provider - 1.0.2.GA - - - junit - junit - 4.1 - test - - - - - - - javax.security - jaas - 1.0.01 - provided - - - - dom4j - dom4j - 1.6.1 - provided - - - - - - - - org.nuxeo.ecm.core - nuxeo-core-api - ${nuxeo.version.1.5} - - - jboss-remoting - jboss - - - - - - - - jaxen - jaxen - 1.1.1 - - - - - - - helloworld - - - org.codehaus.mojo - jboss-maven-plugin - - ${jboss.dir} - - - - jboss-undeploy - pre-integration-test - - undeploy - - - ${basedir}/target/helloworld.war - - - - jboss-deploy - pre-integration-test - - deploy - - - ${basedir}/target/helloworld.war - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - surefire-it - integration-test - - test - - - false - - - - - - org.apache.maven.plugins - maven-war-plugin - 2.0 - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - - diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java deleted file mode 100644 index 479d5888a..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java +++ /dev/null @@ -1,373 +0,0 @@ -package org.collectionspace.hello.services; - -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import java.util.Map; -import javax.ws.rs.DELETE; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.PathParam; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.collectionspace.hello.*; -import org.collectionspace.hello.services.nuxeo.NuxeoRESTClient; -import org.collectionspace.hello.CollectionObjectList.CollectionObjectListItem; -import org.collectionspace.hello.services.CollectionObjectJAXBSchema; -import org.collectionspace.hello.services.CollectionObjectListItemJAXBSchema; - -import org.dom4j.Document; -import org.dom4j.Element; -import org.dom4j.Namespace; -import org.dom4j.io.SAXReader; -import org.restlet.resource.Representation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Path("/collectionobjects") -@Consumes("application/xml") -@Produces("application/xml") -public class CollectionObjectResource extends CollectionSpaceResource { - - final static String CO_NUXEO_DOCTYPE = "CollectionObject"; - final static String CO_NUXEO_SCHEMA_NAME = "collectionobject"; - final static String CO_NUXEO_DC_TITLE = "CollectionSpace-CollectionObject"; - - final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class); - - public CollectionObjectResource() { - // do nothing - } - - @GET - public CollectionObjectList getCollectionObjectList(@Context UriInfo ui) { - CollectionObjectList p = new CollectionObjectList(); - try{ - NuxeoRESTClient nxClient = getClient(); - - List pathParams = new ArrayList(); - Map queryParams = new HashMap(); - pathParams = Arrays.asList("default", CS_COLLECTIONOBJECT_WORKSPACE_UID, "browse"); - Representation res = nxClient.get(pathParams, queryParams); - SAXReader reader = new SAXReader(); - Document document = reader.read(res.getStream()); - Element root = document.getRootElement(); - - //debug - System.err.println(res.toString()); - System.err.println(document.asXML()); - - List list = p.getCollectionObjectListItem(); - for(Iterator i = root.elementIterator(); i.hasNext();){ - Element element = (Element) i.next(); - //debug - System.err.println();element.asXML(); - - // set the CollectionObject list item entity elements - CollectionObjectListItem pli = new CollectionObjectListItem(); - pli.setObjectNumber(element.attributeValue("title")); - pli.setUri(element.attributeValue("url")); - pli.setCsid(element.attributeValue("id")); - list.add(pli); - } - - }catch(Exception e){ - e.printStackTrace(); - } - - return p; - } - - @POST - public Response createCollectionObject(CollectionObject co) { - - NuxeoRESTClient nxClient = getClient(); - - List pathParams = new ArrayList(); - Map queryParams = new HashMap(); - pathParams.add("default"); - pathParams.add(CS_COLLECTIONOBJECT_WORKSPACE_UID); - pathParams.add("createDocument"); - queryParams.put("docType", CO_NUXEO_DOCTYPE); - - // a default title for the Dublin Core schema - queryParams.put("dublincore:title", CO_NUXEO_DC_TITLE); - - // CollectionObject core values - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NUMBER, - co.getObjectNumber()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OTHER_NUMBER, - co.getOtherNumber()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, - co.getBriefDescription()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.COMMENTS, - co.getComments()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.DIST_FEATURES, - co.getDistFeatures()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NAME, - co.getObjectName()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, - co.getResponsibleDept()); - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.TITLE, - co.getTitle()); - - ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); - Representation res = nxClient.post(pathParams, queryParams, bais); - - String csid = null; - SAXReader reader = new SAXReader(); - try { - Document document = reader.read(res.getStream()); - Element root = document.getRootElement(); - for (Iterator i = root.elementIterator(); i.hasNext();){ - Element element = (Element) i.next(); - if ("docRef".equals(element.getName())){ - csid = (String) element.getData(); - co.setCsid(csid); - } - } - } catch(Exception e){ - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "Create failed").type("text/plain").build(); - throw new WebApplicationException(response); - } - - - verbose("createCollectionObject: ", co); - UriBuilder path = UriBuilder.fromResource(CollectionObjectResource.class); - path.path("" + csid); - Response response = Response.created(path.build()).build(); - - return response; - } - - @GET - @Path("{csid}") - public CollectionObject getCollectionObject(@PathParam("csid") String csid) { - - CollectionObject co = null; - try { - List pathParams = new ArrayList(); - Map queryParams = new HashMap(); - - pathParams.add("default"); - pathParams.add(csid); - pathParams.add("export"); - queryParams.put("format", "XML"); - - NuxeoRESTClient nxClient = getClient(); - Representation res = nxClient.get(pathParams, queryParams); - - SAXReader reader = new SAXReader(); - Document document = reader.read(res.getStream()); - Element root = document.getRootElement(); - co = new CollectionObject(); - - // TODO: recognize schema thru namespace uri -// Namespace ns = new Namespace("collectionobject", "http://collectionspace.org/collectionobject"); - - Iterator siter = root.elementIterator("schema"); - while (siter.hasNext()) { - - Element schemaElement = siter.next(); - System.err.println("CollectionObject.getCollectionObject() called."); - - //TODO: recognize schema thru namespace uri - if (CO_NUXEO_SCHEMA_NAME.equals(schemaElement.attribute("name").getValue())){ - Element ele = schemaElement.element(CollectionObjectJAXBSchema.OBJECT_NUMBER); - if(ele != null){ - co.setObjectNumber((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.OTHER_NUMBER); - if(ele != null){ - co.setOtherNumber((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.BRIEF_DESCRIPTION); - if(ele != null){ - co.setBriefDescription((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.COMMENTS); - if(ele != null){ - co.setComments((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.DIST_FEATURES); - if(ele != null){ - co.setDistFeatures((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.OBJECT_NAME); - if(ele != null){ - co.setObjectName((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.RESPONSIBLE_DEPT); - if(ele != null){ - co.setResponsibleDept((String) ele.getData()); - } - ele = schemaElement.element(CollectionObjectJAXBSchema.TITLE); - if(ele != null){ - co.setTitle((String) ele.getData()); - } - } - } - } catch(Exception e){ - e.printStackTrace(); - Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity( - "Get failed").type("text/plain").build(); - throw new WebApplicationException(response); - } - if (co == null) { - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "Get failed, the requested CollectionObject CSID:" + csid + ": was not found.").type("text/plain").build(); - throw new WebApplicationException(response); - } - verbose("getCollectionObject: ", co); - - return co; - } - - @PUT - @Path("{csid}") - public CollectionObject updateCollectionObject( - @PathParam("csid") String csid, - CollectionObject theUpdate) { - - verbose("updateCollectionObject with input: ", theUpdate); - - List pathParams = new ArrayList(); - Map queryParams = new HashMap(); - pathParams.add("default"); - pathParams.add(csid); - pathParams.add("updateDocumentRestlet"); - - //todo: intelligent merge needed - if(theUpdate.getObjectNumber() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NUMBER, - theUpdate.getObjectNumber()); - } - - if(theUpdate.getOtherNumber() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OTHER_NUMBER, - theUpdate.getOtherNumber()); - } - - if(theUpdate.getBriefDescription()!= null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, - theUpdate.getBriefDescription()); - } - - if(theUpdate.getComments() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.COMMENTS, - theUpdate.getComments()); - } - - if(theUpdate.getDistFeatures() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.DIST_FEATURES, - theUpdate.getDistFeatures()); - } - - if(theUpdate.getObjectName() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NAME, - theUpdate.getObjectName()); - } - - if(theUpdate.getResponsibleDept() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, - theUpdate.getResponsibleDept()); - } - - if(theUpdate.getTitle() != null){ - queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.TITLE, - theUpdate.getTitle()); - } - - NuxeoRESTClient nxClient = getClient(); - Representation res = nxClient.get(pathParams, queryParams); - SAXReader reader = new SAXReader(); - String status = null; - try { - Document document = reader.read(res.getStream()); - Element root = document.getRootElement(); - for(Iterator i = root.elementIterator(); i.hasNext();){ - Element element = (Element) i.next(); - if("docRef".equals(element.getName())){ - status = (String) element.getData(); - verbose("updateCollectionObject response: " + status); - } - } - } catch(Exception e) { - //FIXME: NOT_FOUND? - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "Update failed ").type("text/plain").build(); - throw new WebApplicationException(response); - } - - return theUpdate; - } - - @DELETE - @Path("{csid}") - public void deleteCollectionObject(@PathParam("csid") String csid) { - - verbose("deleteCollectionObject with csid=" + csid); - - NuxeoRESTClient nxClient = getClient(); - List pathParams = new ArrayList(); - Map queryParams = new HashMap(); - - pathParams.add("default"); - pathParams.add(csid); - pathParams.add("deleteDocumentRestlet"); - Representation res = nxClient.get(pathParams, queryParams); - SAXReader reader = new SAXReader(); - String status = ""; - - try { - Document document = reader.read(res.getStream()); - Element root = document.getRootElement(); - for(Iterator i = root.elementIterator(); i.hasNext();){ - Element element = (Element) i.next(); - if("docRef".equals(element.getName())){ - status = (String) element.getData(); - verbose("deleteCollectionObjectt response: " + status); - } - } - }catch(Exception e){ - //FIXME: NOT_FOUND? - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "Delete failed ").type("text/plain").build(); - throw new WebApplicationException(response); - } - - } - - private void verbose(String msg, CollectionObject co) { - try { - verbose(msg); - JAXBContext jc = JAXBContext.newInstance( - CollectionObject.class); - - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(co, System.out); - } catch(Exception e){ - e.printStackTrace(); - } - } - - private void verbose(String msg) { - System.out.println("CollectionObjectResource. " + msg); - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionSpaceResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionSpaceResource.java deleted file mode 100644 index b58739bd0..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionSpaceResource.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.collectionspace.hello.services; - -import org.collectionspace.hello.services.nuxeo.NuxeoRESTClient; - -public abstract class CollectionSpaceResource { - //replace WORKSPACE_UID for resource workspace - static String CS_COLLECTIONOBJECT_WORKSPACE_UID = "5a37d40f-59c4-4d15-93ad-e0e6a0c33587"; - //sanjay 6c7881fe-54c5-486e-b144-a025dee3a484 - //demo eae0d7b6-580a-45a3-a0f3-e25e980e03bb - static String CS_PERSON_WORKSPACE_UID = "eae0d7b6-580a-45a3-a0f3-e25e980e03bb"; - - //replace host if not running on localhost - //static String CS_NUXEO_HOST = "173.45.234.217"; - static String CS_NUXEO_HOST = "localhost"; - static String CS_NUXEO_URI = "http://" + CS_NUXEO_HOST + ":8080/nuxeo"; - - NuxeoRESTClient getClient() { - NuxeoRESTClient nxClient = new NuxeoRESTClient(CS_NUXEO_URI); - nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC); - nxClient.setBasicAuthentication("Administrator", "Administrator"); - return nxClient; - } - -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/DomainIdentifierResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/DomainIdentifierResource.java deleted file mode 100644 index 9ddf5965a..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/DomainIdentifierResource.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.collectionspace.hello.services; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicLong; -import javax.ws.rs.core.UriBuilder; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Marshaller; - -import org.collectionspace.hello.DomainIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Path("/domainidentifiers") -@Consumes("application/xml") -@Produces("application/xml") -public class DomainIdentifierResource extends CollectionSpaceResource { - - final Logger logger = LoggerFactory.getLogger(DomainIdentifierResource.class); - private Map idDB = new ConcurrentHashMap(); - - public DomainIdentifierResource() { - // do nothing - } - - @POST - public Response createIdentifier(DomainIdentifier id) { - DomainIdentifier newId = id; - - if (newId.getDsid() == null) { - newId.setDsid("org.collectionspace"); - } - newId.setDsid(newId.getDsid() + "." + System.currentTimeMillis()); - idDB.put(newId.getDsid(), newId); - - verbose("createIdentifier: ", newId); - UriBuilder path = UriBuilder.fromResource(DomainIdentifierResource.class); - path.path("" + newId.getDsid()); - Response response = Response.created(path.build()).build(); - - return response; - } - - @GET - @Path("{id}") - public DomainIdentifier getIdentifier(@PathParam("id") String id) { - DomainIdentifier result = idDB.get(id); - if (result == null) { - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "The requested DomainIdentifier was not found.").type("text/plain").build(); - throw new WebApplicationException(response); - } - verbose("getIdentifier: ", result); - - return result; - } - - private void verbose(String msg, DomainIdentifier id) { - try { - System.out.println("DomainIdentifierResource: " + msg); - JAXBContext jc = JAXBContext.newInstance(DomainIdentifier.class); - Marshaller m = jc.createMarshaller(); - m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, - Boolean.TRUE); - m.marshal(id, System.out); - - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java deleted file mode 100644 index 1a0e2cc93..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.collectionspace.hello.services; - -import javax.ws.rs.core.Application; -import java.util.HashSet; -import java.util.Set; - -public class HelloworldNuxeoApplication extends Application { - - private Set singletons = new HashSet(); - private Set> empty = new HashSet>(); - - public HelloworldNuxeoApplication() { - singletons.add(new CollectionObjectResource()); - singletons.add(new DomainIdentifierResource()); - singletons.add(new PingResource()); - } - - @Override - public Set> getClasses() { - return empty; - } - - @Override - public Set getSingletons() { - return singletons; - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java deleted file mode 100755 index 2d389127d..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.collectionspace.hello.services; - -/** - * PingResource - * - * Service that returns a brief "ping"-type response. - * Allows clients to test basic connectivity. - * - * @author $Author: aron $ - * @version $Revision: 547 $ - * @version $Date: 2009-01-30 12:48:42 -0800 (Fri, 30 Jan 2009) $ - * - */ - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -@Path("") -@Produces("text/plain") -public class PingResource { - - // Paths relative to the root path, defined above. - final static String ECHO_RELATIVE_PATH = "echo"; - final static String PING_RELATIVE_PATH = "ping"; - - // Ping or echo message to return. - final static String SERVICE_NAME = "CollectionSpace"; - final static String SERVICE_PING_MESSAGE = - "The " + SERVICE_NAME + " system is alive and listening.\n"; - - ///////////////////////////////////////////////////////////////// - /** - * Class constructor (no argument). - */ - public PingResource() { - // do nothing - } - - ///////////////////////////////////////////////////////////////// - /** - * Returns a brief "ping"-type message. - * - * @return A brief "ping"-type message. - */ - @Path(PING_RELATIVE_PATH) - @GET - public String getPing() { - return SERVICE_PING_MESSAGE; - } - - ///////////////////////////////////////////////////////////////// - /** - * Returns a brief "ping"-type message. Allows this message to be retrieved - * from an "echo" URI, as well as a "ping" URI. - * - * @return A brief "ping"-type message. - */ - @Path(ECHO_RELATIVE_PATH) - @GET - public String getEcho() { - return getPing(); - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallback.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallback.java deleted file mode 100644 index 8e78e0076..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallback.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.collectionspace.hello.services.nuxeo; - - -import javax.security.auth.callback.Callback; - -/** - * Copied from jbossx - * - * An implementation of Callback that simply obtains an Object to be used - * as the authentication credential. Interpretation of the Object is up to - * the LoginModules that validate the credential. - * - * @author Scott.Stark@jboss.org - */ -public class NuxeoCallback implements Callback { - - private final String prompt; - - private Object credential; - - public NuxeoCallback() { - this(""); - } - - public NuxeoCallback(String prompt) { - this.prompt = prompt; - } - - public String getPrompt() { - return prompt; - } - - public Object getCredential() { - return credential; - } - - public void setCredential(Object credential) { - this.credential = credential; - } - - public void clearCredential() { - credential = null; - } - -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallbackHandler.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallbackHandler.java deleted file mode 100644 index e8fff8c25..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoCallbackHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.collectionspace.hello.services.nuxeo; - -/** - * - * @author sanjaydalal - */ -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.NameCallback; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; - -/** - * Copied from jbossx. - * - * @author Scott.Stark@jboss.org - */ -public class NuxeoCallbackHandler implements CallbackHandler { - - private final String username; - private char[] password; - private final Object credential; - - /** - * Initializes the UsernamePasswordHandler with the username and password to - * use. - * - * @param username the user name - * @param password the password for this user - */ - public NuxeoCallbackHandler(String username, char[] password) { - this.username = username; - this.password = password; - credential = password; - } - - public NuxeoCallbackHandler(String username, Object credential) { - this.username = username; - this.credential = credential; - if (credential instanceof char[]) { - password = (char[]) credential; - } else if (credential instanceof CharSequence) { - password = credential.toString().toCharArray(); - } - } - - /** - * Sets any NameCallback name property to the instance username, sets any - * PasswordCallback password property to the instance, and any password. - * - * @exception UnsupportedCallbackException, - * thrown if any callback of type other than NameCallback or - * PasswordCallback are seen. - */ - public void handle(Callback[] callbacks) - throws UnsupportedCallbackException { - for (Callback c : callbacks) { - if (c instanceof NameCallback) { - NameCallback nc = (NameCallback) c; - nc.setName(username); - } else if (c instanceof PasswordCallback) { - PasswordCallback pc = (PasswordCallback) c; - if (password == null) { - // We were given an opaque Object credential but a char[] is - // requested? - if (credential != null) { - String tmp = credential.toString(); - password = tmp.toCharArray(); - } - } - pc.setPassword(password); - } else if (c instanceof NuxeoCallback) { - NuxeoCallback oc = (NuxeoCallback) c; - oc.setCredential(credential); - } else { - throw new UnsupportedCallbackException(c, - "Unrecognized Callback"); - } - } - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginConfiguration.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginConfiguration.java deleted file mode 100644 index 81cedc3c4..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.collectionspace.hello.services.nuxeo; - -/** - * - * @author sanjaydalal - */ -import java.util.HashMap; -import java.util.Map; - -import javax.security.auth.login.AppConfigurationEntry; -import javax.security.auth.login.Configuration; -import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; - -public class NuxeoLoginConfiguration extends Configuration { - - private final Configuration parent; - public static final String LOGIN_DOMAIN = "nuxeo-client-login"; - - public NuxeoLoginConfiguration(Configuration parent) { - this.parent = parent; - } - - @Override - public AppConfigurationEntry[] getAppConfigurationEntry(String name) { - - if (LOGIN_DOMAIN.equals(name)) { - AppConfigurationEntry[] entries = new AppConfigurationEntry[1]; - - Map options = new HashMap(); - - options.put("restore-login-identity", "True"); - options.put("multi-threaded", "True"); - - entries[0] = new AppConfigurationEntry("org.jboss.security.ClientLoginModule", LoginModuleControlFlag.REQUIRED, options); - - - return entries; - } else { - return parent.getAppConfigurationEntry(name); - } - } - - @Override - public void refresh() { - if (parent != null) { - parent.refresh(); - } - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginContextFactory.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginContextFactory.java deleted file mode 100644 index d1d23f7fc..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoLoginContextFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.collectionspace.hello.services.nuxeo; - -/** - * - * @author sanjaydalal - */ - -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.login.Configuration; -import javax.security.auth.login.LoginContext; -import javax.security.auth.login.LoginException; - -public class NuxeoLoginContextFactory { - - - private static boolean initDone=false; - - private static void initLoginConfig() - { - if (initDone) - return; - - Configuration parentConfig = null; - try { - parentConfig = Configuration.getConfiguration(); - } catch (Exception e) { - // do nothing - this can happen if default configuration provider is not correctly configured - // for examnple FileConfig fails if no config file was defined - } - Configuration config = new NuxeoLoginConfiguration(parentConfig); - Configuration.setConfiguration(config); - - initDone=true; - - } - - - public static LoginContext getLoginContext(CallbackHandler handler) throws LoginException - { - initLoginConfig(); - return new LoginContext(NuxeoLoginConfiguration.LOGIN_DOMAIN, handler); - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoRESTClient.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoRESTClient.java deleted file mode 100644 index 9f76f7b92..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/NuxeoRESTClient.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public License - * (LGPL) version 2.1 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * This library 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. - * - * Contributors: - * Nuxeo - initial API and implementation - * - * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ - */ -package org.collectionspace.hello.services.nuxeo; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; -import java.util.Map; - - -import org.restlet.Client; -import org.restlet.data.ChallengeResponse; -import org.restlet.data.ChallengeScheme; -import org.restlet.data.Cookie; -import org.restlet.data.Form; -import org.restlet.data.MediaType; -import org.restlet.data.Method; -import org.restlet.data.Parameter; -import org.restlet.data.Protocol; -import org.restlet.data.Request; -import org.restlet.resource.OutputRepresentation; -import org.restlet.resource.Representation; -import org.restlet.util.Series; - -public class NuxeoRESTClient { - - public static final int AUTH_TYPE_NONE = 0; - public static final int AUTH_TYPE_BASIC = 1; - public static final int AUTH_TYPE_SECRET = 2; - protected String baseURL = "http://127.0.0.1:8080/nuxeo"; - protected String restPrefix = "restAPI"; - protected String davPrefix = "dav"; - protected List cookies; - protected int authType = AUTH_TYPE_NONE; - protected String userName; - protected String password; - protected String secretToken; - protected Client restClient; - - public NuxeoRESTClient(String baseURL) { - this.baseURL = baseURL; - } - - public NuxeoRESTClient(String protocol, String serverIP, String serverPort) { - this(protocol, serverIP, serverPort, "nuxeo"); - } - - public NuxeoRESTClient(String protocol, String serverIP, String serverPort, - String servletPath) { - StringBuffer sb = new StringBuffer(); - sb.append(protocol); - sb.append("://"); - sb.append(serverIP); - if (serverPort != null && !serverIP.equals("80")) { - sb.append(':'); - sb.append(serverPort); - } - sb.append(servletPath); - sb.append('/'); - baseURL = sb.toString(); - } - - public void setBasicAuthentication(String userName, String password) { - authType = AUTH_TYPE_BASIC; - this.userName = userName; - this.password = password; - } - - public void setSharedSecretAuthentication(String userName, - String secretToken) { - authType = AUTH_TYPE_SECRET; - this.userName = userName; - this.secretToken = secretToken; - } - - public void setCookies(List cookies) { - this.cookies = cookies; - } - - public Representation post(List pathParams, - Map queryParams, InputStream istream) { - String path = ""; - StringBuffer pathBuffer = new StringBuffer(); - - if (pathParams != null) { - for (String p : pathParams) { - pathBuffer.append(p); - pathBuffer.append('/'); - } - path = pathBuffer.toString(); - } - - return post(path, queryParams, istream); - } - - public Representation post(String subPath, - Map queryParams, InputStream istream) { - StringBuffer urlBuffer = new StringBuffer(); - - if (subPath.startsWith("/")) { - subPath = subPath.substring(1); - } - if (subPath.endsWith("/")) { - subPath = subPath.substring(0, subPath.length() - 1); - } - - urlBuffer.append(baseURL); - urlBuffer.append('/'); - urlBuffer.append(restPrefix); - urlBuffer.append('/'); - urlBuffer.append(subPath); - - if (queryParams != null) { - urlBuffer.append('?'); - - String qpValue = null; - for (String qpName : queryParams.keySet()) { - urlBuffer.append(qpName); - urlBuffer.append('='); - qpValue = queryParams.get(qpName); - if (qpValue != null) { - urlBuffer.append(qpValue.replaceAll(" ", "%20")); - } - urlBuffer.append('&'); - } - } - - String completeURL = urlBuffer.toString(); - System.out.println("\nNuxeoRESTClient: calling " + completeURL); - Request request = new Request(Method.POST, completeURL); - - setupAuth(request); - setupCookies(request); - final InputStream in = istream; - request.setEntity(new OutputRepresentation( - MediaType.MULTIPART_FORM_DATA) { - - @Override - public void write(OutputStream outputStream) throws IOException { - byte[] buffer = new byte[1024 * 64]; - int read; - while ((read = in.read(buffer)) != -1) { - outputStream.write(buffer, 0, read); - } - - } - }); - - return getRestClient().handle(request).getEntity(); - } - - public Representation get(List pathParams, - Map queryParams) { - String path = ""; - StringBuffer pathBuffer = new StringBuffer(); - - if (pathParams != null) { - for (String p : pathParams) { - pathBuffer.append(p); - pathBuffer.append('/'); - } - path = pathBuffer.toString(); - } - - return get(path, queryParams); - } - - public Representation get(String subPath, - Map queryParams) { - StringBuffer urlBuffer = new StringBuffer(); - - if (subPath.startsWith("/")) { - subPath = subPath.substring(1); - } - if (subPath.endsWith("/")) { - subPath = subPath.substring(0, subPath.length() - 1); - } - - urlBuffer.append(baseURL); - urlBuffer.append('/'); - urlBuffer.append(restPrefix); - urlBuffer.append('/'); - urlBuffer.append(subPath); - - if (queryParams != null) { - urlBuffer.append('?'); - for (String qpName : queryParams.keySet()) { - urlBuffer.append(qpName); - urlBuffer.append('='); - urlBuffer.append(queryParams.get(qpName).replaceAll(" ", "%20")); - urlBuffer.append('&'); - } - } - - String completeURL = urlBuffer.toString(); - System.out.println("\nNuxeoRESTClient: calling " + completeURL); - Request request = new Request(Method.GET, completeURL); - setupAuth(request); - setupCookies(request); - - return getRestClient().handle(request).getEntity(); - } - - protected void setupAuth(Request request) { - - if (authType == AUTH_TYPE_BASIC) { - ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC; - ChallengeResponse authentication = new ChallengeResponse(scheme, - userName, password); - request.setChallengeResponse(authentication); - - } else if (authType == AUTH_TYPE_SECRET) { - Series additionnalHeaders = new Form(); - - Map securityHeaders = PortalSSOAuthenticationProvider.getHeaders( - secretToken, userName); - - for (String hn : securityHeaders.keySet()) { - additionnalHeaders.add(hn, securityHeaders.get(hn)); - } - - request.getAttributes().put("org.restlet.http.headers", - additionnalHeaders); - } - } - - protected void setupCookies(Request request) { - if (cookies != null) { - request.getCookies().clear(); - for (Cookie cookie : cookies) { - request.getCookies().add(cookie); - } - } - - } - - protected Client getRestClient() { - if (restClient == null) { - if (baseURL.startsWith("https")) { - restClient = new Client(Protocol.HTTPS); - } else { - restClient = new Client(Protocol.HTTP); - } - } - - return restClient; - } - - public int getAuthType() { - return authType; - } - - public void setAuthType(int authType) { - this.authType = authType; - } - - public String getDavPrefix() { - return davPrefix; - } - - public void setDavPrefix(String davPrefix) { - this.davPrefix = davPrefix; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getRestPrefix() { - return restPrefix; - } - - public void setRestPrefix(String restPrefix) { - this.restPrefix = restPrefix; - } - - public String getSecretToken() { - return secretToken; - } - - public void setSecretToken(String secretToken) { - this.secretToken = secretToken; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/PortalSSOAuthenticationProvider.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/PortalSSOAuthenticationProvider.java deleted file mode 100644 index ef1a61a40..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/nuxeo/PortalSSOAuthenticationProvider.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser General Public License - * (LGPL) version 2.1 which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl.html - * - * This library 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. - * - * Contributors: - * Nuxeo - initial API and implementation - * - * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ - */ - -package org.collectionspace.hello.services.nuxeo; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -import com.noelios.restlet.util.Base64; - -public class PortalSSOAuthenticationProvider { - - private static final String TOKEN_SEP = ":"; - - private static final String TS_HEADER = "NX_TS"; - - private static final String RANDOM_HEADER = "NX_RD"; - - private static final String TOKEN_HEADER = "NX_TOKEN"; - - private static final String USER_HEADER = "NX_USER"; - - public static Map getHeaders(String secretKey, - String userName) { - - Map headers = new HashMap(); - - Date timestamp = new Date(); - int randomData = new Random(timestamp.getTime()).nextInt(); - - String clearToken = timestamp.getTime() + TOKEN_SEP + randomData - + TOKEN_SEP + secretKey + TOKEN_SEP + userName; - - byte[] hashedToken; - - try { - hashedToken = MessageDigest.getInstance("MD5").digest( - clearToken.getBytes()); - } catch (NoSuchAlgorithmException e) { - return null; - } - - String base64HashedToken = Base64.encodeBytes(hashedToken); - - headers.put(TS_HEADER, String.valueOf(timestamp.getTime())); - headers.put(RANDOM_HEADER, String.valueOf(randomData)); - headers.put(TOKEN_HEADER, base64HashedToken); - headers.put(USER_HEADER, userName); - - return headers; - } - -} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/resources/jndi.properties b/HelloWorld/HelloWorldNuxeoService/src/main/resources/jndi.properties deleted file mode 100644 index a3aa40712..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/resources/jndi.properties +++ /dev/null @@ -1,3 +0,0 @@ -java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -java.naming.provider.url=jnp://localhost:1099 \ No newline at end of file diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/resources/nuxeo.properties b/HelloWorld/HelloWorldNuxeoService/src/main/resources/nuxeo.properties deleted file mode 100644 index 3c9d5afb5..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/resources/nuxeo.properties +++ /dev/null @@ -1,2 +0,0 @@ -org.nuxeo.runtime.server.enabled=false -org.nuxeo.runtime.streaming.isServer=false diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/webapp/WEB-INF/web.xml b/HelloWorld/HelloWorldNuxeoService/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 0c188a4fb..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - HelloworldNuxeo - - - javax.ws.rs.Application - org.collectionspace.hello.services.HelloworldNuxeoApplication - - - - resteasy.servlet.mapping.prefix - /cspace-nuxeo - - - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - - Resteasy - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - - - Resteasy - /cspace-nuxeo/* - - - diff --git a/HelloWorld/pom.xml b/HelloWorld/pom.xml deleted file mode 100644 index 4020e517c..000000000 --- a/HelloWorld/pom.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - - 4.0.0 - org.collectionspace.hello.services - 0.1 - helloworld - pom - HelloWorld - - HelloWorldJaxb - HelloWorldClient - HelloWorldNuxeoService - - - - - jboss - http://repository.jboss.org/maven2 - - - sun - http://download.java.net/maven/2 - - - java.net - java.net Maven Repository - https://maven-repository.dev.java.net/nonav/repository - legacy - - - maven2-repository.dev.java.net - Java.net Maven 2 Repository - http://download.java.net/maven/2 - - - - - - java.net - java.net Maven Repository - https://maven-repository.dev.java.net/nonav/repository - legacy - - - maven2-repository.dev.java.net - Java.net Maven 2 Repository - http://download.java.net/maven/2 - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-site-plugin - - /usr/bin/unzip -o > err.txt - - - - org.apache.maven.plugins - maven-war-plugin - 2.0.1 - - - WEB-INF/lib/*.jar - - - true - - - - - - - - - - - - - net.java.dev.jaxb2-commons - jaxb-fluent-api - 2.0.1 - - - org.testng - testng - 5.6 - test - jdk15 - - - org.jboss.resteasy - jaxrs-api - 1.0.2.GA - - - net.java.dev.jaxb2-commons - jaxb-fluent-api - 2.0.1 - - - org.jvnet.jaxb2-commons - property-listener-injector - 1.0 - - - org.jvnet.jaxb2_commons - runtime - 0.4.1 - - - org.jboss.resteasy - resteasy-jaxrs - 1.0.2.GA - - - commons-httpclient - commons-httpclient - 3.1 - - - com.sun.xml.bind - jaxb-impl - 2.1.7 - - - org.testng - testng - 5.6 - test - jdk15 - - - org.slf4j - slf4j-api - 1.5.2 - - - org.slf4j - slf4j-log4j12 - 1.5.2 - - - mysql - mysql-connector-java - 5.1.5 - test - - - com.jgoodies - binding - 2.0.2 - - - com.jgoodies - forms - 1.2.0 - - - - -- 2.47.3