]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-149. Adding basic code for Organization service. Compiles, but testing remains...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 4 Jan 2010 20:12:59 +0000 (20:12 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Mon, 4 Jan 2010 20:12:59 +0000 (20:12 +0000)
76 files changed:
services/organization/.classpath [new file with mode: 0644]
services/organization/.project [new file with mode: 0644]
services/organization/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/3rdparty/.classpath [new file with mode: 0644]
services/organization/3rdparty/.project [new file with mode: 0644]
services/organization/3rdparty/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/3rdparty/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/3rdparty/build.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/.project [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/build.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/pom.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/META-INF/MANIFEST.MF [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/core-types-contrib.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/deployment-fragment.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/ecm-types-contrib.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd [new file with mode: 0644]
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/orgauthorities_common.xsd [new file with mode: 0644]
services/organization/3rdparty/pom.xml [new file with mode: 0644]
services/organization/build.xml [new file with mode: 0644]
services/organization/client/.classpath [new file with mode: 0644]
services/organization/client/.project [new file with mode: 0644]
services/organization/client/pom.xml [new file with mode: 0644]
services/organization/client/settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/client/settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java [new file with mode: 0644]
services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java [new file with mode: 0644]
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java [new file with mode: 0644]
services/organization/client/src/test/resources/log4j.properties [new file with mode: 0644]
services/organization/import/.classpath [new file with mode: 0644]
services/organization/import/.project [new file with mode: 0644]
services/organization/import/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/import/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/import/build.xml [new file with mode: 0644]
services/organization/import/pom.xml [new file with mode: 0644]
services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java [new file with mode: 0644]
services/organization/installer/build.xml [new file with mode: 0644]
services/organization/jaxb/.classpath [new file with mode: 0644]
services/organization/jaxb/.project [new file with mode: 0644]
services/organization/jaxb/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/jaxb/pom.xml [new file with mode: 0644]
services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityJAXBSchema.java [new file with mode: 0644]
services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityListItemJAXBSchema.java [new file with mode: 0644]
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java [new file with mode: 0644]
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationListItemJAXBSchema.java [new file with mode: 0644]
services/organization/jaxb/src/main/resources/organization_common.xsd [new file with mode: 0644]
services/organization/jaxb/src/main/resources/orgauthority_common.xsd [new file with mode: 0644]
services/organization/pom.xml [new file with mode: 0644]
services/organization/sample/.classpath [new file with mode: 0644]
services/organization/sample/.project [new file with mode: 0644]
services/organization/sample/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/sample/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/sample/pom.xml [new file with mode: 0644]
services/organization/sample/sample/.classpath [new file with mode: 0644]
services/organization/sample/sample/.project [new file with mode: 0644]
services/organization/sample/sample/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/organization/sample/sample/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/organization/sample/sample/pom.xml [new file with mode: 0644]
services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java [new file with mode: 0644]
services/organization/sample/sample/src/main/resources/collectionspace-client.properties [new file with mode: 0644]
services/organization/sample/sample/src/main/resources/log4j.xml [new file with mode: 0644]
services/organization/service/.classpath [new file with mode: 0644]
services/organization/service/.project [new file with mode: 0644]
services/organization/service/pom.xml [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityConstants.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityHandlerFactory.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationConstants.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java [new file with mode: 0644]
services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationHandlerFactory.java [new file with mode: 0644]

diff --git a/services/organization/.classpath b/services/organization/.classpath
new file mode 100644 (file)
index 0000000..0469885
--- /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/JavaSE-1.6"/>\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/services/organization/.project b/services/organization/.project
new file mode 100644 (file)
index 0000000..a1651b4
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization</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/services/organization/.settings/org.eclipse.jdt.core.prefs b/services/organization/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..2341888
--- /dev/null
@@ -0,0 +1,5 @@
+#Tue Oct 06 13:26:43 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/.settings/org.maven.ide.eclipse.prefs b/services/organization/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..95a5ba0
--- /dev/null
@@ -0,0 +1,9 @@
+#Fri Sep 11 17:00:29 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/3rdparty/.classpath b/services/organization/3rdparty/.classpath
new file mode 100644 (file)
index 0000000..0469885
--- /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/JavaSE-1.6"/>\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/services/organization/3rdparty/.project b/services/organization/3rdparty/.project
new file mode 100644 (file)
index 0000000..6e3baca
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.3rdparty</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/services/organization/3rdparty/.settings/org.eclipse.jdt.core.prefs b/services/organization/3rdparty/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..4956ebc
--- /dev/null
@@ -0,0 +1,5 @@
+#Mon Oct 05 17:07:08 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/3rdparty/.settings/org.maven.ide.eclipse.prefs b/services/organization/3rdparty/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..93b6f8a
--- /dev/null
@@ -0,0 +1,9 @@
+#Fri Sep 11 17:00:30 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/3rdparty/build.xml b/services/organization/3rdparty/build.xml
new file mode 100644 (file)
index 0000000..2b77792
--- /dev/null
@@ -0,0 +1,131 @@
+\r
+<project name="organization.3rdparty" default="package" basedir=".">\r
+    <description>\r
+        organization service 3rdparty\r
+    </description>\r
+  <!-- set global properties for this build -->\r
+    <property name="services.trunk" value="../../.."/>\r
+    <!-- enviornment should be declared before reading build.properties -->\r
+    <property environment="env" />\r
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+\r
+    <target name="init" >\r
+    <!-- Create the time stamp -->\r
+        <tstamp/>\r
+    </target>\r
+\r
+    <target name="package" depends="package-unix,package-windows"\r
+  description="Package CollectionSpace Services" />\r
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="install" depends="package,install-unix,install-windows"\r
+  description="Install" />\r
+    <target name="install-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="install-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    \r
+    <target name="clean" depends="clean-unix,clean-windows"\r
+  description="Delete target directories" >\r
+        <delete dir="${build}"/>\r
+    </target>\r
+    <target name="clean-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="clean-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+    <target name="test-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="test-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="deploy" depends="install"\r
+    description="deploy organization in ${jboss.server.nuxeo}">\r
+        <ant antfile="nuxeo-platform-cs-organization/build.xml" target="deploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="undeploy"\r
+    description="undeploy organization from ${jboss.server.nuxeo}">\r
+        <ant antfile="nuxeo-platform-cs-organization/build.xml" target="undeploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="dist"\r
+    description="generate distribution for organization" depends="package">\r
+        <ant antfile="nuxeo-platform-cs-organization/build.xml" target="dist" inheritall="false"/>\r
+    </target>\r
+    \r
+    <target name="dist_installer"\r
+    description="generate distribution for collectionobject" depends="package">\r
+        <ant antfile="nuxeo-platform-cs-organization/build.xml" target="dist_installer" inheritall="false"/>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath b/services/organization/3rdparty/nuxeo-platform-cs-organization/.classpath
new file mode 100644 (file)
index 0000000..9757920
--- /dev/null
@@ -0,0 +1,9 @@
+<?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.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+       <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.project b/services/organization/3rdparty/nuxeo-platform-cs-organization/.project
new file mode 100644 (file)
index 0000000..48d5893
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.3rdparty.nuxeo</name>\r
+       <comment>Organization Nuxeo Document Type</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.maven.ide.eclipse.maven2Nature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.eclipse.jdt.core.prefs b/services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..82d33d3
--- /dev/null
@@ -0,0 +1,5 @@
+#Tue Oct 06 13:26:44 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.maven.ide.eclipse.prefs b/services/organization/3rdparty/nuxeo-platform-cs-organization/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..552ddbf
--- /dev/null
@@ -0,0 +1,9 @@
+#Tue Oct 06 13:25:17 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/build.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/build.xml
new file mode 100644 (file)
index 0000000..f3161e1
--- /dev/null
@@ -0,0 +1,138 @@
+
+<project name="nuxeo-platform-cs-organization" default="package" basedir=".">
+    <description>
+        organization nuxeo document type
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../../../.."/>
+    <!-- enviornment should be declared before reading build.properties -->
+    <property environment="env" />
+    <property file="${services.trunk}/build.properties" />
+    <property name="mvn.opts" value="" />
+    <property name="src" location="src"/>
+    <property name="nuxeo.organization.jar" value="org.collectionspace.services.organization.3rdparty.nuxeo-1.0.jar"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <target name="init" >
+    <!-- Create the time stamp -->
+        <tstamp/>
+    </target>
+
+    <target name="package" depends="package-unix,package-windows"
+  description="Package CollectionSpace Services" />
+    <target name="package-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="package-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="package" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="install" depends="package,install-unix,install-windows"
+  description="Install" />
+    <target name="install-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="install-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="install" />
+            <arg value="-Dmaven.test.skip=true" />
+            <arg value="-f" />
+            <arg value="${basedir}/pom.xml" />
+            <arg value="-N" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="clean" depends="clean-unix,clean-windows"
+  description="Delete target directories" >
+        <delete dir="${build}"/>
+    </target>
+    <target name="clean-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="clean-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="clean" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />
+    <target name="test-unix" if="osfamily-unix">
+        <exec executable="mvn" failonerror="true">
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+    <target name="test-windows" if="osfamily-windows">
+        <exec executable="cmd" failonerror="true">
+            <arg value="/c" />
+            <arg value="mvn.bat" />
+            <arg value="test" />
+            <arg value="${mvn.opts}" />
+        </exec>
+    </target>
+
+    <target name="deploy" depends="install"
+    description="deploy organization doctype in ${jboss.server.nuxeo}">
+        <copy file="${basedir}/target/${nuxeo.organization.jar}"
+        todir="${jboss.deploy.nuxeo.system}"/>
+    </target>
+
+    <target name="undeploy"
+    description="undeploy organization doctype from ${jboss.server.nuxeo}">
+        <delete file="${jboss.deploy.nuxeo.system}/${nuxeo.organization.jar}"/>
+    </target>
+
+    <target name="dist"
+    description="generate distribution for organization doctype" depends="package">
+        <copy todir="${services.trunk}/${dist.deploy.nuxeo.system}">
+            <fileset file="${basedir}/target/${nuxeo.organization.jar}"/>
+        </copy>
+    </target>
+
+    <target name="dist_installer"
+       description="Creates an installer distribution for organization doctype" depends="package">
+        <copy todir="${services.trunk}/${dist.installer.services}/organization/nuxeo">
+            <fileset file="${basedir}/target/${nuxeo.organization.jar}"/>
+        </copy>
+    </target>
+
+</project>
+
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/pom.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/pom.xml
new file mode 100644 (file)
index 0000000..20f4a3b
--- /dev/null
@@ -0,0 +1,19 @@
+<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>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>nuxeo-platform-collectionspace</artifactId>
+        <version>1.0</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <version>1.0</version>
+    <artifactId>org.collectionspace.services.organization.3rdparty.nuxeo</artifactId>
+    <packaging>jar</packaging>
+    <name>services.organization.3rdparty.nuxeo</name>
+    <description>
+    Organization Nuxeo Document Type
+    </description>
+</project>
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/META-INF/MANIFEST.MF b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..8113da6
--- /dev/null
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0 \r
+Bundle-ManifestVersion: 1 \r
+Bundle-Name: NuxeoCS\r
+Bundle-SymbolicName: org.collectionspace.organization;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.organization\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/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/core-types-contrib.xml
new file mode 100644 (file)
index 0000000..7e1f0fe
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.organization.coreTypes">
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+    <schema name="orgauthorities_common" prefix="orgauthorities_common" src="schemas/orgauthorities_common.xsd"/>
+  </extension>
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+    <schema name="organizations_common" prefix="organizations_common" src="schemas/organizations_common.xsd"/>
+  </extension>
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+    <doctype name="OrgAuthority" extends="Document">
+      <schema name="common"/>
+      <schema name="dublincore"/>
+      <schema name="orgauthorities_common"/>
+    </doctype>
+  </extension>
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+    <doctype name="Organization" extends="Document">
+      <schema name="common"/>
+      <schema name="dublincore"/>
+      <schema name="organizations_common"/>
+    </doctype>
+  </extension>
+</component>
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/deployment-fragment.xml
new file mode 100644 (file)
index 0000000..8bbdd72
--- /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_orgauthorities.xhtml">
+      breadcrumb=title.orgauthorities
+    </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_orgauthorities</from-outcome>
+      <to-view-id>/view_orgauthorities.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_orgauthority</from-outcome>
+      <to-view-id>/view_orgauthority.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/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/ecm-types-contrib.xml
new file mode 100644 (file)
index 0000000..c29c8f8
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.organization.ecm.types">
+  <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+    <type id="OrgAuthority" coretype="OrgAuthority">
+      <label>org.collectionspace.orgauthority</label>
+      <!--icon>/icons/file.gif</icon-->
+      <default-view>view_documents</default-view>
+
+      <layouts mode="any">
+        <layout>heading</layout>
+        <layout>csorgauthority</layout>
+      </layouts>        
+    </type>
+
+    <type id="Folder" coretype="Folder">
+      <subtypes>
+        <type>OrgAuthority</type>
+      </subtypes>
+    </type>
+    
+    <type id="Workspace" coretype="Workspace">
+      <subtypes>
+        <type>OrgAuthority</type>
+      </subtypes>
+    </type>
+
+  </extension>
+  <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+    <type id="Organization" coretype="Organization">
+      <label>org.collectionspace.organization</label>
+      <!--icon>/icons/file.gif</icon-->
+      <default-view>view_documents</default-view>
+
+      <layouts mode="any">
+        <layout>heading</layout>
+        <layout>organization</layout>
+      </layouts>        
+    </type>
+
+    <type id="Folder" coretype="Folder">
+      <subtypes>
+        <type>Organization</type>
+      </subtypes>
+    </type>
+    
+    <type id="Workspace" coretype="Workspace">
+      <subtypes>
+        <type>Organization</type>
+      </subtypes>
+    </type>
+
+  </extension>
+</component>
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/OSGI-INF/layouts-contrib.xml
new file mode 100644 (file)
index 0000000..daacbfd
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+
+<component name="org.collectionspace.organization.layouts.webapp">
+
+       <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+    point="layouts">
+
+    <layout name="csorgauthority">
+      <templates>
+        <template mode="any">/layouts/layout_default_template.xhtml</template>
+      </templates>
+      <rows>
+        <row><widget>displayName</widget></row>
+        <row><widget>refName</widget></row>
+        <row><widget>vocabType</widget></row>
+      </rows>
+
+      <widget name="displayName" type="text">
+        <labels>
+          <label mode="any">Name</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="orgauthorities_common">displayName</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+      <widget name="refName" type="text">
+        <labels>
+          <label mode="any">RefName</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="orgauthorities_common">refName</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+      <widget name="vocabType" type="text">
+        <labels>
+          <label mode="any">Type</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="orgauthorities_common">vocabType</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+    </layout>
+  </extension>
+
+  <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+    point="layouts">
+
+               <layout name="organization">
+      <templates>
+        <template mode="any">/layouts/layout_default_template.xhtml</template>
+      </templates>
+      <rows>
+        <row><widget>displayName</widget></row>
+        <row><widget>refName</widget></row>
+        <row><widget>inAuthority</widget></row>
+      </rows>
+
+      <widget name="displayName" type="text">
+        <labels>
+          <label mode="any">Name</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="organizations_common">displayName</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+      <widget name="refName" type="text">
+        <labels>
+          <label mode="any">RefName</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="organizations_common">refName</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+      
+      <widget name="inAuthority" type="text">
+        <labels>
+          <label mode="any">OrgAuthority</label>
+        </labels>
+        <translated>true</translated>
+        <fields>
+          <field schema="organizations_common">inAuthority</field>
+        </fields>
+        <properties widgetMode="edit">
+          <property name="styleClass">dataInputText</property>
+        </properties>
+      </widget>
+    </layout>
+  </extension>
+</component>
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd
new file mode 100644 (file)
index 0000000..a150577
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    Organization schema (XSD)
+    
+    Entity  : Organization
+    Part    : Common
+    Used for: Nuxeo EP core document type
+    
+    $LastChangedRevision: 860 $
+    $LastChangedDate: 2009-10-14 14:48:05 -0700 (Wed, 14 Oct 2009) $
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/services/organization"
+  xmlns="http://collectionspace.org/services/organization"
+  targetNamespace="http://collectionspace.org/services/organization"
+  version="0.1"
+>
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
+
+               <!--  Organization Information Group -->
+               <!--  inAuthority is the csid of the owning OrgAuthority -->
+               <xs:element name="inAuthority" type="xs:string" />
+               <xs:element name="refName" type="xs:string"/>
+               <xs:element name="displayName" type="xs:string"/>
+               <xs:element name="longName" type="xs:string"/>
+               <xs:element name="description" type="xs:string"/>
+
+</xs:schema>
+
diff --git a/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/orgauthorities_common.xsd b/services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/orgauthorities_common.xsd
new file mode 100644 (file)
index 0000000..a1238c7
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    OrgAuthority schema (XSD)
+    
+    Entity  : OrgAuthority
+    Part    : Common
+    Used for: Nuxeo EP core document type
+    
+    $LastChangedRevision: 928 $
+    $LastChangedDate: 2009-11-10 12:25:58 -0800 (Tue, 10 Nov 2009) $
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/services/organization"
+  xmlns="http://collectionspace.org/services/organization"
+  targetNamespace="http://collectionspace.org/services/organization"
+  version="0.1"
+>
+
+<!-- Flattened version of jaxb schema for nuxeo -->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
+
+               <!--  OrgAuthority Information Group -->
+               <xs:element name="displayName" type="xs:string"/>
+               <xs:element name="refName" type="xs:string"/>
+               <xs:element name="vocabType" type="xs:string"/>
+
+</xs:schema>
+
diff --git a/services/organization/3rdparty/pom.xml b/services/organization/3rdparty/pom.xml
new file mode 100644 (file)
index 0000000..d790b56
--- /dev/null
@@ -0,0 +1,23 @@
+\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>org.collectionspace.services.organization</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>1.0</version>\r
+    </parent>\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <version>1.0</version>\r
+    <artifactId>org.collectionspace.services.organization.3rdparty</artifactId>\r
+    <packaging>pom</packaging>\r
+    <name>services.organization.3rdparty</name>\r
+    <description>\r
+    3rd party build for organization service\r
+    </description>\r
+\r
+    <modules>\r
+        <module>nuxeo-platform-cs-organization</module>\r
+    </modules>\r
+</project>\r
diff --git a/services/organization/build.xml b/services/organization/build.xml
new file mode 100644 (file)
index 0000000..1b8d8fc
--- /dev/null
@@ -0,0 +1,134 @@
+\r
+<project name="organization" default="package" basedir=".">\r
+    <description>\r
+        organization service\r
+    </description>\r
+  <!-- set global properties for this build -->\r
+    <property name="services.trunk" value="../.."/>\r
+        <!-- enviornment should be declared before reading build.properties -->\r
+    <property environment="env" />\r
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+\r
+    <target name="package" depends="package-unix,package-windows"\r
+  description="Package CollectionSpace Services" />\r
+  \r
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    \r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="install" depends="package,install-unix,install-windows"\r
+  description="Install" />\r
+    <target name="install-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="install-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="clean" depends="clean-unix,clean-windows"\r
+  description="Delete target directories" >\r
+        <delete dir="${build}"/>\r
+    </target>\r
+    <target name="clean-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="clean-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+    <target name="test-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="test-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="deploy" depends="install"\r
+        description="deploy organization service">\r
+        <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="undeploy"\r
+        description="undeploy organization service">\r
+        <ant antfile="3rdparty/build.xml" target="undeploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="dist" depends="package"\r
+        description="distribute organization service">\r
+        <ant antfile="3rdparty/build.xml" target="dist" inheritall="false"/>\r
+        <ant antfile="import/build.xml" target="dist" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="dist_installer" depends="package"\r
+        description="distribute organization service">        \r
+        <!-- copy install scripts, etc. -->\r
+        <copy todir="${services.trunk}/${dist.installer.services}/organization">\r
+            <fileset dir="${basedir}/installer/"/>\r
+        </copy>\r
+        <ant antfile="3rdparty/build.xml" target="dist_installer" inheritall="false"/>\r
+        <ant antfile="import/build.xml" target="dist_installer" inheritall="false"/>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/organization/client/.classpath b/services/organization/client/.classpath
new file mode 100644 (file)
index 0000000..425cd16
--- /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 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/JavaSE-1.6"/>\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/services/organization/client/.project b/services/organization/client/.project
new file mode 100644 (file)
index 0000000..3b636e0
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.client</name>\r
+       <comment></comment>\r
+       <projects>\r
+               <project>org.collectionspace.services.client</project>\r
+               <project>org.collectionspace.services.common</project>\r
+               <project>org.collectionspace.services.organization.jaxb</project>\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.maven.ide.eclipse.maven2Nature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/organization/client/pom.xml b/services/organization/client/pom.xml
new file mode 100644 (file)
index 0000000..f375194
--- /dev/null
@@ -0,0 +1,111 @@
+<?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
+\r
+    <parent>\r
+        <artifactId>org.collectionspace.services.organization</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>1.0</version>\r
+    </parent>\r
+\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.organization.client</artifactId>\r
+    <version>1.0</version>\r
+    <name>services.organization.client</name>\r
+    \r
+    <dependencies>\r
+        <!-- keep slf4j dependencies on the top -->\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-api</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-log4j12</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.jaxb</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.client</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        \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
+            <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>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
+            <version>3.1</version>\r
+        </dependency>\r
+    </dependencies>\r
+    \r
+    <build>\r
+        <finalName>collectionspace-services-organization-client</finalName>\r
+        <plugins>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-surefire-plugin</artifactId>\r
+                <configuration>\r
+                    <systemProperties>\r
+                        <property>\r
+                            <name>log4j.configuration</name>\r
+                            <value>file:target/test-classes/log4j.properties</value>\r
+                        </property>\r
+                    </systemProperties>\r
+                </configuration>\r
+            </plugin>\r
+            <plugin>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <version>2.0.2</version>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+</project>\r
+\r
diff --git a/services/organization/client/settings/org.eclipse.jdt.core.prefs b/services/organization/client/settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..0b4dbbe
--- /dev/null
@@ -0,0 +1,5 @@
+#Mon Oct 05 17:07:09 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/client/settings/org.maven.ide.eclipse.prefs b/services/organization/client/settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..93b6f8a
--- /dev/null
@@ -0,0 +1,9 @@
+#Fri Sep 11 17:00:30 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java
new file mode 100644 (file)
index 0000000..669fd16
--- /dev/null
@@ -0,0 +1,157 @@
+package org.collectionspace.services.client;
+
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.organization.OrgauthoritiesCommonList;
+import org.collectionspace.services.organization.OrganizationsCommonList;
+import org.collectionspace.services.client.OrgAuthorityProxy;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+
+/**
+ * A OrgAuthorityClient.
+
+ * @version $Revision:$
+ */
+public class OrgAuthorityClient extends BaseServiceClient {
+
+       /* (non-Javadoc)
+        * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent()
+        */
+    @Override
+       public String getServicePathComponent() {
+               return "orgauthorities";
+       }
+       
+       public String getItemCommonPartName() {
+               return getCommonPartName("organizations");
+       }
+
+    /**
+     *
+     */
+    private static final OrgAuthorityClient instance = new OrgAuthorityClient();
+    /**
+     *
+     */
+    private OrgAuthorityProxy orgAuthorityProxy;
+
+    /**
+     *
+     * Default constructor for OrgAuthorityClient class.
+     *
+     */
+    public OrgAuthorityClient() {
+        ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
+        RegisterBuiltin.register(factory);
+        orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class, getBaseURL());
+    }
+
+    /**
+     * FIXME Comment this
+     *
+     * @return
+     */
+    public static OrgAuthorityClient getInstance() {
+        return instance;
+    }
+
+    /**
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#readList()
+     */
+    public ClientResponse<OrgauthoritiesCommonList> readList() {
+        return orgAuthorityProxy.readList();
+    }
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#read(java.lang.String)
+     */
+
+    public ClientResponse<MultipartInput> read(String csid) {
+        return orgAuthorityProxy.read(csid);
+    }
+
+    /**
+     * @param orgAuthority
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#createOrgAuthority(org.collectionspace.hello.OrgAuthority)
+     */
+    public ClientResponse<Response> create(MultipartOutput multipart) {
+        return orgAuthorityProxy.create(multipart);
+    }
+
+    /**
+     * @param csid
+     * @param orgAuthority
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#updateOrgAuthority(java.lang.Long, org.collectionspace.hello.OrgAuthority)
+     */
+    public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
+        return orgAuthorityProxy.update(csid, multipart);
+
+    }
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#deleteOrgAuthority(java.lang.Long)
+     */
+    public ClientResponse<Response> delete(String csid) {
+        return orgAuthorityProxy.delete(csid);
+    }
+
+    /**
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#readItemList()
+     */
+    public ClientResponse<OrganizationsCommonList> readItemList(String vcsid) {
+        return orgAuthorityProxy.readItemList(vcsid);
+    }
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#read(java.lang.String)
+     */
+
+    public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
+        return orgAuthorityProxy.readItem(vcsid, csid);
+    }
+
+    /**
+     * @param orgAuthority
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#createOrgAuthority(org.collectionspace.hello.OrgAuthority)
+     */
+    public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
+        return orgAuthorityProxy.createItem(vcsid, multipart);
+    }
+
+    /**
+     * @param csid
+     * @param orgAuthority
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#updateOrgAuthority(java.lang.Long, org.collectionspace.hello.OrgAuthority)
+     */
+    public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
+        return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
+
+    }
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.OrgAuthorityProxy#deleteOrgAuthority(java.lang.Long)
+     */
+    public ClientResponse<Response> deleteItem(String vcsid, String csid) {
+        return orgAuthorityProxy.deleteItem(vcsid, csid);
+    }
+}
diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityProxy.java
new file mode 100644 (file)
index 0000000..269836d
--- /dev/null
@@ -0,0 +1,76 @@
+package org.collectionspace.services.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.services.organization.OrgauthoritiesCommonList;
+import org.collectionspace.services.organization.OrganizationsCommonList;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+
+/**
+ * @version $Revision:$
+ */
+@Path("/orgauthorities/")
+@Produces({"multipart/mixed"})
+@Consumes({"multipart/mixed"})
+public interface OrgAuthorityProxy {
+
+    // List Orgauthorities
+    @GET
+    @Produces({"application/xml"})
+    ClientResponse<OrgauthoritiesCommonList> readList();
+
+    //(C)reate
+    @POST
+    ClientResponse<Response> create(MultipartOutput multipart);
+
+    //(R)ead
+    @GET
+    @Path("/{csid}")
+    ClientResponse<MultipartInput> read(@PathParam("csid") String csid);
+
+    //(U)pdate
+    @PUT
+    @Path("/{csid}")
+    ClientResponse<MultipartInput> update(@PathParam("csid") String csid, MultipartOutput multipart);
+
+    //(D)elete
+    @DELETE
+    @Path("/{csid}")
+    ClientResponse<Response> delete(@PathParam("csid") String csid);
+
+    // List Items
+    @GET
+    @Produces({"application/xml"})
+    @Path("/{vcsid}/items/")
+    ClientResponse<OrganizationsCommonList> readItemList(@PathParam("vcsid") String vcsid);
+
+    //(C)reate Item
+    @POST
+    @Path("/{vcsid}/items/")
+    ClientResponse<Response> createItem(@PathParam("vcsid") String vcsid, MultipartOutput multipart);
+
+    //(R)ead
+    @GET
+    @Path("/{vcsid}/items/{csid}")
+    ClientResponse<MultipartInput> readItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
+
+    //(U)pdate
+    @PUT
+    @Path("/{vcsid}/items/{csid}")
+    ClientResponse<MultipartInput> updateItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid, MultipartOutput multipart);
+
+    //(D)elete
+    @DELETE
+    @Path("/{vcsid}/items/{csid}")
+    ClientResponse<Response> deleteItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
+}
diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
new file mode 100644 (file)
index 0000000..d5f8dad
--- /dev/null
@@ -0,0 +1,1058 @@
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c)) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.client.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.OrgAuthorityClient;
+import org.collectionspace.services.organization.OrgauthoritiesCommon;
+import org.collectionspace.services.organization.OrgauthoritiesCommonList;
+import org.collectionspace.services.organization.OrganizationsCommon;
+import org.collectionspace.services.organization.OrganizationsCommonList;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * OrgAuthorityServiceTest, carries out tests against a
+ * deployed and running OrgAuthority Service.
+ *
+ * $LastChangedRevision: 753 $
+ * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
+ */
+public class OrgAuthorityServiceTest extends AbstractServiceTest {
+
+    private final Logger logger =
+        LoggerFactory.getLogger(OrgAuthorityServiceTest.class);
+
+    // Instance variables specific to this test.
+    private OrgAuthorityClient client = new OrgAuthorityClient();
+    final String SERVICE_PATH_COMPONENT = "orgauthorities";
+    final String ITEM_SERVICE_PATH_COMPONENT = "items";
+    private String knownResourceId = null;
+    private String knownResourceRefName = null;
+    private String knownItemResourceId = null;
+    private List<String> allResourceIdsCreated = new ArrayList<String>();
+    private Map<String, String> allResourceItemIdsCreated =
+        new HashMap<String, String>();
+    
+    protected String createRefName(String displayName) {
+       return displayName.replaceAll("\\W", "");
+    }    
+
+    // ---------------------------------------------------------------
+    // CRUD tests : CREATE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class)
+    public void create(String testName) throws Exception {
+
+        // Perform setup, such as initializing the type of service request
+        // (e.g. CREATE, DELETE), its valid and expected status codes, and
+        // its associated HTTP method name (e.g. POST, DELETE).
+        setupCreate(testName);
+
+        // Submit the request to the service and store the response.
+        String identifier = createIdentifier();
+        String displayName = "displayName-" + identifier;
+       String refName = createRefName(displayName);
+       String typeName = "vocabType-" + identifier;
+       MultipartOutput multipart = 
+               createOrgAuthorityInstance(displayName, refName, typeName);
+        ClientResponse<Response> res = client.create(multipart);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        //
+        // Specifically:
+        // Does it fall within the set of valid status codes?
+        // Does it exactly match the expected status code?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Store the refname from the first resource created
+        // for additional tests below.
+        knownResourceRefName = refName;
+
+        // Store the ID returned from the first resource created
+        // for additional tests below.
+        if (knownResourceId == null){
+            knownResourceId = extractId(res);
+            if (logger.isDebugEnabled()) {
+                logger.debug(testName + ": knownResourceId=" + knownResourceId);
+            }
+        }
+        // Store the IDs from every resource created by tests,
+        // so they can be deleted after tests have been run.
+        allResourceIdsCreated.add(extractId(res));
+
+    }
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create"})
+    public void createItem(String testName) {
+        setupCreate(testName);
+
+        knownItemResourceId = createItemInOrgAuthority(knownResourceId);
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
+        }
+    }
+
+    private String createItemInOrgAuthority(String vcsid) {
+
+        final String testName = "createItemInOrgAuthority";
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ":...");
+        }
+
+        // Submit the request to the service and store the response.
+        String identifier = createIdentifier();
+        String refName = createRefName(identifier);
+        MultipartOutput multipart = createOrganizationInstance(vcsid, identifier, refName);
+        ClientResponse<Response> res = client.createItem(vcsid, multipart);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Store the ID returned from the first item resource created
+        // for additional tests below.
+        if (knownItemResourceId == null){
+            knownItemResourceId = extractId(res);
+            if (logger.isDebugEnabled()) {
+                logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
+            }
+        }
+
+        // Store the IDs from any item resources created
+        // by tests, along with the IDs of their parents, so these items
+        // can be deleted after all tests have been run.
+        //
+        // Item resource IDs are unique, so these are used as keys;
+        // the non-unique IDs of their parents are stored as associated values.
+        allResourceItemIdsCreated.put(extractId(res), vcsid);
+
+        return extractId(res);
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+            dependsOnMethods = {"create", "createItem"})
+    public void createList(String testName) throws Exception {
+        for (int i = 0; i < 3; i++) {
+            create(testName);
+            // Add 3 items to each orgauthority
+            for (int j = 0; j < 3; j++) {
+                createItem(testName);
+            }
+        }
+    }
+
+    // Failure outcomes
+    // Placeholders until the three tests below can be uncommented.
+    // See Issue CSPACE-401.
+    @Override
+    public void createWithEmptyEntityBody(String testName) throws Exception {
+    }
+
+    @Override
+    public void createWithMalformedXml(String testName) throws Exception {
+    }
+
+    @Override
+    public void createWithWrongXmlSchema(String testName) throws Exception {
+    }
+
+    /*
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithEmptyEntityBody(String testName) throws Exception {
+
+    // Perform setup.
+    setupCreateWithEmptyEntityBody(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getServiceRootURL();
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = "";
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()) {
+        logger.debug(testName + ": url=" + url +
+            " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithMalformedXml(String testName) throws Exception {
+
+    // Perform setup.
+    setupCreateWithMalformedXml(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getServiceRootURL();
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = MALFORMED_XML_DATA; // Constant from base class.
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()){
+        logger.debug(testName + ": url=" + url +
+            " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "testSubmitRequest"})
+    public void createWithWrongXmlSchema(String testName) throws Exception {
+
+    // Perform setup.
+    setupCreateWithWrongXmlSchema(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getServiceRootURL();
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = WRONG_XML_SCHEMA_DATA;
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()){
+        logger.debug(testName + ": url=" + url +
+            " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+     */
+
+    // ---------------------------------------------------------------
+    // CRUD tests : READ tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create"})
+    public void read(String testName) throws Exception {
+
+        // Perform setup.
+        setupRead();
+
+        // Submit the request to the service and store the response.
+        ClientResponse<MultipartInput> res = client.read(knownResourceId);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        //FIXME: remove the following try catch once Aron fixes signatures
+        try {
+            MultipartInput input = (MultipartInput) res.getEntity();
+            OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                    client.getCommonPartName(), OrgauthoritiesCommon.class);
+            Assert.assertNotNull(orgAuthority);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /*
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+            dependsOnMethods = {"read"})
+        public void readByName(String testName) throws Exception {
+
+            // Perform setup.
+            setupRead();
+
+            // Submit the request to the service and store the response.
+            ClientResponse<MultipartInput> res = client.read(knownResourceId);
+            int statusCode = res.getStatus();
+
+            // Check the status code of the response: does it match
+            // the expected response(s)?
+            if(logger.isDebugEnabled()){
+                logger.debug(testName + ": status = " + statusCode);
+            }
+            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            //FIXME: remove the following try catch once Aron fixes signatures
+            try {
+                MultipartInput input = (MultipartInput) res.getEntity();
+                OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                        client.getCommonPartName(), OrgauthoritiesCommon.class);
+                Assert.assertNotNull(orgAuthority);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+    */
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"createItem", "read"})
+    public void readItem(String testName) throws Exception {
+
+        // Perform setup.
+        setupRead(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Check whether we've received a organization.
+        MultipartInput input = (MultipartInput) res.getEntity();
+        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+                client.getItemCommonPartName(), OrganizationsCommon.class);
+        Assert.assertNotNull(organization);
+
+    }
+
+    // Failure outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"read"})
+    public void readNonExistent(String testName) {
+
+        // Perform setup.
+        setupReadNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"readItem", "readNonExistent"})
+    public void readItemNonExistent(String testName) {
+
+        // Perform setup.
+        setupReadNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+    // ---------------------------------------------------------------
+    // CRUD tests : READ_LIST tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"createList", "read"})
+    public void readList(String testName) throws Exception {
+
+        // Perform setup.
+        setupReadList(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<OrgauthoritiesCommonList> res = client.readList();
+        OrgauthoritiesCommonList list = res.getEntity();
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Optionally output additional data about list members for debugging.
+        boolean iterateThroughList = false;
+        if (iterateThroughList && logger.isDebugEnabled()) {
+            List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
+                    list.getOrgauthorityListItem();
+            int i = 0;
+            for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
+                String csid = item.getCsid();
+                logger.debug(testName + ": list-item[" + i + "] csid=" +
+                        csid);
+                logger.debug(testName + ": list-item[" + i + "] displayName=" +
+                        item.getDisplayName());
+                logger.debug(testName + ": list-item[" + i + "] URI=" +
+                        item.getUri());
+                readItemList(csid);
+                i++;
+            }
+        }
+    }
+
+    @Test(dependsOnMethods = {"createList", "readItem"})
+    public void readItemList() {
+        readItemList(knownResourceId);
+    }
+
+    private void readItemList(String vcsid) {
+
+        final String testName = "readItemList";
+
+        // Perform setup.
+        setupReadList(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<OrganizationsCommonList> res =
+                client.readItemList(vcsid);
+        OrganizationsCommonList list = res.getEntity();
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("  " + testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Optionally output additional data about list members for debugging.
+        boolean iterateThroughList = false;
+        if (iterateThroughList && logger.isDebugEnabled()) {
+            List<OrganizationsCommonList.OrganizationListItem> items =
+                    list.getOrganizationListItem();
+            int i = 0;
+            for (OrganizationsCommonList.OrganizationListItem item : items) {
+                logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
+                        item.getCsid());
+                logger.debug("  " + testName + ": list-item[" + i + "] displayName=" +
+                        item.getDisplayName());
+                logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
+                        item.getUri());
+                i++;
+            }
+        }
+    }
+
+    // Failure outcomes
+    // None at present.
+    // ---------------------------------------------------------------
+    // CRUD tests : UPDATE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"read"})
+    public void update(String testName) throws Exception {
+
+        // Perform setup.
+        setupUpdate(testName);
+
+        // Retrieve the contents of a resource to update.
+        ClientResponse<MultipartInput> res =
+                client.read(knownResourceId);
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": read status = " + res.getStatus());
+        }
+        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+        if(logger.isDebugEnabled()){
+            logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
+        }
+        MultipartInput input = (MultipartInput) res.getEntity();
+        OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                client.getCommonPartName(), OrgauthoritiesCommon.class);
+        Assert.assertNotNull(orgAuthority);
+
+        // Update the contents of this resource.
+        orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
+        orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
+        if(logger.isDebugEnabled()){
+            logger.debug("to be updated OrgAuthority");
+            logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+        }
+
+        // Submit the updated resource to the service and store the response.
+        MultipartOutput output = new MultipartOutput();
+        OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getCommonPartName());
+        res = client.update(knownResourceId, output);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("update: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Retrieve the updated resource and verify that its contents exist.
+        input = (MultipartInput) res.getEntity();
+        OrgauthoritiesCommon updatedOrgAuthority =
+                (OrgauthoritiesCommon) extractPart(input,
+                        client.getCommonPartName(), OrgauthoritiesCommon.class);
+        Assert.assertNotNull(updatedOrgAuthority);
+
+        // Verify that the updated resource received the correct data.
+        Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
+                orgAuthority.getDisplayName(),
+                "Data in updated object did not match submitted data.");
+    }
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"readItem", "update"})
+    public void updateItem(String testName) throws Exception {
+
+        // Perform setup.
+        setupUpdate(testName);
+
+        ClientResponse<MultipartInput> res =
+                client.readItem(knownResourceId, knownItemResourceId);
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": read status = " + res.getStatus());
+        }
+        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+        if(logger.isDebugEnabled()){
+            logger.debug("got Organization to update with ID: " +
+                knownItemResourceId +
+                " in OrgAuthority: " + knownResourceId );
+        }
+        MultipartInput input = (MultipartInput) res.getEntity();
+        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+                client.getItemCommonPartName(), OrganizationsCommon.class);
+        Assert.assertNotNull(organization);
+
+        // Update the contents of this resource.
+        organization.setDisplayName("updated-" + organization.getDisplayName());
+        if(logger.isDebugEnabled()){
+            logger.debug("to be updated Organization");
+            logger.debug(objectAsXmlString(organization,
+                OrganizationsCommon.class));
+        }
+
+        // Submit the updated resource to the service and store the response.
+        MultipartOutput output = new MultipartOutput();
+        OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getItemCommonPartName());
+        res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("updateItem: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        // Retrieve the updated resource and verify that its contents exist.
+        input = (MultipartInput) res.getEntity();
+        OrganizationsCommon updatedOrganization =
+                (OrganizationsCommon) extractPart(input,
+                        client.getItemCommonPartName(), OrganizationsCommon.class);
+        Assert.assertNotNull(updatedOrganization);
+
+        // Verify that the updated resource received the correct data.
+        Assert.assertEquals(updatedOrganization.getDisplayName(),
+                organization.getDisplayName(),
+                "Data in updated Organization did not match submitted data.");
+    }
+
+    // Failure outcomes
+    // Placeholders until the three tests below can be uncommented.
+    // See Issue CSPACE-401.
+    @Override
+    public void updateWithEmptyEntityBody(String testName) throws Exception {
+    }
+
+    @Override
+    public void updateWithMalformedXml(String testName) throws Exception {
+    }
+
+    @Override
+    public void updateWithWrongXmlSchema(String testName) throws Exception {
+    }
+
+    /*
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithEmptyEntityBody(String testName) throws Exception {
+
+    // Perform setup.
+    setupUpdateWithEmptyEntityBody(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getResourceURL(knownResourceId);
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = "";
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()){
+        logger.debug(testName + ": url=" + url +
+            " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithMalformedXml(String testName) throws Exception {
+
+    // Perform setup.
+    setupUpdateWithMalformedXml(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getResourceURL(knownResourceId);
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = MALFORMED_XML_DATA;
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()){
+        logger.debug(testName + ": url=" + url +
+           " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "update", "testSubmitRequest"})
+    public void updateWithWrongXmlSchema(String testName) throws Exception {
+
+    // Perform setup.
+    setupUpdateWithWrongXmlSchema(testName);
+
+    // Submit the request to the service and store the response.
+    String method = REQUEST_TYPE.httpMethodName();
+    String url = getResourceURL(knownResourceId);
+    String mediaType = MediaType.APPLICATION_XML;
+    final String entity = WRONG_XML_SCHEMA_DATA;
+    int statusCode = submitRequest(method, url, mediaType, entity);
+
+    // Check the status code of the response: does it match
+    // the expected response(s)?
+    if(logger.isDebugEnabled()){
+        logger.debug("updateWithWrongXmlSchema: url=" + url +
+            " status=" + statusCode);
+     }
+    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+     */
+
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"update", "testSubmitRequest"})
+    public void updateNonExistent(String testName) throws Exception {
+
+        // Perform setup.
+        setupUpdateNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        // Note: The ID used in this 'create' call may be arbitrary.
+        // The only relevant ID may be the one used in update(), below.
+
+        // The only relevant ID may be the one used in update(), below.
+        MultipartOutput multipart = createOrgAuthorityInstance(NON_EXISTENT_ID);
+        ClientResponse<MultipartInput> res =
+                client.update(NON_EXISTENT_ID, multipart);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
+    public void updateNonExistentItem(String testName) throws Exception {
+
+        // Perform setup.
+        setupUpdateNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        // Note: The ID used in this 'create' call may be arbitrary.
+        // The only relevant ID may be the one used in update(), below.
+
+        // The only relevant ID may be the one used in update(), below.
+        MultipartOutput multipart = createOrganizationInstance(
+                       knownResourceId, NON_EXISTENT_ID, createRefName(NON_EXISTENT_ID));
+        ClientResponse<MultipartInput> res =
+                client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    // ---------------------------------------------------------------
+    // CRUD tests : DELETE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
+    public void delete(String testName) throws Exception {
+
+        // Perform setup.
+        setupDelete(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<Response> res = client.delete(knownResourceId);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+   @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"createItem", "readItemList", "testItemSubmitRequest",
+            "updateItem"})
+    public void deleteItem(String testName) throws Exception {
+
+        // Perform setup.
+        setupDelete(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("delete: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    // Failure outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"delete"})
+    public void deleteNonExistent(String testName) throws Exception {
+
+        // Perform setup.
+        setupDeleteNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
+        dependsOnMethods = {"deleteItem"})
+    public void deleteNonExistentItem(String testName) {
+
+        // Perform setup.
+        setupDeleteNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
+        int statusCode = res.getStatus();
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+    }
+
+    // ---------------------------------------------------------------
+    // Utility tests : tests of code used in tests above
+    // ---------------------------------------------------------------
+    /**
+     * Tests the code for manually submitting data that is used by several
+     * of the methods above.
+     */
+    @Test(dependsOnMethods = {"create", "read"})
+    public void testSubmitRequest() {
+
+        // Expected status code: 200 OK
+        final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
+
+        // Submit the request to the service and store the response.
+        String method = ServiceRequestType.READ.httpMethodName();
+        String url = getResourceURL(knownResourceId);
+        int statusCode = submitRequest(method, url);
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("testSubmitRequest: url=" + url +
+                " status=" + statusCode);
+        }
+        Assert.assertEquals(statusCode, EXPECTED_STATUS);
+
+    }
+
+    @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
+    public void testItemSubmitRequest() {
+
+        // Expected status code: 200 OK
+        final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
+
+        // Submit the request to the service and store the response.
+        String method = ServiceRequestType.READ.httpMethodName();
+        String url = getItemResourceURL(knownResourceId, knownItemResourceId);
+        int statusCode = submitRequest(method, url);
+
+        // Check the status code of the response: does it match
+        // the expected response(s)?
+        if(logger.isDebugEnabled()){
+            logger.debug("testItemSubmitRequest: url=" + url +
+                " status=" + statusCode);
+        }
+        Assert.assertEquals(statusCode, EXPECTED_STATUS);
+
+    }
+
+    // ---------------------------------------------------------------
+    // Cleanup of resources created during testing
+    // ---------------------------------------------------------------
+    
+    /**
+     * Deletes all resources created by tests, after all tests have been run.
+     *
+     * This cleanup method will always be run, even if one or more tests fail.
+     * For this reason, it attempts to remove all resources created
+     * at any point during testing, even if some of those resources
+     * may be expected to be deleted by certain tests.
+     */
+    @AfterClass(alwaysRun=true)
+    public void cleanUp() {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("Cleaning up temporary resources created for testing ...");
+        }
+        // Clean up organization resources.
+        String orgAuthorityResourceId;
+        String organizationResourceId;
+        for (Map.Entry<String, String> entry : allResourceItemIdsCreated.entrySet()) {
+            organizationResourceId = entry.getKey();
+            orgAuthorityResourceId = entry.getValue();
+            // Note: Any non-success responses are ignored and not reported.
+            ClientResponse<Response> res =
+                client.deleteItem(orgAuthorityResourceId, organizationResourceId);
+        }
+        // Clean up orgAuthority resources.
+        for (String resourceId : allResourceIdsCreated) {
+            // Note: Any non-success responses are ignored and not reported.
+            ClientResponse<Response> res = client.delete(resourceId);
+        }
+
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+    @Override
+    public String getServicePathComponent() {
+        return SERVICE_PATH_COMPONENT;
+    }
+
+    public String getItemServicePathComponent() {
+        return ITEM_SERVICE_PATH_COMPONENT;
+    }
+
+    /**
+     * Returns the root URL for a service.
+     *
+     * This URL consists of a base URL for all services, followed by
+     * a path component for the owning orgAuthority, followed by the 
+     * path component for the items.
+     *
+     * @return The root URL for a service.
+     */
+    protected String getItemServiceRootURL(String parentResourceIdentifier) {
+        return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
+    }
+
+    /**
+     * Returns the URL of a specific resource managed by a service, and
+     * designated by an identifier (such as a universally unique ID, or UUID).
+     *
+     * @param  resourceIdentifier  An identifier (such as a UUID) for a resource.
+     *
+     * @return The URL of a specific resource managed by a service.
+     */
+    protected String getItemResourceURL(String parentResourceIdentifier, String resourceIdentifier) {
+        return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier;
+    }
+
+    private MultipartOutput createOrgAuthorityInstance(String identifier) {
+       String displayName = "displayName-" + identifier;
+       String refName = createRefName(displayName);
+       String typeName = "vocabType-" + identifier;
+        return createOrgAuthorityInstance(
+                displayName, refName,typeName );
+    }
+
+    private MultipartOutput createOrgAuthorityInstance(
+               String displayName, String refName, String vocabType) {
+        OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();
+        orgAuthority.setDisplayName(displayName);
+        if(refName!=null)
+            orgAuthority.setRefName(refName);
+        orgAuthority.setVocabType(vocabType);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getCommonPartName());
+
+        if(logger.isDebugEnabled()) {
+            logger.debug("to be created, orgAuthority common");
+            logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+        }
+        return multipart;
+    }
+
+    private MultipartOutput createOrganizationInstance(String inOrgAuthority,
+        String displayName, String refName) {
+        OrganizationsCommon organization = new OrganizationsCommon();
+        organization.setDisplayName(displayName);
+        if(refName!=null)
+               organization.setRefName(refName);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart = multipart.addPart(organization,
+            MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getItemCommonPartName());
+
+        if(logger.isDebugEnabled()){
+            logger.debug("to be created, organization common");
+            logger.debug(objectAsXmlString(organization,
+                OrganizationsCommon.class));
+        }
+
+        return multipart;
+    }
+}
diff --git a/services/organization/client/src/test/resources/log4j.properties b/services/organization/client/src/test/resources/log4j.properties
new file mode 100644 (file)
index 0000000..18c5103
--- /dev/null
@@ -0,0 +1,23 @@
+log4j.rootLogger=debug, stdout, R\r
+\r
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender\r
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout\r
+\r
+# Pattern to output the caller's file name and line number.\r
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n\r
+\r
+log4j.appender.R=org.apache.log4j.RollingFileAppender\r
+log4j.appender.R.File=target/test-client.log\r
+\r
+log4j.appender.R.MaxFileSize=100KB\r
+# Keep one backup file\r
+log4j.appender.R.MaxBackupIndex=1\r
+\r
+log4j.appender.R.layout=org.apache.log4j.PatternLayout\r
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n\r
+\r
+#packages\r
+log4j.logger.org.collectionspace=DEBUG\r
+log4j.logger.org.apache=INFO\r
+log4j.logger.httpclient=INFO\r
+log4j.logger.org.jboss.resteasy=INFO\r
diff --git a/services/organization/import/.classpath b/services/organization/import/.classpath
new file mode 100644 (file)
index 0000000..199bbbb
--- /dev/null
@@ -0,0 +1,8 @@
+<?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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\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/services/organization/import/.project b/services/organization/import/.project
new file mode 100644 (file)
index 0000000..245a8c2
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.importer</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/services/organization/import/.settings/org.eclipse.jdt.core.prefs b/services/organization/import/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..8bc3504
--- /dev/null
@@ -0,0 +1,5 @@
+#Tue Nov 10 14:56:23 PST 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/import/.settings/org.maven.ide.eclipse.prefs b/services/organization/import/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..fd8796b
--- /dev/null
@@ -0,0 +1,9 @@
+#Tue Nov 10 14:56:18 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/import/build.xml b/services/organization/import/build.xml
new file mode 100644 (file)
index 0000000..001ca5d
--- /dev/null
@@ -0,0 +1,60 @@
+\r
+<project name="organization" default="package" basedir=".">\r
+    <description>\r
+        organization service\r
+    </description>\r
+  <!-- set global properties for this build -->\r
+    <property name="services.trunk" value="../../.."/>\r
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+    \r
+    <target name="package" depends="package-unix,package-windows"\r
+  description="Package CollectionSpace Services" />\r
+  \r
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    \r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>    \r
+\r
+    <target name="dist" depends="package"\r
+       description="distribute organization service importer tool">\r
+    </target>\r
+\r
+    <target name="dist_installer" depends="package"\r
+       description="distribute organization service importer tool">        \r
+        <!-- copy install scripts, etc. -->\r
+        <copy todir="${services.trunk}/${dist.installer.services}/organization/postdeploy">\r
+            <fileset dir="${basedir}/target">\r
+               <include name="*with-dependencies*.jar"/>\r
+            </fileset>\r
+        </copy>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/organization/import/pom.xml b/services/organization/import/pom.xml
new file mode 100644 (file)
index 0000000..2cc3821
--- /dev/null
@@ -0,0 +1,130 @@
+<?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
+\r
+    <parent>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <artifactId>org.collectionspace.services.organization</artifactId>\r
+        <version>1.0</version>\r
+    </parent>\r
+\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.organization.importer</artifactId>\r
+    <version>1.0</version>\r
+    <name>services.organization.importer</name>\r
+    \r
+    <dependencies>\r
+        <!-- keep slf4j dependencies on the top -->\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.jaxb</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.client</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.client</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        \r
+<!--         \r
+        <dependency>\r
+            <groupId>org.testng</groupId>\r
+            <artifactId>testng</artifactId>\r
+            <version>5.6</version>\r
+        </dependency>\r
+ -->        \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>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
+            <version>3.1</version>\r
+        </dependency>\r
+    </dependencies>\r
+    \r
+    <build>\r
+        <finalName>collectionspace-services-organization-importer</finalName>\r
+        <plugins>\r
+                       <plugin>\r
+                         <groupId>org.apache.maven.plugins</groupId>\r
+                         <artifactId>maven-assembly-plugin</artifactId>\r
+                           <executions>\r
+                             <execution>\r
+                                <goals>\r
+                                  <goal>attached</goal>\r
+                                </goals>\r
+                                <phase>package</phase>\r
+                                <configuration>\r
+                                  <descriptorRefs>\r
+                                    <descriptorRef>jar-with-dependencies</descriptorRef>\r
+                                 </descriptorRefs>\r
+                                 <archive>\r
+                                   <manifest>\r
+                                     <mainClass>org.collectionspace.services.organization.importer.OrgAuthorityBaseImport</mainClass>\r
+                                   </manifest>\r
+                                 </archive>\r
+                               </configuration>\r
+                            </execution>\r
+                         </executions>\r
+                       </plugin>        \r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-surefire-plugin</artifactId>\r
+                <configuration>\r
+                    <systemProperties>\r
+                        <property>\r
+                            <name>log4j.configuration</name>\r
+                            <value>file:target/test-classes/log4j.properties</value>\r
+                        </property>\r
+                    </systemProperties>\r
+                </configuration>\r
+            </plugin>\r
+            <plugin>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <version>2.0.2</version>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+</project>\r
+\r
diff --git a/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java b/services/organization/import/src/main/java/org/collectionspace/services/organization/importer/OrgAuthorityBaseImport.java
new file mode 100644 (file)
index 0000000..f01658c
--- /dev/null
@@ -0,0 +1,229 @@
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c)) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.collectionspace.services.organization.importer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.log4j.BasicConfigurator;
+import org.collectionspace.services.client.OrgAuthorityClient;
+import org.collectionspace.services.client.test.ServiceRequestType;
+import org.collectionspace.services.organization.OrgauthoritiesCommon;
+import org.collectionspace.services.organization.OrganizationsCommon;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OrgAuthorityServiceTest, carries out tests against a
+ * deployed and running OrgAuthority Service.
+ *
+ * $LastChangedRevision: 753 $
+ * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
+ */
+public class OrgAuthorityBaseImport {
+    private static final Logger logger =
+        LoggerFactory.getLogger(OrgAuthorityBaseImport.class);
+
+    // Instance variables specific to this test.
+    private OrgAuthorityClient client = new OrgAuthorityClient();
+    final String SERVICE_PATH_COMPONENT = "orgauthorities";
+    final String ITEM_SERVICE_PATH_COMPONENT = "items";
+
+    public void createOrgAuthority(String orgAuthorityName, List<String> enumValues ) {
+
+       // Expected status code: 201 Created
+       int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+       // Type of service request being tested
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+       if(logger.isDebugEnabled()){
+               logger.debug("Import: Create orgAuthority: \"" + orgAuthorityName +"\"");
+       }
+       MultipartOutput multipart = createOrgAuthorityInstance(orgAuthorityName, 
+                       createRefName(orgAuthorityName), "enum");
+       ClientResponse<Response> res = client.create(multipart);
+
+       int statusCode = res.getStatus();
+
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+               throw new RuntimeException("Could not create enumeration: \""+orgAuthorityName
+                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+       }
+       if(statusCode != EXPECTED_STATUS_CODE) {
+               throw new RuntimeException("Unexpected Status when creating enumeration: \""
+                               +orgAuthorityName +"\", Status:"+ statusCode);
+       }
+
+       // Store the ID returned from this create operation
+       // for additional tests below.
+       String newOrgAuthorityId = extractId(res);
+       if(logger.isDebugEnabled()){
+               logger.debug("Import: Created orgAuthorityulary: \"" + orgAuthorityName +"\" ID:"
+                               +newOrgAuthorityId );
+       }
+       for(String itemName : enumValues){
+               createItemInOrgAuthority(newOrgAuthorityId, orgAuthorityName, itemName, createRefName(itemName));
+       }
+    }
+    
+    private String createItemInOrgAuthority(String vcsid, String orgAuthorityName, String itemName, String refName) {
+       // Expected status code: 201 Created
+       int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+       // Type of service request being tested
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+       if(logger.isDebugEnabled()){
+               logger.debug("Import: Create Item: \""+itemName+"\" in orgAuthorityulary: \"" + orgAuthorityName +"\"");
+       }
+       MultipartOutput multipart = createOrganizationInstance(itemName, refName);
+       ClientResponse<Response> res = client.createItem(vcsid, multipart);
+
+       int statusCode = res.getStatus();
+
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+               throw new RuntimeException("Could not create Item: \""+itemName
+                               +"\" in orgAuthority: \"" + orgAuthorityName
+                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+       }
+       if(statusCode != EXPECTED_STATUS_CODE) {
+               throw new RuntimeException("Unexpected Status when creating Item: \""+itemName
+                               +"\" in orgAuthority: \"" + orgAuthorityName +"\", Status:"+ statusCode);
+       }
+
+       return extractId(res);
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+
+    private MultipartOutput createOrgAuthorityInstance(
+               String displayName, String refName, String vocabType) {
+        OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();
+        orgAuthority.setDisplayName(displayName);
+        orgAuthority.setRefName(refName);
+        orgAuthority.setVocabType(vocabType);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getCommonPartName());
+
+        if(logger.isDebugEnabled()){
+               logger.debug("to be created, orgAuthority common ", 
+                                       orgAuthority, OrgauthoritiesCommon.class);
+        }
+
+        return multipart;
+    }
+
+    private MultipartOutput createOrganizationInstance(
+               String displayName, String refName) {
+       OrganizationsCommon organization = new OrganizationsCommon();
+       organization.setDisplayName(displayName);
+       organization.setRefName(refName);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart = multipart.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", client.getItemCommonPartName());
+
+        if(logger.isDebugEnabled()){
+               logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);
+        }
+
+        return multipart;
+    }
+
+
+    /**
+     * Returns an error message indicating that the status code returned by a
+     * specific call to a service does not fall within a set of valid status
+     * codes for that service.
+     *
+     * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).
+     *
+     * @param statusCode  The invalid status code that was returned in the response,
+     *                    from submitting that type of request to the service.
+     *
+     * @return An error message.
+     */
+    protected String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {
+        return "Status code '" + statusCode + "' in response is NOT within the expected set: " +
+                requestType.validStatusCodesAsString();
+    }
+
+    protected String extractId(ClientResponse<Response> res) {
+        MultivaluedMap<String, Object> mvm = res.getMetadata();
+        String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
+        if(logger.isDebugEnabled()){
+               logger.debug("extractId:uri=" + uri);
+        }
+        String[] segments = uri.split("/");
+        String id = segments[segments.length - 1];
+        if(logger.isDebugEnabled()){
+               logger.debug("id=" + id);
+        }
+        return id;
+    }
+    
+    protected String createRefName(String displayName) {
+       return displayName.replaceAll("\\W", "");
+    }
+
+       public static void main(String[] args) {
+               
+               BasicConfigurator.configure();
+               logger.info("OrgAuthorityBaseImport starting...");
+
+               OrgAuthorityBaseImport oabi = new OrgAuthorityBaseImport();
+               final String acquisitionMethodsOrgAuthorityName = "Acquisition Methods";
+               final String entryMethodsOrgAuthorityName = "Entry Methods";
+               final String entryReasonsOrgAuthorityName = "Entry Reasons";
+               final String responsibleDeptsOrgAuthorityName = "Responsible Departments";
+
+               List<String> acquisitionMethodsEnumValues = 
+                       Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");
+               List<String> entryMethodsEnumValues = 
+                       Arrays.asList("In person","Post","Found on doorstep");
+               List<String> entryReasonsEnumValues = 
+                       Arrays.asList("Enquiry","Commission","Loan");
+               List<String> respDeptNamesEnumValues = 
+                       Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",
+                                                                       "Ethnography","Herpetology","Media and Performance Art",
+                                                                       "Paintings and Sculpture","Paleobotany","Photographs",
+                                                                       "Prints and Drawings");
+
+               oabi.createOrgAuthority(acquisitionMethodsOrgAuthorityName, acquisitionMethodsEnumValues);
+               oabi.createOrgAuthority(entryMethodsOrgAuthorityName, entryMethodsEnumValues);
+               oabi.createOrgAuthority(entryReasonsOrgAuthorityName, entryReasonsEnumValues);
+               oabi.createOrgAuthority(responsibleDeptsOrgAuthorityName, respDeptNamesEnumValues);
+
+               logger.info("OrgAuthorityBaseImport complete.");
+       }
+}
diff --git a/services/organization/installer/build.xml b/services/organization/installer/build.xml
new file mode 100644 (file)
index 0000000..250fa2a
--- /dev/null
@@ -0,0 +1,61 @@
+\r
+<project name="organization" default="package" basedir=".">\r
+    <description>\r
+        organization service\r
+    </description>\r
+  <!-- set global properties for this build -->\r
+    <property name="services.trunk" value="../.."/>\r
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+    \r
+    <target name="install" description="">\r
+        <exec executable="echo">\r
+                       <arg value="Installer: Executing Organization Service's &apos;install&apos; target." />\r
+                               </exec>\r
+                               <!-- Copy the Nuxeo DocType jar files to the Nuxeo app server domain -->\r
+        <copy todir="${jboss.deploy.nuxeo.system}">\r
+            <fileset file="nuxeo/*.jar"/>\r
+        </copy>                                \r
+    </target>    \r
+\r
+    <target name="config" description="" depends="install">\r
+        <exec executable="echo">\r
+                       <arg value="Installer: Executing Organization Service's &apos;config&apos; target." />\r
+                               </exec>\r
+    </target>\r
+    \r
+    <target name="predeploy" description="" depends="config">\r
+        <exec executable="echo">\r
+                       <arg value="Installer: Executing Organization Service's &apos;predeploy&apos; target." />\r
+                               </exec>\r
+    </target>    \r
+    \r
+    <target name="deploy" description="">\r
+        <exec executable="echo">\r
+                       <arg value="Installer: Executing Organization Service's &apos;deploy&apos; target." />\r
+                               </exec>\r
+    </target>\r
+    \r
+    <target name="postdeploy">\r
+        <exec executable="echo">\r
+                       <arg value="Installer: Executing installer's &apos;postdeploy&apos; target for the Organization Service." />\r
+                               </exec>         \r
+        <exec executable="echo">\r
+                       <arg value="Importing necessary orgauthorities." />\r
+                               </exec>                         \r
+        <java jar="./postdeploy/collectionspace-services-organization-importer-jar-with-dependencies.jar"\r
+               fork="true"\r
+               failonerror="true">\r
+                               </java> \r
+    </target>\r
+    \r
+\r
+</project>\r
diff --git a/services/organization/jaxb/.classpath b/services/organization/jaxb/.classpath
new file mode 100644 (file)
index 0000000..fef07b2
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+       <classpathentry kind="src" output="target/classes" path="target/generated-sources/xjc"/>\r
+       <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\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/services/organization/jaxb/.project b/services/organization/jaxb/.project
new file mode 100644 (file)
index 0000000..4e88299
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.jaxb</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.maven.ide.eclipse.maven2Nature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/organization/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/organization/jaxb/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..0b4dbbe
--- /dev/null
@@ -0,0 +1,5 @@
+#Mon Oct 05 17:07:09 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/organization/jaxb/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..5288436
--- /dev/null
@@ -0,0 +1,9 @@
+#Mon Oct 05 17:07:08 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/jaxb/pom.xml b/services/organization/jaxb/pom.xml
new file mode 100644 (file)
index 0000000..22259af
--- /dev/null
@@ -0,0 +1,105 @@
+<?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>org.collectionspace.services.organization</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>1.0</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.organization.jaxb</artifactId>
+    <version>1.0</version>
+    <name>services.organization.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>
+        <finalName>collectionspace-services-organization-jaxb</finalName>
+        <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.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+
diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityJAXBSchema.java
new file mode 100644 (file)
index 0000000..ad67484
--- /dev/null
@@ -0,0 +1,17 @@
+/**\r
+ * \r
+ */\r
+package org.collectionspace.services;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface OrgAuthorityJAXBSchema {\r
+       final static String DISPLAY_NAME = "displayName";\r
+       final static String REF_NAME = "refName";\r
+       final static String VOCAB_TYPE = "vocabType";\r
+       final static String CSID = "csid";\r
+}\r
+\r
+\r
diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityListItemJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrgAuthorityListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..d326dc9
--- /dev/null
@@ -0,0 +1,9 @@
+package org.collectionspace.services;\r
+\r
+public interface OrgAuthorityListItemJAXBSchema {\r
+       final static String DISPLAY_NAME = "displayName";\r
+       final static String REF_NAME = "refName";\r
+       final static String VOCAB_TYPE = "vocabType";\r
+       final static String CSID = "csid";\r
+       final static String URI = "url";\r
+}\r
diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java
new file mode 100644 (file)
index 0000000..67ae422
--- /dev/null
@@ -0,0 +1,18 @@
+/**\r
+ * \r
+ */\r
+package org.collectionspace.services;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface OrganizationJAXBSchema {\r
+       final static String DISPLAY_NAME = "displayName";\r
+       final static String REF_NAME = "refName";\r
+       final static String CSID = "csid";\r
+       final static String LONG_NAME = "longName";\r
+       final static String DESCRIPTION = "description";\r
+}\r
+\r
+\r
diff --git a/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationListItemJAXBSchema.java b/services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..86653cf
--- /dev/null
@@ -0,0 +1,8 @@
+package org.collectionspace.services;\r
+\r
+public interface OrganizationListItemJAXBSchema {\r
+       final static String DISPLAY_NAME = "displayName";\r
+       final static String REF_NAME = "refName";\r
+       final static String CSID = "csid";\r
+       final static String URI = "url";\r
+}\r
diff --git a/services/organization/jaxb/src/main/resources/organization_common.xsd b/services/organization/jaxb/src/main/resources/organization_common.xsd
new file mode 100644 (file)
index 0000000..3104fbd
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/services/organization"
+  xmlns="http://collectionspace.org/services/organization"
+  targetNamespace="http://collectionspace.org/services/organization"
+  version="0.1"
+>
+
+
+<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
+    
+    <!-- Organization -->
+    <xs:element name="organizations_common">
+        <xs:complexType>
+            <xs:sequence>
+                <!--  Common identifier -->
+                <xs:element name="csid" type="xs:string" />
+                
+                <!--  Vocabularyitem Information Group -->
+                <xs:element name="displayName" type="xs:string"/>
+                <xs:element name="refName" type="xs:string"/>
+                <xs:element name="longName" type="xs:string"/>
+                <xs:element name="description" type="xs:string"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    
+    <!-- Organization instances, as in nuxeo repository -->
+    <xs:element name="organizations-common-list">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="organization_list_item" maxOccurs="unbounded">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="displayName" type="xs:string"
+                                minOccurs="1" />
+                            <!-- uri to retrieve organization details -->
+                            <xs:element name="uri" type="xs:anyURI"
+                                minOccurs="1" />
+                            <xs:element name="refName" type="xs:string"
+                                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>
+
diff --git a/services/organization/jaxb/src/main/resources/orgauthority_common.xsd b/services/organization/jaxb/src/main/resources/orgauthority_common.xsd
new file mode 100644 (file)
index 0000000..8859e26
--- /dev/null
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    OrgAuthority schema (XSD)
+    
+    Entity  : OrgAuthority
+    Part    : Common
+    Used for: JAXB binding between XML and Java objects
+    
+    $LastChangedRevision: 1055 $
+    $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/services/organization"
+  xmlns="http://collectionspace.org/services/organization"
+  targetNamespace="http://collectionspace.org/services/organization"
+  version="0.1"
+>
+
+<!--
+    Avoid XmlRootElement nightmare:
+    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Organization+Service+Home -->    
+    
+    <!-- OrgAuthority  -->
+    <xs:element name="orgauthorities_common">
+        <xs:complexType>
+            <xs:sequence>
+                <!--  Common identifier -->
+                <xs:element name="csid" type="xs:string" />
+                
+                <!--  OrgAuthority Information Group -->
+                <xs:element name="displayName" type="xs:string"/>
+                <xs:element name="refName" type="xs:string"/>
+                <xs:element name="vocabType" type="xs:string"/>
+
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    
+    <!-- OrgAuthority instances, as in nuxeo repository -->
+    <xs:element name="orgauthorities-common-list">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="displayName" type="xs:string"
+                                minOccurs="1" />
+                            <xs:element name="refName" type="xs:string"
+                                minOccurs="1" />
+                            <xs:element name="vocabType" type="xs:string"
+                                minOccurs="1" />
+                            <!-- uri to retrieve orgauthority 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>
+
diff --git a/services/organization/pom.xml b/services/organization/pom.xml
new file mode 100644 (file)
index 0000000..06a65c2
--- /dev/null
@@ -0,0 +1,70 @@
+<?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>org.collectionspace.services.main</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>1.0</version>\r
+    </parent>\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <version>1.0</version>\r
+    <artifactId>org.collectionspace.services.organization</artifactId>\r
+    <packaging>pom</packaging>\r
+    <name>services.organization</name>\r
+\r
+    <modules>\r
+        <module>jaxb</module>\r
+        <module>service</module>\r
+        <module>3rdparty</module>\r
+        <module>client</module>\r
+        <module>import</module>\r
+        <module>sample</module>\r
+    </modules>\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 &gt; 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
+                        <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>\r
+                        <archive>\r
+                            <manifest>\r
+                                <addClasspath>true</addClasspath>\r
+                            </manifest>\r
+                        </archive>\r
+                    </configuration>\r
+                </plugin>\r
+            </plugins>\r
+        </pluginManagement>\r
+        <plugins>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <version>2.0.2</version>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+</project>\r
+\r
diff --git a/services/organization/sample/.classpath b/services/organization/sample/.classpath
new file mode 100644 (file)
index 0000000..d8f2919
--- /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"/>\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/services/organization/sample/.project b/services/organization/sample/.project
new file mode 100644 (file)
index 0000000..9c027e0
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.samples</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/services/organization/sample/.settings/org.eclipse.jdt.core.prefs b/services/organization/sample/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..9fa2bf3
--- /dev/null
@@ -0,0 +1,5 @@
+#Mon Nov 23 11:54:01 PST 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2\r
+org.eclipse.jdt.core.compiler.compliance=1.4\r
+org.eclipse.jdt.core.compiler.source=1.3\r
diff --git a/services/organization/sample/.settings/org.maven.ide.eclipse.prefs b/services/organization/sample/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..e3f71bd
--- /dev/null
@@ -0,0 +1,9 @@
+#Mon Nov 23 11:53:50 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/sample/pom.xml b/services/organization/sample/pom.xml
new file mode 100644 (file)
index 0000000..9a991a1
--- /dev/null
@@ -0,0 +1,14 @@
+<?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
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.organization.client.samples</artifactId>\r
+    <packaging>pom</packaging>\r
+    <version>1.0</version>\r
+    <name>organization.client.samples</name>\r
+\r
+    <modules>\r
+        <module>sample</module>\r
+    </modules>\r
+</project>\r
+\r
diff --git a/services/organization/sample/sample/.classpath b/services/organization/sample/sample/.classpath
new file mode 100644 (file)
index 0000000..c7613ed
--- /dev/null
@@ -0,0 +1,117 @@
+<classpath>\r
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>\r
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>\r
+  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>\r
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>\r
+  <classpathentry kind="output" path="target/classes"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1/activation-1.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.0/jaxb-api-2.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jsr173_api/1.0/jsr173_api-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/mail/mail/1.4/mail-1.4.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/script/script-api/1.0/script-api-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0/stax-api-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/classworlds/classworlds/1.1/classworlds-1.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/noelios/restlet/com.noelios.restlet/1.0.7/com.noelios.restlet-1.0.7.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/noelios/restlet/com.noelios.restlet.ext.httpclient/1.0.7/com.noelios.restlet.ext.httpclient-1.0.7.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.0/commons-cli-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.2/commons-codec-1.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.2/commons-lang-2.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-7/doxia-sink-api-1.0-alpha-7.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/fastinfoset/FastInfoset/1.2.2/FastInfoset-1.2.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.GA/hibernate-commons-annotations-3.1.0.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-core/3.3.0.SP1/hibernate-core-3.3.0.SP1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.4.0.GA/hibernate-entitymanager-3.4.0.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/ibm/icu/icu4j/2.6.1/icu4j-2.6.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/cup/java-cup/0.11a/java-cup-0.11a.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.4.GA/javassist-3.4.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-impl/2.0.2/jaxb-impl-2.0.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/bind/jaxb-xjc/2.1/jaxb-xjc-2.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/jaxen/jaxen/1.1.1/jaxen-1.1.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jboss/resteasy/jaxrs-api/1.0.2.GA/jaxrs-api-1.0.2.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-common/4.0.4.GA/jboss-common-4.0.4.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-remoting/2.2.2.SP1/jboss-remoting-2.2.2.SP1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/jdom/jdom/1.0/jdom-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/jettison/jettison/1.0.1/jettison-1.0.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/joda-time/joda-time/1.4/joda-time-1.4.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/jcraft/jsch/0.1.27/jsch-0.1.27.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact/2.0.6/maven-artifact-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact-manager/2.0.6/maven-artifact-manager-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-core/2.0.6/maven-core-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-error-diagnostics/2.0.6/maven-error-diagnostics-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-model/2.0.6/maven-model-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-monitor/2.0.6/maven-monitor-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-descriptor/2.0.6/maven-plugin-descriptor-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-parameter-documenter/2.0.6/maven-plugin-parameter-documenter-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-registry/2.0.6/maven-plugin-registry-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-profile/2.0.6/maven-profile-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/reporting/maven-reporting-api/2.0.6/maven-reporting-api-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-repository-metadata/2.0.6/maven-repository-metadata-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-settings/2.0.6/maven-settings-2.0.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/plugins/maven-surefire-plugin/2.4.3/maven-surefire-plugin-2.4.3.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-toolchain/1.0/maven-toolchain-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/common/nuxeo-common/1.5.1-SNAPSHOT/nuxeo-common-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core/1.5.1-SNAPSHOT/nuxeo-core-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-api/1.5.1-SNAPSHOT/nuxeo-core-api-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-client/1.5.1-SNAPSHOT/nuxeo-core-client-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-event/1.5.1-SNAPSHOT/nuxeo-core-event-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-facade/1.5.1-SNAPSHOT/nuxeo-core-facade-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-io/1.5.1-SNAPSHOT/nuxeo-core-io-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-query/1.5.1-SNAPSHOT/nuxeo-core-query-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/ecm/core/nuxeo-core-schema/1.5.1-SNAPSHOT/nuxeo-core-schema-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/runtime/nuxeo-runtime/1.5.1-SNAPSHOT/nuxeo-runtime-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/runtime/nuxeo-runtime-management/1.5.1-SNAPSHOT/nuxeo-runtime-management-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/nuxeo/runtime/nuxeo-runtime-osgi/1.5.1-SNAPSHOT/nuxeo-runtime-osgi-1.5.1-SNAPSHOT.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/collectionspace/services/org.collectionspace.services.client/1.0/org.collectionspace.services.client-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/collectionspace/services/org.collectionspace.services.common/1.0/org.collectionspace.services.common-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/collectionspace/services/org.collectionspace.services.organization.client/1.0/org.collectionspace.services.organization.client-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/collectionspace/services/org.collectionspace.services.organization.jaxb/1.0/org.collectionspace.services.organization.jaxb-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/osgi/org.osgi.core/4.1.0/org.osgi.core-4.1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/restlet/org.restlet/1.0.7/org.restlet-1.0.7.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jvnet/jaxb2-commons/property-listener-injector/1.0/property-listener-injector-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/relaxngDatatype/1.0/relaxngDatatype-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-jaxb-provider/1.0.2.GA/resteasy-jaxb-provider-1.0.2.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-jaxrs/1.0.2.GA/resteasy-jaxrs-1.0.2.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jboss/resteasy/resteasy-multipart-provider/1.0.2.GA/resteasy-multipart-provider-1.0.2.GA.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/jvnet/jaxb2_commons/runtime/0.4.1.4/runtime-0.4.1.4.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/scannotation/scannotation/1.0.2/scannotation-1.0.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/stream/sjsxp/1.0.1/sjsxp-1.0.1.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.2/slf4j-api-1.5.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.2/slf4j-log4j12-1.5.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-simple/1.5.2/slf4j-simple-1.5.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/testng/testng/5.6/testng-5.6.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-file/1.0-beta-2/wagon-file-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-http-lightweight/1.0-beta-2/wagon-http-lightweight-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-http-shared/1.0-beta-2/wagon-http-shared-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-provider-api/1.0-beta-2/wagon-provider-api-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-ssh/1.0-beta-2/wagon-ssh-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-ssh-common/1.0-beta-2/wagon-ssh-common-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-ssh-external/1.0-beta-2/wagon-ssh-external-1.0-beta-2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/xalan/xalan/2.6.0/xalan-2.6.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.3.02/xml-apis-1.3.02.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/xom/xom/1.0/xom-1.0.jar"/>\r
+  <classpathentry kind="var" path="M2_REPO/com/sun/xml/xsom/20060306/xsom-20060306.jar"/>\r
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+</classpath>\r
diff --git a/services/organization/sample/sample/.project b/services/organization/sample/sample/.project
new file mode 100644 (file)
index 0000000..86c07bf
--- /dev/null
@@ -0,0 +1,17 @@
+<projectDescription>\r
+  <name>org.collectionspace.services.organization.client.sample</name>\r
+  <comment/>\r
+  <projects/>\r
+  <buildSpec>\r
+    <buildCommand>\r
+      <name>org.eclipse.jdt.core.javabuilder</name>\r
+    </buildCommand>\r
+    <buildCommand>\r
+      <name>org.maven.ide.eclipse.maven2Builder</name>\r
+    </buildCommand>\r
+  </buildSpec>\r
+  <natures>\r
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+    <nature>org.eclipse.jdt.core.javanature</nature>\r
+  </natures>\r
+</projectDescription>\r
diff --git a/services/organization/sample/sample/.settings/org.eclipse.jdt.core.prefs b/services/organization/sample/sample/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..8ee16c2
--- /dev/null
@@ -0,0 +1,5 @@
+#Fri Oct 02 14:55:57 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/organization/sample/sample/.settings/org.maven.ide.eclipse.prefs b/services/organization/sample/sample/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..0624c1a
--- /dev/null
@@ -0,0 +1,9 @@
+#Wed Sep 16 16:14:17 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
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/organization/sample/sample/pom.xml b/services/organization/sample/sample/pom.xml
new file mode 100644 (file)
index 0000000..03ef7c5
--- /dev/null
@@ -0,0 +1,112 @@
+<?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
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.organization.client.sample</artifactId>\r
+    <packaging>jar</packaging>\r
+    <version>1.0</version>\r
+    <name>organization.client.sample</name>\r
+    \r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.jaxb</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.client</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.client</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+    </dependencies>\r
+    \r
+    <repositories>\r
+        <repository>\r
+            <id>libs-releases-local</id>\r
+            <name>libs-releases-local</name>\r
+            <url>http://source.collectionspace.org:8081/artifactory/libs-releases-local</url>\r
+            <releases>\r
+                <enabled>true</enabled>\r
+            </releases>\r
+            <snapshots>\r
+                <enabled>false</enabled>\r
+            </snapshots>            \r
+        </repository>\r
+        \r
+        <repository>\r
+            <id>libs-snapshots-local</id>\r
+            <name>libs-snapshots-local</name>\r
+            <url>http://source.collectionspace.org:8081/artifactory/libs-snapshots-local</url>\r
+            <releases>\r
+                <enabled>false</enabled>\r
+            </releases>\r
+            <snapshots>\r
+                <enabled>true</enabled>\r
+            </snapshots>            \r
+        </repository>\r
+        <repository>\r
+            <id>collectionspace-releases</id>\r
+            <name>collectionspace-releases</name>\r
+            <url>http://source.collectionspace.org:8081/artifactory/public-nuxeo</url>            \r
+            <releases>\r
+                <enabled>true</enabled>\r
+            </releases>\r
+            <snapshots>\r
+                <enabled>false</enabled>\r
+            </snapshots>            \r
+        </repository>\r
+        <repository>\r
+            <id>collectionspace-snapshots</id>\r
+            <name>collectionspace-snapshots</name>\r
+            <url>http://source.collectionspace.org:8081/artifactory/public-snapshot-nuxeo</url>\r
+            <releases>\r
+                <enabled>false</enabled>\r
+            </releases>\r
+            <snapshots>\r
+                <enabled>true</enabled>\r
+            </snapshots>\r
+        </repository>\r
+    </repositories>    \r
+    \r
+    <build>\r
+        <finalName>organization-client-sample</finalName>\r
+        <plugins>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-assembly-plugin</artifactId>\r
+                <executions>\r
+                    <execution>\r
+                        <goals>\r
+                            <goal>attached</goal>\r
+                        </goals>\r
+                        <phase>package</phase>\r
+                        <configuration>\r
+                            <descriptorRefs>\r
+                                <descriptorRef>jar-with-dependencies</descriptorRef>\r
+                            </descriptorRefs>\r
+                            <archive>\r
+                                <manifest>\r
+                                    <mainClass>org.collectionspace.services.organization.client.sample.Sample</mainClass>\r
+                                </manifest>\r
+                            </archive>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+</project>\r
+\r
diff --git a/services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java b/services/organization/sample/sample/src/main/java/org/collectionspace/services/organization/client/sample/Sample.java
new file mode 100644 (file)
index 0000000..cc9d7bb
--- /dev/null
@@ -0,0 +1,548 @@
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright (c)) 2009 Regents of the University of California\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.collectionspace.services.organization.client.sample;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.MultivaluedMap;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.apache.log4j.BasicConfigurator;\r
+import org.collectionspace.services.client.OrgAuthorityClient;\r
+import org.collectionspace.services.client.test.ServiceRequestType;\r
+import org.collectionspace.services.organization.OrgauthoritiesCommon;\r
+import org.collectionspace.services.organization.OrgauthoritiesCommonList;\r
+import org.collectionspace.services.organization.OrganizationsCommon;\r
+import org.collectionspace.services.organization.OrganizationsCommonList;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
+import org.jboss.resteasy.plugins.providers.multipart.InputPart;\r
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * OrgAuthority Sample, carries out tests against a\r
+ * deployed and running OrgAuthority Service.\r
+ *\r
+ * $LastChangedRevision: 1055 $\r
+ * $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $\r
+ */\r
+public class Sample {\r
+    private static final Logger logger =\r
+        LoggerFactory.getLogger(Sample.class);\r
+\r
+    // Instance variables specific to this test.\r
+    private OrgAuthorityClient client = new OrgAuthorityClient();\r
+    final String SERVICE_PATH_COMPONENT = "organizations";\r
+    final String ITEM_SERVICE_PATH_COMPONENT = "items";\r
+\r
+\r
+    // ---------------------------------------------------------------\r
+    // Create\r
+    // ---------------------------------------------------------------\r
+\r
+    public void createEnumeration(String orgAuthName, List<String> enumValues ) {\r
+\r
+       // Expected status code: 201 Created\r
+       int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
+\r
+       logger.info("Import: Create orgAuthority: \"" + orgAuthName +"\"");\r
+       MultipartOutput multipart = createOrgAuthorityInstance(orgAuthName, \r
+                       createRefName(orgAuthName), "enum");\r
+       ClientResponse<Response> res = client.create(multipart);\r
+\r
+       int statusCode = res.getStatus();\r
+\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not create enumeration: \""+orgAuthName\r
+                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when creating enumeration: \""\r
+                               +orgAuthName +"\", Status:"+ statusCode);\r
+       }\r
+\r
+       // Store the ID returned from this create operation\r
+       // for additional tests below.\r
+       String newOrgAuthId = extractId(res);\r
+        logger.info("Import: Created orgAuthority: \"" + orgAuthName +"\" ID:"\r
+                               +newOrgAuthId );\r
+        \r
+        // Add items to the orgAuthority\r
+       for(String itemName : enumValues){\r
+               createItemInOrgAuth(newOrgAuthId, orgAuthName, itemName, createRefName(itemName));\r
+       }\r
+        \r
+    }\r
+    \r
+    private String createItemInOrgAuth(String vcsid, String orgAuthName, String itemName, String refName) {\r
+       // Expected status code: 201 Created\r
+       int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
+\r
+       logger.info("Import: Create Item: \""+itemName+"\" in orgAuthority: \"" + orgAuthName +"\"");\r
+       MultipartOutput multipart = createOrganizationInstance(itemName, refName);\r
+       ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+\r
+       int statusCode = res.getStatus();\r
+\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not create Item: \""+itemName\r
+                               +"\" in orgAuthority: \"" + orgAuthName\r
+                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when creating Item: \""+itemName\r
+                               +"\" in orgAuthority: \"" + orgAuthName +"\", Status:"+ statusCode);\r
+       }\r
+\r
+       return extractId(res);\r
+    }\r
+\r
+\r
+   // ---------------------------------------------------------------\r
+   // Read\r
+   // ---------------------------------------------------------------\r
+\r
+   private OrgauthoritiesCommonList readOrgAuthorities() {\r
+\r
+        // Expected status code: 200 OK\r
+       int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;\r
+\r
+        // Submit the request to the service and store the response.\r
+        ClientResponse<OrgauthoritiesCommonList> res = client.readList();\r
+        OrgauthoritiesCommonList list = res.getEntity();\r
+\r
+        int statusCode = res.getStatus();\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not read list of orgAuthorities: "\r
+                + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when reading " +\r
+                "list of orgAuthorities, Status:"+ statusCode);\r
+       }\r
+\r
+        return list;\r
+   }\r
+\r
+    private List<String> readOrgAuthorityIds(OrgauthoritiesCommonList list) {\r
+\r
+        List<String> ids = new ArrayList<String>();\r
+        List<OrgauthoritiesCommonList.OrgauthorityListItem> orgAuthorities =\r
+            list.getOrgauthorityListItem();\r
+        for (OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority : orgAuthorities) {\r
+            ids.add(orgAuthority.getCsid());\r
+        }\r
+        return ids;\r
+   }\r
+    \r
+   private OrgauthoritiesCommon readOrgAuthority(String orgAuthId) {\r
+\r
+        // Expected status code: 200 OK\r
+       int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;\r
+\r
+        // Submit the request to the service and store the response.\r
+        OrgauthoritiesCommon orgAuthority = null;\r
+        try {\r
+            ClientResponse<MultipartInput> res = client.read(orgAuthId);\r
+            int statusCode = res.getStatus();\r
+            if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+                throw new RuntimeException("Could not read orgAuthority"\r
+                    + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+            }\r
+            if(statusCode != EXPECTED_STATUS_CODE) {\r
+                throw new RuntimeException("Unexpected Status when reading " +\r
+                    "orgAuthority, Status:"+ statusCode);\r
+            }\r
+            MultipartInput input = (MultipartInput) res.getEntity();\r
+            orgAuthority = (OrgauthoritiesCommon) extractPart(input,\r
+                    client.getCommonPartName(), OrgauthoritiesCommon.class);\r
+        } catch (Exception e) {\r
+            throw new RuntimeException("Could not read orgAuthority: ", e);\r
+        }\r
+\r
+        return orgAuthority;\r
+    }\r
+\r
+    private OrganizationsCommonList readItemsInOrgAuth(String orgAuthId) {\r
+\r
+        // Expected status code: 200 OK\r
+       int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;\r
+\r
+        // Submit the request to the service and store the response.\r
+        ClientResponse<OrganizationsCommonList> res =\r
+                client.readItemList(orgAuthId);\r
+        OrganizationsCommonList list = res.getEntity();\r
+\r
+        int statusCode = res.getStatus();\r
+\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not read items in orgAuthority: "\r
+                + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when reading " +\r
+                "items in orgAuthority, Status:"+ statusCode);\r
+       }\r
+\r
+        return list;\r
+    }\r
+\r
+    private List<String> readOrganizationIds(OrganizationsCommonList list) {\r
+\r
+        List<String> ids = new ArrayList<String>();\r
+        List<OrganizationsCommonList.OrganizationListItem> items =\r
+            list.getOrganizationListItem();\r
+        for (OrganizationsCommonList.OrganizationListItem item : items) {\r
+            ids.add(item.getCsid());\r
+        }\r
+        return ids;\r
+   }\r
+\r
+    // ---------------------------------------------------------------\r
+    // Delete\r
+    // ---------------------------------------------------------------\r
+\r
+    private void deleteOrgAuthority(String vcsid) {\r
+         // Expected status code: 200 OK\r
+       int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;\r
+\r
+        ClientResponse<Response> res = client.delete(vcsid);\r
+        int statusCode = res.getStatus();\r
+\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not delete orgAuthority: "\r
+                + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when deleting " +\r
+                "orgAuthority, Status:"+ statusCode);\r
+       }\r
+    }\r
+\r
+    private void deleteAllOrgAuthorities() {\r
+        List<String> ids = readOrgAuthorityIds(readOrgAuthorities());\r
+        for (String id : ids) {\r
+            deleteOrgAuthority(id);\r
+        }\r
+    }\r
+\r
+        private void deleteOrganization(String vcsid, String itemcsid) {\r
+         // Expected status code: 200 OK\r
+       int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();\r
+       // Type of service request being tested\r
+       ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;\r
+\r
+        ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);\r
+        int statusCode = res.getStatus();\r
+\r
+       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+               throw new RuntimeException("Could not delete orgAuthority item: "\r
+                + invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+       }\r
+       if(statusCode != EXPECTED_STATUS_CODE) {\r
+               throw new RuntimeException("Unexpected Status when deleting " +\r
+                "orgAuthority item, Status:"+ statusCode);\r
+       }\r
+    }\r
+\r
+    private void deleteAllItemsForOrgAuth(String orgAuthId) {\r
+        List<String> itemIds = readOrganizationIds(readItemsInOrgAuth(orgAuthId));\r
+        for (String itemId : itemIds) {\r
+            deleteOrganization(orgAuthId, itemId);\r
+        }\r
+    }\r
+\r
+    // ---------------------------------------------------------------\r
+    // Utility methods used by tests above\r
+    // ---------------------------------------------------------------\r
+\r
+    private MultipartOutput createOrgAuthorityInstance(\r
+               String displayName, String refName, String vocabType) {\r
+        OrgauthoritiesCommon orgAuthority = new OrgauthoritiesCommon();\r
+        orgAuthority.setDisplayName(displayName);\r
+        orgAuthority.setRefName(refName);\r
+        orgAuthority.setVocabType(vocabType);\r
+        MultipartOutput multipart = new MultipartOutput();\r
+        OutputPart commonPart = multipart.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);\r
+        commonPart.getHeaders().add("label", client.getCommonPartName());\r
+\r
+        if(logger.isDebugEnabled()){\r
+               logger.debug("to be created, orgAuthority common ",\r
+                                       orgAuthority, OrgauthoritiesCommon.class);\r
+        }\r
+\r
+        return multipart;\r
+    }\r
+\r
+    private MultipartOutput createOrganizationInstance(\r
+               String displayName, String refName) {\r
+       OrganizationsCommon organization = new OrganizationsCommon();\r
+       organization.setDisplayName(displayName);\r
+       organization.setRefName(refName);\r
+        MultipartOutput multipart = new MultipartOutput();\r
+        OutputPart commonPart = multipart.addPart(organization, MediaType.APPLICATION_XML_TYPE);\r
+        commonPart.getHeaders().add("label", client.getItemCommonPartName());\r
+\r
+        if(logger.isDebugEnabled()){\r
+               logger.debug("to be created, organization common ", organization, OrganizationsCommon.class);\r
+        }\r
+\r
+        return multipart;\r
+    }\r
+\r
+    // Retrieve individual fields of orgAuthority records.\r
+\r
+    private String displayAllOrgAuthorities(OrgauthoritiesCommonList list) {\r
+        StringBuffer sb = new StringBuffer();\r
+            List<OrgauthoritiesCommonList.OrgauthorityListItem> orgAuthorities =\r
+                    list.getOrgauthorityListItem();\r
+            int i = 0;\r
+        for (OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority : orgAuthorities) {\r
+            sb.append("orgAuthority [" + i + "]" + "\n");\r
+            sb.append(displayOrgAuthorityDetails(orgAuthority));\r
+            i++;\r
+        }\r
+        return sb.toString();\r
+    }\r
+\r
+    private String displayOrgAuthorityDetails(\r
+        OrgauthoritiesCommonList.OrgauthorityListItem orgAuthority) {\r
+            StringBuffer sb = new StringBuffer();\r
+            sb.append("displayName=" + orgAuthority.getDisplayName() + "\n");\r
+            sb.append("vocabType=" + orgAuthority.getVocabType() + "\n");\r
+            // sb.append("csid=" + orgAuthority.getCsid() + "\n");\r
+            sb.append("URI=" + orgAuthority.getUri() + "\n");\r
+        return sb.toString();\r
+    }\r
+\r
+    // Retrieve individual fields of organization records.\r
+\r
+    private String displayAllOrganizations(OrganizationsCommonList list) {\r
+        StringBuffer sb = new StringBuffer();\r
+        List<OrganizationsCommonList.OrganizationListItem> items =\r
+                list.getOrganizationListItem();\r
+        int i = 0;\r
+        for (OrganizationsCommonList.OrganizationListItem item : items) {\r
+            sb.append("organization [" + i + "]" + "\n");\r
+            sb.append(displayOrganizationDetails(item));\r
+            i++;\r
+        }\r
+        return sb.toString();\r
+    }\r
+\r
+    private String displayOrganizationDetails(\r
+        OrganizationsCommonList.OrganizationListItem item) {\r
+            StringBuffer sb = new StringBuffer();\r
+            sb.append("csid=" + item.getCsid() + "\n");\r
+            sb.append("displayName=" + item.getDisplayName() + "\n");\r
+            // sb.append("URI=" + item.getUri() + "\n");\r
+        return sb.toString();\r
+    }\r
+\r
+    private Object extractPart(MultipartInput input, String label,\r
+        Class clazz) throws Exception {\r
+        Object obj = null;\r
+        for(InputPart part : input.getParts()){\r
+            String partLabel = part.getHeaders().getFirst("label");\r
+            if(label.equalsIgnoreCase(partLabel)){\r
+                String partStr = part.getBodyAsString();\r
+                if(logger.isDebugEnabled()){\r
+                    logger.debug("extracted part str=\n" + partStr);\r
+                }\r
+                obj = part.getBody(clazz, null);\r
+                if(logger.isDebugEnabled()){\r
+                    logger.debug("extracted part obj=\n", obj, clazz);\r
+                }\r
+                break;\r
+            }\r
+        }\r
+        return obj;\r
+    }\r
+\r
+    /**\r
+     * Returns an error message indicating that the status code returned by a\r
+     * specific call to a service does not fall within a set of valid status\r
+     * codes for that service.\r
+     *\r
+     * @param serviceRequestType  A type of service request (e.g. CREATE, DELETE).\r
+     *\r
+     * @param statusCode  The invalid status code that was returned in the response,\r
+     *                    from submitting that type of request to the service.\r
+     *\r
+     * @return An error message.\r
+     */\r
+    protected String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {\r
+        return "Status code '" + statusCode + "' in response is NOT within the expected set: " +\r
+                requestType.validStatusCodesAsString();\r
+    }\r
+\r
+    protected String extractId(ClientResponse<Response> res) {\r
+        MultivaluedMap<String, Object> mvm = res.getMetadata();\r
+        String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
+        if(logger.isDebugEnabled()){\r
+               logger.info("extractId:uri=" + uri);\r
+        }\r
+        String[] segments = uri.split("/");\r
+        String id = segments[segments.length - 1];\r
+        if(logger.isDebugEnabled()){\r
+               logger.debug("id=" + id);\r
+        }\r
+        return id;\r
+    }\r
+    \r
+    protected String createRefName(String displayName) {\r
+       return displayName.replaceAll("\\W", "");\r
+    }\r
+\r
+       public static void main(String[] args) {\r
+\r
+        // Configure logging.\r
+               BasicConfigurator.configure();\r
+\r
+        logger.info("OrgAuthority Sample starting...");\r
+\r
+               Sample vbi = new Sample();\r
+        OrgauthoritiesCommonList orgAuthorities;\r
+        List<String> orgAuthIds;\r
+        String details = "";\r
+\r
+        // Optionally delete all orgAuthorities and organizations.\r
+\r
+        boolean ENABLE_DELETE_ALL = false;\r
+        if (ENABLE_DELETE_ALL) {\r
+\r
+            logger.info("Deleting all organizations and orgAuthorities ...");\r
+\r
+            // For each orgAuthority ...\r
+            orgAuthorities = vbi.readOrgAuthorities();\r
+            orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+            for (String orgAuthId : orgAuthIds) {\r
+                logger.info("Deleting all organizations for orgAuthority ...");\r
+                vbi.deleteAllItemsForOrgAuth(orgAuthId);\r
+                logger.info("Deleting orgAuthority ...");\r
+                vbi.deleteOrgAuthority(orgAuthId);\r
+            }\r
+\r
+            logger.info("Reading orgAuthorities after deletion ...");\r
+            orgAuthorities = vbi.readOrgAuthorities();\r
+            details = vbi.displayAllOrgAuthorities(orgAuthorities);\r
+            logger.info(details);\r
+\r
+            logger.info("Reading items in each orgAuthority after deletion ...");\r
+            orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+            for (String orgAuthId : orgAuthIds) {\r
+                OrganizationsCommonList items = vbi.readItemsInOrgAuth(orgAuthId);\r
+                details = vbi.displayAllOrganizations(items);\r
+                logger.info(details);\r
+            }\r
+\r
+        }\r
+\r
+        // Create new authorities, each populated with organizations.\r
+\r
+                               /*\r
+               final String acquisitionMethodsVocabName = "Acquisition Methods";\r
+               final String entryMethodsVocabName = "Entry Methods";\r
+               final String entryReasonsVocabName = "Entry Reasons";\r
+               final String responsibleDeptsVocabName = "Responsible Departments";\r
+\r
+               List<String> acquisitionMethodsEnumValues = \r
+                       Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");\r
+               List<String> entryMethodsEnumValues = \r
+                       Arrays.asList("In person","Post","Found on doorstep");\r
+               List<String> entryReasonsEnumValues = \r
+                       Arrays.asList("Enquiry","Commission","Loan");\r
+               List<String> respDeptNamesEnumValues = \r
+                       Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",\r
+                                                                       "Ethnography","Herpetology","Media and Performance Art",\r
+                                                                       "Paintings and Sculpture","Paleobotany","Photographs",\r
+                                                                       "Prints and Drawings");\r
+        \r
+               vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);\r
+               vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);\r
+               vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);\r
+               vbi.createEnumeration(responsibleDeptsVocabName, respDeptNamesEnumValues);\r
+               */\r
+\r
+               logger.info("OrgAuthority Sample complete.");\r
+\r
+        logger.info("Reading orgAuthorities and items ...");\r
+        // Get a list of orgAuthorities.\r
+        orgAuthorities = vbi.readOrgAuthorities();\r
+        // For each orgAuthority ...\r
+        for (OrgauthoritiesCommonList.OrgauthorityListItem\r
+            orgAuthority : orgAuthorities.getOrgauthorityListItem()) {\r
+            // Get its display name.\r
+            logger.info(orgAuthority.getDisplayName());\r
+            // Get a list of the organizations in this orgAuthority.\r
+            OrganizationsCommonList items =\r
+                vbi.readItemsInOrgAuth(orgAuthority.getCsid());\r
+            // For each organization ...\r
+            for (OrganizationsCommonList.OrganizationListItem\r
+                item : items.getOrganizationListItem()) {\r
+                // Get its display name.\r
+                logger.info(" " + item.getDisplayName());\r
+            }\r
+        }\r
+\r
+        // Sample alternate methods of reading all orgAuthorities and\r
+        // organizations separately.\r
+        boolean RUN_ADDITIONAL_SAMPLES = false;\r
+        if (RUN_ADDITIONAL_SAMPLES) {\r
+\r
+            logger.info("Reading all orgAuthorities ...");\r
+            details = vbi.displayAllOrgAuthorities(orgAuthorities);\r
+            logger.info(details);\r
+\r
+            logger.info("Reading all organizations ...");\r
+            orgAuthIds = vbi.readOrgAuthorityIds(orgAuthorities);\r
+            for (String orgAuthId : orgAuthIds) {\r
+                OrganizationsCommonList items = vbi.readItemsInOrgAuth(orgAuthId);\r
+                details = vbi.displayAllOrganizations(items);\r
+                logger.info(details);\r
+            }\r
+\r
+        }\r
+\r
+       }\r
+\r
+}\r
diff --git a/services/organization/sample/sample/src/main/resources/collectionspace-client.properties b/services/organization/sample/sample/src/main/resources/collectionspace-client.properties
new file mode 100644 (file)
index 0000000..429b9f6
--- /dev/null
@@ -0,0 +1,6 @@
+#url of the collectionspace server\r
+cspace.url=http://localhost:8180/cspace-services/\r
+cspace.ssl=false\r
+cspace.auth=false\r
+cspace.user=test\r
+cspace.password=test
\ No newline at end of file
diff --git a/services/organization/sample/sample/src/main/resources/log4j.xml b/services/organization/sample/sample/src/main/resources/log4j.xml
new file mode 100644 (file)
index 0000000..2e9dd00
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">\r
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">\r
+\r
+       <appender name="console" class="org.apache.log4j.ConsoleAppender">\r
+               <param name="Target" value="System.out" />\r
+               <layout class="org.apache.log4j.TTCCLayout">\r
+                       <param name="DateFormat" value="ISO8601" />\r
+               </layout>\r
+       </appender>\r
+\r
+       <logger name="org.apache.commons.httpclient" additivity="false">\r
+               <level value="warn" />\r
+               <appender-ref ref="console" />\r
+       </logger>\r
+\r
+       <logger name="httpclient.wire" additivity="false">\r
+               <level value="info" />\r
+               <appender-ref ref="console" />\r
+       </logger>\r
+\r
+<!--\r
+       <logger name="org.collectionspace.services.organization.client.sample.Sample" additivity="false">\r
+               <level value="debug" />\r
+               <appender-ref ref="console" />\r
+       </logger>\r
+-->\r
+\r
+       <root>\r
+               <priority value="debug" />\r
+               <appender-ref ref="console" />\r
+       </root>\r
+\r
+</log4j:configuration>\r
+\r
+\r
+\r
+\r
diff --git a/services/organization/service/.classpath b/services/organization/service/.classpath
new file mode 100644 (file)
index 0000000..425cd16
--- /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 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/JavaSE-1.6"/>\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/services/organization/service/.project b/services/organization/service/.project
new file mode 100644 (file)
index 0000000..d7542a3
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.organization.service</name>\r
+       <comment></comment>\r
+       <projects>\r
+               <project>org.collectionspace.services.common</project>\r
+               <project>org.collectionspace.services.organization.jaxb</project>\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.maven.ide.eclipse.maven2Nature</nature>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/organization/service/pom.xml b/services/organization/service/pom.xml
new file mode 100644 (file)
index 0000000..a307e2a
--- /dev/null
@@ -0,0 +1,154 @@
+<?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
+    <parent>\r
+        <artifactId>org.collectionspace.services.organization</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>1.0</version>\r
+    </parent>\r
+    \r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.organization.service</artifactId>\r
+    <packaging>jar</packaging>\r
+    <version>1.0</version>\r
+    <name>services.organization.service</name>\r
+\r
+    <dependencies>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.common</artifactId>\r
+            <version>1.0</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.organization.jaxb</artifactId>\r
+            <version>1.0</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>junit</groupId>\r
+            <artifactId>junit</artifactId>\r
+            <version>4.1</version>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.testng</groupId>\r
+            <artifactId>testng</artifactId>\r
+            <version>5.6</version>\r
+        </dependency>\r
+        \r
+        <!-- apache -->\r
+        <dependency>\r
+            <groupId>commons-beanutils</groupId>\r
+            <artifactId>commons-beanutils</artifactId>\r
+            <version>1.6.1</version>\r
+        </dependency>\r
+        <!-- use explict 1.1 version to prevent errors coming from Nuxeo client -->\r
+        <dependency>\r
+            <groupId>commons-logging</groupId>\r
+            <artifactId>commons-logging</artifactId>\r
+            <version>1.1</version>\r
+        </dependency>\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
+        <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
+        \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
+        <dependency>\r
+            <groupId>org.restlet</groupId>\r
+            <artifactId>org.restlet</artifactId>\r
+            <version>1.0.7</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>com.noelios.restlet</groupId>\r
+            <artifactId>com.noelios.restlet.ext.httpclient</artifactId>\r
+            <version>1.0.7</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>com.noelios.restlet</groupId>\r
+            <artifactId>com.noelios.restlet</artifactId>\r
+            <version>1.0.7</version>\r
+        </dependency>\r
+\r
+    </dependencies>\r
+    \r
+    <build>\r
+        <finalName>collectionspace-services-organization</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
+            </plugin>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+</project>\r
+\r
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java
new file mode 100644 (file)
index 0000000..4f8ddb8
--- /dev/null
@@ -0,0 +1,524 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization;
+
+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.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.collectionspace.services.common.AbstractCollectionSpaceResource;
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentNotFoundException;
+import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.organization.nuxeo.OrgAuthorityHandlerFactory;
+import org.collectionspace.services.organization.nuxeo.OrganizationDocumentModelHandler;
+import org.collectionspace.services.organization.nuxeo.OrganizationHandlerFactory;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.util.HttpResponseCodes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/orgauthorities")
+@Consumes("multipart/mixed")
+@Produces("multipart/mixed")
+public class OrgAuthorityResource extends AbstractCollectionSpaceResource {
+
+    private final static String orgAuthorityServiceName = "orgauthorities";
+    private final static String organizationServiceName = "organizations";
+    final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
+    //FIXME retrieve client type from configuration
+    final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+    public OrgAuthorityResource() {
+        // do nothing
+    }
+
+    @Override
+    public String getServiceName() {
+        return orgAuthorityServiceName;
+    }
+
+    public String getItemServiceName() {
+        return organizationServiceName;
+    }
+
+    /*
+    public RemoteServiceContext createItemServiceContext(MultipartInput input) throws Exception {
+    RemoteServiceContext ctx = new RemoteServiceContextImpl(getItemServiceName());
+    ctx.setInput(input);
+    return ctx;
+    }
+     */
+    @Override
+    public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+        DocumentHandler docHandler = OrgAuthorityHandlerFactory.getInstance().getHandler(
+                ctx.getRepositoryClientType().toString());
+        docHandler.setServiceContext(ctx);
+        if (ctx.getInput() != null) {
+            Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), OrgauthoritiesCommon.class);
+            if (obj != null) {
+                docHandler.setCommonPart((OrgauthoritiesCommon) obj);
+            }
+        }
+        return docHandler;
+    }
+
+    private DocumentHandler createItemDocumentHandler(
+            ServiceContext ctx,
+            String inOrgAuthority) throws Exception {
+        DocumentHandler docHandler = OrganizationHandlerFactory.getInstance().getHandler(
+                ctx.getRepositoryClientType().toString());
+        docHandler.setServiceContext(ctx);
+        ((OrganizationDocumentModelHandler) docHandler).setInOrgAuthority(inOrgAuthority);
+        if (ctx.getInput() != null) {
+            Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(getItemServiceName()),
+                    OrganizationsCommon.class);
+            if (obj != null) {
+                docHandler.setCommonPart((OrganizationsCommon) obj);
+            }
+        }
+        return docHandler;
+    }
+
+    @POST
+    public Response createOrgAuthority(MultipartInput input) {
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+            DocumentHandler handler = createDocumentHandler(ctx);
+            String csid = getRepositoryClient(ctx).create(ctx, handler);
+            //orgAuthorityObject.setCsid(csid);
+            UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
+            path.path("" + csid);
+            Response response = Response.created(path.build()).build();
+            return response;
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in createOrgAuthority", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+    }
+
+    @GET
+    @Path("{csid}")
+    public MultipartOutput getOrgAuthority(@PathParam("csid") String csid) {
+        String idValue = null;
+        if (csid == null) {
+            logger.error("getOrgAuthority: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "get failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (logger.isDebugEnabled()) {
+            logger.debug("getOrgAuthority with path(id)=" + csid);
+        }
+        MultipartOutput result = null;
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+            DocumentHandler handler = createDocumentHandler(ctx);
+            getRepositoryClient(ctx).get(ctx, csid, handler);
+            result = (MultipartOutput) ctx.getOutput();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("getOrgAuthority", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("getOrgAuthority", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (result == null) {
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed, the requested OrgAuthority CSID:" + csid + ": was not found.").type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return result;
+    }
+
+    @GET
+    @Produces("application/xml")
+    public OrgauthoritiesCommonList getOrgAuthorityList(@Context UriInfo ui) {
+        OrgauthoritiesCommonList orgAuthorityObjectList = new OrgauthoritiesCommonList();
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+            DocumentHandler handler = createDocumentHandler(ctx);
+            DocumentFilter myFilter =
+                    DocumentFilter.CreatePaginatedDocumentFilter(queryParams);
+            String nameQ = queryParams.getFirst("refName");
+            if (nameQ != null) {
+                myFilter.setWhereClause("orgauthorities_common:refName='" + nameQ + "'");
+            }
+            handler.setDocumentFilter(myFilter);
+            getRepositoryClient(ctx).getFiltered(ctx, handler);
+            orgAuthorityObjectList = (OrgauthoritiesCommonList) handler.getCommonPartList();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in getOrgAuthorityList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return orgAuthorityObjectList;
+    }
+
+    @PUT
+    @Path("{csid}")
+    public MultipartOutput updateOrgAuthority(
+            @PathParam("csid") String csid,
+            MultipartInput theUpdate) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("updateOrgAuthority with csid=" + csid);
+        }
+        if (csid == null || "".equals(csid)) {
+            logger.error("updateOrgAuthority: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "update failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        MultipartOutput result = null;
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+            DocumentHandler handler = createDocumentHandler(ctx);
+            getRepositoryClient(ctx).update(ctx, csid, handler);
+            result = (MultipartOutput) ctx.getOutput();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("caugth exception in updateOrgAuthority", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Update failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return result;
+    }
+
+    @DELETE
+    @Path("{csid}")
+    public Response deleteOrgAuthority(@PathParam("csid") String csid) {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("deleteOrgAuthority with csid=" + csid);
+        }
+        if (csid == null || "".equals(csid)) {
+            logger.error("deleteOrgAuthority: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "delete failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+            getRepositoryClient(ctx).delete(ctx, csid);
+            return Response.status(HttpResponseCodes.SC_OK).build();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("caught exception in deleteOrgAuthority", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Delete failed on OrgAuthority csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+
+    }
+
+    /*************************************************************************
+     * Organization parts - this is a sub-resource of OrgAuthority
+     *************************************************************************/
+    @POST
+    @Path("{csid}/items")
+    public Response createOrganization(@PathParam("csid") String parentcsid, MultipartInput input) {
+        try {
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getItemServiceName());
+            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+            String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
+            UriBuilder path = UriBuilder.fromResource(OrgAuthorityResource.class);
+            path.path(parentcsid + "/items/" + itemcsid);
+            Response response = Response.created(path.build()).build();
+            return response;
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in createOrganization", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+    }
+
+    @GET
+    @Path("{csid}/items/{itemcsid}")
+    public MultipartOutput getOrganization(
+            @PathParam("csid") String parentcsid,
+            @PathParam("itemcsid") String itemcsid) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("getOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+        }
+        if (parentcsid == null || "".equals(parentcsid)) {
+            logger.error("getOrganization: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "get failed on Organization csid=" + parentcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (itemcsid == null || "".equals(itemcsid)) {
+            logger.error("getOrganization: missing itemcsid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "get failed on Organization itemcsid=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        MultipartOutput result = null;
+        try {
+            // Note that we have to create the service context for the Items, not the main service
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+            getRepositoryClient(ctx).get(ctx, itemcsid, handler);
+            // TODO should we assert that the item is in the passed orgAuthority?
+            result = (MultipartOutput) ctx.getOutput();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("getOrganization", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed on Organization csid=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("getOrganization", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (result == null) {
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed, the requested Organization CSID:" + itemcsid + ": was not found.").type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return result;
+    }
+
+    @GET
+    @Path("{csid}/items")
+    @Produces("application/xml")
+    public OrganizationsCommonList getOrganizationList(
+            @PathParam("csid") String parentcsid,
+            @Context UriInfo ui) {
+        OrganizationsCommonList organizationObjectList = new OrganizationsCommonList();
+        try {
+            // Note that docType defaults to the ServiceName, so we're fine with that.
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+            DocumentFilter myFilter =
+                DocumentFilter.CreatePaginatedDocumentFilter(queryParams);
+            myFilter.setWhereClause(
+                    "organizations_common:inOrgAuthority='" + parentcsid + "'");
+            handler.setDocumentFilter(myFilter);
+            getRepositoryClient(ctx).getFiltered(ctx, handler);
+            organizationObjectList = (OrganizationsCommonList) handler.getCommonPartList();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in getOrganizationList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return organizationObjectList;
+    }
+
+    @PUT
+    @Path("{csid}/items/{itemcsid}")
+    public MultipartOutput updateOrganization(
+            @PathParam("csid") String parentcsid,
+            @PathParam("itemcsid") String itemcsid,
+            MultipartInput theUpdate) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("updateOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+        }
+        if (parentcsid == null || "".equals(parentcsid)) {
+            logger.error("updateOrganization: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "update failed on Organization parentcsid=" + parentcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (itemcsid == null || "".equals(itemcsid)) {
+            logger.error("updateOrganization: missing itemcsid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "update failed on Organization=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        MultipartOutput result = null;
+        try {
+            // Note that we have to create the service context for the Items, not the main service
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getItemServiceName());
+            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+            getRepositoryClient(ctx).update(ctx, itemcsid, handler);
+            result = (MultipartOutput) ctx.getOutput();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("caugth exception in updateOrganization", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Update failed on Organization csid=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return result;
+    }
+
+    @DELETE
+    @Path("{csid}/items/{itemcsid}")
+    public Response deleteOrganization(
+            @PathParam("csid") String parentcsid,
+            @PathParam("itemcsid") String itemcsid) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("deleteOrganization with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+        }
+        if (parentcsid == null || "".equals(parentcsid)) {
+            logger.error("deleteOrganization: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "delete failed on Organization parentcsid=" + parentcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        if (itemcsid == null || "".equals(itemcsid)) {
+            logger.error("deleteOrganization: missing itemcsid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "delete failed on Organization=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        try {
+            // Note that we have to create the service context for the Items, not the main service
+            ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getItemServiceName());
+            getRepositoryClient(ctx).delete(ctx, itemcsid);
+            return Response.status(HttpResponseCodes.SC_OK).build();
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (DocumentNotFoundException dnfe) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("caught exception in deleteOrganization", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Delete failed on Organization itemcsid=" + itemcsid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+
+    }
+}
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityConstants.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityConstants.java
new file mode 100644 (file)
index 0000000..c21bbe9
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+/**
+ * OrgAuthorityConstants processes CollectionObject document
+ *
+ */
+public class OrgAuthorityConstants {
+
+    public final static String NUXEO_DOCTYPE = "OrgAuthority";
+    public final static String NUXEO_SCHEMA_NAME = "orgauthority";
+    public final static String NUXEO_DC_TITLE = "CollectionSpace-OrgAuthority";
+}
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityDocumentModelHandler.java
new file mode 100644 (file)
index 0000000..4be73cd
--- /dev/null
@@ -0,0 +1,150 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.collectionspace.services.OrgAuthorityJAXBSchema;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.organization.OrgauthoritiesCommon;
+import org.collectionspace.services.organization.OrgauthoritiesCommonList;
+import org.collectionspace.services.organization.OrgauthoritiesCommonList.OrgauthorityListItem;
+
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandler;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OrgAuthorityDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class OrgAuthorityDocumentModelHandler
+        extends RemoteDocumentModelHandler<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
+
+    private final Logger logger = LoggerFactory.getLogger(OrgAuthorityDocumentModelHandler.class);
+    /**
+     * orgAuthority is used to stash JAXB object to use when handle is called
+     * for Action.CREATE, Action.UPDATE or Action.GET
+     */
+    private OrgauthoritiesCommon orgAuthority;
+    /**
+     * orgAuthorityList is stashed when handle is called
+     * for ACTION.GET_ALL
+     */
+    private OrgauthoritiesCommonList orgAuthorityList;
+
+    @Override
+    public void prepare(Action action) throws Exception {
+        //no specific action needed
+    }
+
+    /**
+     * getCommonPart get associated orgAuthority
+     * @return
+     */
+    @Override
+    public OrgauthoritiesCommon getCommonPart() {
+        return orgAuthority;
+    }
+
+    /**
+     * setCommonPart set associated orgAuthority
+     * @param orgAuthority
+     */
+    @Override
+    public void setCommonPart(OrgauthoritiesCommon orgAuthority) {
+        this.orgAuthority = orgAuthority;
+    }
+
+    /**
+     * getCommonPartList get associated orgAuthority (for index/GET_ALL)
+     * @return
+     */
+    @Override
+    public OrgauthoritiesCommonList getCommonPartList() {
+        return orgAuthorityList;
+    }
+
+    @Override
+    public void setCommonPartList(OrgauthoritiesCommonList orgAuthorityList) {
+        this.orgAuthorityList = orgAuthorityList;
+    }
+
+    @Override
+    public OrgauthoritiesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+            throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void fillCommonPart(OrgauthoritiesCommon orgAuthorityObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public OrgauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
+
+        OrgauthoritiesCommonList coList = new OrgauthoritiesCommonList();
+        List<OrgauthoritiesCommonList.OrgauthorityListItem> list = coList.getOrgauthorityListItem();
+
+        //FIXME: iterating over a long list of documents is not a long term
+        //strategy...need to change to more efficient iterating in future
+        Iterator<DocumentModel> iter = docList.iterator();
+        while(iter.hasNext()){
+            DocumentModel docModel = iter.next();
+            OrgauthorityListItem ilistItem = new OrgauthorityListItem();
+            ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+                    OrgAuthorityJAXBSchema.DISPLAY_NAME));
+            ilistItem.setRefName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+                    OrgAuthorityJAXBSchema.REF_NAME));
+            ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+                    OrgAuthorityJAXBSchema.VOCAB_TYPE));
+            String id = NuxeoUtils.extractId(docModel.getPathAsString());
+            ilistItem.setUri(getServiceContextPath() + id);
+            ilistItem.setCsid(id);
+            list.add(ilistItem);
+        }
+
+        return coList;
+    }
+
+    /**
+     * getQProperty converts the given property to qualified schema property
+     * @param prop
+     * @return
+     */
+    @Override
+    public String getQProperty(String prop) {
+        return OrgAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+    }
+}
+
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityHandlerFactory.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrgAuthorityHandlerFactory.java
new file mode 100644 (file)
index 0000000..b85cec6
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentHandlerFactory;
+
+
+/**
+ * OrgAuthorityHandlerFactory creates handlers for organization based
+ * on type of Nuxeo client used
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class OrgAuthorityHandlerFactory implements DocumentHandlerFactory {
+
+    private static final OrgAuthorityHandlerFactory self = new OrgAuthorityHandlerFactory();
+
+    private OrgAuthorityHandlerFactory() {
+    }
+
+    public static OrgAuthorityHandlerFactory getInstance() {
+        return self;
+    }
+
+               @Override
+    public DocumentHandler getHandler(String clientType) {
+        if(ClientType.JAVA.toString().equals(clientType)){
+            return new OrgAuthorityDocumentModelHandler();
+        } 
+        throw new IllegalArgumentException("Not supported client=" + clientType);
+    }
+}
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationConstants.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationConstants.java
new file mode 100644 (file)
index 0000000..e292fcb
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+/**
+ * OrganizationConstants processes CollectionObject document
+ *
+ */
+public class OrganizationConstants {
+
+    public final static String NUXEO_DOCTYPE = "Organization";
+    public final static String NUXEO_SCHEMA_NAME = "organization";
+    public final static String NUXEO_DC_TITLE = "CollectionSpace-Organization";
+}
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java
new file mode 100644 (file)
index 0000000..4276f43
--- /dev/null
@@ -0,0 +1,178 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.collectionspace.services.OrganizationJAXBSchema;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandler;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.collectionspace.services.organization.OrganizationsCommon;
+import org.collectionspace.services.organization.OrganizationsCommonList;
+import org.collectionspace.services.organization.OrganizationsCommonList.OrganizationListItem;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OrganizationDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class OrganizationDocumentModelHandler
+        extends RemoteDocumentModelHandler<OrganizationsCommon, OrganizationsCommonList> {
+
+    private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class);
+    /**
+     * organization is used to stash JAXB object to use when handle is called
+     * for Action.CREATE, Action.UPDATE or Action.GET
+     */
+    private OrganizationsCommon organization;
+    /**
+     * organizationList is stashed when handle is called
+     * for ACTION.GET_ALL
+     */
+    private OrganizationsCommonList organizationList;
+    
+    /**
+     * inOrgAuthority is the parent OrgAuthority for this context
+     */
+    private String inOrgAuthority;
+
+    public String getInOrgAuthority() {
+               return inOrgAuthority;
+       }
+
+       public void setInOrgAuthority(String inOrgAuthority) {
+               this.inOrgAuthority = inOrgAuthority;
+       }
+
+       @Override
+    public void prepare(Action action) throws Exception {
+        //no specific action needed
+    }
+
+    /**
+     * getCommonPart get associated organization
+     * @return
+     */
+    @Override
+    public OrganizationsCommon getCommonPart() {
+        return organization;
+    }
+
+    /**
+     * setCommonPart set associated organization
+     * @param organization
+     */
+    @Override
+    public void setCommonPart(OrganizationsCommon organization) {
+        this.organization = organization;
+    }
+
+    /**
+     * getCommonPartList get associated organization (for index/GET_ALL)
+     * @return
+     */
+    @Override
+    public OrganizationsCommonList getCommonPartList() {
+        return organizationList;
+    }
+
+    @Override
+    public void setCommonPartList(OrganizationsCommonList organizationList) {
+        this.organizationList = organizationList;
+    }
+
+    @Override
+    public OrganizationsCommon extractCommonPart(DocumentWrapper wrapDoc)
+            throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void fillCommonPart(OrganizationsCommon organizationObject, DocumentWrapper wrapDoc) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public OrganizationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) 
+       throws Exception {
+        OrganizationsCommonList coList = new OrganizationsCommonList();
+        try{
+               DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
+       
+               List<OrganizationsCommonList.OrganizationListItem> list = 
+                       coList.getOrganizationListItem();
+       
+               //FIXME: iterating over a long list of documents is not a long term
+               //strategy...need to change to more efficient iterating in future
+               Iterator<DocumentModel> iter = docList.iterator();
+               while(iter.hasNext()){
+                   DocumentModel docModel = iter.next();
+                   OrganizationListItem ilistItem = new OrganizationListItem();
+                   ilistItem.setDisplayName(
+                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("organizations"),
+                                                                       OrganizationJAXBSchema.DISPLAY_NAME));
+                   ilistItem.setRefName(
+                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("organizations"),
+                                                                       OrganizationJAXBSchema.REF_NAME));
+                                                       /*
+                                                        * These are not currently included in the listing - only in the details
+                   ilistItem.setLongName(
+                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("organizations"),
+                                                                       OrganizationJAXBSchema.LONG_NAME));
+                   ilistItem.setDescription(
+                                                                       (String) docModel.getProperty(getServiceContext().getCommonPartLabel("organizations"),
+                                                                       OrganizationJAXBSchema.DESCRIPTION));
+                                                        */
+                                                       String id = NuxeoUtils.extractId(docModel.getPathAsString());
+                   ilistItem.setUri("/organizations/"+inOrgAuthority+"/items/" + id);
+                   ilistItem.setCsid(id);
+                   list.add(ilistItem);
+               }
+        }catch(Exception e){
+            if(logger.isDebugEnabled()){
+                logger.debug("Caught exception in extractCommonPartList", e);
+            }
+            throw e;
+        }
+        return coList;
+    }
+
+    /**
+     * getQProperty converts the given property to qualified schema property
+     * @param prop
+     * @return
+     */
+    @Override
+    public String getQProperty(String prop) {
+        return OrganizationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+    }
+}
+
diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationHandlerFactory.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationHandlerFactory.java
new file mode 100644 (file)
index 0000000..d756258
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.collectionspace.services.organization.nuxeo;
+
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentHandlerFactory;
+
+
+/**
+ * OrganizationHandlerFactory creates handlers for organization based
+ * on type of Nuxeo client used
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class OrganizationHandlerFactory implements DocumentHandlerFactory {
+
+    private static final OrganizationHandlerFactory self = new OrganizationHandlerFactory();
+
+    private OrganizationHandlerFactory() {
+    }
+
+    public static OrganizationHandlerFactory getInstance() {
+        return self;
+    }
+
+               @Override
+    public DocumentHandler getHandler(String clientType) {
+        if(ClientType.JAVA.toString().equals(clientType)){
+            return new OrganizationDocumentModelHandler();
+        } 
+        throw new IllegalArgumentException("Not supported client=" + clientType);
+    }
+}