+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<classpath>\r
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
- <classpathentry kind="lib" path="/helloworld-jaxb/target/helloworld-jaxb-0.1.jar"/>\r
- <classpathentry kind="output" path="target/classes"/>\r
-</classpath>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>javaee-addressbook-client</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Thu Feb 26 16:30:28 PST 2009\r
-activeProfiles=\r
-eclipse.preferences.version=1\r
-fullBuildGoals=process-test-resources\r
-includeModules=false\r
-resolveWorkspaceProjects=true\r
-resourceFilterGoals=process-resources resources\:testResources\r
-version=1\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project-shared-configuration>\r
- <!--
-This file contains additional configuration written by modules in the NetBeans IDE.
-The configuration is intended to be shared among all the users of project and
-therefore it is assumed to be part of version control checkout.
-Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->\r
- <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">\r
- <!--
-Properties that influence various parts of the IDE, especially code formatting and the like.
-You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
-That way multiple projects can share the same settings (useful for formatting rules for example).
-Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->\r
- <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>\r
- </properties>\r
-</project-shared-configuration>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<actions>\r
- <action>\r
- <actionName>rebuild</actionName>\r
- <packagings>\r
- <packaging>*</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>clean</goal>\r
- <goal>install</goal>\r
- </goals>\r
- <properties>\r
- <maven.test.skip>true</maven.test.skip>\r
- </properties>\r
- </action>\r
- \r
- </actions>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project xmlns="http://maven.apache.org/POM/4.0.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
- <parent>\r
- <artifactId>helloworld</artifactId>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <version>0.1</version>\r
- </parent>\r
- <modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <artifactId>helloworld-client</artifactId>\r
- <packaging>jar</packaging>\r
- <version>0.1</version>\r
- <name>Helloworld Client</name>\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <artifactId>helloworld-jaxb</artifactId>\r
- <version>0.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.testng</groupId>\r
- <artifactId>testng</artifactId>\r
- <version>5.6</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-api</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-jaxrs</artifactId>\r
- <version>1.0.2.GA</version>\r
- <!-- filter out unwanted jars -->\r
- <exclusions>\r
- <exclusion>\r
- <groupId>tjws</groupId>\r
- <artifactId>webserver</artifactId>\r
- </exclusion>\r
- </exclusions>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-jaxb-provider</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-multipart-provider</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>commons-httpclient</groupId>\r
- <artifactId>commons-httpclient</artifactId>\r
- </dependency>\r
- </dependencies>\r
- <build>\r
- <plugins>\r
- <plugin>\r
- <artifactId>maven-compiler-plugin</artifactId>\r
- <version>2.0.2</version>\r
- <configuration>\r
- <source>1.5</source>\r
- <target>1.5</target>\r
- </configuration>\r
- </plugin>\r
- </plugins>\r
- </build>\r
-</project>\r
+++ /dev/null
-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<CollectionObjectList> getCollectionObjectList() {
- return collectionObjectProxy.getCollectionObjectList();
- }
-
- /**
- * @param csid
- * @return
- * @see org.collectionspace.hello.client.CollectionObjectProxy#getCollectionObject(java.lang.String)
- */
- public ClientResponse<CollectionObject> getCollectionObject(String csid) {
- return collectionObjectProxy.getCollectionObject(csid);
- }
-
- /**
- * @param collectionobject
- * @return
- * @see org.collectionspace.hello.client.CollectionObjectProxy#createCollectionObject(org.collectionspace.hello.CollectionObject)
- */
- public ClientResponse<Response> 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<CollectionObject> 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<Response> deleteCollectionObject(String csid) {
- return collectionObjectProxy.deleteCollectionObject(csid);
- }
-}
+++ /dev/null
-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<CollectionObjectList> getCollectionObjectList();
-
- //(C)reate
- @POST
- ClientResponse<Response> createCollectionObject(CollectionObject co);
-
- //(R)ead
- @GET
- @Path("/{csid}")
- ClientResponse<CollectionObject> getCollectionObject(@PathParam("csid") String csid);
-
- //(U)pdate
- @PUT
- @Path("/{csid}")
- ClientResponse<CollectionObject> updateCollectionObject(@PathParam("csid") String csid, CollectionObject co);
-
- //(D)elete
- @DELETE
- @Path("/{csid}")
- ClientResponse<Response> deleteCollectionObject(@PathParam("csid") String csid);
-}
\ No newline at end of file
+++ /dev/null
-package org.collectionspace.hello.client;\r
-\r
-import java.util.*;\r
-\r
-public abstract class CollectionSpaceClient {\r
- static final String URL_PROPERTY = "org.collectionspace.url";\r
- /*\r
- static final String URL_PROPERTY_SCHEME = "org.collectionspace.url.schme";\r
- static final String URL_PROPERTY_HOST = "org.collectionspace.url.host";\r
- static final String URL_PROPERTY_PORT = "org.collectionspace.url.port";\r
- static final String URL_PROPERTY_CONTEXT = "org.collectionspace.url.context";\r
- */\r
- \r
- private static final String SCHEME = "http";\r
- private static final String HOST = "localhost";\r
- private static final String PORT = "8080";\r
- private static final String URI = "/helloworld/cspace-nuxeo";\r
- private static final String URL = SCHEME + "://" +\r
- HOST + ":" +\r
- PORT +\r
- URI;\r
- private String collectionSpaceURL = null;\r
- \r
- \r
- String getURL() {\r
- String result = collectionSpaceURL;\r
- \r
- if (collectionSpaceURL == null) {\r
- result = collectionSpaceURL = System.getProperty(URL_PROPERTY, URL);\r
- }\r
- \r
- return result;\r
- }\r
-}\r
+++ /dev/null
-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<DomainIdentifier> 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<Response> createIdentifier(DomainIdentifier identifier) {
- return identifierProxy.createIdentifier(identifier);
- }
-}
+++ /dev/null
-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<DomainIdentifier> getIdentifier(@PathParam("id") String id);
-
- @POST
- ClientResponse<Response> createIdentifier(DomainIdentifier so);
-}
\ No newline at end of file
+++ /dev/null
-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<Response> 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<CollectionObject> 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<CollectionObjectList.CollectionObjectListItem> 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<Response> 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<Response> 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;
- }
-}
+++ /dev/null
-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<Response> 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<Response> 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();
- }
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out" />
- <layout class="org.apache.log4j.TTCCLayout">
- <param name="DateFormat" value="ISO8601" />
- </layout>
- </appender>
-
-
- <appender name="unit-tests"
- class="org.apache.log4j.RollingFileAppender">
- <param name="File" value="./target/unit-tests.log" />
- <param name="MaxFileSize" value="10240KB" />
- <param name="MaxBackupIndex" value="6" />
- <layout class="org.apache.log4j.TTCCLayout">
- <param name="DateFormat" value="ISO8601" />
- </layout>
- </appender>
-
- <logger name="org.apache.commons.httpclient" additivity="false">
- <level value="warn" />
- <appender-ref ref="console" />
- <appender-ref ref="unit-tests" />
- </logger>
-
- <logger name="httpclient.wire" additivity="false">
- <level value="info" />
- <appender-ref ref="console" />
- <appender-ref ref="unit-tests" />
- </logger>
-
- <root>
- <priority value="debug" />
- <appender-ref ref="console" />
- <appender-ref ref="unit-tests" />
- </root>
-
-</log4j:configuration>
-
-
-
-
+++ /dev/null
-<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
-<suite name="javaee-addressbook-client">
- <test verbose="2" name="org.jboss.resteasy.examples.addressbook.client.AddressBookTest" annotations="JDK">
- <classes>
- <class name="org.jboss.resteasy.examples.addressbook.client.AddressBookTest"/>
- </classes>
- </test>
-</suite>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<classpath>\r
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
- <classpathentry kind="output" path="target/classes"/>\r
-</classpath>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>javaee-addressbook-jaxb</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Thu Feb 26 16:30:28 PST 2009\r
-activeProfiles=\r
-eclipse.preferences.version=1\r
-fullBuildGoals=process-test-resources\r
-includeModules=false\r
-resolveWorkspaceProjects=true\r
-resourceFilterGoals=process-resources resources\:testResources\r
-version=1\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project-shared-configuration>\r
- <!--
-This file contains additional configuration written by modules in the NetBeans IDE.
-The configuration is intended to be shared among all the users of project and
-therefore it is assumed to be part of version control checkout.
-Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->\r
- <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">\r
- <!--
-Properties that influence various parts of the IDE, especially code formatting and the like.
-You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
-That way multiple projects can share the same settings (useful for formatting rules for example).
-Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->\r
- <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>\r
- </properties>\r
-</project-shared-configuration>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>helloworld</artifactId>
- <groupId>org.collectionspace.hello.services</groupId>
- <version>0.1</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.hello.services</groupId>
- <artifactId>helloworld-jaxb</artifactId>
- <version>0.1</version>
- <name>Helloworld Client JAXB</name>
- <dependencies>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.jvnet.jaxb2-commons</groupId>
- <artifactId>property-listener-injector</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.jvnet.jaxb2_commons</groupId>
- <artifactId>runtime</artifactId>
- <version>0.4.1.4</version>
- </dependency>
- </dependencies>
- <build>
- <defaultGoal>install</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.jvnet.jaxb2.maven2</groupId>
- <artifactId>maven-jaxb2-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <!-- javax.activation.DataSource provider is required by spec -->
- <dependency>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.1.2</version>
- </dependency>
- </dependencies>
- <configuration>
- <args>
- <arg>-XtoString</arg>
- <arg>-Xinject-listener-code</arg>
-
- <!-- <arg>-Xcollection-setter-injector</arg>
- <arg>-Xfluent-api</arg> -->
- </args>
- <plugins>
- <plugin>
- <groupId>
- org.jvnet.jaxb2_commons
- </groupId>
- <artifactId>basic</artifactId>
- <version>0.4.1</version>
- </plugin>
- <plugin>
- <groupId>
- org.jvnet.jaxb2-commons
- </groupId>
- <artifactId>
- property-listener-injector
- </artifactId>
- <version>1.0</version>
- </plugin>
-
- </plugins>
- <!--generatePackage>
- org.collectionspace.hello
- </generatePackage-->
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/**\r
- * \r
- */\r
-package org.collectionspace.hello.services;\r
-\r
-/**\r
- * @author remillet\r
- *\r
- */\r
-public interface CollectionObjectJAXBSchema {\r
- final static String OBJECT_NUMBER = "objectNumber";\r
- final static String OTHER_NUMBER = "otherNumber";\r
- final static String BRIEF_DESCRIPTION = "briefDescription";\r
- final static String COMMENTS = "comments";\r
- final static String DIST_FEATURES = "distFeatures";\r
- final static String OBJECT_NAME = "objectName";\r
- final static String RESPONSIBLE_DEPT = "responsibleDept";\r
- final static String TITLE = "title";\r
-}\r
-\r
-\r
+++ /dev/null
-package org.collectionspace.hello.services;\r
-\r
-public interface CollectionObjectListItemJAXBSchema {\r
- final static String OBJECT_NUMBER = "objectNumber";\r
- final static String CSID = "csid";\r
- final static String URI = "url";\r
-}\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<xs:schema
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ns="http://collectionspace.org/hello"
- xmlns="http://collectionspace.org/hello"
- targetNamespace="http://collectionspace.org/hello"
- version="0.1"
->
-
-<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
-
- <!-- domain-identifier -->
- <xs:element name="domain-identifier">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="dsid" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
-
- <!-- collection-object -->
- <xs:element name="collection-object">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="csid" type="xs:string" />
- <xs:element name="objectNumber" type="xs:string"/>
- <xs:element name="otherNumber" type="xs:string"/>
- <xs:element name="briefDescription" type="xs:string"/>
- <xs:element name="comments" type="xs:string"/>
- <xs:element name="distFeatures" type="xs:string"/>
- <xs:element name="objectName" type="xs:string"/>
- <xs:element name="responsibleDept" type="xs:string"/>
- <xs:element name="title" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- collection objects as in nuxeo repository -->
- <xs:element name="collection-object-list">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="collection-object-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="objectNumber" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrive collection object details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
-</xs:schema>
-
+++ /dev/null
-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
+++ /dev/null
-jboss.dir=/usr/local/jboss-4.2.3.GA\r
-nuxeo.dir=${jboss.dir}/server/default/deploy/nuxeo.ear/system\r
-nuxeo.local.repo.dir=file:///C:/dev/jboss-4.2.3.GA/server/default/deploy/nuxeo.ear/system\r
-nuxeo.local.repo.client.dir=file:///C:/dev/nuxeo/nuxeo-core/nuxeo-core-client/target\r
+++ /dev/null
-<?xml version="1.0"?>
-<project name="helloworld" default="deploy" basedir=".">
-
- <property file="build.properties" />
-
-
- <target name="deploy" description="Deploy">
- <copy todir="${jee.dir}/server/default/deploy">
- <fileset file="${basedir}/target/helloworld.war" />
- </copy>
- </target>
-
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project-shared-configuration>\r
- <!--
-This file contains additional configuration written by modules in the NetBeans IDE.
-The configuration is intended to be shared among all the users of project and
-therefore it is assumed to be part of version control checkout.
-Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->\r
- <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">\r
- <!--
-Properties that influence various parts of the IDE, especially code formatting and the like.
-You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
-That way multiple projects can share the same settings (useful for formatting rules for example).
-Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->\r
- <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>\r
- <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>\r
- <netbeans.hint.useExternalMaven>false</netbeans.hint.useExternalMaven>\r
- </properties>\r
-</project-shared-configuration>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<actions>\r
- <action>\r
- <actionName>test</actionName>\r
- <packagings>\r
- <packaging>*</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>test</goal>\r
- </goals>\r
- </action>\r
- <action>\r
- <actionName>build</actionName>\r
- <packagings>\r
- <packaging>*</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>install</goal>\r
- </goals>\r
- </action>\r
- <action>\r
- <actionName>clean</actionName>\r
- <packagings>\r
- <packaging>*</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>clean</goal>\r
- </goals>\r
- </action>\r
- <action>\r
- <actionName>rebuild</actionName>\r
- <packagings>\r
- <packaging>*</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>clean</goal>\r
- <goal>install</goal>\r
- </goals>\r
- <properties>\r
- <maven.test.skip>true</maven.test.skip>\r
- </properties>\r
- </action>\r
- <action>\r
- <actionName>run</actionName>\r
- <packagings>\r
- <packaging>war</packaging>\r
- <packaging>ear</packaging>\r
- <packaging>ejb</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>package</goal>\r
- </goals>\r
- <properties>\r
- \r
- <netbeans.deploy>true</netbeans.deploy>\r
- </properties>\r
- </action>\r
- <action>\r
- <actionName>debug</actionName>\r
- <packagings>\r
- <packaging>war</packaging>\r
- <packaging>ear</packaging>\r
- <packaging>ejb</packaging>\r
- </packagings>\r
- <goals>\r
- <goal>package</goal>\r
- </goals>\r
- <properties>\r
- \r
- <netbeans.deploy>true</netbeans.deploy>\r
- <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>\r
- </properties>\r
- </action>\r
- </actions>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
- <parent>\r
- <artifactId>helloworld</artifactId>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <version>0.1</version>\r
- </parent>\r
- <modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <artifactId>helloworld-nuxeo-service</artifactId>\r
- <packaging>war</packaging>\r
- <version>0.1</version>\r
- <name>Helloworld Nuxeo Service</name>\r
-\r
- <repositories>\r
- <repository>\r
- <id>java.net</id>\r
- <url>http://download.java.net/maven/1</url>\r
- <layout>legacy</layout>\r
- </repository>\r
- <repository>\r
- <id>maven repo</id>\r
- <name>maven repo</name>\r
- <url>http://repo1.maven.org/maven2/</url>\r
- </repository>\r
- <!-- For resteasy -->\r
- <repository>\r
- <id>jboss</id>\r
- <name>jboss repo</name>\r
- <url>http://repository.jboss.org/maven2</url>\r
- </repository>\r
- <repository>\r
- <id>mojo</id>\r
- <name>mojo repo</name>\r
- <url>http://svn.codehaus.org/mojo/trunk/mojo/jboss-maven-plugin</url>\r
- </repository>\r
-\r
- <repository>\r
- <id>cspace.local.nuxeo</id>\r
- <url>${nuxeo.local.repo.dir}</url>\r
- </repository>\r
- <repository>\r
- <id>cspace.local.nuxeo.client</id>\r
- <url>${nuxeo.local.repo.client.dir}</url>\r
- </repository>\r
- <repository>\r
- <id>public</id>\r
- <url>http://maven.nuxeo.org/public</url>\r
- <releases>\r
- </releases>\r
- <snapshots>\r
- <enabled>false</enabled>\r
- </snapshots>\r
- </repository>\r
- <repository>\r
- <id>public-snapshot</id>\r
- <url>http://maven.nuxeo.org/public-snapshot</url>\r
- <releases>\r
- <enabled>false</enabled>\r
- </releases>\r
- <snapshots>\r
- </snapshots>\r
- </repository>\r
-\r
-\r
- </repositories>\r
-\r
- <pluginRepositories>\r
- <pluginRepository>\r
- <id>public</id>\r
- <url>http://maven.nuxeo.org/public</url>\r
- <name>Nuxeo virtual release repository</name>\r
- <releases>\r
- </releases>\r
- <snapshots>\r
- <enabled>false</enabled>\r
- </snapshots>\r
- </pluginRepository>\r
- <pluginRepository>\r
- <id>public-snapshot</id>\r
- <url>http://maven.nuxeo.org/public-snapshot</url>\r
- <name>Nuxeo virtual snapshot repository</name>\r
- <releases>\r
- <enabled>false</enabled>\r
- </releases>\r
- <snapshots>\r
- </snapshots>\r
- </pluginRepository>\r
- </pluginRepositories>\r
-\r
-\r
- <properties>\r
- <jboss.version>4.2.3.GA</jboss.version>\r
- <jboss.ejb.version>3.0</jboss.ejb.version>\r
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
- <apacheds.version>1.5.1</apacheds.version>\r
- <apachedshared.version>0.9.7</apachedshared.version>\r
- <nuxeo.version.5.2>5.2-SNAPSHOT</nuxeo.version.5.2>\r
- <nuxeo.version.1.5>1.11-SNAPSHOT</nuxeo.version.1.5>\r
- </properties>\r
-\r
-\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <artifactId>helloworld-jaxb</artifactId>\r
- <version>0.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-jaxrs</artifactId>\r
- <version>1.0.2.GA</version>\r
- <exclusions>\r
- <exclusion>\r
- <groupId>tjws</groupId>\r
- <artifactId>webserver</artifactId>\r
- </exclusion>\r
- </exclusions>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-jaxb-provider</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-multipart-provider</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>junit</groupId>\r
- <artifactId>junit</artifactId>\r
- <version>4.1</version>\r
- <scope>test</scope>\r
- </dependency>\r
-\r
- <!-- javax -->\r
-\r
-\r
- <dependency>\r
- <groupId>javax.security</groupId>\r
- <artifactId>jaas</artifactId>\r
- <version>1.0.01</version>\r
- <scope>provided</scope>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>dom4j</groupId>\r
- <artifactId>dom4j</artifactId>\r
- <version>1.6.1</version>\r
- <scope>provided</scope>\r
- </dependency>\r
- \r
- <!-- jboss -->\r
-\r
- <!-- nuxeo -->\r
-\r
- <dependency>\r
- <groupId>org.nuxeo.ecm.core</groupId>\r
- <artifactId>nuxeo-core-api</artifactId>\r
- <version>${nuxeo.version.1.5}</version>\r
- <exclusions>\r
- <exclusion>\r
- <artifactId>jboss-remoting</artifactId>\r
- <groupId>jboss</groupId>\r
- </exclusion>\r
- </exclusions>\r
- </dependency>\r
-\r
-<!--\r
- <dependency>\r
- <groupId>org.nuxeo.ecm.core</groupId>\r
- <artifactId>nuxeo-core-client</artifactId>\r
- <version>${nuxeo.version.1.5}</version>\r
- </dependency>\r
--->\r
-\r
- <dependency>\r
- <groupId>jaxen</groupId>\r
- <artifactId>jaxen</artifactId>\r
- <version>1.1.1</version>\r
- </dependency>\r
-\r
-\r
- </dependencies>\r
- \r
- <build>\r
- <finalName>helloworld</finalName>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.codehaus.mojo</groupId>\r
- <artifactId>jboss-maven-plugin</artifactId>\r
- <configuration>\r
- <jbossHome>${jboss.dir}</jbossHome>\r
- </configuration>\r
- <executions>\r
- <execution>\r
- <id>jboss-undeploy</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>undeploy</goal>\r
- </goals>\r
- <configuration>\r
- <fileName>${basedir}/target/helloworld.war</fileName>\r
- </configuration>\r
- </execution>\r
- <execution>\r
- <id>jboss-deploy</id>\r
- <phase>pre-integration-test</phase>\r
- <goals>\r
- <goal>deploy</goal>\r
- </goals>\r
- <configuration>\r
- <fileName>${basedir}/target/helloworld.war</fileName>\r
- </configuration>\r
- </execution>\r
-\r
- </executions>\r
- </plugin>\r
-\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-surefire-plugin</artifactId>\r
- <configuration></configuration>\r
- <executions>\r
- <execution>\r
- <id>surefire-it</id>\r
- <phase>integration-test</phase>\r
- <goals>\r
- <goal>test</goal>\r
- </goals>\r
- <configuration>\r
- <skip>false</skip>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-war-plugin</artifactId>\r
- <version>2.0</version>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-compiler-plugin</artifactId>\r
- <configuration>\r
- <source>1.5</source>\r
- <target>1.5</target>\r
- </configuration>\r
- </plugin>\r
- </plugins>\r
- </build>\r
-</project>\r
+++ /dev/null
-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<String> pathParams = new ArrayList<String>();
- Map<String, String> queryParams = new HashMap<String, String>();
- 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<CollectionObjectList.CollectionObjectListItem> 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<String> pathParams = new ArrayList<String>();
- Map<String, String> queryParams = new HashMap<String, String>();
- 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<String> pathParams = new ArrayList<String>();
- Map<String, String> queryParams = new HashMap<String, String>();
-
- 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<Element> 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<String> pathParams = new ArrayList<String>();
- Map<String, String> queryParams = new HashMap<String, String>();
- 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<String> pathParams = new ArrayList<String>();
- Map<String, String> queryParams = new HashMap<String, String>();
-
- 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);
- }
-}
+++ /dev/null
-package org.collectionspace.hello.services;\r
-\r
-import org.collectionspace.hello.services.nuxeo.NuxeoRESTClient;\r
-\r
-public abstract class CollectionSpaceResource {\r
- //replace WORKSPACE_UID for resource workspace\r
- static String CS_COLLECTIONOBJECT_WORKSPACE_UID = "5a37d40f-59c4-4d15-93ad-e0e6a0c33587";\r
- //sanjay 6c7881fe-54c5-486e-b144-a025dee3a484\r
- //demo eae0d7b6-580a-45a3-a0f3-e25e980e03bb\r
- static String CS_PERSON_WORKSPACE_UID = "eae0d7b6-580a-45a3-a0f3-e25e980e03bb";\r
- \r
- //replace host if not running on localhost\r
- //static String CS_NUXEO_HOST = "173.45.234.217";\r
- static String CS_NUXEO_HOST = "localhost";\r
- static String CS_NUXEO_URI = "http://" + CS_NUXEO_HOST + ":8080/nuxeo";\r
- \r
- NuxeoRESTClient getClient() {\r
- NuxeoRESTClient nxClient = new NuxeoRESTClient(CS_NUXEO_URI);\r
- nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC);\r
- nxClient.setBasicAuthentication("Administrator", "Administrator");\r
- return nxClient;\r
- }\r
- \r
-}\r
+++ /dev/null
-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<String, DomainIdentifier> idDB = new ConcurrentHashMap<String, DomainIdentifier>();
-
- 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();
- }
- }
-}
+++ /dev/null
-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<Object> singletons = new HashSet<Object>();
- private Set<Class<?>> empty = new HashSet<Class<?>>();
-
- public HelloworldNuxeoApplication() {
- singletons.add(new CollectionObjectResource());
- singletons.add(new DomainIdentifierResource());
- singletons.add(new PingResource());
- }
-
- @Override
- public Set<Class<?>> getClasses() {
- return empty;
- }
-
- @Override
- public Set<Object> getSingletons() {
- return singletons;
- }
-}
+++ /dev/null
-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();
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-
-}
+++ /dev/null
-/*
- * 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");
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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<String, Object> options = new HashMap<String, Object>();
-
- 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();
- }
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
+++ /dev/null
-/*
- * (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<Cookie> 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<Cookie> cookies) {
- this.cookies = cookies;
- }
-
- public Representation post(List<String> pathParams,
- Map<String, String> 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<String, String> 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<String> pathParams,
- Map<String, String> 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<String, String> 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<Parameter> additionnalHeaders = new Form();
-
- Map<String, String> 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;
- }
-}
+++ /dev/null
-/*
- * (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<String, String> getHeaders(String secretKey,
- String userName) {
-
- Map<String, String> headers = new HashMap<String, String>();
-
- 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;
- }
-
-}
+++ /dev/null
-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
+++ /dev/null
-org.nuxeo.runtime.server.enabled=false
-org.nuxeo.runtime.streaming.isServer=false
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">\r
-<web-app>\r
- <display-name>HelloworldNuxeo</display-name>\r
-\r
- <context-param>\r
- <param-name>javax.ws.rs.Application</param-name>\r
- <param-value>org.collectionspace.hello.services.HelloworldNuxeoApplication</param-value>\r
- </context-param>\r
-\r
- <context-param>\r
- <param-name>resteasy.servlet.mapping.prefix</param-name>\r
- <param-value>/cspace-nuxeo</param-value>\r
- </context-param>\r
-\r
- <listener>\r
- <listener-class>\r
- org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap\r
- </listener-class>\r
- </listener>\r
-\r
- <servlet>\r
- <servlet-name>Resteasy</servlet-name>\r
- <servlet-class>\r
- org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher\r
- </servlet-class>\r
- </servlet>\r
-\r
- <servlet-mapping>\r
- <servlet-name>Resteasy</servlet-name>\r
- <url-pattern>/cspace-nuxeo/*</url-pattern>\r
- </servlet-mapping>\r
-\r
-</web-app>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
-\r
- <modelVersion>4.0.0</modelVersion>\r
- <groupId>org.collectionspace.hello.services</groupId>\r
- <version>0.1</version>\r
- <artifactId>helloworld</artifactId>\r
- <packaging>pom</packaging>\r
- <name>HelloWorld</name>\r
- <modules>\r
- <module>HelloWorldJaxb</module>\r
- <module>HelloWorldClient</module>\r
- <module>HelloWorldNuxeoService</module>\r
- \r
-</modules>\r
- <repositories>\r
- <repository>\r
- <id>jboss</id>\r
- <url>http://repository.jboss.org/maven2</url>\r
- </repository>\r
- <repository>\r
- <id>sun</id>\r
- <url>http://download.java.net/maven/2</url>\r
- </repository>\r
- <repository>\r
- <id>java.net</id>\r
- <name>java.net Maven Repository</name>\r
- <url>https://maven-repository.dev.java.net/nonav/repository</url>\r
- <layout>legacy</layout>\r
- </repository>\r
- <repository>\r
- <id>maven2-repository.dev.java.net</id>\r
- <name>Java.net Maven 2 Repository</name>\r
- <url>http://download.java.net/maven/2</url>\r
- </repository>\r
- </repositories>\r
- <pluginRepositories>\r
-\r
- <pluginRepository>\r
- <id>java.net</id>\r
- <name>java.net Maven Repository</name>\r
- <url>https://maven-repository.dev.java.net/nonav/repository</url>\r
- <layout>legacy</layout>\r
- </pluginRepository>\r
- <pluginRepository>\r
- <id>maven2-repository.dev.java.net</id>\r
- <name>Java.net Maven 2 Repository</name>\r
- <url>http://download.java.net/maven/2</url>\r
- </pluginRepository>\r
- </pluginRepositories>\r
-\r
- <build>\r
- <pluginManagement>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-compiler-plugin</artifactId>\r
- <configuration>\r
- <source>1.5</source>\r
- <target>1.5</target>\r
- </configuration>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-site-plugin</artifactId>\r
- <configuration>\r
- <unzipCommand>/usr/bin/unzip -o > err.txt</unzipCommand>\r
- </configuration>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-war-plugin</artifactId>\r
- <version>2.0.1</version>\r
- <configuration>\r
-\r
- <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>\r
- <archive>\r
- <manifest>\r
- <addClasspath>true</addClasspath>\r
-\r
- </manifest>\r
- </archive>\r
- </configuration>\r
- </plugin>\r
-\r
- </plugins>\r
- </pluginManagement>\r
- </build>\r
- <dependencyManagement>\r
- <dependencies>\r
- <dependency>\r
- <groupId>net.java.dev.jaxb2-commons</groupId>\r
- <artifactId>jaxb-fluent-api</artifactId>\r
- <version>2.0.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.testng</groupId>\r
- <artifactId>testng</artifactId>\r
- <version>5.6</version>\r
- <scope>test</scope>\r
- <classifier>jdk15</classifier>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>jaxrs-api</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>net.java.dev.jaxb2-commons</groupId>\r
- <artifactId>jaxb-fluent-api</artifactId>\r
- <version>2.0.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jvnet.jaxb2-commons</groupId>\r
- <artifactId>property-listener-injector</artifactId>\r
- <version>1.0</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jvnet.jaxb2_commons</groupId>\r
- <artifactId>runtime</artifactId>\r
- <version>0.4.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.resteasy</groupId>\r
- <artifactId>resteasy-jaxrs</artifactId>\r
- <version>1.0.2.GA</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>commons-httpclient</groupId>\r
- <artifactId>commons-httpclient</artifactId>\r
- <version>3.1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>com.sun.xml.bind</groupId>\r
- <artifactId>jaxb-impl</artifactId>\r
- <version>2.1.7</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.testng</groupId>\r
- <artifactId>testng</artifactId>\r
- <version>5.6</version>\r
- <scope>test</scope>\r
- <classifier>jdk15</classifier>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-api</artifactId>\r
- <version>1.5.2</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- <version>1.5.2</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>mysql</groupId>\r
- <artifactId>mysql-connector-java</artifactId>\r
- <version>5.1.5</version>\r
- <scope>test</scope>\r
- </dependency>\r
- <dependency>\r
- <groupId>com.jgoodies</groupId>\r
- <artifactId>binding</artifactId>\r
- <version>2.0.2</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>com.jgoodies</groupId>\r
- <artifactId>forms</artifactId>\r
- <version>1.2.0</version>\r
- </dependency>\r
- </dependencies>\r
- </dependencyManagement>\r
-</project>\r