]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1292: Initial release of the Loan Out (aka Loans Out) service. Introduces...
authorAron Roberts <aron@socrates.berkeley.edu>
Sat, 17 Apr 2010 00:10:02 +0000 (00:10 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Sat, 17 Apr 2010 00:10:02 +0000 (00:10 +0000)
34 files changed:
services/JaxRsServiceProvider/pom.xml
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java
services/common/src/main/config/services/tenant-bindings.xml
services/loanout/3rdparty/build.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/build.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/pom.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/META-INF/MANIFEST.MF [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/core-types-contrib.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/deployment-fragment.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/ecm-types-contrib.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/layouts-contrib.xml [new file with mode: 0644]
services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd [new file with mode: 0644]
services/loanout/3rdparty/pom.xml [new file with mode: 0644]
services/loanout/build.xml [new file with mode: 0644]
services/loanout/client/pom.xml [new file with mode: 0644]
services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java [new file with mode: 0644]
services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java [new file with mode: 0644]
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java [new file with mode: 0644]
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java [new file with mode: 0644]
services/loanout/client/src/test/resources/log4j.properties [new file with mode: 0644]
services/loanout/jaxb/pom.xml [new file with mode: 0644]
services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutJAXBSchema.java [new file with mode: 0644]
services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutListItemJAXBSchema.java [new file with mode: 0644]
services/loanout/jaxb/src/main/resources/loansout-common.xsd [new file with mode: 0644]
services/loanout/pom.xml [new file with mode: 0644]
services/loanout/service/pom.xml [new file with mode: 0644]
services/loanout/service/profiles.xml [new file with mode: 0644]
services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java [new file with mode: 0644]
services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutConstants.java [new file with mode: 0644]
services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java [new file with mode: 0644]
services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutValidatorHandler.java [new file with mode: 0644]
services/loanout/service/src/test/java/org/collectionspace/services/test/LoanoutServiceTest.java [new file with mode: 0644]
services/loanout/service/src/test/resources/log4j.xml [new file with mode: 0644]
services/pom.xml

index cc0e8e7be010bd88eedee87c1bfe0a3bf571bb7c..f4e4f6ab7f816afbb79c24bbd7b46ed42377dda3 100644 (file)
             <artifactId>org.collectionspace.services.loanin.service</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.loanout.service</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.dimension.service</artifactId>\r
index 10c7b755446b6fe740696c31390a2e91d2dd209d..3bf763ec3cc71f912d5a60c2de8df09a458d2f3b 100644 (file)
@@ -27,6 +27,7 @@ import org.collectionspace.services.collectionobject.CollectionObjectResource;
 import org.collectionspace.services.id.IDResource;
 import org.collectionspace.services.intake.IntakeResource;
 import org.collectionspace.services.loanin.LoaninResource;
+import org.collectionspace.services.loanout.LoanoutResource;
 import org.collectionspace.services.relation.NewRelationResource;
 import org.collectionspace.services.acquisition.AcquisitionResource;
 import org.collectionspace.services.dimension.DimensionResource;
@@ -67,6 +68,7 @@ public class CollectionSpaceJaxRsApplication extends Application {
         singletons.add(new IDResource());
         singletons.add(new IntakeResource());
         singletons.add(new LoaninResource());
+        singletons.add(new LoanoutResource());
         singletons.add(new AcquisitionResource());
         singletons.add(new NewRelationResource());
         singletons.add(new VocabularyResource());
index a2e82ac476235f8ba54fa8d4d309df21d2ae2624..7660a6a3a43d685687efa67f3661df26ef36ff06 100644 (file)
             </service:object>
         </tenant:serviceBindings>
         <!-- end loanin service meta-data -->
+        <!-- begin loanout service meta-data -->
+        <tenant:serviceBindings name="Loansout" type="procedure" version="0.1">
+            <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
+                nuxeo-java
+            </service:repositoryClient>
+            <service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
+                org.collectionspace.services.loanout.nuxeo.LoanoutDocumentModelHandler
+            </service:documentHandler>
+            <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+                org.collectionspace.services.loanout.nuxeo.LoanoutValidatorHandler
+            </service:validatorHandler>
+            <service:object name="Loanout" version="0.1"
+                            xmlns:service='http://collectionspace.org/services/common/service'>
+                <service:part id="0" control_group="Managed"
+                              versionable="true" auditable="false"
+                              label="loansout-system" updated="" order="0">
+                    <service:content contentType="application/xml">
+                        <service:xmlContent
+                            namespaceURI="http://collectionspace.org/services/common/system"
+                            schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd">
+                        </service:xmlContent>
+                    </service:content>
+                </service:part>
+                <service:part id="1" control_group="Managed"
+                              versionable="true" auditable="false"
+                              label="loansout_common" updated="" order="1">
+                    <service:properties>
+                        <types:item><types:key>authRef</types:key><types:value>borrower</types:value></types:item>
+                        <types:item><types:key>authRef</types:key><types:value>borrowersContact</types:value></types:item>
+                        <types:item><types:key>authRef</types:key><types:value>lendersAuthorizer</types:value></types:item>
+                        <types:item><types:key>authRef</types:key><types:value>lendersContact</types:value></types:item>
+                    </service:properties>
+                    <service:content contentType="application/xml">
+                        <service:xmlContent
+                            namespaceURI="http://collectionspace.org/services/loanout"
+                            schemaLocation="http://collectionspace.org/services/loanout http://services.collectionspace.org/loanout/loansout_common.xsd">
+                        </service:xmlContent>
+                    </service:content>
+                </service:part>
+            </service:object>
+        </tenant:serviceBindings>
+        <!-- end loanout service meta-data -->
         <!-- begin vocabulary service meta-data -->
         <tenant:serviceBindings name="Vocabularies" version="0.1">
             <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
diff --git a/services/loanout/3rdparty/build.xml b/services/loanout/3rdparty/build.xml
new file mode 100644 (file)
index 0000000..4a351d9
--- /dev/null
@@ -0,0 +1,127 @@
+
+<project name="loanout.3rdparty" default="package" basedir=".">
+    <description>
+        loanout service 3rdparty
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../../.."/>
+    <!-- environment 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"/>
+
+    <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="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 loanout in ${jboss.server.nuxeo}">
+        <ant antfile="nuxeo-platform-cs-loanout/build.xml" target="deploy" inheritall="false"/>
+    </target>
+
+    <target name="undeploy"
+    description="undeploy loanout from ${jboss.server.nuxeo}">
+        <ant antfile="nuxeo-platform-cs-loanout/build.xml" target="undeploy" inheritall="false"/>
+    </target>
+
+    <target name="dist"
+    description="generate distribution for loanout" depends="package">
+        <ant antfile="nuxeo-platform-cs-loanout/build.xml" target="dist" inheritall="false"/>
+    </target>
+
+
+</project>
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/build.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/build.xml
new file mode 100644 (file)
index 0000000..faa7237
--- /dev/null
@@ -0,0 +1,132 @@
+
+<project name="nuxeo-platform-cs-loanout" default="package" basedir=".">
+    <description>
+        loanout 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.loanout.jar" value="org.collectionspace.services.loanout.3rdparty.nuxeo-${cspace.release}.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="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 loanout doctype in ${jboss.server.nuxeo}">
+        <copy file="${basedir}/target/${nuxeo.loanout.jar}"
+        todir="${jboss.deploy.nuxeo.system}"/>
+    </target>
+
+    <target name="undeploy"
+    description="undeploy loanout doctype from ${jboss.server.nuxeo}">
+        <delete file="${jboss.deploy.nuxeo.system}/${nuxeo.loanout.jar}"/>
+    </target>
+
+
+    <target name="dist"
+    description="generate distribution for loanout doctype" depends="package">
+        <copy todir="${services.trunk}/${dist.deploy.nuxeo.system}">
+            <fileset file="${basedir}/target/${nuxeo.loanout.jar}"/>
+        </copy>
+    </target>
+
+</project>
+
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/pom.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/pom.xml
new file mode 100644 (file)
index 0000000..4b2800b
--- /dev/null
@@ -0,0 +1,38 @@
+<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>org.collectionspace.services.loanout.3rdparty</artifactId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout.3rdparty.nuxeo</artifactId>
+    <name>services.loanout.3rdparty.nuxeo</name>
+    <packaging>jar</packaging>
+    <description>
+        Loanout Nuxeo Document Type
+    </description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestFile> src/main/resources/META-INF/MANIFEST.MF </manifestFile>
+                        <manifestEntries>
+                            <Bundle-Version>${eclipseVersion}</Bundle-Version>
+                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
+                        </manifestEntries>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/META-INF/MANIFEST.MF b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..69f1fdf
--- /dev/null
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0 \r
+Bundle-ManifestVersion: 1 \r
+Bundle-Name: NuxeoCS\r
+Bundle-SymbolicName: org.collectionspace.loanout;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.loanout\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/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/core-types-contrib.xml
new file mode 100644 (file)
index 0000000..4d4171b
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.loanout.coreTypes">
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+    <schema name="loansout_common" prefix="loansout_common" src="schemas/loansout_common.xsd"/>
+  </extension>
+  <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+    <doctype name="Loanout" extends="Document">
+      <schema name="common"/>
+      <schema name="dublincore"/>
+      <schema name="loansout_common"/>
+    </doctype>
+  </extension>
+</component>
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/deployment-fragment.xml
new file mode 100644 (file)
index 0000000..88b94ff
--- /dev/null
@@ -0,0 +1,408 @@
+<?xml version="1.0"?>
+<fragment>
+
+  <extension target="application#MODULE">
+    <module>
+      <ejb>${bundle.fileName}</ejb>
+    </module>
+
+    <module>
+      <web>
+        <web-uri>nuxeo.war</web-uri>
+        <context-root>/nuxeo</context-root>
+      </web>
+    </module>
+  </extension>
+
+  <!-- uncomment that to enable tomcat based auth
+    <extension target="web#LOGIN-CONFIG">
+    <login-config>
+    <auth-method>FORM</auth-method>
+    <realm-name>nuxeo.ecm</realm-name>
+    <form-login-config>
+    <form-login-page>/login.jsp</form-login-page>
+    <form-error-page>/login.jsp?loginFailed=true</form-error-page>
+    </form-login-config>
+    </login-config>
+    </extension>
+  -->
+
+  <extension target="web#FILTER-MAPPING">
+
+    <!-- Seam Context Filter is declared in org.nuxeo.ecm.platform.ui.web
+      deployment fragment -->
+
+    <filter-mapping>
+      <filter-name>Seam Context Filter</filter-name>
+      <url-pattern>/ws/FileManageWS</url-pattern>
+    </filter-mapping>
+
+    <filter-mapping>
+      <filter-name>Seam Context Filter</filter-name>
+      <url-pattern>/DocumentManagerWS</url-pattern>
+    </filter-mapping>
+  </extension>
+
+  <extension target="web#SERVLET">
+  </extension>
+
+  <extension target="web#SERVLET-MAPPING">
+  </extension>
+
+  <extension target="pages#PAGES">
+    <!-- This calls a method which load the Workspace logo -->
+    <page view-id="/showLogo.xhtml" action="#{logoHelper.getLogo}"/>
+
+    <!-- Bind URL to the Document URL resolver-->
+    <page view-id="/getDocument.xhtml"
+        action="#{navigationContext.navigateToURL}">
+    </page>
+
+    <page view-id="/nxliveedit.xhtml" action="#{liveEditHelper.getBootstrap()}"/>
+
+    <!-- Bind URL to the Parallele conversation Document URL resolver-->
+    <page view-id="/parallele.xhtml"
+        action="#{paralleleNavigationHelper.navigateToURL}">
+    </page>
+
+    <!-- Post login and 'home' view handler -->
+    <page view-id="/nxstartup.xhtml"
+        action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'view')}"/>
+
+    <!-- To redirect to the user dashboard instead, use instead:
+
+      <page view-id="/nxstartup.xhtml"
+      action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'user_dashboard')}" />
+    -->
+
+    <!--  config for workspace management
+      = give a description for each viewId
+    -->
+
+    <page view-id="/view_domains.xhtml">
+      #{currentServerLocation.name}/#{currentTabAction.label}
+    </page>
+
+    <page view-id="/select_document_type.faces.xhtml">
+      Create new document in #{currentDocument.name}
+    </page>
+
+    <page view-id="/create_document.faces.xhtml">
+      Create new document in #{currentDocument.name}
+    </page>
+
+    <page view-id="/user_dashboard.xhtml">
+      breadcrumb=command.user_dashboard
+    </page>
+
+    <page view-id="/view_users.xhtml">
+      breadcrumb=command.manageMembers
+    </page>
+
+    <page view-id="/view_many_users.xhtml">
+      breadcrumb=command.manageMembers
+    </page>
+
+    <page view-id="/view_vocabularies.xhtml">
+      breadcrumb=title.vocabularies
+    </page>
+
+    <page view-id="/search/search_form.xhtml">
+      breadcrumb=command.advancedSearch
+    </page>
+  </extension>
+
+  <extension target="faces-config#APPLICATION">
+    <locale-config>
+      <default-locale>en</default-locale>
+      <supported-locale>en_GB</supported-locale>
+      <supported-locale>en_US</supported-locale>
+      <supported-locale>fr</supported-locale>
+      <supported-locale>de</supported-locale>
+      <supported-locale>es</supported-locale>
+      <supported-locale>it</supported-locale>
+      <supported-locale>ar</supported-locale>
+      <supported-locale>ru</supported-locale>
+      <supported-locale>ja</supported-locale>
+      <supported-locale>vn</supported-locale>
+    </locale-config>
+
+    <message-bundle>messages</message-bundle>
+  </extension>
+
+  <extension target="components#PAGEFLOW">
+    <value>config/addWorkspace.jpdl.xml</value>
+  </extension>
+
+  <extension target="faces-config#NAVIGATION">
+    <!-- generic pages -->
+    <navigation-case>
+      <from-outcome>generic_error_page</from-outcome>
+      <to-view-id>/generic_error_page.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>generic_message_page</from-outcome>
+      <to-view-id>/generic_message_page.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>home</from-outcome>
+      <to-view-id>/nxstartup.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_login</from-outcome>
+      <to-view-id>/login.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_logout</from-outcome>
+      <to-view-id>/logout.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_servers</from-outcome>
+      <to-view-id>/view_servers.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- pages for document actions -->
+
+    <navigation-case>
+      <from-outcome>view_domains</from-outcome>
+      <to-view-id>/view_domains.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>select_document_type</from-outcome>
+      <to-view-id>/select_document_type.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_document</from-outcome>
+      <to-view-id>/create_document.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_document</from-outcome>
+      <to-view-id>/edit_document.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_documents</from-outcome>
+      <to-view-id>/view_documents.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_file</from-outcome>
+      <to-view-id>/create_file.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_workspace_wizard</from-outcome>
+      <to-view-id>/createWorkspaceWizard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>send_email</from-outcome>
+      <to-view-id>/document_email.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use view_documents instead -->
+    <navigation-case>
+      <from-outcome>view_workspaces</from-outcome>
+      <to-view-id>/view_workspaces.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use create_document instead -->
+    <navigation-case>
+      <from-outcome>create_domain</from-outcome>
+      <to-view-id>/create_domain.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use edit_document instead -->
+    <navigation-case>
+      <from-outcome>edit_domain</from-outcome>
+      <to-view-id>/edit_domain.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use create_document instead -->
+    <navigation-case>
+      <from-outcome>create_workspace</from-outcome>
+      <to-view-id>/create_workspace.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- AT: BBB, use edit_document instead -->
+    <navigation-case>
+      <from-outcome>edit_workspace</from-outcome>
+      <to-view-id>/edit_workspace.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- users ang groups -->
+
+    <navigation-case>
+      <from-outcome>members_management</from-outcome>
+      <to-view-id>/members_management.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_users</from-outcome>
+      <to-view-id>/view_users.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_many_users</from-outcome>
+      <to-view-id>/view_many_users.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_user</from-outcome>
+      <to-view-id>/edit_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_user_password</from-outcome>
+      <to-view-id>/edit_user_password.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_user</from-outcome>
+      <to-view-id>/view_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_user</from-outcome>
+      <to-view-id>/create_user.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_groups</from-outcome>
+      <to-view-id>/view_groups.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_group</from-outcome>
+      <to-view-id>/view_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>edit_group</from-outcome>
+      <to-view-id>/edit_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>create_group</from-outcome>
+      <to-view-id>/create_group.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_vocabularies</from-outcome>
+      <to-view-id>/view_vocabularies.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>view_vocabulary</from-outcome>
+      <to-view-id>/view_vocabulary.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- search -->
+
+    <navigation-case>
+      <from-outcome>search_form</from-outcome>
+      <to-view-id>/search/search_form.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_nxql</from-outcome>
+      <to-view-id>/search/search_results_nxql.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_advanced</from-outcome>
+      <to-view-id>
+        /search/search_results_advanced.xhtml
+      </to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>search_results_simple</from-outcome>
+      <to-view-id>/search/search_results_simple.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <!-- miscellaneaous -->
+
+    <navigation-case>
+      <from-outcome>clipboard</from-outcome>
+      <to-view-id>/incl/clipboard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>user_dashboard</from-outcome>
+      <to-view-id>/user_dashboard.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>select_workspace_template</from-outcome>
+      <to-view-id>/select_workspace_template.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>pdf_generation_error</from-outcome>
+      <to-view-id>/pdf_generation_error.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>mass_edit</from-outcome>
+      <to-view-id>/massedit_documents.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+
+    <navigation-case>
+      <from-outcome>mass_edit_confirm</from-outcome>
+      <to-view-id>/massedit_documents_preview.xhtml</to-view-id>
+      <redirect/>
+    </navigation-case>
+  </extension>
+
+</fragment>
+
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/ecm-types-contrib.xml
new file mode 100644 (file)
index 0000000..3abdb6d
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<component name="org.collectionspace.loanout.ecm.types">
+  <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+    <type id="Loanout" coretype="Loanout">
+      <label>org.collectionspace.loanout</label>
+      <!--icon>/icons/file.gif</icon-->
+      <default-view>view_documents</default-view>
+
+      <layouts mode="any">
+        <layout>heading</layout>
+        <layout>loanout</layout>
+      </layouts>        
+    </type>
+
+    <type id="Folder" coretype="Folder">
+      <subtypes>
+        <type>Loanout</type>
+      </subtypes>
+    </type>
+    
+    <type id="Workspace" coretype="Workspace">
+      <subtypes>
+        <type>Loanout</type>
+      </subtypes>
+    </type>
+
+  </extension>
+</component>
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/OSGI-INF/layouts-contrib.xml
new file mode 100644 (file)
index 0000000..b8405c1
--- /dev/null
@@ -0,0 +1,212 @@
+<?xml version="1.0"?>
+
+<!--
+layouts-contrib.xml
+
+Layout file for configuring screen layouts in the
+user interface of Nuxeo EP's web application, for
+viewing or editing CollectionSpace records stored
+in the Nuxeo repository,
+
+See the "Nuxeo Book" for an introductory description
+of how to edit this file.  For instance, for Nuxeo EP 5.3:
+http://doc.nuxeo.org/5.3/books/nuxeo-book/html/
+
+$LastChangedRevision: $
+$LastChangedDate: $
+-->
+
+<component name="org.collectionspace.loanout.layouts.webapp">
+
+    <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+               point="layouts">
+
+        <layout name="loanout">
+            <templates>
+                <template mode="any">/layouts/layout_default_template.xhtml</template>
+            </templates>       
+            
+            <rows>
+                <row><widget>loanOutNumber</widget></row>
+                <row><widget>borrower</widget></row>
+                <row><widget>borrowersContact</widget></row>
+                <row><widget>lendersAuthorizer</widget></row>
+                <row><widget>lendersAuthorizationDate</widget></row>
+                <row><widget>lendersContact</widget></row>
+                
+                <!--
+                     Omitting loaned object status fields in release 0.5.2,
+                     as these are likely to be repeatable or else handled
+                     in some alternate way in release 0.7.
+                -->
+                <!-- <row><widget>loanedObjectStatus</widget></row> -->
+                <!-- <row><widget>loanedObjectStatusDate</widget></row> -->
+                <!-- <row><widget>loanedObjectStatusNote</widget></row> -->
+                
+                <row><widget>loanOutDate</widget></row>
+                <row><widget>loanReturnDate</widget></row>
+                <row><widget>loanRenewalApplicationDate</widget></row>
+                <row><widget>specialConditionsOfLoan</widget></row>
+                <row><widget>loanOutNote</widget></row>
+                <row><widget>loanPurpose</widget></row>
+            </rows>
+
+            <widget name="loanOutNumber" type="text">
+                <labels>
+                    <label mode="any">loanOutNumber</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanOutNumber</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="borrower" type="text">
+                <labels>
+                    <label mode="any">borrower</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">borrower</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+            
+            <widget name="borrowersContact" type="text">
+                <labels>
+                    <label mode="any">borrowersContact</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">borrowersContact</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="lendersAuthorizer" type="text">
+                <labels>
+                    <label mode="any">lendersAuthorizer</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">lendersAuthorizer</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="lendersAuthorizationDate" type="text">
+                <labels>
+                    <label mode="any">lendersAuthorizationDate</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">lendersAuthorizationDate</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="lendersContact" type="text">
+                <labels>
+                    <label mode="any">lendersContact</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">lendersContact</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="loanOutDate" type="text">
+                <labels>
+                    <label mode="any">loanOutDate</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanOutDate</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="loanReturnDate" type="text">
+                <labels>
+                    <label mode="any">loanReturnDate</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanReturnDate</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="loanRenewalApplicationDate" type="text">
+                <labels>
+                    <label mode="any">loanRenewalApplicationDate</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanRenewalApplicationDate</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="specialConditionsOfLoan" type="text">
+                <labels>
+                    <label mode="any">specialConditionsOfLoan</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">specialConditionsOfLoan</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+          </widget>
+
+          <widget name="loanOutNote" type="text">
+                <labels>
+                    <label mode="any">loanOutNote</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanOutNote</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+            <widget name="loanPurpose" type="text">
+                <labels>
+                    <label mode="any">loanPurpose</label>
+                </labels>
+                <translated>true</translated>
+                <fields>
+                    <field schema="loansout_common">loanPurpose</field>
+                </fields>
+                <properties widgetMode="edit">
+                    <property name="styleClass">dataInputText</property>
+                </properties>
+            </widget>
+
+        </layout>
+    </extension>
+</component>
diff --git a/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd b/services/loanout/3rdparty/nuxeo-platform-cs-loanout/src/main/resources/schemas/loansout_common.xsd
new file mode 100644 (file)
index 0000000..beca480
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
+\r
+<!--\r
+    Loan Out schema (XSD)\r
+    \r
+    Entity  : Loanout\r
+    Part    : Common\r
+    Used for: Nuxeo EP core document type\r
+\r
+    $LastChangedRevision: 1442 $\r
+    $LastChangedDate: 2010-02-25 14:22:30 -0800 (Thu, 25 Feb 2010) $\r
+-->\r
+\r
+<xs:schema \r
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+    xmlns:ns="http://collectionspace.org/loanout/"\r
+    xmlns="http://collectionspace.org/loanout/"\r
+    targetNamespace="http://collectionspace.org/loanout/"\r
+    version="0.1">\r
+    \r
+    <!-- See http://wiki.collectionspace.org/display/collectionspace/Loans+Out+Schema -->\r
+\r
+    <!--  Loan Out Information Group -->\r
+    <xs:element name="loanOutNumber" type="xs:string"/>\r
+    <xs:element name="borrower" type="xs:string"/>\r
+    <xs:element name="borrowersContact" type="xs:string"/>\r
+    <xs:element name="lendersAuthorizer" type="xs:string"/>\r
+    <xs:element name="lendersAuthorizationDate" type="xs:string"/>\r
+    <xs:element name="lendersContact" type="xs:string"/>\r
+    \r
+    <!--\r
+         Omitting loaned object status fields in release 0.5.2,\r
+         as these are likely to be repeatable or else handled\r
+         in some alternate way in release 0.7.\r
+    -->\r
+    <!-- xs:element name="loanedObjectStatus" type="xs:string"/ -->\r
+    <!-- xs:element name="loanedObjectStatusDate" type="xs:string"/ -->\r
+    <!-- xs:element name="loanedObjectStatusNote" type="xs:string"/ -->\r
+    \r
+    <xs:element name="loanOutDate" type="xs:string"/>\r
+    <xs:element name="loanReturnDate" type="xs:string"/>\r
+    <xs:element name="loanRenewalApplicationDate" type="xs:string"/>\r
+    <xs:element name="specialConditionsOfLoan" type="xs:string"/>\r
+    <xs:element name="loanOutNote" type="xs:string"/>\r
+    <xs:element name="loanPurpose" type="xs:string"/>\r
+    \r
+</xs:schema>\r
diff --git a/services/loanout/3rdparty/pom.xml b/services/loanout/3rdparty/pom.xml
new file mode 100644 (file)
index 0000000..bdaa4e8
--- /dev/null
@@ -0,0 +1,24 @@
+
+<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.loanout</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout.3rdparty</artifactId>
+    <name>services.loanout.3rdparty</name>
+    <packaging>pom</packaging>
+    
+    <description>
+        3rd party build for loanout service
+    </description>
+
+    <modules>
+        <module>nuxeo-platform-cs-loanout</module>
+    </modules>
+</project>
diff --git a/services/loanout/build.xml b/services/loanout/build.xml
new file mode 100644 (file)
index 0000000..609b490
--- /dev/null
@@ -0,0 +1,124 @@
+
+<project name="loanout" default="package" basedir=".">
+    <description>
+        loanout service
+    </description>
+  <!-- set global properties for this build -->
+    <property name="services.trunk" value="../.."/>
+    <!-- environment 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"/>
+
+    <condition property="osfamily-unix">
+        <os family="unix" />
+    </condition>
+    <condition property="osfamily-windows">
+        <os family="windows" />
+    </condition>
+
+    <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="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 loanout service">
+        <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>
+    </target>
+
+    <target name="undeploy"
+    description="undeploy loanout service">
+        <ant antfile="3rdparty/build.xml" target="undeploy" inheritall="false"/>
+    </target>
+
+    <target name="dist" depends="package"
+    description="distribute loanout service">
+        <ant antfile="3rdparty/build.xml" target="dist" inheritall="false"/>
+    </target>
+
+</project>
diff --git a/services/loanout/client/pom.xml b/services/loanout/client/pom.xml
new file mode 100644 (file)
index 0000000..f2ebfe1
--- /dev/null
@@ -0,0 +1,115 @@
+<?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>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.loanout</artifactId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout.client</artifactId>
+    <name>services.loanout.client</name>
+    
+    <dependencies>
+        <!-- keep slf4j dependencies on the top -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+<!-- CollectionSpace dependencies -->
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <optional>true</optional>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+         <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.loanout.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.person.client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+<!-- External dependencies -->        
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <version>1.1.GA</version>
+            <!-- filter out unwanted jars -->
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+            <version>1.1.GA</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+            <version>1.1.GA</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-loanout-client</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>log4j.configuration</name>
+                            <value>file:target/test-classes/log4j.properties</value>
+                        </property>
+                    </systemProperties>
+                </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/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutClient.java
new file mode 100644 (file)
index 0000000..c78b27a
--- /dev/null
@@ -0,0 +1,145 @@
+/**    
+ * 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
+ */
+package org.collectionspace.services.client;
+
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+//import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.loanout.LoansoutCommonList;
+
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+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.spi.ResteasyProviderFactory;
+
+/**
+ * LoanoutClient.java
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ */
+public class LoanoutClient extends AbstractServiceClientImpl {
+
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
+     */
+    public String getServicePathComponent() {
+        return "loansout";
+    }
+    /**
+     *
+     */
+    private static final LoanoutClient instance = new LoanoutClient();
+    /**
+     *
+     */
+    private LoanoutProxy loanoutProxy;
+
+    /**
+     *
+     * Default constructor for LoanoutClient class.
+     *
+     */
+    public LoanoutClient() {
+        ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
+        RegisterBuiltin.register(factory);
+        setProxy();
+    }
+
+    /**
+     * allow to reset proxy as per security needs
+     */
+    public void setProxy() {
+        if (useAuth()) {
+            loanoutProxy = ProxyFactory.create(LoanoutProxy.class,
+                    getBaseURL(), getHttpClient());
+        } else {
+            loanoutProxy = ProxyFactory.create(LoanoutProxy.class,
+                    getBaseURL());
+        }
+    }
+
+    /**
+     * FIXME Comment this
+     *
+     * @return
+     */
+    public static LoanoutClient getInstance() {
+        return instance;
+    }
+
+    /**
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#getLoanout()
+     */
+    public ClientResponse<LoansoutCommonList> readList() {
+        return loanoutProxy.readList();
+    }
+    
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#getAuthorityRefs(java.lang.String)
+     */
+    public ClientResponse<AuthorityRefList> getAuthorityRefs(String csid) {
+        return loanoutProxy.getAuthorityRefs(csid);
+    }
+
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#getLoanout(java.lang.String)
+     */
+    public ClientResponse<MultipartInput> read(String csid) {
+        return loanoutProxy.read(csid);
+    }
+
+    /**
+     * @param loanout
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#createLoanout(org.collectionspace.hello.Loanout)
+     */
+    public ClientResponse<Response> create(MultipartOutput multipart) {
+        return loanoutProxy.create(multipart);
+    }
+
+    /**
+     * @param csid
+     * @param loanout
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#updateLoanout(java.lang.Long, org.collectionspace.hello.Loanout)
+     */
+    public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
+        return loanoutProxy.update(csid, multipart);
+
+    }
+
+    /**
+     * @param csid
+     * @return
+     * @see org.collectionspace.services.client.LoanoutProxy#deleteLoanout(java.lang.Long)
+     */
+    public ClientResponse<Response> delete(String csid) {
+        return loanoutProxy.delete(csid);
+    }
+}
diff --git a/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java b/services/loanout/client/src/main/java/org/collectionspace/services/client/LoanoutProxy.java
new file mode 100644 (file)
index 0000000..5111581
--- /dev/null
@@ -0,0 +1,57 @@
+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.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.loanout.LoansoutCommonList;
+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("/loansout/")
+@Produces({"multipart/mixed"})
+@Consumes({"multipart/mixed"})
+public interface LoanoutProxy {
+
+    //(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
+    @GET
+    @Produces({"application/xml"})
+    ClientResponse<LoansoutCommonList> readList();
+
+    // List Authority References
+    @GET
+    @Produces({"application/xml"})
+    @Path("/{csid}/authorityrefs/")
+    ClientResponse<AuthorityRefList> getAuthorityRefs(@PathParam("csid") String csid);
+    
+}
diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java
new file mode 100644 (file)
index 0000000..d9e4f78
--- /dev/null
@@ -0,0 +1,323 @@
+/**
+ * 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 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.PersonJAXBSchema;
+import org.collectionspace.services.client.LoanoutClient;
+import org.collectionspace.services.client.PersonAuthorityClient;
+import org.collectionspace.services.client.PersonAuthorityClientUtils;
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.authorityref.AuthorityRefList.AuthorityRefItem;
+import org.collectionspace.services.loanout.LoansoutCommon;
+import org.collectionspace.services.loanout.LoansoutCommonList;
+
+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.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * LoanoutAuthRefsTest, carries out Authority References tests against a
+ * deployed and running Loanout (aka Loans Out) Service.
+ *
+ * $LastChangedRevision: 1327 $
+ * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
+ */
+public class LoanoutAuthRefsTest extends BaseServiceTest {
+
+   private final Logger logger =
+       LoggerFactory.getLogger(LoanoutAuthRefsTest.class);
+
+    // Instance variables specific to this test.
+    final String SERVICE_PATH_COMPONENT = "loansout";
+    final String PERSON_AUTHORITY_NAME = "TestPersonAuth";
+    private String knownResourceId = null;
+    private List<String> loanoutIdsCreated = new ArrayList();
+    private List<String> personIdsCreated = new ArrayList();
+    private int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
+    private int OK_STATUS = Response.Status.OK.getStatusCode();
+    private String personAuthCSID = null;
+    private String borrowersContactRefName = null;
+    private String lendersAuthorizerRefName = null;
+    private String lendersContactRefName = null;
+
+    // FIXME: Can add 'borrower' - likely to be an organization
+    // authority - as an authRef to tests below, and increase the
+    // number of expected authRefs to 4.
+    private final int NUM_AUTH_REFS_EXPECTED = 3;
+
+    // ---------------------------------------------------------------
+    // CRUD tests : CREATE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class)
+    public void createWithAuthRefs(String testName) throws Exception {
+
+        testSetup(CREATED_STATUS, ServiceRequestType.CREATE,testName);
+
+        // Submit the request to the service and store the response.
+        String identifier = createIdentifier();
+
+        // Create all the person refs and entities
+        createPersonRefs();
+
+        // Create a new Loans In resource.
+        //
+        // One or more fields in this resource will be PersonAuthority
+        // references, and will refer to Person resources by their refNames.
+        LoanoutClient loanoutClient = new LoanoutClient();
+        MultipartOutput multipart = createLoanoutInstance(
+                "loanOutNumber-" + identifier,
+                "returnDate-" + identifier,
+                borrowersContactRefName,
+                lendersAuthorizerRefName,
+                lendersContactRefName);
+        ClientResponse<Response> res = loanoutClient.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 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.
+        loanoutIdsCreated.add(extractId(res));
+    }
+
+    protected void createPersonRefs(){
+
+        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
+        // Create a temporary PersonAuthority resource, and its corresponding
+        // refName by which it can be identified.
+       String authRefName = 
+               PersonAuthorityClientUtils.createPersonAuthRefName(PERSON_AUTHORITY_NAME, false);
+       MultipartOutput multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
+           PERSON_AUTHORITY_NAME, authRefName, personAuthClient.getCommonPartName());
+        ClientResponse<Response> res = personAuthClient.create(multipart);
+        int statusCode = res.getStatus();
+
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, CREATED_STATUS);
+        personAuthCSID = extractId(res);
+
+        // Create temporary Person resources, and their corresponding refNames
+        // by which they can be identified.
+        borrowersContactRefName =
+            PersonAuthorityClientUtils.createPersonRefName(authRefName, "Bradley BorrowersContact", true);
+        personIdsCreated.add(createPerson("Bradley", "BorrowersContact", borrowersContactRefName));
+
+        lendersAuthorizerRefName =
+            PersonAuthorityClientUtils.createPersonRefName(authRefName, "Art Lendersauthorizor", true);
+        personIdsCreated.add(createPerson("Art", "Lendersauthorizor", lendersAuthorizerRefName));
+
+        lendersContactRefName =
+            PersonAuthorityClientUtils.createPersonRefName(authRefName, "Larry Lenderscontact", true);
+        personIdsCreated.add(createPerson("Larry", "Lenderscontact", lendersContactRefName));
+    }
+    
+    protected String createPerson(String firstName, String surName, String refName ) {
+        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
+        Map<String, String> personInfo = new HashMap<String,String>();
+        personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
+        personInfo.put(PersonJAXBSchema.SUR_NAME, surName);
+       MultipartOutput multipart = 
+               PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, 
+                               refName, personInfo, personAuthClient.getItemCommonPartName());
+        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
+        int statusCode = res.getStatus();
+
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, CREATED_STATUS);
+       return extractId(res);
+    }
+
+    // Success outcomes
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"createWithAuthRefs"})
+    public void readAndCheckAuthRefs(String testName) throws Exception {
+
+        // Perform setup.
+        testSetup(OK_STATUS, ServiceRequestType.READ,testName);
+
+        // Submit the request to the service and store the response.
+        LoanoutClient loanoutClient = new LoanoutClient();
+        ClientResponse<MultipartInput> res = loanoutClient.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 + ".read: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+        MultipartInput input = (MultipartInput) res.getEntity();
+        LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
+            loanoutClient.getCommonPartName(), LoansoutCommon.class);
+        Assert.assertNotNull(loanout);
+        if(logger.isDebugEnabled()){
+            logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
+        }
+        // Check a couple of fields
+        // FIXME
+        Assert.assertEquals(loanout.getLendersAuthorizer(), lendersAuthorizerRefName);
+        Assert.assertEquals(loanout.getLendersContact(), lendersContactRefName);
+        
+        // Get the auth refs and check them
+        ClientResponse<AuthorityRefList> res2 =
+           loanoutClient.getAuthorityRefs(knownResourceId);
+        statusCode = res2.getStatus();
+
+        if(logger.isDebugEnabled()){
+            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        AuthorityRefList list = res2.getEntity();
+
+        // Optionally output additional data about list members for debugging.
+        boolean iterateThroughList = true;
+        if(iterateThroughList && logger.isDebugEnabled()){
+            List<AuthorityRefList.AuthorityRefItem> items =
+                    list.getAuthorityRefItem();
+            int i = 0;
+            for(AuthorityRefList.AuthorityRefItem item : items){
+                logger.debug(testName + ": list-item[" + i + "] Field:" +
+                               item.getSourceField() + "= " +
+                        item.getAuthDisplayName() +
+                        item.getItemDisplayName());
+                logger.debug(testName + ": list-item[" + i + "] refName=" +
+                        item.getRefName());
+                logger.debug(testName + ": list-item[" + i + "] URI=" +
+                        item.getUri());
+                i++;
+            }
+            Assert.assertEquals(i, NUM_AUTH_REFS_EXPECTED, "Did not find all authrefs!");
+        }
+    }
+
+
+    // ---------------------------------------------------------------
+    // 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 ...");
+        }
+        // Note: Any non-success responses are ignored and not reported.
+
+        PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
+        // Delete Person resource(s) (before PersonAuthority resources).
+        ClientResponse<Response> res;
+        for (String resourceId : personIdsCreated) {
+            res = personAuthClient.deleteItem(personAuthCSID, resourceId);
+        }
+        // Delete PersonAuthority resource(s).
+        res = personAuthClient.delete(personAuthCSID);
+        // Delete Loans In resource(s).
+        LoanoutClient loanoutClient = new LoanoutClient();
+        for (String resourceId : loanoutIdsCreated) {
+            res = loanoutClient.delete(resourceId);
+        }
+    }
+
+    // ---------------------------------------------------------------
+    // Utility methods used by tests above
+    // ---------------------------------------------------------------
+    @Override
+    public String getServicePathComponent() {
+        return SERVICE_PATH_COMPONENT;
+    }
+
+   private MultipartOutput createLoanoutInstance(String loanoutNumber,
+               String returnDate,
+                String borrowersContact,
+                String lendersAuthorizer,
+                String lendersContact) {
+        LoansoutCommon loanout = new LoansoutCommon();
+        loanout.setLoanOutNumber(loanoutNumber);
+        loanout.setLoanReturnDate(returnDate);
+        loanout.setBorrowersContact(lendersContact);
+        loanout.setLendersAuthorizer(lendersAuthorizer);
+        loanout.setLendersContact(lendersContact);
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart =
+            multipart.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", new LoanoutClient().getCommonPartName());
+
+        if(logger.isDebugEnabled()){
+            logger.debug("to be created, loanout common");
+            logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
+        }
+
+        return multipart;
+    }
+}
diff --git a/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java b/services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
new file mode 100644 (file)
index 0000000..fbfc7f6
--- /dev/null
@@ -0,0 +1,642 @@
+/**
+ * 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 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.List;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.LoanoutClient;
+import org.collectionspace.services.loanout.LoansoutCommon;
+import org.collectionspace.services.loanout.LoansoutCommonList;
+
+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.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * LoanoutServiceTest, carries out tests against a
+ * deployed and running Loanout (aka Loans Out) Service.
+ *
+ * $LastChangedRevision: 1327 $
+ * $LastChangedDate: 2010-02-12 10:35:11 -0800 (Fri, 12 Feb 2010) $
+ */
+public class LoanoutServiceTest extends AbstractServiceTestImpl {
+
+   private final Logger logger =
+       LoggerFactory.getLogger(LoanoutServiceTest.class);
+
+    // Instance variables specific to this test.
+    final String SERVICE_PATH_COMPONENT = "loansout";
+    private String knownResourceId = null;
+    private List<String> allResourceIdsCreated = new ArrayList();
+
+    // ---------------------------------------------------------------
+    // CRUD tests : CREATE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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.
+        LoanoutClient client = new LoanoutClient();
+        String identifier = createIdentifier();
+        MultipartOutput multipart = createLoanoutInstance(identifier);
+        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 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));
+    }
+
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"create"})
+    public void createList(String testName) throws Exception {
+        for(int i = 0; i < 3; i++){
+            create(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("createWithEmptyEntityBody 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=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"create"})
+    public void read(String testName) throws Exception {
+
+        // Perform setup.
+        setupRead(testName);
+
+        // Submit the request to the service and store the response.
+        LoanoutClient client = new LoanoutClient();
+        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);
+
+        MultipartInput input = (MultipartInput) res.getEntity();
+        LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
+                client.getCommonPartName(), LoansoutCommon.class);
+        Assert.assertNotNull(loanout);
+    }
+
+    // Failure outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"read"})
+    public void readNonExistent(String testName) throws Exception {
+
+        // Perform setup.
+        setupReadNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        LoanoutClient client = new LoanoutClient();
+        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);
+    }
+
+    // ---------------------------------------------------------------
+    // CRUD tests : READ_LIST tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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.
+        LoanoutClient client = new LoanoutClient();
+        ClientResponse<LoansoutCommonList> res = client.readList();
+        LoansoutCommonList 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<LoansoutCommonList.LoanoutListItem> items =
+                    list.getLoanoutListItem();
+            int i = 0;
+            for(LoansoutCommonList.LoanoutListItem item : items){
+                logger.debug(testName + ": list-item[" + i + "] csid=" +
+                        item.getCsid());
+                logger.debug(testName + ": list-item[" + i + "] loanOutNumber=" +
+                        item.getLoanOutNumber());
+                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=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"read"})
+    public void update(String testName) throws Exception {
+
+        // Perform setup.
+        setupUpdate(testName);
+
+        // Retrieve the contents of a resource to update.
+        LoanoutClient client = new LoanoutClient();
+        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 object to update with ID: " + knownResourceId);
+        }
+        MultipartInput input = (MultipartInput) res.getEntity();
+        LoansoutCommon loanout = (LoansoutCommon) extractPart(input,
+                client.getCommonPartName(), LoansoutCommon.class);
+        Assert.assertNotNull(loanout);
+
+        // Update the content of this resource.
+        loanout.setLoanOutNumber("updated-" + loanout.getLoanOutNumber());
+        loanout.setLoanReturnDate("updated-" + loanout.getLoanReturnDate());
+        if(logger.isDebugEnabled()){
+            logger.debug("to be updated object");
+            logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
+        }
+        // Submit the request to the service and store the response.
+        MultipartOutput output = new MultipartOutput();
+        OutputPart commonPart = output.addPart(loanout, 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(testName + ": status = " + statusCode);
+        }
+        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+
+        input = (MultipartInput) res.getEntity();
+        LoansoutCommon updatedLoanout =
+                (LoansoutCommon) extractPart(input,
+                        client.getCommonPartName(), LoansoutCommon.class);
+        Assert.assertNotNull(updatedLoanout);
+
+        Assert.assertEquals(updatedLoanout.getLoanReturnDate(),
+                loanout.getLoanReturnDate(),
+                "Data in updated object 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(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=AbstractServiceTestImpl.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.
+        LoanoutClient client = new LoanoutClient();
+        MultipartOutput multipart = createLoanoutInstance(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);
+    }
+
+    // ---------------------------------------------------------------
+    // CRUD tests : DELETE tests
+    // ---------------------------------------------------------------
+    // Success outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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.
+        LoanoutClient client = new LoanoutClient();
+        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);
+    }
+
+    // Failure outcomes
+    @Override
+    @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+        dependsOnMethods = {"delete"})
+    public void deleteNonExistent(String testName) throws Exception {
+
+        // Perform setup.
+        setupDeleteNonExistent(testName);
+
+        // Submit the request to the service and store the response.
+        LoanoutClient client = new LoanoutClient();
+        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);
+    }
+
+    // ---------------------------------------------------------------
+    // 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);
+
+    }
+
+    // ---------------------------------------------------------------
+    // 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 ...");
+        }
+       LoanoutClient client = new LoanoutClient();
+       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;
+    }
+
+    private MultipartOutput createLoanoutInstance(String identifier) {
+        return createLoanoutInstance(
+                "loanoutNumber-" + identifier,
+                "returnDate-" + identifier);
+    }
+
+    private MultipartOutput createLoanoutInstance(String loanOutNumber,
+               String returnDate) {
+        LoansoutCommon loanout = new LoansoutCommon();
+        loanout.setLoanOutNumber(loanOutNumber);
+        loanout.setLoanReturnDate(returnDate);
+        loanout.setBorrower(
+           "urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'");
+        loanout.setBorrowersContact(
+            "urn:cspace:org.collectionspace.demo:personauthority:name(TestPersonAuth):person:name(Chris Contact)'Chris Contact'");
+        loanout.setLoanPurpose("Allow people in cold climes to share the magic of Surfboards of the 1960s.");
+        MultipartOutput multipart = new MultipartOutput();
+        OutputPart commonPart =
+            multipart.addPart(loanout, MediaType.APPLICATION_XML_TYPE);
+        commonPart.getHeaders().add("label", new LoanoutClient().getCommonPartName());
+
+        if(logger.isDebugEnabled()){
+            logger.debug("to be created, loanout common");
+            logger.debug(objectAsXmlString(loanout, LoansoutCommon.class));
+        }
+
+        return multipart;
+    }
+}
diff --git a/services/loanout/client/src/test/resources/log4j.properties b/services/loanout/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/loanout/jaxb/pom.xml b/services/loanout/jaxb/pom.xml
new file mode 100644 (file)
index 0000000..6d5fd02
--- /dev/null
@@ -0,0 +1,42 @@
+<?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.loanout</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout.jaxb</artifactId>
+    <name>services.loanout.jaxb</name>
+    
+    <dependencies>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jvnet.jaxb2-commons</groupId>
+            <artifactId>property-listener-injector</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.jvnet.jaxb2_commons</groupId>
+            <artifactId>runtime</artifactId>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-loanout-jaxb</finalName>
+        <defaultGoal>install</defaultGoal>
+        <plugins>
+            <plugin>
+                <groupId>org.jvnet.jaxb2.maven2</groupId>
+                <artifactId>maven-jaxb2-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+
diff --git a/services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutJAXBSchema.java b/services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutJAXBSchema.java
new file mode 100644 (file)
index 0000000..0d5bf47
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * 
+ */
+package org.collectionspace.services;
+
+public interface LoanoutJAXBSchema {
+
+    final static String LOAN_OUT_NUMBER = "loanOutNumber";
+    final static String BORROWER = "borrower";
+    final static String BORROWERS_CONTACT = "borrowersContact";
+    final static String LENDERS_AUTHORIZER = "lendersAuthorizer";
+    final static String LENDERS_AUTHORIZATION_DATE = "lendersAuthorizationDate";
+    final static String LENDERS_CONTACT = "lendersContact";
+    
+    /*
+     * Omitting loaned object status fields in release 0.5.2,
+     * as these are likely to be repeatable or else
+     * handled in some alternate way in release 0.7.
+     */
+    // final static String LOANED_OBJECT_STATUS = "loanedObjectStatus";
+    // final static String LOANED_OBJECT_STATUS_DATE = "loanedObjectStatusDate";
+    // final static String LOANED_OBJECT_STATUS_NOTE = "loanedObjectStatusNote";
+               
+    final static String LOAN_OUT_DATE = "loanOutDate";
+    final static String LOAN_RETURN_DATE = "loanReturnDate";
+    final static String LOAN_RENEWAL_APPLICATION_DATE = "loanRenewalApplicationDate";
+    final static String SPECIAL_CONDITIONS_OF_LOAN = "specialConditionsOfLoan";
+    final static String LOAN_OUT_NOTE = "loanOutNote";
+    final static String LOAN_PURPOSE = "loanPurpose";
+}
diff --git a/services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutListItemJAXBSchema.java b/services/loanout/jaxb/src/main/java/org/collectionspace/services/LoanoutListItemJAXBSchema.java
new file mode 100644 (file)
index 0000000..c495994
--- /dev/null
@@ -0,0 +1,8 @@
+package org.collectionspace.services;
+
+public interface LoanoutListItemJAXBSchema {
+       final static String LOAN_OUT_NUMBER = "loanoutNumber";
+    final static String LOAN_RETURN_DATE = "loanReturnDate";
+       final static String CSID = "csid";
+       final static String URI = "url";
+}
diff --git a/services/loanout/jaxb/src/main/resources/loansout-common.xsd b/services/loanout/jaxb/src/main/resources/loansout-common.xsd
new file mode 100644 (file)
index 0000000..6591ef4
--- /dev/null
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    Loan Out schema (XSD)
+    
+    Entity  : Loanout
+    Part    : Common
+    Used for: JAXB binding between XML and Java objects
+
+    $LastChangedRevision: 1692 $
+    $LastChangedDate: 2010-03-24 20:20:55 -0800 (Wed, 24 Mar 2010) $
+-->
+
+<xs:schema 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:ns="http://collectionspace.org/services/loanout"
+  xmlns="http://collectionspace.org/services/loanout"
+  targetNamespace="http://collectionspace.org/services/loanout"
+  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/Loans+Out+Schema -->    
+    
+    <!-- loanout -->
+    <xs:element name="loansout_common">
+        <xs:complexType>
+            <xs:sequence>                
+                <!--  Loan Out Information Group -->
+                <xs:element name="loanOutNumber" type="xs:string"/>
+                <xs:element name="borrower" type="xs:string"/>
+                <xs:element name="borrowersContact" type="xs:string"/>
+                <xs:element name="lendersAuthorizer" type="xs:string"/>
+                <xs:element name="lendersAuthorizationDate" type="xs:string"/>
+                <xs:element name="lendersContact" type="xs:string"/>
+                
+                <!--
+                     Omitting loaned object status fields in release 0.5.2,
+                     as these are likely to be repeatable or else handled
+                     in some alternate way in release 0.7.
+                -->
+                <!-- xs:element name="loanedObjectStatus" type="xs:string"/ -->
+                <!-- xs:element name="loanedObjectStatusDate" type="xs:string"/ -->
+                <!-- xs:element name="loanedObjectStatusNote" type="xs:string"/ -->
+                
+                <xs:element name="loanOutDate" type="xs:string"/>
+                <xs:element name="loanReturnDate" type="xs:string"/>
+                <xs:element name="loanRenewalApplicationDate" type="xs:string"/>
+                <xs:element name="specialConditionsOfLoan" type="xs:string"/>
+                <xs:element name="loanOutNote" type="xs:string"/>
+                <xs:element name="loanPurpose" type="xs:string"/>
+             </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    <!-- loansout records, as in nuxeo repository -->
+    <xs:element name="loansout-common-list">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="loanout-list-item" maxOccurs="unbounded">
+                    <xs:complexType>
+                        <xs:sequence>
+                            <xs:element name="loanOutNumber" type="xs:string"
+                                minOccurs="1" />
+                            <xs:element name="loanReturnDate" type="xs:string"
+                                minOccurs="1" />
+                            <!-- uri to retrive 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/loanout/pom.xml b/services/loanout/pom.xml
new file mode 100644 (file)
index 0000000..675c049
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A comment. -->
+<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>org.collectionspace.services.main</artifactId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout</artifactId>
+    <name>services.loanout</name>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>jaxb</module>
+        <module>service</module>
+        <module>3rdparty</module>
+        <module>client</module>
+    </modules>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <source>1.5</source>
+                        <target>1.5</target>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-site-plugin</artifactId>
+                    <configuration>
+                        <unzipCommand>/usr/bin/unzip -o &gt; err.txt</unzipCommand>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <version>2.0.1</version>
+                    <configuration>
+                        <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
+                        <archive>
+                            <manifest>
+                                <addClasspath>true</addClasspath>
+                            </manifest>
+                        </archive>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <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/loanout/service/pom.xml b/services/loanout/service/pom.xml
new file mode 100644 (file)
index 0000000..545cb44
--- /dev/null
@@ -0,0 +1,138 @@
+<?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>
+        <groupId>org.collectionspace.services</groupId>
+        <artifactId>org.collectionspace.services.loanout</artifactId>        
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.loanout.service</artifactId>
+    <name>services.loanout.service</name>
+    <packaging>jar</packaging>       
+
+    <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.loanout.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!-- External dependencies -->        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.6</version>
+        </dependency>
+        
+      <!-- javax -->
+
+        <dependency>
+            <groupId>javax.security</groupId>
+            <artifactId>jaas</artifactId>
+            <version>1.0.01</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>dom4j</groupId>
+            <artifactId>dom4j</artifactId>
+            <version>1.6.1</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- jboss -->
+
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxrs</artifactId>
+            <version>1.0.2.GA</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>tjws</groupId>
+                    <artifactId>webserver</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-jaxb-provider</artifactId>
+            <version>1.0.2.GA</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.resteasy</groupId>
+            <artifactId>resteasy-multipart-provider</artifactId>
+            <version>1.0.2.GA</version>
+        </dependency>
+        
+        <!-- nuxeo -->
+
+        <dependency>
+            <groupId>org.nuxeo.ecm.core</groupId>
+            <artifactId>nuxeo-core-api</artifactId>
+            <version>1.5.1-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>jboss-remoting</artifactId>
+                    <groupId>jboss</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.restlet</groupId>
+            <artifactId>org.restlet</artifactId>
+            <version>1.0.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.noelios.restlet</groupId>
+            <artifactId>com.noelios.restlet.ext.httpclient</artifactId>
+            <version>1.0.7</version>
+        </dependency>
+        <dependency>
+            <groupId>com.noelios.restlet</groupId>
+            <artifactId>com.noelios.restlet</artifactId>
+            <version>1.0.7</version>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <finalName>collectionspace-services-loanout</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jboss-maven-plugin</artifactId>
+                <configuration>
+                    <jbossHome>${jboss.dir}</jbossHome>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                    <showDeprecation>true</showDeprecation>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
+
diff --git a/services/loanout/service/profiles.xml b/services/loanout/service/profiles.xml
new file mode 100644 (file)
index 0000000..347b9df
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
+</profilesXml>
\ No newline at end of file
diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/LoanoutResource.java
new file mode 100644 (file)
index 0000000..6ea529f
--- /dev/null
@@ -0,0 +1,476 @@
+/**
+ *  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.loanout;
+
+import java.util.List;
+
+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.QueryParam;
+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.AbstractMultiPartCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+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.document.DocumentWrapper;
+import org.collectionspace.services.common.query.IQueryManager;
+import org.collectionspace.services.common.query.QueryManager;
+import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.util.HttpResponseCodes;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class LoanoutResource.
+ */
+@Path("/loansout")
+@Consumes("multipart/mixed")
+@Produces("multipart/mixed")
+public class LoanoutResource extends
+               AbstractMultiPartCollectionSpaceResourceImpl {
+
+    /** The Constant serviceName. */
+    private final static String serviceName = "loansout";
+    
+    /** The logger. */
+    final Logger logger = LoggerFactory.getLogger(LoanoutResource.class);
+    //FIXME retrieve client type from configuration
+    /** The Constant CLIENT_TYPE. */
+    final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+    /**
+     * Instantiates a new loanout resource.
+     */
+    public LoanoutResource() {
+        // do nothing
+    }
+
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+     */
+    @Override
+    protected String getVersionString() {
+       /** The last change revision. */
+       final String lastChangeRevision = "$LastChangedRevision: 1627 $";
+       return lastChangeRevision;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+     */
+    @Override
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass()
+     */
+    @Override
+    public Class<LoansoutCommon> getCommonPartClass() {
+       return LoansoutCommon.class;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+     */
+//    @Override
+//    public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+//        DocumentHandler docHandler = ctx.getDocumentHandler();
+//        if (ctx.getInput() != null) {
+//            Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), LoansoutCommon.class);
+//            if (obj != null) {
+//                docHandler.setCommonPart((LoansoutCommon) obj);
+//            }
+//        }
+//        return docHandler;
+//    }
+
+    /**
+     * Creates the loanout.
+     * 
+     * @param input the input
+     * 
+     * @return the response
+     */
+    @POST
+    public Response createLoanout(MultipartInput input) {
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
+            DocumentHandler handler = createDocumentHandler(ctx);
+            String csid = getRepositoryClient(ctx).create(ctx, handler);
+            //loanoutObject.setCsid(csid);
+            UriBuilder path = UriBuilder.fromResource(LoanoutResource.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 createLoanout", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+    }
+
+    /**
+     * Gets the loanout.
+     * 
+     * @param csid the csid
+     * 
+     * @return the loanout
+     */
+    @GET
+    @Path("{csid}")
+    public MultipartOutput getLoanout(
+            @PathParam("csid") String csid) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("getLoanout with csid=" + csid);
+        }
+        if (csid == null || "".equals(csid)) {
+            logger.error("getLoanout: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "get failed on Loanout csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        MultipartOutput result = null;
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+            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("getLoanout", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Get failed on Loanout csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("getLoanout", 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 Loanout CSID:" + csid + ": was not found.").type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return result;
+    }
+
+    /**
+     * Gets the loanout list.
+     * 
+     * @param ui the ui
+     * @param keywords the keywords
+     * 
+     * @return the loanout list
+     */
+    @GET
+    @Produces("application/xml")
+    public LoansoutCommonList getLoanoutList(@Context UriInfo ui,
+               @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
+       LoansoutCommonList result = null;
+       MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+       if (keywords != null) {
+               result = searchLoansout(queryParams, keywords);
+       } else {
+               result = getLoanoutList(queryParams);
+       }
+       return result;
+    }
+    
+    /**
+     * Gets the loanout list.
+     * 
+     * @return the loanout list
+     */
+    private LoansoutCommonList getLoanoutList(MultivaluedMap<String, String> queryParams) {
+        LoansoutCommonList loanoutObjectList;
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+            DocumentHandler handler = createDocumentHandler(ctx);
+            getRepositoryClient(ctx).getAll(ctx, handler);
+            loanoutObjectList = (LoansoutCommonList) 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 getLoanoutList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return loanoutObjectList;
+    }
+
+    /**
+     * Gets the authority refs.
+     * 
+     * @param csid the csid
+     * @param ui the ui
+     * 
+     * @return the authority refs
+     */
+    @GET
+    @Path("{csid}/authorityrefs")
+    @Produces("application/xml")
+    public AuthorityRefList getAuthorityRefs(
+               @PathParam("csid") String csid, 
+               @Context UriInfo ui) {
+       AuthorityRefList authRefList = null;
+        try {
+               MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+            DocumentWrapper<DocumentModel> docWrapper = 
+               getRepositoryClient(ctx).getDoc(ctx, csid);
+            RemoteDocumentModelHandlerImpl handler 
+               = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+            List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+            authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
+        } catch (UnauthorizedException ue) {
+            Response response = Response.status(
+                    Response.Status.UNAUTHORIZED).entity("Failed to retrieve authority references: reason " + ue.getErrorReason()).type("text/plain").build();
+            throw new WebApplicationException(response);
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Caught exception in getAuthorityRefs", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Failed to retrieve authority references").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return authRefList;
+    }
+
+    /**
+     * Gets the loanout list.
+     * 
+     * @param csidList the csid list
+     * 
+     * @return the loanout list
+     */
+    @Deprecated
+    public LoansoutCommonList getLoanoutList(List<String> csidList) {
+        LoansoutCommonList loanoutObjectList = new LoansoutCommonList();
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+            DocumentHandler handler = createDocumentHandler(ctx);
+            getRepositoryClient(ctx).get(ctx, csidList, handler);
+            loanoutObjectList = (LoansoutCommonList) 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 getLoanoutList", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return loanoutObjectList;
+    }
+    
+    /**
+     * Update loanout.
+     * 
+     * @param csid the csid
+     * @param theUpdate the the update
+     * 
+     * @return the multipart output
+     */
+    @PUT
+    @Path("{csid}")
+    public MultipartOutput updateLoanout(
+            @PathParam("csid") String csid,
+            MultipartInput theUpdate) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("updateLoanout with csid=" + csid);
+        }
+        if (csid == null || "".equals(csid)) {
+            logger.error("updateLoanout: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "update failed on Loanout csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        MultipartOutput result = null;
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
+            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("caught exception in updateLoanout", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Update failed on Loanout 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 loanout.
+     * 
+     * @param csid the csid
+     * 
+     * @return the response
+     */
+    @DELETE
+    @Path("{csid}")
+    public Response deleteLoanout(@PathParam("csid") String csid) {
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("deleteLoanout with csid=" + csid);
+        }
+        if (csid == null || "".equals(csid)) {
+            logger.error("deleteLoanout: missing csid!");
+            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+                    "delete failed on Loanout csid=" + csid).type(
+                    "text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+            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 deleteLoanout", dnfe);
+            }
+            Response response = Response.status(Response.Status.NOT_FOUND).entity(
+                    "Delete failed on Loanout 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);
+        }
+    }
+               
+    /**
+     * Search loansout.
+     * 
+     * @param keywords the keywords
+     * 
+     * @return the loansout common list
+     */
+    private LoansoutCommonList searchLoansout(MultivaluedMap<String, String> queryParams,
+               String keywords) {
+       LoansoutCommonList loansoutObjectList;
+        try {
+               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+            DocumentHandler handler = createDocumentHandler(ctx);
+
+            // perform a keyword search
+            if (keywords != null && !keywords.isEmpty()) {
+               String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
+                   DocumentFilter documentFilter = handler.getDocumentFilter();
+                   documentFilter.setWhereClause(whereClause);
+                   if (logger.isDebugEnabled()) {
+                       logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
+                   }
+                   getRepositoryClient(ctx).getFiltered(ctx, handler);
+            } else {
+               getRepositoryClient(ctx).getAll(ctx, handler);
+            }            
+            loansoutObjectList = (LoansoutCommonList) 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 search for Loansout", e);
+            }
+            Response response = Response.status(
+                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+            throw new WebApplicationException(response);
+        }
+        return loansoutObjectList;
+    }
+}
diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutConstants.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutConstants.java
new file mode 100644 (file)
index 0000000..8bdecb7
--- /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.loanout.nuxeo;
+
+/**
+ * LoanoutConstants specifies constants for the Loans Out service
+ *
+ */
+public class LoanoutConstants {
+
+    public final static String NUXEO_DOCTYPE = "Loanout";
+    public final static String NUXEO_SCHEMA_NAME = "loanout";
+    public final static String NUXEO_DC_TITLE = "CollectionSpace-Loanout";
+}
diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutDocumentModelHandler.java
new file mode 100644 (file)
index 0000000..a14ce2a
--- /dev/null
@@ -0,0 +1,143 @@
+/**
+ *  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.loanout.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.collectionspace.services.LoanoutJAXBSchema;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.loanout.LoansoutCommon;
+import org.collectionspace.services.loanout.LoansoutCommonList;
+import org.collectionspace.services.loanout.LoansoutCommonList.LoanoutListItem;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+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;
+
+/**
+ * LoanoutDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class LoanoutDocumentModelHandler
+        extends RemoteDocumentModelHandlerImpl<LoansoutCommon, LoansoutCommonList> {
+
+    private final Logger logger = LoggerFactory.getLogger(LoanoutDocumentModelHandler.class);
+    /**
+     * loanout is used to stash JAXB object to use when handle is called
+     * for Action.CREATE, Action.UPDATE or Action.GET
+     */
+    private LoansoutCommon loanout;
+    /**
+     * loanoutList is stashed when handle is called
+     * for ACTION.GET_ALL
+     */
+    private LoansoutCommonList loanoutList;
+
+
+    /**
+     * getCommonPart get associated loanout
+     * @return
+     */
+    @Override
+    public LoansoutCommon getCommonPart() {
+        return loanout;
+    }
+
+    /**
+     * setCommonPart set associated loanout
+     * @param loanout
+     */
+    @Override
+    public void setCommonPart(LoansoutCommon loanout) {
+        this.loanout = loanout;
+    }
+
+    /**
+     * getCommonPartList get associated loanout (for index/GET_ALL)
+     * @return
+     */
+    @Override
+    public LoansoutCommonList getCommonPartList() {
+        return loanoutList;
+    }
+
+    @Override
+    public void setCommonPartList(LoansoutCommonList loanoutList) {
+        this.loanoutList = loanoutList;
+    }
+
+    @Override
+    public LoansoutCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+            throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void fillCommonPart(LoansoutCommon loanoutObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public LoansoutCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
+
+        LoansoutCommonList coList = new LoansoutCommonList();
+        List<LoansoutCommonList.LoanoutListItem> list = coList.getLoanoutListItem();
+
+        //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();
+            LoanoutListItem ilistItem = new LoanoutListItem();
+            ilistItem.setLoanOutNumber((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+                    LoanoutJAXBSchema.LOAN_OUT_NUMBER));
+            ilistItem.setLoanReturnDate((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+                    LoanoutJAXBSchema.LOAN_RETURN_DATE));
+            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 LoanoutConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+    }
+}
+
diff --git a/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutValidatorHandler.java b/services/loanout/service/src/main/java/org/collectionspace/services/loanout/nuxeo/LoanoutValidatorHandler.java
new file mode 100644 (file)
index 0000000..bb3e18f
--- /dev/null
@@ -0,0 +1,18 @@
+package org.collectionspace.services.loanout.nuxeo;
+
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+import org.collectionspace.services.common.document.ValidatorHandler;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+
+public class LoanoutValidatorHandler implements ValidatorHandler {
+
+       @Override
+       public void validate(Action action, ServiceContext ctx)
+                       throws InvalidDocumentException {
+               // TODO Auto-generated method stub
+               System.out.println("LoanoutValidatorHandler executed.");
+
+       }
+
+}
diff --git a/services/loanout/service/src/test/java/org/collectionspace/services/test/LoanoutServiceTest.java b/services/loanout/service/src/test/java/org/collectionspace/services/test/LoanoutServiceTest.java
new file mode 100644 (file)
index 0000000..f082012
--- /dev/null
@@ -0,0 +1,13 @@
+package org.collectionspace.services.test;
+
+//import org.collectionspace.services.loanout.Loanout;
+//import org.collectionspace.services.loanout.LoanoutList;
+
+/**
+ * Placeholder for server-side testing of Loan Out service code.
+ * 
+ * @version $Revision:$
+ */
+public class LoanoutServiceTest {
+       //empty
+}
diff --git a/services/loanout/service/src/test/resources/log4j.xml b/services/loanout/service/src/test/resources/log4j.xml
new file mode 100644 (file)
index 0000000..52121cb
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+       <appender name="console" class="org.apache.log4j.ConsoleAppender">
+               <param name="Target" value="System.out" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+
+       <appender name="unit-tests"
+               class="org.apache.log4j.RollingFileAppender">
+               <param name="File" value="./target/unit-tests.log" />
+               <param name="MaxFileSize" value="10240KB" />
+               <param name="MaxBackupIndex" value="6" />
+               <layout class="org.apache.log4j.TTCCLayout">
+                       <param name="DateFormat" value="ISO8601" />
+               </layout>
+       </appender>
+
+       <logger name="org.apache.commons.httpclient" additivity="false">
+               <level value="warn" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <logger name="httpclient.wire" additivity="false">
+               <level value="info" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </logger>
+
+       <root>
+               <priority value="debug" />
+               <appender-ref ref="console" />
+               <appender-ref ref="unit-tests" />
+       </root>
+
+</log4j:configuration>
+
+
+
+
index 5bd7c6dd872433ff92354cd025a397da56cc964f..4556e2b2fe2a3c08b44befea561a19070a65eee7 100644 (file)
@@ -30,6 +30,7 @@
         <module>collectionobject</module>
         <module>intake</module>
         <module>loanin</module>
+        <module>loanout</module>
         <module>dimension</module>
         <module>contact</module>
         <module>JaxRsServiceProvider</module>
             </dependency>
         </dependencies>
     </dependencyManagement>
-</project>
\ No newline at end of file
+</project>