]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
Integrating CollectionObject and Identifier services into Restful Nuxeo prototype.
authorRichard Millet <richard.millet@berkeley.edu>
Tue, 7 Apr 2009 00:09:04 +0000 (00:09 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Tue, 7 Apr 2009 00:09:04 +0000 (00:09 +0000)
21 files changed:
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.properties [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/pom.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/META-INF/MANIFEST.MF [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/core-types-contrib.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/deployment-fragment.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/ecm-types-contrib.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/layouts-contrib.xml [new file with mode: 0644]
sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/schemas/collectionobject.xsd [new file with mode: 0644]
sandbox/richard/HelloWorld/.classpath [new file with mode: 0644]
sandbox/richard/HelloWorld/.project [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd
sandbox/richard/HelloWorld/HelloWorldNuxeoService/.classpath [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldNuxeoService/.project [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java [new file with mode: 0644]
sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java
sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/IdentifierResource.java [new file with mode: 0644]

diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.properties b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.properties
new file mode 100644 (file)
index 0000000..c26799a
--- /dev/null
@@ -0,0 +1,15 @@
+# Example for Windows
+jboss.dir=c:/dev/jboss-4.2.3.GA
+# Example for Unix
+#jboss.dir=/opt/jboss
+
+# Which JBoss server config to use
+jboss.config=default
+
+# nuxeo deployment
+jboss.nuxeo.ear.dir=${jboss.dir}/server/${jboss.config}/deploy/nuxeo.ear
+
+
+# additional command line parameters for mvn commands
+# e.g. to work offline:
+#mvn.opts=-o
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/build.xml
new file mode 100644 (file)
index 0000000..d4e3b26
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<project name="nuxeo cs" default="all" basedir=".">
+
+  <property file="build.properties" />
+  <property name="cs.nuxeo.jar" value="nuxeo-platform-collectionspace-5.2-SNAPSHOT.jar"/>
+
+  <target name="all" description="all">
+    <delete file="${jboss.nuxeo.ear.dir}/system/${cs.nuxeo.jar}"/>
+    <copy todir="${jboss.nuxeo.ear.dir}/system">
+      <fileset file="${basedir}/target/${cs.nuxeo.jar}" />
+    </copy>
+  </target>
+
+</project>
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/pom.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/pom.xml
new file mode 100644 (file)
index 0000000..540859e
--- /dev/null
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.nuxeo.ecm.platform</groupId>
+    <artifactId>nuxeo-platform-parent</artifactId>
+    <version>5.2-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>nuxeo-platform-collectionspace</artifactId>
+  <packaging>jar</packaging>
+  <name>Nuxeo CS extensions</name>
+  <description>
+    Nuxeo Enterprise Platform: CS extensions
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.nuxeo.ecm.core</groupId>
+      <artifactId>nuxeo-core-schema</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.nuxeo.ecm.platform</groupId>
+      <artifactId>nuxeo-platform-types-core</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/META-INF/MANIFEST.MF b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..91c5341
--- /dev/null
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0 \r
+Bundle-ManifestVersion: 1 \r
+Bundle-Name: NuxeoCS\r
+Bundle-SymbolicName: org.collectionspace.collectionobject;singleton:=true \r
+Bundle-Version: 1.0.0\r
+Bundle-Localization: plugin\r
+Bundle-Vendor: Nuxeo \r
+Require-Bundle: org.nuxeo.runtime, \r
+ org.nuxeo.ecm.core.api, \r
+ org.nuxeo.ecm.core,\r
+ org.nuxeo.ecm.core.api,\r
+ org.nuxeo.ecm.platform.types.api,\r
+ org.nuxeo.ecm.platform.versioning.api,\r
+ org.nuxeo.ecm.platform.ui,\r
+ org.nuxeo.ecm.platform.forms.layout.client,\r
+ org.nuxeo.ecm.platform.publishing.api,\r
+ org.nuxeo.ecm.platform.ws \r
+Provide-Package: org.collectionspace.collectionobject\r
+Nuxeo-Component: OSGI-INF/core-types-contrib.xml,\r
+ OSGI-INF/ecm-types-contrib.xml,\r
+ OSGI-INF/layouts-contrib.xml\r
+\r
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/core-types-contrib.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/core-types-contrib.xml
new file mode 100644 (file)
index 0000000..72aa5ef
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.collectionobject.coreTypes">
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+    <schema name="collectionobject" prefix="collectionobject" src="schemas/collectionobject.xsd"/>
+  </extension>
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+    <doctype name="CollectionObject" extends="Document">
+      <schema name="common"/>
+      <schema name="dublincore"/>
+      <schema name="collectionobject"/>
+    </doctype>
+  </extension>
+</component>
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/deployment-fragment.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/deployment-fragment.xml
new file mode 100644 (file)
index 0000000..88b94ff
--- /dev/null
@@ -0,0 +1,408 @@
+<?xml version="1.0"?>
+<fragment>
+
+  <extension target="application#MODULE">
+    <module>
+      <ejb>${bundle.fileName}</ejb>
+    </module>
+
+    <module>
+      <web>
+        <web-uri>nuxeo.war</web-uri>
+        <context-root>/nuxeo</context-root>
+      </web>
+    </module>
+  </extension>
+
+  <!-- uncomment that to enable tomcat based auth
+    <extension target="web#LOGIN-CONFIG">
+    <login-config>
+    <auth-method>FORM</auth-method>
+    <realm-name>nuxeo.ecm</realm-name>
+    <form-login-config>
+    <form-login-page>/login.jsp</form-login-page>
+    <form-error-page>/login.jsp?loginFailed=true</form-error-page>
+    </form-login-config>
+    </login-config>
+    </extension>
+  -->
+
+  <extension target="web#FILTER-MAPPING">
+
+    <!-- Seam Context Filter is declared in org.nuxeo.ecm.platform.ui.web
+      deployment fragment -->
+
+    <filter-mapping>
+      <filter-name>Seam Context Filter</filter-name>
+      <url-pattern>/ws/FileManageWS</url-pattern>
+    </filter-mapping>
+
+    <filter-mapping>
+      <filter-name>Seam Context Filter</filter-name>
+      <url-pattern>/DocumentManagerWS</url-pattern>
+    </filter-mapping>
+  </extension>
+
+  <extension target="web#SERVLET">
+  </extension>
+
+  <extension target="web#SERVLET-MAPPING">
+  </extension>
+
+  <extension target="pages#PAGES">
+    <!-- This calls a method which load the Workspace logo -->
+    <page view-id="/showLogo.xhtml" action="#{logoHelper.getLogo}"/>
+
+    <!-- Bind URL to the Document URL resolver-->
+    <page view-id="/getDocument.xhtml"
+        action="#{navigationContext.navigateToURL}">
+    </page>
+
+    <page view-id="/nxliveedit.xhtml" action="#{liveEditHelper.getBootstrap()}"/>
+
+    <!-- Bind URL to the Parallele conversation Document URL resolver-->
+    <page view-id="/parallele.xhtml"
+        action="#{paralleleNavigationHelper.navigateToURL}">
+    </page>
+
+    <!-- Post login and 'home' view handler -->
+    <page view-id="/nxstartup.xhtml"
+        action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'view')}"/>
+
+    <!-- To redirect to the user dashboard instead, use instead:
+
+      <page view-id="/nxstartup.xhtml"
+      action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'user_dashboard')}" />
+    -->
+
+    <!--  config for workspace management
+      = give a description for each viewId
+    -->
+
+    <page view-id="/view_domains.xhtml">
+      #{currentServerLocation.name}/#{currentTabAction.label}
+    </page>
+
+    <page view-id="/select_document_type.faces.xhtml">
+      Create new document in #{currentDocument.name}
+    </page>
+
+    <page view-id="/create_document.faces.xhtml">
+      Create new document in #{currentDocument.name}
+    </page>
+
+    <page view-id="/user_dashboard.xhtml">
+      breadcrumb=command.user_dashboard
+    </page>
+
+    <page view-id="/view_users.xhtml">
+      breadcrumb=command.manageMembers
+    </page>
+
+    <page view-id="/view_many_users.xhtml">
+      breadcrumb=command.manageMembers
+    </page>
+
+    <page view-id="/view_vocabularies.xhtml">
+      breadcrumb=title.vocabularies
+    </page>
+
+    <page view-id="/search/search_form.xhtml">
+      breadcrumb=command.advancedSearch
+    </page>
+  </extension>
+
+  <extension target="faces-config#APPLICATION">
+    <locale-config>
+      <default-locale>en</default-locale>
+      <supported-locale>en_GB</supported-locale>
+      <supported-locale>en_US</supported-locale>
+      <supported-locale>fr</supported-locale>
+      <supported-locale>de</supported-locale>
+      <supported-locale>es</supported-locale>
+      <supported-locale>it</supported-locale>
+      <supported-locale>ar</supported-locale>
+      <supported-locale>ru</supported-locale>
+      <supported-locale>ja</supported-locale>
+      <supported-locale>vn</supported-locale>
+    </locale-config>
+
+    <message-bundle>messages</message-bundle>
+  </extension>
+
+  <extension target="components#PAGEFLOW">
+    <value>config/addWorkspace.jpdl.xml</value>
+  </extension>
+
+  <extension target="faces-config#NAVIGATION">
+    <!-- generic pages -->
+    <navigation-case>
+      <from-outcome>generic_error_page</from-outcome>
+      <to-view-id>/generic_error_page.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>generic_message_page</from-outcome>
+      <to-view-id>/generic_message_page.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>home</from-outcome>
+      <to-view-id>/nxstartup.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_login</from-outcome>
+      <to-view-id>/login.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_logout</from-outcome>
+      <to-view-id>/logout.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_servers</from-outcome>
+      <to-view-id>/view_servers.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- pages for document actions -->
+
+    <navigation-case>
+      <from-outcome>view_domains</from-outcome>
+      <to-view-id>/view_domains.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>select_document_type</from-outcome>
+      <to-view-id>/select_document_type.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_document</from-outcome>
+      <to-view-id>/create_document.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_document</from-outcome>
+      <to-view-id>/edit_document.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_documents</from-outcome>
+      <to-view-id>/view_documents.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_file</from-outcome>
+      <to-view-id>/create_file.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_workspace_wizard</from-outcome>
+      <to-view-id>/createWorkspaceWizard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>send_email</from-outcome>
+      <to-view-id>/document_email.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use view_documents instead -->
+    <navigation-case>
+      <from-outcome>view_workspaces</from-outcome>
+      <to-view-id>/view_workspaces.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use create_document instead -->
+    <navigation-case>
+      <from-outcome>create_domain</from-outcome>
+      <to-view-id>/create_domain.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use edit_document instead -->
+    <navigation-case>
+      <from-outcome>edit_domain</from-outcome>
+      <to-view-id>/edit_domain.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use create_document instead -->
+    <navigation-case>
+      <from-outcome>create_workspace</from-outcome>
+      <to-view-id>/create_workspace.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use edit_document instead -->
+    <navigation-case>
+      <from-outcome>edit_workspace</from-outcome>
+      <to-view-id>/edit_workspace.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- users ang groups -->
+
+    <navigation-case>
+      <from-outcome>members_management</from-outcome>
+      <to-view-id>/members_management.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_users</from-outcome>
+      <to-view-id>/view_users.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_many_users</from-outcome>
+      <to-view-id>/view_many_users.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_user</from-outcome>
+      <to-view-id>/edit_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_user_password</from-outcome>
+      <to-view-id>/edit_user_password.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_user</from-outcome>
+      <to-view-id>/view_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_user</from-outcome>
+      <to-view-id>/create_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_groups</from-outcome>
+      <to-view-id>/view_groups.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_group</from-outcome>
+      <to-view-id>/view_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_group</from-outcome>
+      <to-view-id>/edit_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_group</from-outcome>
+      <to-view-id>/create_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_vocabularies</from-outcome>
+      <to-view-id>/view_vocabularies.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_vocabulary</from-outcome>
+      <to-view-id>/view_vocabulary.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- search -->
+
+    <navigation-case>
+      <from-outcome>search_form</from-outcome>
+      <to-view-id>/search/search_form.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_nxql</from-outcome>
+      <to-view-id>/search/search_results_nxql.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_advanced</from-outcome>
+      <to-view-id>
+        /search/search_results_advanced.xhtml
+      </to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_simple</from-outcome>
+      <to-view-id>/search/search_results_simple.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- miscellaneaous -->
+
+    <navigation-case>
+      <from-outcome>clipboard</from-outcome>
+      <to-view-id>/incl/clipboard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_dashboard</from-outcome>
+      <to-view-id>/user_dashboard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>select_workspace_template</from-outcome>
+      <to-view-id>/select_workspace_template.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>pdf_generation_error</from-outcome>
+      <to-view-id>/pdf_generation_error.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>mass_edit</from-outcome>
+      <to-view-id>/massedit_documents.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>mass_edit_confirm</from-outcome>
+      <to-view-id>/massedit_documents_preview.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+  </extension>
+
+</fragment>
+
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/ecm-types-contrib.xml
new file mode 100644 (file)
index 0000000..541251f
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.collectionobject.ecm.types">
+  <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+    <type id="CollectionObject" coretype="CollectionObject">
+      <label>org.collectionspace.collectionobject</label>
+      <!--icon>/icons/file.gif</icon-->
+      <default-view>view_documents</default-view>
+
+      <layouts mode="any">
+        <layout>heading</layout>
+        <layout>collectionobject</layout>
+      </layouts>        
+    </type>
+
+    <type id="Folder" coretype="Folder">
+      <subtypes>
+        <type>CollectionObject</type>
+      </subtypes>
+    </type>
+    
+    <type id="Workspace" coretype="Workspace">
+      <subtypes>
+        <type>CollectionObject</type>
+      </subtypes>
+    </type>
+
+  </extension>
+</component>
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/layouts-contrib.xml b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/OSGI-INF/layouts-contrib.xml
new file mode 100644 (file)
index 0000000..f3db69e
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+
+<component name="org.collectionspace.collectionobject.layouts.webapp">
+
+  <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+    point="layouts">
+
+    <layout name="collectionobject">
+      <templates>
+        <template mode="any">/layouts/layout_default_template.xhtml</template>
+      </templates>
+      <rows>
+        <row><widget>csid</widget></row>
+        <row><widget>identifier</widget></row>
+        <row><widget>description</widget></row>
+      </rows>
+
+      <widget name="csid" type="text">
+        <labels>
+          <label mode="any">csid</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="collectionobject">csid</field>
+        </fields>
+        <widgetModes>
+          <!-- not shown in create mode -->
+          <mode value="create">hidden</mode>
+        </widgetModes>
+        <properties widgetMode="edit">
+          <!-- required in widget mode edit -->
+          <property name="required">true</property>
+        </properties>
+        <properties mode="view">
+          <!-- property applying in view mode -->
+          <property name="styleClass">cssClass</property>
+        </properties>
+      </widget>
+      
+      <widget name="identifier" type="text">
+        <labels>
+          <label mode="any">identifier</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="collectionobject">identifier</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+      <widget name="description" type="text">
+        <labels>
+          <label mode="any">description</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="collectionobject">description</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+    </layout>
+  </extension>
+</component>
diff --git a/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/schemas/collectionobject.xsd b/sandbox/richard/3rdparty/nuxeo/nuxeo-platform-cs/src/main/resources/schemas/collectionobject.xsd
new file mode 100644 (file)
index 0000000..0a126c9
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
+<xs:schema \r
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+    xmlns:ns="http://collectionspace.org/collectionobject/"\r
+    xmlns="http://collectionspace.org/collectionobject/"\r
+    targetNamespace="http://collectionspace.org/collectionobject/"\r
+    version="0.1">\r
+\r
+    <xs:element name="csid" type="xs:string"/>\r
+    <xs:element name="identifier" type="xs:string"/>\r
+    <xs:element name="description" type="xs:string"/>\r
+\r
+</xs:schema>\r
diff --git a/sandbox/richard/HelloWorld/.classpath b/sandbox/richard/HelloWorld/.classpath
new file mode 100644 (file)
index 0000000..cad20f7
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\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
diff --git a/sandbox/richard/HelloWorld/.project b/sandbox/richard/HelloWorld/.project
new file mode 100644 (file)
index 0000000..234cbef
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>helloworld</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.maven.ide.eclipse.maven2Builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java b/sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectClient.java
new file mode 100644 (file)
index 0000000..8e5a7cf
--- /dev/null
@@ -0,0 +1,96 @@
+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 {
+
+       private static final String HOST = "http://localhost:8080";
+       private static final String URI = "/helloworld/cspace-nuxeo";
+
+    /**
+     *
+     */
+    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, HOST + URI);
+    }
+
+    /**
+     * 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);
+    }
+}
diff --git a/sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java b/sandbox/richard/HelloWorld/HelloWorldClient/src/main/java/org/collectionspace/hello/client/CollectionObjectProxy.java
new file mode 100644 (file)
index 0000000..6097fed
--- /dev/null
@@ -0,0 +1,46 @@
+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
index 64a6b43b4c3a5740901fe4be8a85fd07bbaa710e..65d724a576acfd31daa42437cad63e238ab19342 100644 (file)
         </xs:complexType>
     </xs:element>
 
-<!-- person-nuxeo uses both id and version as string -->
+    <!-- collection-object  -->
+    <xs:element name="collection-object">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="csid" type="xs:string" minOccurs="1" />
+                <xs:element name="identifier" type="xs:string" minOccurs="1" />
+                <xs:element name="description" type="xs:string" minOccurs="1" />
+            </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="identifier" type="xs:string"
+                                minOccurs="1" />
+                            <!-- uri to retrive person 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>
+    
+    
+    <!-- person-nuxeo uses both id and version as string -->
     <xs:element name="person-nuxeo">
         <xs:complexType>
 
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.classpath b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.classpath
new file mode 100644 (file)
index 0000000..1d6493d
--- /dev/null
@@ -0,0 +1,10 @@
+<?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="lib" path="/helloworld-jaxb/target/helloworld-jaxb-0.1.jar" sourcepath="/helloworld-jaxb/target/generated-sources/xjc"/>\r
+       <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.project b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.project
new file mode 100644 (file)
index 0000000..dde7b1c
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>helloworld-nuxeo-service</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.maven.ide.eclipse.maven2Builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.eclipse.jdt.core.prefs b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..bf687d5
--- /dev/null
@@ -0,0 +1,5 @@
+#Wed Apr 01 10:19:44 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
+org.eclipse.jdt.core.compiler.compliance=1.5\r
+org.eclipse.jdt.core.compiler.source=1.5\r
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.maven.ide.eclipse.prefs b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..fe1aa95
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed Apr 01 10:19:28 PDT 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
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/CollectionObjectResource.java
new file mode 100644 (file)
index 0000000..d861fc8
--- /dev/null
@@ -0,0 +1,300 @@
+package org.collectionspace.hello.services;
+
+import java.io.ByteArrayInputStream;
+import org.collectionspace.hello.services.nuxeo.NuxeoRESTClient;
+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.CollectionObjectList.CollectionObjectListItem;
+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 {
+
+       final static String NUXEO_WORKSPACE_UID = "776a8787-9d81-41b0-a02c-1ba674638c0a";
+       final static String NUXEO_DOCTYPE = "CollectionObject";
+       
+    final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class);
+
+    public CollectionObjectResource() {
+       // do nothing
+    }
+
+    @GET
+    public CollectionObjectList getCollectionObjectList(@Context UriInfo ui) {
+       CollectionObjectList p = new CollectionObjectList();
+        try{
+            List<CollectionObjectList.CollectionObjectListItem> list = p.getCollectionObjectListItem();
+            NuxeoRESTClient nxClient = getClient();
+
+            List<String> pathParams = new ArrayList<String>();
+            Map<String, String> queryParams = new HashMap<String, String>();
+            pathParams = Arrays.asList("default", NUXEO_WORKSPACE_UID, "browse");
+            Representation res = nxClient.get(pathParams, queryParams);
+            SAXReader reader = new SAXReader();
+            Document document = reader.read(res.getStream());
+            Element root = document.getRootElement();
+            for(Iterator i = root.elementIterator(); i.hasNext();){
+                Element element = (Element) i.next();
+                CollectionObjectListItem pli = new CollectionObjectListItem();
+                //
+                pli.setCsid(element.attributeValue("csid"));
+                pli.setUri(element.attributeValue("url"));
+                pli.setIdentifier(element.attributeValue("identifier"));
+                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(NUXEO_WORKSPACE_UID);
+        pathParams.add("createDocument");
+        queryParams.put("docType", NUXEO_DOCTYPE);
+        
+        queryParams.put("dublincore:title", co.getIdentifier());
+        // CollectionObject core values
+        queryParams.put("collectionobject:csid", Integer.valueOf(1).toString());
+        queryParams.put("collectionobject:identifier", co.getIdentifier());
+        queryParams.put("collectionobject:description", co.getDescription());
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
+        Representation res = nxClient.post(pathParams, queryParams, bais);
+
+        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())){
+                    String id = (String) element.getData();
+                    co.setCsid(id);
+                }
+            }
+        } catch(Exception e){
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Create failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+
+        verbose("created collectionobject", co);
+        UriBuilder path = UriBuilder.fromResource(PersonNuxeoResource.class);
+        path.path("" + co.getCsid());
+        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 ("collectionobject".equals(schemaElement.attribute("name").getValue())){
+                    co.setCsid(csid);
+                    Element ele = schemaElement.element("identifier");
+                    if(ele != null){
+                        co.setIdentifier((String) ele.getData());
+                    }
+                    ele = schemaElement.element("description");
+                    if(ele != null){
+                        co.setDescription((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("get collectionobject", co);
+        
+        return co;
+    }
+
+    @PUT
+    @Path("{csid}")
+    public CollectionObject updateCollectionObject(
+            @PathParam("csid") String csid,
+            CollectionObject update) {
+
+        verbose("updating collectionobject input", update);
+
+        List<String> pathParams = new ArrayList<String>();
+        Map<String, String> queryParams = new HashMap<String, String>();
+        pathParams.add("default");
+        pathParams.add(update.getCsid());
+        pathParams.add("updateDocumentRestlet");
+        
+        //todo: intelligent merge needed
+        if(update.getIdentifier() != null){
+            queryParams.put("collectionobject:identifier", update.getIdentifier());
+        }
+
+        if(update.getDescription() != null){
+            queryParams.put("collectionobject:description", update.getDescription());
+        }
+
+        NuxeoRESTClient nxClient = getClient();
+        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("update collectionobject: 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 update;
+    }
+
+    @DELETE
+    @Path("{csid}")
+    public void deleteCollectionObject(@PathParam("csid") String csid) {
+
+       verbose("deleting collectionobject 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("delete collectionobject: 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 NuxeoRESTClient getClient() {
+        NuxeoRESTClient nxClient = new NuxeoRESTClient("http://127.0.0.1:8080/nuxeo");
+        nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC);
+        nxClient.setBasicAuthentication("Administrator", "Administrator");
+        return nxClient;
+    }
+
+    private void verbose(String msg) {
+        System.out.println("CollectionObjectResource: " + msg);
+    }
+}
index 9443764b960da467d732f99098bc8626cb2f4f69..d6b05c69194a3b5b5f7cad7535cbb565faea7284 100644 (file)
@@ -10,6 +10,7 @@ public class HelloworldNuxeoApplication extends Application {
     private Set<Class<?>> empty = new HashSet<Class<?>>();
 
     public HelloworldNuxeoApplication() {
+        singletons.add(new CollectionObjectResource());
         singletons.add(new PersonNuxeoResource());
     }
 
diff --git a/sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/IdentifierResource.java b/sandbox/richard/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/IdentifierResource.java
new file mode 100644 (file)
index 0000000..4c41048
--- /dev/null
@@ -0,0 +1,77 @@
+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.Identifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/identifiers")
+@Consumes("application/xml")
+@Produces("application/xml")
+public class IdentifierResource {
+
+    final Logger logger = LoggerFactory.getLogger(IdentifierResource.class);
+    private Map<Long, Identifier> idDB = new ConcurrentHashMap<Long, Identifier>();
+    private AtomicLong idCounter = new AtomicLong();
+
+    public IdentifierResource() {
+    }
+
+    @POST
+    public Response createIdentifier(Identifier id) {
+        if (id.getNamespace() == null) {
+            id.setNamespace("edu.berkeley");
+        }
+        id.setId(idCounter.incrementAndGet());
+        id.setVersion(1);
+        UUID uuid = UUID.nameUUIDFromBytes(id.getNamespace().getBytes());
+        id.setValue(uuid.toString());
+        idDB.put(id.getId(), id);
+        verbose("created Id", id);
+        UriBuilder path = UriBuilder.fromResource(IdentifierResource.class);
+        path.path("" + id.getId());
+        Response response = Response.created(path.build()).build();
+        return response;
+    }
+
+    @GET
+    @Path("{id}")
+    public Identifier getIdentifier(@PathParam("id") Long id) {
+        Identifier i = idDB.get(id);
+        if (i == null) {
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "The requested ID was not found.").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        verbose("get Id", i);
+        return i;
+    }
+
+    private void verbose(String msg, Identifier id) {
+        try {
+            System.out.println("IdentifierResource : " + msg);
+            JAXBContext jc = JAXBContext.newInstance(Identifier.class);
+            Marshaller m = jc.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
+                    Boolean.TRUE);
+            m.marshal(id, System.out);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}