<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.location.service</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.movement.service</artifactId>\r
import org.collectionspace.services.intake.IntakeResource;
import org.collectionspace.services.loanin.LoaninResource;
import org.collectionspace.services.loanout.LoanoutResource;
+import org.collectionspace.services.location.LocationAuthorityResource;
import org.collectionspace.services.movement.MovementResource;
import org.collectionspace.services.relation.NewRelationResource;
import org.collectionspace.services.acquisition.AcquisitionResource;
singletons.add(new IntakeResource());
singletons.add(new LoaninResource());
singletons.add(new LoanoutResource());
+ singletons.add(new LocationAuthorityResource());
singletons.add(new MovementResource());
singletons.add(new AcquisitionResource());
singletons.add(new NewRelationResource());
<ant antfile="intake/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="loanin/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="loanout/build.xml" target="deploy" inheritAll="false"/>\r
+ <ant antfile="location/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="movement/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="vocabulary/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="organization/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="contact/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="dimension/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="acquisition/build.xml" target="undeploy" inheritAll="false"/>\r
+ <ant antfile="location/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="movement/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="loanout/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="loanin/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="loanin/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="loanout/build.xml" target="dist" inheritAll="false"/>\r
+ <ant antfile="location/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="movement/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="vocabulary/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="organization/build.xml" target="dist" inheritAll="false"/>\r
</service:object>
</tenant:serviceBindings>
<!-- end person service meta-data -->
+ <!-- begin locationauthority service meta-data -->
+ <tenant:serviceBindings name="Locationauthorities" 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.location.nuxeo.LocationAuthorityDocumentModelHandler
+ </service:documentHandler>
+ <service:object id="1" name="Locationauthority" version="0.1"
+ xmlns:service='http://collectionspace.org/services/common/service'>
+ <service:part id="0" control_group="Managed"
+ versionable="true" auditable="false"
+ label="locationauthorities-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="locationauthorities_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/location"
+ schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locationauthorities_common.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end locationauthority service meta-data -->
+ <!-- begin location service meta-data.
+ Note there is no Location service, but there is a
+ Repository workspace so we have to configure that.
+ -->
+ <tenant:serviceBindings name="Locations" 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.location.nuxeo.LocationDocumentModelHandler
+ </service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.location.nuxeo.LocationValidatorHandler
+ </service:validatorHandler>
+ <service:object id="1" name="Locationitem" version="0.1"
+ xmlns:service='http://collectionspace.org/services/common/service'>
+ <service:part id="0" control_group="Managed"
+ versionable="true" auditable="false"
+ label="locations-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="locations_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/location"
+ schemaLocation="http://collectionspace.org/services/location http://services.collectionspace.org/location/locations_common.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end location service meta-data -->
<!-- begin acquisition service meta-data -->
<tenant:serviceBindings name="Acquisitions" type="procedure" version="0.1">
<service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Tue Oct 06 13:26:43 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Fri Sep 11 17:00:29 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.3rdparty</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Mon Oct 05 17:07:08 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Fri Sep 11 17:00:30 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+\r
+<project name="location.3rdparty" default="package" basedir=".">\r
+ <description>\r
+ location service 3rdparty\r
+ </description>\r
+ <!-- set global properties for this build -->\r
+ <property name="services.trunk" value="../../.."/>\r
+ <!-- enviornment should be declared before reading build.properties -->\r
+ <property environment="env" />\r
+ <property file="${services.trunk}/build.properties" />\r
+ <property name="mvn.opts" value="" />\r
+ <property name="src" location="src"/>\r
+\r
+ <condition property="osfamily-unix">\r
+ <os family="unix" />\r
+ </condition>\r
+ <condition property="osfamily-windows">\r
+ <os family="windows" />\r
+ </condition>\r
+\r
+ <target name="init" >\r
+ <!-- Create the time stamp -->\r
+ <tstamp/>\r
+ </target>\r
+\r
+ <target name="package" depends="package-unix,package-windows"\r
+ description="Package CollectionSpace Services" />\r
+ <target name="package-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="package-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="install" depends="install-unix,install-windows"\r
+ description="Install" />\r
+ <target name="install-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="install" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="install-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="install" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ \r
+ <target name="clean" depends="clean-unix,clean-windows"\r
+ description="Delete target directories" >\r
+ <delete dir="${build}"/>\r
+ </target>\r
+ <target name="clean-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="clean" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="clean-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="clean" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+ <target name="test-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="test" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="test-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="test" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="deploy" depends="install"\r
+ description="deploy location in ${jboss.server.nuxeo}">\r
+ <ant antfile="nuxeo-platform-cs-location/build.xml" target="deploy" inheritall="false"/>\r
+ </target>\r
+\r
+ <target name="undeploy"\r
+ description="undeploy location from ${jboss.server.nuxeo}">\r
+ <ant antfile="nuxeo-platform-cs-location/build.xml" target="undeploy" inheritall="false"/>\r
+ </target>\r
+\r
+ <target name="dist"\r
+ description="generate distribution for location" depends="package">\r
+ <ant antfile="nuxeo-platform-cs-location/build.xml" target="dist" inheritall="false"/>\r
+ </target>\r
+ \r
+ <target name="dist_installer"\r
+ description="generate distribution for collectionobject" depends="package">\r
+ <ant antfile="nuxeo-platform-cs-location/build.xml" target="dist_installer" inheritall="false"/>\r
+ </target>\r
+\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.3rdparty.nuxeo</name>\r
+ <comment>Person Nuxeo Document Type</comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Tue May 18 21:45:35 PDT 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Tue Oct 06 13:25:17 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+
+<project name="nuxeo-platform-cs-location" default="package" basedir=".">
+ <description>
+ location nuxeo document type
+ </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"/>
+ <property name="nuxeo.location.jar"
+ value="org.collectionspace.services.location.3rdparty.nuxeo-${cspace.release}.jar"/>
+ <property name="nuxeo.location.jars.all"
+ value="org.collectionspace.services.location.3rdparty.nuxeo-*.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 location doctype in ${jboss.server.nuxeo}">
+ <copy file="${basedir}/target/${nuxeo.location.jar}"
+ todir="${jboss.deploy.nuxeo.plugins}"/>
+ </target>
+
+ <target name="undeploy"
+ description="undeploy location doctype from ${jboss.server.nuxeo}">
+ <delete>
+ <fileset dir="${jboss.deploy.nuxeo.plugins}">
+ <include name="${nuxeo.location.jars.all}"/>
+ </fileset>
+ <!-- Legacy deployment location through release 0.6 -->
+ <fileset dir="${jboss.deploy.nuxeo.system}">
+ <include name="${nuxeo.location.jars.all}"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="dist"
+ description="generate distribution for location doctype" depends="package">
+ <copy todir="${services.trunk}/${dist.deploy.nuxeo.plugins}">
+ <fileset file="${basedir}/target/${nuxeo.location.jar}"/>
+ </copy>
+ </target>
+
+ <target name="dist_installer"
+ description="Creates an installer distribution for location doctype" depends="package">
+ <copy todir="${services.trunk}/${dist.installer.services}/location/nuxeo">
+ <fileset file="${basedir}/target/${nuxeo.location.jar}"/>
+ </copy>
+ </target>
+
+</project>
+
--- /dev/null
+<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.location.3rdparty</artifactId>
+ <version>0.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.location.3rdparty.nuxeo</artifactId>
+ <name>services.location.3rdparty.nuxeo</name>
+ <packaging>jar</packaging>
+ <description>
+ Location 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>
--- /dev/null
+Manifest-Version: 1.0 \r
+Bundle-ManifestVersion: 1 \r
+Bundle-Name: NuxeoCS\r
+Bundle-SymbolicName: org.collectionspace.location;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.location\r
+Nuxeo-Component: OSGI-INF/core-types-contrib.xml,\r
+ OSGI-INF/ecm-types-contrib.xml,\r
+ OSGI-INF/layouts-contrib.xml\r
+\r
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.location.coreTypes">
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+ <schema name="locationauthorities_common" prefix="locationauthorities_common" src="schemas/locationauthorities_common.xsd"/>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+ <schema name="locations_common" prefix="locations_common" src="schemas/locations_common.xsd"/>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+ <doctype name="Locationauthority" extends="Document">
+ <schema name="common"/>
+ <schema name="collectionspace_core"/>
+ <schema name="dublincore"/>
+ <schema name="locationauthorities_common"/>
+ </doctype>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+ <doctype name="Locationitem" extends="Document">
+ <schema name="common"/>
+ <schema name="collectionspace_core"/>
+ <schema name="dublincore"/>
+ <schema name="locations_common"/>
+ </doctype>
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+<fragment>
+
+ <extension target="application#MODULE">
+ <module>
+ <ejb>${bundle.fileName}</ejb>
+ </module>
+
+ <module>
+ <web>
+ <web-uri>nuxeo.war</web-uri>
+ <context-root>/nuxeo</context-root>
+ </web>
+ </module>
+ </extension>
+
+ <!-- uncomment that to enable tomcat based auth
+ <extension target="web#LOGIN-CONFIG">
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <realm-name>nuxeo.ecm</realm-name>
+ <form-login-config>
+ <form-login-page>/login.jsp</form-login-page>
+ <form-error-page>/login.jsp?loginFailed=true</form-error-page>
+ </form-login-config>
+ </login-config>
+ </extension>
+ -->
+
+ <extension target="web#FILTER-MAPPING">
+
+ <!-- Seam Context Filter is declared in org.nuxeo.ecm.platform.ui.web
+ deployment fragment -->
+
+ <filter-mapping>
+ <filter-name>Seam Context Filter</filter-name>
+ <url-pattern>/ws/FileManageWS</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>Seam Context Filter</filter-name>
+ <url-pattern>/DocumentManagerWS</url-pattern>
+ </filter-mapping>
+ </extension>
+
+ <extension target="web#SERVLET">
+ </extension>
+
+ <extension target="web#SERVLET-MAPPING">
+ </extension>
+
+ <extension target="pages#PAGES">
+ <!-- This calls a method which load the Workspace logo -->
+ <page view-id="/showLogo.xhtml" action="#{logoHelper.getLogo}"/>
+
+ <!-- Bind URL to the Document URL resolver-->
+ <page view-id="/getDocument.xhtml"
+ action="#{navigationContext.navigateToURL}">
+ </page>
+
+ <page view-id="/nxliveedit.xhtml" action="#{liveEditHelper.getBootstrap()}"/>
+
+ <!-- Bind URL to the Parallele conversation Document URL resolver-->
+ <page view-id="/parallele.xhtml"
+ action="#{paralleleNavigationHelper.navigateToURL}">
+ </page>
+
+ <!-- Post login and 'home' view handler -->
+ <page view-id="/nxstartup.xhtml"
+ action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'view')}"/>
+
+ <!-- To redirect to the user dashboard instead, use instead:
+
+ <page view-id="/nxstartup.xhtml"
+ action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'user_dashboard')}" />
+ -->
+
+ <!-- config for workspace management
+ = give a description for each viewId
+ -->
+
+ <page view-id="/view_domains.xhtml">
+ #{currentServerLocation.name}/#{currentTabAction.label}
+ </page>
+
+ <page view-id="/select_document_type.faces.xhtml">
+ Create new document in #{currentDocument.name}
+ </page>
+
+ <page view-id="/create_document.faces.xhtml">
+ Create new document in #{currentDocument.name}
+ </page>
+
+ <page view-id="/user_dashboard.xhtml">
+ breadcrumb=command.user_dashboard
+ </page>
+
+ <page view-id="/view_users.xhtml">
+ breadcrumb=command.manageMembers
+ </page>
+
+ <page view-id="/view_many_users.xhtml">
+ breadcrumb=command.manageMembers
+ </page>
+
+ <page view-id="/view_orgauthorities.xhtml">
+ breadcrumb=title.orgauthorities
+ </page>
+
+ <page view-id="/search/search_form.xhtml">
+ breadcrumb=command.advancedSearch
+ </page>
+ </extension>
+
+ <extension target="faces-config#APPLICATION">
+ <locale-config>
+ <default-locale>en</default-locale>
+ <supported-locale>en_GB</supported-locale>
+ <supported-locale>en_US</supported-locale>
+ <supported-locale>fr</supported-locale>
+ <supported-locale>de</supported-locale>
+ <supported-locale>es</supported-locale>
+ <supported-locale>it</supported-locale>
+ <supported-locale>ar</supported-locale>
+ <supported-locale>ru</supported-locale>
+ <supported-locale>ja</supported-locale>
+ <supported-locale>vn</supported-locale>
+ </locale-config>
+
+ <message-bundle>messages</message-bundle>
+ </extension>
+
+ <extension target="components#PAGEFLOW">
+ <value>config/addWorkspace.jpdl.xml</value>
+ </extension>
+
+ <extension target="faces-config#NAVIGATION">
+ <!-- generic pages -->
+ <navigation-case>
+ <from-outcome>generic_error_page</from-outcome>
+ <to-view-id>/generic_error_page.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>generic_message_page</from-outcome>
+ <to-view-id>/generic_message_page.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/nxstartup.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_login</from-outcome>
+ <to-view-id>/login.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_logout</from-outcome>
+ <to-view-id>/logout.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_servers</from-outcome>
+ <to-view-id>/view_servers.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- pages for document actions -->
+
+ <navigation-case>
+ <from-outcome>view_domains</from-outcome>
+ <to-view-id>/view_domains.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>select_document_type</from-outcome>
+ <to-view-id>/select_document_type.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_document</from-outcome>
+ <to-view-id>/create_document.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_document</from-outcome>
+ <to-view-id>/edit_document.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_documents</from-outcome>
+ <to-view-id>/view_documents.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_file</from-outcome>
+ <to-view-id>/create_file.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_workspace_wizard</from-outcome>
+ <to-view-id>/createWorkspaceWizard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>send_email</from-outcome>
+ <to-view-id>/document_email.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use view_documents instead -->
+ <navigation-case>
+ <from-outcome>view_workspaces</from-outcome>
+ <to-view-id>/view_workspaces.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use create_document instead -->
+ <navigation-case>
+ <from-outcome>create_domain</from-outcome>
+ <to-view-id>/create_domain.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use edit_document instead -->
+ <navigation-case>
+ <from-outcome>edit_domain</from-outcome>
+ <to-view-id>/edit_domain.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use create_document instead -->
+ <navigation-case>
+ <from-outcome>create_workspace</from-outcome>
+ <to-view-id>/create_workspace.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use edit_document instead -->
+ <navigation-case>
+ <from-outcome>edit_workspace</from-outcome>
+ <to-view-id>/edit_workspace.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- users ang groups -->
+
+ <navigation-case>
+ <from-outcome>members_management</from-outcome>
+ <to-view-id>/members_management.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_users</from-outcome>
+ <to-view-id>/view_users.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_many_users</from-outcome>
+ <to-view-id>/view_many_users.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_user</from-outcome>
+ <to-view-id>/edit_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_user_password</from-outcome>
+ <to-view-id>/edit_user_password.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_user</from-outcome>
+ <to-view-id>/view_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_user</from-outcome>
+ <to-view-id>/create_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_groups</from-outcome>
+ <to-view-id>/view_groups.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_group</from-outcome>
+ <to-view-id>/view_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_group</from-outcome>
+ <to-view-id>/edit_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_group</from-outcome>
+ <to-view-id>/create_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_orgauthorities</from-outcome>
+ <to-view-id>/view_orgauthorities.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_orgauthority</from-outcome>
+ <to-view-id>/view_orgauthority.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- search -->
+
+ <navigation-case>
+ <from-outcome>search_form</from-outcome>
+ <to-view-id>/search/search_form.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_nxql</from-outcome>
+ <to-view-id>/search/search_results_nxql.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_advanced</from-outcome>
+ <to-view-id>
+ /search/search_results_advanced.xhtml
+ </to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_simple</from-outcome>
+ <to-view-id>/search/search_results_simple.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- miscellaneaous -->
+
+ <navigation-case>
+ <from-outcome>clipboard</from-outcome>
+ <to-view-id>/incl/clipboard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_dashboard</from-outcome>
+ <to-view-id>/user_dashboard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>select_workspace_template</from-outcome>
+ <to-view-id>/select_workspace_template.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>pdf_generation_error</from-outcome>
+ <to-view-id>/pdf_generation_error.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>mass_edit</from-outcome>
+ <to-view-id>/massedit_documents.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>mass_edit_confirm</from-outcome>
+ <to-view-id>/massedit_documents_preview.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </extension>
+
+</fragment>
+
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.location.ecm.types">
+ <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+ <type id="Locationauthority" coretype="Locationauthority">
+ <label>org.collectionspace.locationauthority</label>
+ <!--icon>/icons/file.gif</icon-->
+ <default-view>view_documents</default-view>
+
+ <layouts mode="any">
+ <layout>heading</layout>
+ <layout>cslocationauthority</layout>
+ </layouts>
+ </type>
+
+ <type id="Folder" coretype="Folder">
+ <subtypes>
+ <type>Locationauthority</type>
+ </subtypes>
+ </type>
+
+ <type id="Workspace" coretype="Workspace">
+ <subtypes>
+ <type>Locationauthority</type>
+ </subtypes>
+ </type>
+
+ </extension>
+ <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+ <type id="Locationitem" coretype="Locationitem">
+ <label>org.collectionspace.location</label>
+ <!--icon>/icons/file.gif</icon-->
+ <default-view>view_documents</default-view>
+
+ <layouts mode="any">
+ <layout>heading</layout>
+ <layout>location</layout>
+ </layouts>
+ </type>
+
+ <type id="Folder" coretype="Folder">
+ <subtypes>
+ <type>Location</type>
+ </subtypes>
+ </type>
+
+ <type id="Workspace" coretype="Workspace">
+ <subtypes>
+ <type>Location</type>
+ </subtypes>
+ </type>
+
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+
+<component name="org.collectionspace.location.layouts.webapp">
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="layouts">
+
+ <layout name="cslocationauthority">
+ <templates>
+ <template mode="any">/layouts/layout_default_template.xhtml</template>
+ </templates>
+ <rows>
+ <row><widget>displayName</widget></row>
+ <row><widget>refName</widget></row>
+ <row><widget>vocabType</widget></row>
+ </rows>
+
+ <widget name="displayName" type="text">
+ <labels>
+ <label mode="any">Display Name</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locationauthorities_common">displayName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="refName" type="text">
+ <labels>
+ <label mode="any">RefName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locationauthorities_common">refName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="vocabType" type="text">
+ <labels>
+ <label mode="any">Type</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locationauthorities_common">vocabType</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+ </layout>
+ </extension>
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="layouts">
+
+ <layout name="location">
+ <templates>
+ <template mode="any">/layouts/layout_default_template.xhtml</template>
+ </templates>
+ <rows>
+ <row><widget>inAuthority</widget></row>
+ <row><widget>refName</widget></row>
+ <row><widget>displayName</widget></row>
+ <row><widget>displayNameComputed</widget></row>
+ <row><widget>name</widget></row>
+ <row><widget>conditionNote</widget></row>
+ <row><widget>conditionNoteDate</widget></row>
+ <row><widget>securityNote</widget></row>
+ <row><widget>locationType</widget></row>
+ <row><widget>status</widget></row>
+ </rows>
+
+ <widget name="inAuthority" type="text">
+ <labels>
+ <label mode="any">inAuthority (LocationAuthority)</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">inAuthority</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="refName" type="text">
+ <labels>
+ <label mode="any">refName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">refName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="displayName" type="text">
+ <labels>
+ <label mode="any">displayName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locationauthorities_common">displayName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <!-- This should be some kind of checkbox or something -->
+ <widget name="displayNameComputed" type="text">
+ <labels>
+ <label mode="any">displayNameComputed</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locationauthorities_common">displayNameComputed</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="name" type="text">
+ <labels>
+ <label mode="any">name</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">name</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="conditionNote" type="text">
+ <labels>
+ <label mode="any">conditionNote</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">conditionNote</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="conditionNoteDate" type="text">
+ <labels>
+ <label mode="any">conditionNoteDate</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">conditionNoteDate</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="securityNote" type="text">
+ <labels>
+ <label mode="any">securityNote</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">securityNote</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="locationType" type="text">
+ <labels>
+ <label mode="any">locationType</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">locationType</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="status" type="text">
+ <labels>
+ <label mode="any">status</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="locations_common">status</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ </layout>
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ LocationAuthority schema (XSD)
+
+ Entity : LocationAuthority
+ Part : Common
+ Used for: Nuxeo EP core document type
+
+ $LastChangedRevision: 928 $
+ $LastChangedDate: 2009-11-10 12:25:58 -0800 (Tue, 10 Nov 2009) $
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/location"
+ xmlns="http://collectionspace.org/services/location"
+ targetNamespace="http://collectionspace.org/services/location"
+ version="0.1"
+>
+
+<!-- Flattened version of jaxb schema for nuxeo -->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Location+Service+Home -->
+
+ <!-- LocationAuthority Information Group -->
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="vocabType" type="xs:string"/>
+
+</xs:schema>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ Location schema (XSD)
+
+ Entity : Location
+ Part : Common
+ Used for: Nuxeo EP core document type
+
+ $LastChangedRevision: 860 $
+ $LastChangedDate: 2009-10-14 14:48:05 -0700 (Wed, 14 Oct 2009) $
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/location"
+ xmlns="http://collectionspace.org/services/location"
+ targetNamespace="http://collectionspace.org/services/location"
+ version="0.1"
+>
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Location+Service+Home -->
+
+ <!-- Location Information Group -->
+ <!-- inAuthority is the csid of the owning LocationAuthority -->
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="displayNameComputed" type="xs:boolean"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="conditionNote" type="xs:string"/>
+ <xs:element name="conditionNoteDate" type="xs:string"/>
+ <xs:element name="securityNote" type="xs:string"/>
+ <xs:element name="locationType" type="xs:string"/>
+ <xs:element name="status" type="xs:string"/>
+
+</xs:schema>
+
--- /dev/null
+\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location</artifactId>\r
+ <version>0.7-SNAPSHOT</version>\r
+ </parent>\r
+ \r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.3rdparty</artifactId>\r
+ <name>services.location.3rdparty</name>\r
+ <packaging>pom</packaging>\r
+ <description>\r
+ 3rd party build for location service\r
+ </description>\r
+\r
+ <modules>\r
+ <module>nuxeo-platform-cs-location</module>\r
+ </modules>\r
+</project>\r
--- /dev/null
+\r
+<project name="location" default="package" basedir=".">\r
+ <description>\r
+ Location Authority service\r
+ </description>\r
+ <!-- set global properties for this build -->\r
+ <property name="services.trunk" value="../.."/>\r
+ <!-- enviornment should be declared before reading build.properties -->\r
+ <property environment="env" />\r
+ <property file="${services.trunk}/build.properties" />\r
+ <property name="mvn.opts" value="" />\r
+ <property name="src" location="src"/>\r
+\r
+ <condition property="osfamily-unix">\r
+ <os family="unix" />\r
+ </condition>\r
+ <condition property="osfamily-windows">\r
+ <os family="windows" />\r
+ </condition>\r
+\r
+ <target name="package" depends="package-unix,package-windows"\r
+ description="Package CollectionSpace Services" />\r
+ \r
+ <target name="package-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ \r
+ <target name="package-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="install" depends="install-unix,install-windows"\r
+ description="Install" />\r
+ <target name="install-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="install" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="install-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="install" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="clean" depends="clean-unix,clean-windows"\r
+ description="Delete target directories" >\r
+ <delete dir="${build}"/>\r
+ </target>\r
+ <target name="clean-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="clean" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="clean-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="clean" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+ <target name="test-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="test" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ <target name="test-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="test" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+\r
+ <target name="deploy" depends="install"\r
+ description="deploy location service">\r
+ <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>\r
+ </target>\r
+\r
+ <target name="undeploy"\r
+ description="undeploy location service">\r
+ <ant antfile="3rdparty/build.xml" target="undeploy" inheritall="false"/>\r
+ </target>\r
+\r
+ <target name="dist" depends="package"\r
+ description="distribute location service">\r
+ <ant antfile="3rdparty/build.xml" target="dist" inheritall="false"/>\r
+ <ant antfile="import/build.xml" target="dist" inheritall="false"/>\r
+ </target>\r
+\r
+ <target name="dist_installer" depends="package"\r
+ description="distribute location service"> \r
+ <!-- copy install scripts, etc. -->\r
+ <copy todir="${services.trunk}/${dist.installer.services}/location">\r
+ <fileset dir="${basedir}/installer/"/>\r
+ </copy>\r
+ <ant antfile="3rdparty/build.xml" target="dist_installer" inheritall="false"/>\r
+ <ant antfile="import/build.xml" target="dist_installer" inheritall="false"/>\r
+ </target>\r
+\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.client</name>\r
+ <comment></comment>\r
+ <projects>\r
+ <project>org.collectionspace.services.client</project>\r
+ <project>org.collectionspace.services.common</project>\r
+ <project>org.collectionspace.services.person.jaxb</project>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Mon Jan 04 16:43:16 PST 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Mon Jan 04 16:40:35 PST 2010\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location</artifactId>\r
+ <version>0.7-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.client</artifactId>\r
+ <name>services.location.client</name>\r
+ \r
+ <dependencies>\r
+ <!-- keep slf4j dependencies on the top -->\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ </dependency>\r
+ <!-- CollectionSpace dependencies -->\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common</artifactId>\r
+ <optional>true</optional>\r
+ <version>${project.version}</version>\r
+ </dependency> \r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.contact.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <!-- External dependencies -->\r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>5.6</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <!-- filter out unwanted jars -->\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-httpclient</groupId>\r
+ <artifactId>commons-httpclient</artifactId>\r
+ <version>3.1</version>\r
+ </dependency>\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>collectionspace-services-location-client</finalName>\r
+ <plugins>\r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+/**
+ * LocationAuthorityClient.java
+ *
+ * {Purpose of This Class}
+ *
+ * {Other Notes Relating to This Class (Optional)}
+ *
+ * $LastChangedBy: $
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ *
+ * 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 {Contributing Institution}
+ *
+ * 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.authorityref.AuthorityRefDocList;
+import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.location.LocationauthoritiesCommonList;
+import org.collectionspace.services.location.LocationsCommonList;
+import org.collectionspace.services.client.LocationAuthorityProxy;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+
+/**
+ * The Class LocationAuthorityClient.
+ */
+public class LocationAuthorityClient extends AbstractServiceClientImpl {
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent()
+ */
+ @Override
+ public String getServicePathComponent() {
+ return "locationauthorities";
+ }
+
+ /**
+ * Gets the item common part name.
+ *
+ * @return the item common part name
+ */
+ public String getItemCommonPartName() {
+ return getCommonPartName("locations");
+ }
+
+ /** The location authority proxy. */
+// private static final LocationAuthorityClient instance = new LocationAuthorityClient();
+
+ /**
+ *
+ */
+ private LocationAuthorityProxy locationAuthorityProxy;
+
+ /**
+ * Instantiates a new location authority client.
+ */
+ public LocationAuthorityClient() {
+ ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
+ RegisterBuiltin.register(factory);
+ setProxy();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
+ */
+ @Override
+ public CollectionSpaceProxy getProxy() {
+ return this.locationAuthorityProxy;
+ }
+
+ /**
+ * Sets the proxy.
+ */
+ public void setProxy() {
+ if (useAuth()) {
+ locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
+ getBaseURL(), getHttpClient());
+ } else {
+ locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
+ getBaseURL());
+ }
+ }
+
+ /**
+ * Read list.
+ *
+ * @return the client response
+ */
+// public static LocationAuthorityClient getInstance() {
+// return instance;
+// }
+
+ /**
+ * @return list
+ * @see org.collectionspace.services.client.LocationAuthorityProxy#readList()
+ */
+ public ClientResponse<LocationauthoritiesCommonList> readList() {
+ return locationAuthorityProxy.readList();
+ }
+
+ /**
+ * Read.
+ *
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> read(String csid) {
+ return locationAuthorityProxy.read(csid);
+ }
+
+ /**
+ * Read by name.
+ *
+ * @param name the name
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> readByName(String name) {
+ return locationAuthorityProxy.readByName(name);
+ }
+
+ /**
+ * Creates the.
+ *
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<Response> create(MultipartOutput multipart) {
+ return locationAuthorityProxy.create(multipart);
+ }
+
+ /**
+ * Update.
+ *
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
+ return locationAuthorityProxy.update(csid, multipart);
+
+ }
+
+ /**
+ * Delete.
+ *
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<Response> delete(String csid) {
+ return locationAuthorityProxy.delete(csid);
+ }
+
+ /**
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @return the client response
+ */
+ public ClientResponse<LocationsCommonList> readItemList(String vcsid) {
+ return locationAuthorityProxy.readItemList(vcsid);
+ }
+
+ /**
+ * Gets the referencing objects.
+ *
+ * @param parentcsid the parentcsid
+ * @param csid the csid
+ * @return the referencing objects
+ */
+ public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
+ return locationAuthorityProxy.getReferencingObjects(parentcsid, csid);
+ }
+
+ /**
+ * Read item list for named authority.
+ *
+ * @param specifier the specifier
+ * @return the client response
+ */
+ public ClientResponse<LocationsCommonList> readItemListForNamedAuthority(String specifier) {
+ return locationAuthorityProxy.readItemListForNamedAuthority(specifier);
+ }
+
+ /**
+ * Read item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
+ return locationAuthorityProxy.readItem(vcsid, csid);
+ }
+
+ /**
+ * Creates the item.
+ *
+ * @param vcsid the vcsid
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
+ return locationAuthorityProxy.createItem(vcsid, multipart);
+ }
+
+ /**
+ * Update item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
+ return locationAuthorityProxy.updateItem(vcsid, csid, multipart);
+
+ }
+
+ /**
+ * Delete item.
+ *
+ * @param vcsid the vcsid
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<Response> deleteItem(String vcsid, String csid) {
+ return locationAuthorityProxy.deleteItem(vcsid, csid);
+ }
+
+ /**
+ * Creates the contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<Response> createContact(String parentcsid,
+ String itemcsid, MultipartOutput multipart) {
+ return locationAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
+ }
+
+ /**
+ * Read contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> readContact(String parentcsid,
+ String itemcsid, String csid) {
+ return locationAuthorityProxy.readContact(parentcsid, itemcsid, csid);
+ }
+
+ /**
+ * Read contact list.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @return the client response
+ */
+ public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
+ String itemcsid) {
+ return locationAuthorityProxy.readContactList(parentcsid, itemcsid);
+ }
+
+ /**
+ * Update contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @param multipart the multipart
+ * @return the client response
+ */
+ public ClientResponse<MultipartInput> updateContact(String parentcsid,
+ String itemcsid, String csid, MultipartOutput multipart) {
+ return locationAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
+ }
+
+ /**
+ * Delete contact.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param csid the csid
+ * @return the client response
+ */
+ public ClientResponse<Response> deleteContact(String parentcsid,
+ String itemcsid, String csid) {
+ return locationAuthorityProxy.deleteContact(parentcsid,
+ itemcsid, csid);
+ }
+
+}
--- /dev/null
+package org.collectionspace.services.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.ws.rs.core.MediaType;\r
+import javax.ws.rs.core.MultivaluedMap;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.collectionspace.services.LocationJAXBSchema;\r
+import org.collectionspace.services.client.test.ServiceRequestType;\r
+import org.collectionspace.services.location.LocationsCommon;\r
+import org.collectionspace.services.location.LocationauthoritiesCommon;\r
+import org.jboss.resteasy.client.ClientResponse;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class LocationAuthorityClientUtils {\r
+ private static final Logger logger =\r
+ LoggerFactory.getLogger(LocationAuthorityClientUtils.class);\r
+\r
+ public static MultipartOutput createLocationAuthorityInstance(\r
+ String displayName, String refName, String headerLabel ) {\r
+ LocationauthoritiesCommon locationAuthority = new LocationauthoritiesCommon();\r
+ locationAuthority.setDisplayName(displayName);\r
+ locationAuthority.setRefName(refName);\r
+ locationAuthority.setVocabType("LocationAuthority");\r
+ MultipartOutput multipart = new MultipartOutput();\r
+ OutputPart commonPart = multipart.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);\r
+ commonPart.getHeaders().add("label", headerLabel);\r
+\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("to be created, locationAuthority common ", \r
+ locationAuthority, LocationauthoritiesCommon.class);\r
+ }\r
+\r
+ return multipart;\r
+ }\r
+\r
+ public static MultipartOutput createLocationInstance(String inAuthority, \r
+ String locationRefName, Map<String, String> locationInfo, String headerLabel){\r
+ LocationsCommon location = new LocationsCommon();\r
+ location.setInAuthority(inAuthority);\r
+ location.setRefName(locationRefName);\r
+ String value = null;\r
+ value = locationInfo.get(LocationJAXBSchema.DISPLAY_NAME_COMPUTED);\r
+ boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true"); \r
+ location.setDisplayNameComputed(displayNameComputed);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.NAME))!=null)\r
+ location.setName(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.CONDITION_NOTE))!=null)\r
+ location.setConditionNote(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.CONDITION_NOTE_DATE))!=null)\r
+ location.setConditionNoteDate(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.SECURITY_NOTE))!=null)\r
+ location.setSecurityNote(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.LOCATION_TYPE))!=null)\r
+ location.setLocationType(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.STATUS))!=null)\r
+ location.setStatus(value);\r
+ MultipartOutput multipart = new MultipartOutput();\r
+ OutputPart commonPart = multipart.addPart(location,\r
+ MediaType.APPLICATION_XML_TYPE);\r
+ commonPart.getHeaders().add("label", headerLabel);\r
+\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("to be created, location common ", location, LocationsCommon.class);\r
+ }\r
+\r
+ return multipart;\r
+ }\r
+ \r
+ public static String createItemInAuthority(String vcsid, \r
+ String locationAuthorityRefName, Map<String,String> locationMap,\r
+ LocationAuthorityClient client ) {\r
+ // Expected status code: 201 Created\r
+ int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();\r
+ // Type of service request being tested\r
+ ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;\r
+ \r
+ String displayName = locationMap.get(LocationJAXBSchema.DISPLAY_NAME);\r
+ String displayNameComputedStr = locationMap.get(LocationJAXBSchema.DISPLAY_NAME_COMPUTED);\r
+ boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true");\r
+ if( displayName == null ) {\r
+ if(!displayNameComputed) {\r
+ throw new RuntimeException(\r
+ "CreateItem: Must supply a displayName if displayNameComputed is set to false.");\r
+ }\r
+ displayName = \r
+ prepareDefaultDisplayName(\r
+ locationMap.get(LocationJAXBSchema.NAME));\r
+ }\r
+ \r
+ String refName = createLocationRefName(locationAuthorityRefName, displayName, true);\r
+\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("Import: Create Item: \""+displayName\r
+ +"\" in locationAuthority: \"" + locationAuthorityRefName +"\"");\r
+ }\r
+ MultipartOutput multipart = \r
+ createLocationInstance( vcsid, refName,\r
+ locationMap, client.getItemCommonPartName() );\r
+ ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+\r
+ int statusCode = res.getStatus();\r
+\r
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+ throw new RuntimeException("Could not create Item: \""+refName\r
+ +"\" in locationAuthority: \"" + locationAuthorityRefName\r
+ +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+ }\r
+ if(statusCode != EXPECTED_STATUS_CODE) {\r
+ throw new RuntimeException("Unexpected Status when creating Item: \""+refName\r
+ +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);\r
+ }\r
+\r
+ return extractId(res);\r
+ }\r
+\r
+ public static String createLocationAuthRefName(String locationAuthorityName, boolean withDisplaySuffix) {\r
+ String refName = "urn:cspace:org.collectionspace.demo:locationauthority:name("\r
+ +locationAuthorityName+")";\r
+ if(withDisplaySuffix)\r
+ refName += "'"+locationAuthorityName+"'";\r
+ return refName;\r
+ }\r
+\r
+ public static String createLocationRefName(\r
+ String locationAuthRefName, String locationName, boolean withDisplaySuffix) {\r
+ String refName = locationAuthRefName+":location:name("+locationName+")";\r
+ if(withDisplaySuffix)\r
+ refName += "'"+locationName+"'";\r
+ return refName;\r
+ }\r
+\r
+ public static String extractId(ClientResponse<Response> res) {\r
+ MultivaluedMap<String, Object> mvm = res.getMetadata();\r
+ String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("extractId:uri=" + uri);\r
+ }\r
+ String[] segments = uri.split("/");\r
+ String id = segments[segments.length - 1];\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("id=" + id);\r
+ }\r
+ return id;\r
+ }\r
+ \r
+ /**\r
+ * Returns an error message indicating that the status code returned by a\r
+ * specific call to a service does not fall within a set of valid status\r
+ * codes for that service.\r
+ *\r
+ * @param serviceRequestType A type of service request (e.g. CREATE, DELETE).\r
+ *\r
+ * @param statusCode The invalid status code that was returned in the response,\r
+ * from submitting that type of request to the service.\r
+ *\r
+ * @return An error message.\r
+ */\r
+ public static String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {\r
+ return "Status code '" + statusCode + "' in response is NOT within the expected set: " +\r
+ requestType.validStatusCodesAsString();\r
+ }\r
+\r
+\r
+ \r
+ /**\r
+ * Produces a default displayName from the basic name and dates fields.\r
+ * @see LocationDocumentModelHandler.prepareDefaultDisplayName() which\r
+ * duplicates this logic, until we define a service-general utils package\r
+ * that is neither client nor service specific.\r
+ * @param name \r
+ * @return\r
+ */\r
+ public static String prepareDefaultDisplayName(\r
+ String name ) {\r
+ StringBuilder newStr = new StringBuilder();\r
+ newStr.append(name);\r
+ return newStr.toString();\r
+ }\r
+ \r
+\r
+\r
+}\r
--- /dev/null
+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.AuthorityRefDocList;
+import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.location.LocationauthoritiesCommonList;
+import org.collectionspace.services.location.LocationsCommonList;
+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("/locationauthorities/")
+@Produces({"multipart/mixed"})
+@Consumes({"multipart/mixed"})
+public interface LocationAuthorityProxy extends CollectionSpaceProxy {
+
+ // List Locationauthorities
+ @GET
+ @Produces({"application/xml"})
+ ClientResponse<LocationauthoritiesCommonList> readList();
+
+ //(C)reate
+ @POST
+ ClientResponse<Response> create(MultipartOutput multipart);
+
+ //(R)ead
+ @GET
+ @Path("/{csid}")
+ ClientResponse<MultipartInput> read(@PathParam("csid") String csid);
+
+ //(R)ead by name
+ @GET
+ @Path("/urn:cspace:name({name})")
+ ClientResponse<MultipartInput> readByName(@PathParam("name") String name);
+
+ //(U)pdate
+ @PUT
+ @Path("/{csid}")
+ ClientResponse<MultipartInput> update(@PathParam("csid") String csid, MultipartOutput multipart);
+
+ //(D)elete
+ @DELETE
+ @Path("/{csid}")
+ ClientResponse<Response> delete(@PathParam("csid") String csid);
+
+ // List Items
+ @GET
+ @Produces({"application/xml"})
+ @Path("/{vcsid}/items/")
+ ClientResponse<LocationsCommonList> readItemList(@PathParam("vcsid") String vcsid);
+
+ /**
+ * @param csid
+ * @return
+ * @see org.collectionspace.services.client.IntakeProxy#getAuthorityRefs(java.lang.String)
+ */
+ @GET
+ @Path("{csid}/items/{itemcsid}/refObjs")
+ @Produces("application/xml")
+ ClientResponse<AuthorityRefDocList> getReferencingObjects(
+ @PathParam("csid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid);
+
+ // List Items for a named authority
+ @GET
+ @Produces({"application/xml"})
+ @Path("/urn:cspace:name({specifier})/items/")
+ ClientResponse<LocationsCommonList> readItemListForNamedAuthority(@PathParam("specifier") String specifier);
+
+ //(C)reate Item
+ @POST
+ @Path("/{vcsid}/items/")
+ ClientResponse<Response> createItem(@PathParam("vcsid") String vcsid, MultipartOutput multipart);
+
+ //(R)ead Item
+ @GET
+ @Path("/{vcsid}/items/{csid}")
+ ClientResponse<MultipartInput> readItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
+
+ //(U)pdate Item
+ @PUT
+ @Path("/{vcsid}/items/{csid}")
+ ClientResponse<MultipartInput> updateItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid, MultipartOutput multipart);
+
+ //(D)elete Item
+ @DELETE
+ @Path("/{vcsid}/items/{csid}")
+ ClientResponse<Response> deleteItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid);
+
+ // List Contacts
+ @GET
+ @Produces({"application/xml"})
+ @Path("/{parentcsid}/items/{itemcsid}/contacts/")
+ ClientResponse<ContactsCommonList> readContactList(
+ @PathParam("parentcsid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid);
+
+ //(C)reate Contact
+ @POST
+ @Path("/{parentcsid}/items/{itemcsid}/contacts/")
+ ClientResponse<Response> createContact(
+ @PathParam("parentcsid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ MultipartOutput multipart);
+
+ //(R)ead Contact
+ @GET
+ @Path("/{parentcsid}/items/{itemcsid}/contacts/{csid}")
+ ClientResponse<MultipartInput> readContact(
+ @PathParam("parentcsid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ @PathParam("csid") String csid);
+
+ //(U)pdate Contact
+ @PUT
+ @Path("/{parentcsid}/items/{itemcsid}/contacts/{csid}")
+ ClientResponse<MultipartInput> updateContact(
+ @PathParam("parentcsid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ @PathParam("csid") String csid,
+ MultipartOutput multipart);
+
+ //(D)elete Contact
+ @DELETE
+ @Path("/{parentcsid}/items/{itemcsid}/contacts/{csid}")
+ ClientResponse<Response> deleteContact(
+ @PathParam("parentcsid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ @PathParam("csid") String csid);
+
+}
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c)) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.collectionspace.services.client.test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.LocationJAXBSchema;
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.ContactClient;
+import org.collectionspace.services.client.ContactClientUtils;
+import org.collectionspace.services.contact.ContactsCommon;
+import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.client.LocationAuthorityClient;
+import org.collectionspace.services.client.LocationAuthorityClientUtils;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.location.LocationauthoritiesCommon;
+import org.collectionspace.services.location.LocationauthoritiesCommonList;
+import org.collectionspace.services.location.LocationsCommon;
+import org.collectionspace.services.location.LocationsCommonList;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * LocationAuthorityServiceTest, carries out tests against a
+ * deployed and running LocationAuthority Service.
+ *
+ * $LastChangedRevision: 753 $
+ * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
+ */
+public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
+
+ /** The logger. */
+ private final Logger logger =
+ LoggerFactory.getLogger(LocationAuthorityServiceTest.class);
+
+ // Instance variables specific to this test.
+ /** The SERVICE path component. */
+ final String SERVICE_PATH_COMPONENT = "locationauthorities";
+
+ /** The ITEM servicE path component. */
+ final String ITEM_SERVICE_PATH_COMPONENT = "items";
+
+ /** The CONTACT servicE path component. */
+ final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
+
+ /** The TEST name. */
+ final String TEST_NAME = "Shelf 1";
+
+ /** The TEST conditionNote. */
+ final String TEST_CONDITION_NOTE = "Basically clean";
+
+ /** The TEST death date. */
+ final String TEST_CONDITION_NOTE_DATE = "June 11, 1979";
+
+ /** The TEST securityNote. */
+ final String TEST_SECURITY_NOTE = "Kind of safe";
+
+ /** The TEST location type. */
+ // TODO Make loc type be a controlled vocab term.
+ final String TEST_LOCATION_TYPE = "Shelf";
+
+ /** The TEST location type. */
+ // TODO Make status type be a controlled vocab term.
+ final String TEST_STATUS = "Approved";
+
+ /** The known resource id. */
+ private String knownResourceId = null;
+
+ /** The known resource display name. */
+ private String knownResourceDisplayName = null;
+
+ /** The known resource ref name. */
+ private String knownResourceRefName = null;
+
+ /** The known locationType ref name. */
+ private String knownLocationTypeRefName = null;
+
+ /** The known item resource id. */
+ private String knownItemResourceId = null;
+
+ /** The known contact resource id. */
+ private String knownContactResourceId = null;
+
+ /** The n items to create in list. */
+ private int nItemsToCreateInList = 3;
+
+ /** The all resource ids created. */
+ private List<String> allResourceIdsCreated = new ArrayList<String>();
+
+ /** The all item resource ids created. */
+ private Map<String, String> allItemResourceIdsCreated =
+ new HashMap<String, String>();
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
+ */
+ @Override
+ protected CollectionSpaceClient getClientInstance() {
+ return new LocationAuthorityClient();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
+ */
+ @Override
+ protected AbstractCommonList getAbstractCommonList(
+ ClientResponse<AbstractCommonList> response) {
+ return response.getEntity(LocationsCommonList.class);
+ }
+
+ // ---------------------------------------------------------------
+ // CRUD tests : CREATE tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"create"})
+ 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.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ String identifier = createIdentifier();
+ String displayName = "displayName-" + identifier;
+ String baseRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, false);
+ String fullRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, true);
+ MultipartOutput multipart =
+ LocationAuthorityClientUtils.createLocationAuthorityInstance(
+ displayName, fullRefName, client.getCommonPartName());
+ 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(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+
+ // Store the refname from the first resource created
+ // for additional tests below.
+ knownResourceRefName = baseRefName;
+
+ String newID = LocationAuthorityClientUtils.extractId(res);
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (knownResourceId == null){
+ knownResourceId = newID;
+ knownResourceDisplayName = displayName;
+ 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(newID);
+ }
+
+ /**
+ * Creates the item.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"create"})
+ public void createItem(String testName) {
+ setupCreate(testName);
+ String newID = createItemInAuthority(knownResourceId, knownResourceRefName);
+ }
+
+ /**
+ * Creates the item in authority.
+ *
+ * @param vcsid the vcsid
+ * @param authRefName the auth ref name
+ * @return the string
+ */
+ private String createItemInAuthority(String vcsid, String authRefName) {
+
+ final String testName = "createItemInAuthority";
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ":...");
+ }
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ String identifier = createIdentifier();
+ String refName = LocationAuthorityClientUtils.createLocationRefName(authRefName, TEST_NAME, true);
+ Map<String, String> shelf1Map = new HashMap<String,String>();
+ // TODO Make loc type and status be controlled vocabs.
+ shelf1Map.put(LocationJAXBSchema.NAME, TEST_NAME);
+ shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
+ shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
+ shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
+ shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ shelf1Map.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+ MultipartOutput multipart =
+ LocationAuthorityClientUtils.createLocationInstance(vcsid, refName, shelf1Map,
+ client.getItemCommonPartName() );
+ ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ int statusCode = res.getStatus();
+ String newID = LocationAuthorityClientUtils.extractId(res);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Store the ID returned from the first item resource created
+ // for additional tests below.
+ if (knownItemResourceId == null){
+ knownItemResourceId = newID;
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
+ }
+ }
+
+ // Store the IDs from any item resources created
+ // by tests, along with the IDs of their parents, so these items
+ // can be deleted after all tests have been run.
+ allItemResourceIdsCreated.put(newID, vcsid);
+
+ return newID;
+ }
+
+
+
+ // Failure outcomes
+
+ // Placeholders until the three tests below can be uncommented.
+ // See Issue CSPACE-401.
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
+ */
+ @Override
+ public void createWithEmptyEntityBody(String testName) throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
+ */
+ @Override
+ public void createWithMalformedXml(String testName) throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
+ */
+ @Override
+ public void createWithWrongXmlSchema(String testName) throws Exception {
+ }
+
+
+ // ---------------------------------------------------------------
+ // CRUD tests : CREATE LIST tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnGroups = {"create"})
+ public void createList(String testName) throws Exception {
+ for (int i = 0; i < nItemsToCreateInList; i++) {
+ create(testName);
+ }
+ }
+
+ /**
+ * Creates the item list.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"createList"}, dependsOnMethods = {"createList"})
+ public void createItemList(String testName) throws Exception {
+ // Add items to the initially-created, known parent record.
+ for (int j = 0; j < nItemsToCreateInList; j++) {
+ createItem(testName);
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // CRUD tests : READ tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnGroups = {"create"})
+ public void read(String testName) throws Exception {
+
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.read(knownResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Read by name.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnGroups = {"create"})
+ public void readByName(String testName) throws Exception {
+
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.readByName(knownResourceDisplayName);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
+ * Read item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"read"})
+ public void readItem(String testName) throws Exception {
+
+ // Perform setup.
+ setupRead(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a location.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ boolean showFull = true;
+ if(showFull && logger.isDebugEnabled()){
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(location, LocationsCommon.class));
+ }
+ Assert.assertEquals(location.getInAuthority(), knownResourceId);
+
+ }
+
+ /**
+ * Verify item display name.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ dependsOnMethods = {"readItem", "updateItem"})
+ public void verifyItemDisplayName(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdate(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether location has expected displayName.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ String displayName = location.getDisplayName();
+ // Make sure displayName matches computed form
+ String expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
+ Assert.assertNotNull(displayName, expectedDisplayName);
+
+ // Update the shortName and verify the computed name is updated.
+ location.setCsid(null);
+ location.setDisplayNameComputed(true);
+ location.setName("updated-" + TEST_NAME);
+ expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationsCommon updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.getName(), location.getName(),
+ "Updated ForeName in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
+ "Updated ForeName in Location not reflected in computed DisplayName.");
+
+ // Now Update the displayName, not computed and verify the computed name is overriden.
+ location.setDisplayNameComputed(false);
+ expectedDisplayName = "TestName";
+ location.setDisplayName(expectedDisplayName);
+
+ // Submit the updated resource to the service and store the response.
+ output = new MultipartOutput();
+ commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
+ "Updated displayNameComputed in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(),
+ expectedDisplayName,
+ "Updated DisplayName (not computed) in Location not stored.");
+ }
+
+ /**
+ * Verify illegal item display name.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ dependsOnMethods = {"verifyItemDisplayName"})
+ public void verifyIllegalItemDisplayName(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdateWithWrongXmlSchema(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ // Check whether Location has expected displayName.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ // Try to Update with computed false and no displayName
+ location.setDisplayNameComputed(false);
+ location.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+
+ // Failure outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"read"})
+ public void readNonExistent(String testName) {
+
+ // Perform setup.
+ setupReadNonExistent(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ 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);
+ }
+
+ /**
+ * Read item non existent.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"readItem"})
+ public void readItemNonExistent(String testName) {
+
+ // Perform setup.
+ setupReadNonExistent(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+
+ // ---------------------------------------------------------------
+ // CRUD tests : READ_LIST tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"readList"}, dependsOnGroups = {"createList", "read"})
+ public void readList(String testName) throws Exception {
+
+ // Perform setup.
+ setupReadList(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<LocationauthoritiesCommonList> res = client.readList();
+ LocationauthoritiesCommonList 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<LocationauthoritiesCommonList.LocationauthorityListItem> items =
+ list.getLocationauthorityListItem();
+ int i = 0;
+ for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
+ String csid = item.getCsid();
+ logger.debug(testName + ": list-item[" + i + "] csid=" +
+ csid);
+ logger.debug(testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ readItemList(csid, null);
+ i++;
+ }
+ }
+ }
+
+ /**
+ * Read item list.
+ */
+ @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
+ public void readItemList() {
+ readItemList(knownResourceId, null);
+ }
+
+ /**
+ * Read item list by authority name.
+ */
+ @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ public void readItemListByAuthorityName() {
+ readItemList(null, knownResourceDisplayName);
+ }
+
+ /**
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @param name the name
+ */
+ private void readItemList(String vcsid, String name) {
+
+ final String testName = "readItemList";
+
+ // Perform setup.
+ setupReadList(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<LocationsCommonList> res = null;
+ if(vcsid!= null) {
+ res = client.readItemList(vcsid);
+ } else if(name!= null) {
+ res = client.readItemListForNamedAuthority(name);
+ } else {
+ Assert.fail("readItemList passed null csid and name!");
+ }
+ LocationsCommonList 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);
+
+ List<LocationsCommonList.LocationListItem> items =
+ list.getLocationListItem();
+ int nItemsReturned = items.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": Expected "
+ + nExpectedItems +" items; got: "+nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ int i = 0;
+ for (LocationsCommonList.LocationListItem item : items) {
+ Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
+ Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
+ // Optionally output additional data about list members for debugging.
+ boolean showDetails = true;
+ if (showDetails && logger.isDebugEnabled()) {
+ logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
+ item.getCsid());
+ logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
+ item.getRefName());
+ logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ }
+ i++;
+ }
+ }
+
+
+ // Failure outcomes
+ // None at present.
+
+ // ---------------------------------------------------------------
+ // CRUD tests : UPDATE tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnGroups = {"read", "readList"})
+ public void update(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdate(testName);
+
+ // Retrieve the contents of a resource to update.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ 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 LocationAuthority to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+
+ // Update the contents of this resource.
+ locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
+ locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated LocationAuthority");
+ logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(locationAuthority, 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);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon updatedLocationAuthority =
+ (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(updatedLocationAuthority);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
+ locationAuthority.getDisplayName(),
+ "Data in updated object did not match submitted data.");
+ }
+
+ /**
+ * Update item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"update"})
+ public void updateItem(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdate(testName);
+
+ // Retrieve the contents of a resource to update.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<MultipartInput> res =
+ client.readItem(knownResourceId, knownItemResourceId);
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got Location to update with ID: " +
+ knownItemResourceId +
+ " in LocationAuthority: " + knownResourceId );
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+
+ // Update the contents of this resource.
+ location.setCsid(null);
+ location.setName("updated-" + location.getName());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated Location");
+ logger.debug(objectAsXmlString(location,
+ LocationsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationsCommon updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.getName(), location.getName(),
+ "Data in updated Location did not match submitted data.");
+ }
+
+ // Failure outcomes
+ // Placeholders until the three tests below can be uncommented.
+ // See Issue CSPACE-401.
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
+ */
+ @Override
+ public void updateWithEmptyEntityBody(String testName) throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
+ */
+ @Override
+ public void updateWithMalformedXml(String testName) throws Exception {
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
+ */
+ @Override
+ public void updateWithWrongXmlSchema(String testName) throws Exception {
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
+ */
+@Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"update"}, 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(s) used when creating the request payload may be arbitrary.
+ // The only relevant ID may be the one used in update(), below.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ String displayName = "displayName-NON_EXISTENT_ID";
+ String fullRefName = LocationAuthorityClientUtils.createLocationAuthRefName(displayName, true);
+ MultipartOutput multipart = LocationAuthorityClientUtils.createLocationAuthorityInstance(
+ displayName, fullRefName, client.getCommonPartName());
+ 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);
+ }
+
+ /**
+ * Update non existent item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"update"}, dependsOnMethods = {"updateItem", "testItemSubmitRequest"})
+ public void updateNonExistentItem(String testName) throws Exception {
+
+ // Perform setup.
+ setupUpdateNonExistent(testName);
+
+ // Submit the request to the service and store the response.
+ // Note: The ID used in this 'create' call may be arbitrary.
+ // The only relevant ID may be the one used in update(), below.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ Map<String, String> nonexMap = new HashMap<String,String>();
+ nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
+ nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ nonexMap.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+ MultipartOutput multipart =
+ LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID,
+ LocationAuthorityClientUtils.createLocationRefName(NON_EXISTENT_ID, NON_EXISTENT_ID, true), nonexMap,
+ client.getItemCommonPartName() );
+ ClientResponse<MultipartInput> res =
+ client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+ // ---------------------------------------------------------------
+ // CRUD tests : DELETE tests
+ // ---------------------------------------------------------------
+ // Success outcomes
+
+ // Note: delete sub-resources in ascending hierarchical order,
+ // before deleting their parents.
+
+ /**
+ * Delete item.
+ *
+ * @param testName the test name
+ * @throws Exception the exception
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ //groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "readListByPartialTerm", "update"})
+ groups = {"delete"}, dependsOnGroups = {"create", "read", "readList", "update"})
+ public void deleteItem(String testName) throws Exception {
+
+ // Perform setup.
+ setupDelete(testName);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("parentcsid =" + knownResourceId +
+ " itemcsid = " + knownItemResourceId);
+ }
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ public void delete(String testName) throws Exception {
+
+ // Perform setup.
+ setupDelete(testName);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("parentcsid =" + knownResourceId);
+ }
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ 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
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
+ */
+ @Override
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"delete"})
+ public void deleteNonExistent(String testName) throws Exception {
+
+ // Perform setup.
+ setupDeleteNonExistent(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ 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);
+ }
+
+ /**
+ * Delete non existent item.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ public void deleteNonExistentItem(String testName) {
+
+ // Perform setup.
+ setupDeleteNonExistent(testName);
+
+ // Submit the request to the service and store the response.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ }
+
+ // ---------------------------------------------------------------
+ // Utility tests : tests of code used in tests above
+ // ---------------------------------------------------------------
+ /**
+ * Tests the code for manually submitting data that is used by several
+ * of the methods above.
+ */
+ @Test(dependsOnMethods = {"create", "read"})
+ public void testSubmitRequest() {
+
+ // Expected status code: 200 OK
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
+
+ // Submit the request to the service and store the response.
+ String method = ServiceRequestType.READ.httpMethodName();
+ String url = getResourceURL(knownResourceId);
+ int statusCode = submitRequest(method, url);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("testSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
+
+ }
+
+ /**
+ * Test item submit request.
+ */
+ @Test(dependsOnMethods = {"createItem", "readItem", "testSubmitRequest"})
+ public void testItemSubmitRequest() {
+
+ // Expected status code: 200 OK
+ final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
+
+ // Submit the request to the service and store the response.
+ String method = ServiceRequestType.READ.httpMethodName();
+ String url = getItemResourceURL(knownResourceId, knownItemResourceId);
+ int statusCode = submitRequest(method, url);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("testItemSubmitRequest: url=" + url +
+ " status=" + statusCode);
+ }
+ Assert.assertEquals(statusCode, EXPECTED_STATUS);
+
+ }
+
+ // ---------------------------------------------------------------
+ // Cleanup of resources created during testing
+ // ---------------------------------------------------------------
+
+ /**
+ * Deletes all resources created by tests, after all tests have been run.
+ *
+ * This cleanup method will always be run, even if one or more tests fail.
+ * For this reason, it attempts to remove all resources created
+ * at any point during testing, even if some of those resources
+ * may be expected to be deleted by certain tests.
+ */
+
+ @AfterClass(alwaysRun=true)
+ public void cleanUp() {
+ String noTest = System.getProperty("noTestCleanup");
+ if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Skipping Cleanup phase ...");
+ }
+ return;
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up temporary resources created for testing ...");
+ }
+ String parentResourceId;
+ String itemResourceId;
+ // Clean up contact resources.
+ LocationAuthorityClient client = new LocationAuthorityClient();
+ parentResourceId = knownResourceId;
+ // Clean up item resources.
+ for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
+ itemResourceId = entry.getKey();
+ parentResourceId = entry.getValue();
+ // Note: Any non-success responses from the delete operation
+ // below are ignored and not reported.
+ ClientResponse<Response> res =
+ client.deleteItem(parentResourceId, itemResourceId);
+ }
+ // Clean up parent resources.
+ for (String resourceId : allResourceIdsCreated) {
+ // Note: Any non-success responses from the delete operation
+ // below are ignored and not reported.
+ ClientResponse<Response> res = client.delete(resourceId);
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // Utility methods used by tests above
+ // ---------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+ */
+ @Override
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
+ }
+
+ /**
+ * Gets the item service path component.
+ *
+ * @return the item service path component
+ */
+ public String getItemServicePathComponent() {
+ return ITEM_SERVICE_PATH_COMPONENT;
+ }
+
+ /**
+ * Returns the root URL for the item service.
+ *
+ * This URL consists of a base URL for all services, followed by
+ * a path component for the owning parent, followed by the
+ * path component for the items.
+ *
+ * @param parentResourceIdentifier An identifier (such as a UUID) for the
+ * parent authority resource of the relevant item resource.
+ *
+ * @return The root URL for the item service.
+ */
+ protected String getItemServiceRootURL(String parentResourceIdentifier) {
+ return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
+ }
+
+ /**
+ * Returns the URL of a specific item resource managed by a service, and
+ * designated by an identifier (such as a universally unique ID, or UUID).
+ *
+ * @param parentResourceIdentifier An identifier (such as a UUID) for the
+ * parent authority resource of the relevant item resource.
+ *
+ * @param itemResourceIdentifier An identifier (such as a UUID) for an
+ * item resource.
+ *
+ * @return The URL of a specific item resource managed by a service.
+ */
+ protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
+ return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
+ }
+
+
+}
--- /dev/null
+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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.importer</name>\r
+ <comment></comment>\r
+ <projects>\r
+ <project>org.collectionspace.services.client</project>\r
+ <project>org.collectionspace.services.common</project>\r
+ <project>org.collectionspace.services.person.jaxb</project>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Tue Nov 10 14:56:23 PST 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Tue Nov 10 14:56:18 PST 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+\r
+<project name="location" default="package" basedir=".">\r
+ <description>\r
+ location service\r
+ </description>\r
+ <!-- set global properties for this build -->\r
+ <property name="services.trunk" value="../../.."/>\r
+ <property file="${services.trunk}/build.properties" />\r
+ <property name="mvn.opts" value="" />\r
+ <property name="src" location="src"/>\r
+\r
+ <condition property="osfamily-unix">\r
+ <os family="unix" />\r
+ </condition>\r
+ <condition property="osfamily-windows">\r
+ <os family="windows" />\r
+ </condition>\r
+ \r
+ <target name="package" depends="package-unix,package-windows"\r
+ description="Package CollectionSpace Services" />\r
+ \r
+ <target name="package-unix" if="osfamily-unix">\r
+ <exec executable="mvn" failonerror="true">\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target>\r
+ \r
+ <target name="package-windows" if="osfamily-windows">\r
+ <exec executable="cmd" failonerror="true">\r
+ <arg value="/c" />\r
+ <arg value="mvn.bat" />\r
+ <arg value="package" />\r
+ <arg value="-Dmaven.test.skip=true" />\r
+ <arg value="-f" />\r
+ <arg value="${basedir}/pom.xml" />\r
+ <arg value="-N" />\r
+ <arg value="${mvn.opts}" />\r
+ </exec>\r
+ </target> \r
+\r
+ <target name="dist" depends="package"\r
+ description="distribute location service importer tool">\r
+ </target>\r
+\r
+ <target name="dist_installer" depends="package"\r
+ description="distribute location service importer tool"> \r
+ <!-- copy install scripts, etc. -->\r
+ <copy todir="${services.trunk}/${dist.installer.services}/location/postdeploy">\r
+ <fileset dir="${basedir}/target">\r
+ <include name="*with-dependencies*.jar"/>\r
+ </fileset>\r
+ </copy>\r
+ </target>\r
+\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location</artifactId>\r
+ <version>0.7-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.importer</artifactId>\r
+ <name>services.location.importer</name>\r
+ \r
+ <dependencies>\r
+ <!-- keep slf4j dependencies on the top -->\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ <version>1.5.2</version>\r
+ </dependency>\r
+ <!-- <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ <version>1.5.2</version>\r
+ </dependency> -->\r
+ <!-- CollectionSpace Dependencies -->\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.client</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency> \r
+<!-- \r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>5.6</version>\r
+ </dependency>\r
+ --> \r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <!-- filter out unwanted jars -->\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>commons-httpclient</groupId>\r
+ <artifactId>commons-httpclient</artifactId>\r
+ <version>3.1</version>\r
+ </dependency>\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>collectionspace-services-location-importer</finalName>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-assembly-plugin</artifactId>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>attached</goal>\r
+ </goals>\r
+ <phase>package</phase>\r
+ <configuration>\r
+ <descriptorRefs>\r
+ <descriptorRef>jar-with-dependencies</descriptorRef>\r
+ </descriptorRefs>\r
+ <archive>\r
+ <manifest>\r
+ <mainClass>org.collectionspace.services.location.importer.LocationAuthorityBaseImport</mainClass>\r
+ </manifest>\r
+ </archive>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin> \r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+/**
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright (c)) 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.collectionspace.services.location.importer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.log4j.BasicConfigurator;
+import org.collectionspace.services.LocationJAXBSchema;
+import org.collectionspace.services.client.LocationAuthorityClient;
+import org.collectionspace.services.client.LocationAuthorityClientUtils;
+import org.collectionspace.services.client.test.ServiceRequestType;
+import org.collectionspace.services.location.LocationauthoritiesCommon;
+import org.collectionspace.services.location.LocationauthoritiesCommonList;
+import org.collectionspace.services.location.LocationsCommon;
+import org.collectionspace.services.location.LocationsCommonList;
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * LocationAuthorityServiceTest, carries out tests against a
+ * deployed and running LocationAuthority Service.
+ *
+ * $LastChangedRevision: 753 $
+ * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
+ */
+public class LocationAuthorityBaseImport {
+ private static final Logger logger =
+ LoggerFactory.getLogger(LocationAuthorityBaseImport.class);
+
+ // Instance variables specific to this test.
+ private LocationAuthorityClient client = new LocationAuthorityClient();
+
+ public void createLocationAuthority(String locationAuthorityName,
+ List<Map<String, String>> locationMaps ) {
+
+ // Expected status code: 201 Created
+ int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+ // Type of service request being tested
+ ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+ if(logger.isDebugEnabled()){
+ logger.debug("Import: Create locationAuthority: \"" + locationAuthorityName +"\"");
+ }
+ String baseLocationRefName =
+ LocationAuthorityClientUtils.createLocationAuthRefName(locationAuthorityName, false);
+ String fullLocationRefName =
+ LocationAuthorityClientUtils.createLocationAuthRefName(locationAuthorityName, true);
+ MultipartOutput multipart =
+ LocationAuthorityClientUtils.createLocationAuthorityInstance(
+ locationAuthorityName, fullLocationRefName, client.getCommonPartName());
+ ClientResponse<Response> res = client.create(multipart);
+
+ int statusCode = res.getStatus();
+
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create enumeration: \""+locationAuthorityName
+ +"\" "+ LocationAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ }
+ if(statusCode != EXPECTED_STATUS_CODE) {
+ throw new RuntimeException("Unexpected Status when creating enumeration: \""
+ +locationAuthorityName +"\", Status:"+ statusCode);
+ }
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ String newLocationAuthorityId = LocationAuthorityClientUtils.extractId(res);
+ if(logger.isDebugEnabled()){
+ logger.debug("Import: Created locationAuthorityulary: \"" + locationAuthorityName +"\" ID:"
+ +newLocationAuthorityId );
+ }
+ for(Map<String,String> locationMap : locationMaps){
+ LocationAuthorityClientUtils.createItemInAuthority(
+ newLocationAuthorityId, baseLocationRefName, locationMap, client);
+ }
+ }
+
+ public static void main(String[] args) {
+
+ BasicConfigurator.configure();
+ logger.info("LocationAuthorityBaseImport starting...");
+
+ LocationAuthorityBaseImport pabi = new LocationAuthorityBaseImport();
+ final String demoLocationAuthorityName = "Demo Location Authority";
+
+ /* Strings are:
+ shortName, longName, nameAdditions, contactName,
+ foundingDate, dissolutionDate, foundingPlace, function, description
+ */
+ Map<String, String> johnWayneMap = new HashMap<String,String>();
+ johnWayneMap.put(LocationJAXBSchema.FORE_NAME, "John");
+ johnWayneMap.put(LocationJAXBSchema.SUR_NAME, "Wayne");
+ johnWayneMap.put(LocationJAXBSchema.GENDER, "male");
+ johnWayneMap.put(LocationJAXBSchema.BIRTH_DATE, "May 26, 1907");
+ johnWayneMap.put(LocationJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
+ johnWayneMap.put(LocationJAXBSchema.DEATH_DATE, "June 11, 1979");
+ johnWayneMap.put(LocationJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better" +
+ "known by his stage name John Wayne, was an American film actor, director " +
+ "and producer. He epitomized rugged masculinity and has become an enduring " +
+ "American icon. He is famous for his distinctive voice, walk and height. " +
+ "He was also known for his conservative political views and his support in " +
+ "the 1950s for anti-communist positions.");
+ Map<String, String> patrickSchmitzMap = new HashMap<String,String>();
+ patrickSchmitzMap.put(LocationJAXBSchema.FORE_NAME, "Patrick");
+ patrickSchmitzMap.put(LocationJAXBSchema.SUR_NAME, "Schmitz");
+ patrickSchmitzMap.put(LocationJAXBSchema.GENDER, "male");
+ patrickSchmitzMap.put(LocationJAXBSchema.BIRTH_DATE, "7/15/1960");
+ patrickSchmitzMap.put(LocationJAXBSchema.BIRTH_PLACE, "MI");
+ Map<String, String> janeDoeMap = new HashMap<String,String>();
+ janeDoeMap.put(LocationJAXBSchema.FORE_NAME, "Jane");
+ janeDoeMap.put(LocationJAXBSchema.SUR_NAME, "Doe");
+ janeDoeMap.put(LocationJAXBSchema.GENDER, "female");
+ janeDoeMap.put(LocationJAXBSchema.BIRTH_DATE, "7/04/1901");
+ janeDoeMap.put(LocationJAXBSchema.DEATH_DATE, "4/01/1999");
+ janeDoeMap.put(LocationJAXBSchema.BIRTH_PLACE, "Anytown, USA");
+ janeDoeMap.put(LocationJAXBSchema.BIRTH_PLACE, "Nowheresville, USA");
+ List<Map<String, String>> locationsMaps =
+ Arrays.asList(johnWayneMap, patrickSchmitzMap, janeDoeMap );
+
+ pabi.createLocationAuthority(demoLocationAuthorityName, locationsMaps);
+
+ logger.info("LocationAuthorityBaseImport complete.");
+ }
+}
--- /dev/null
+\r
+<project name="location" default="package" basedir=".">\r
+ <description>\r
+ location service\r
+ </description>\r
+ <!-- set global properties for this build -->\r
+ <property name="services.trunk" value="../.."/>\r
+ <property file="${services.trunk}/build.properties" />\r
+ <property name="mvn.opts" value="" />\r
+ <property name="src" location="src"/>\r
+\r
+ <condition property="osfamily-unix">\r
+ <os family="unix" />\r
+ </condition>\r
+ <condition property="osfamily-windows">\r
+ <os family="windows" />\r
+ </condition>\r
+ \r
+ <target name="install" description="">\r
+ <exec executable="echo">\r
+ <arg value="Installer: Executing location Service's 'install' target." />\r
+ </exec>\r
+ <!-- Copy the Nuxeo DocType jar files to the Nuxeo app server domain -->\r
+ <copy todir="${jboss.deploy.nuxeo.plugins}">\r
+ <fileset file="nuxeo/*.jar"/>\r
+ </copy> \r
+ </target> \r
+\r
+ <target name="config" description="" depends="install">\r
+ <exec executable="echo">\r
+ <arg value="Installer: Executing Location Service's 'config' target." />\r
+ </exec>\r
+ </target>\r
+ \r
+ <target name="predeploy" description="" depends="config">\r
+ <exec executable="echo">\r
+ <arg value="Installer: Executing Location Service's 'predeploy' target." />\r
+ </exec>\r
+ </target> \r
+ \r
+ <target name="deploy" description="">\r
+ <exec executable="echo">\r
+ <arg value="Installer: Executing Location Service's 'deploy' target." />\r
+ </exec>\r
+ </target>\r
+ \r
+ <target name="postdeploy">\r
+ <exec executable="echo">\r
+ <arg value="Installer: Executing installer's 'postdeploy' target for the Location Service." />\r
+ </exec> \r
+ <exec executable="echo">\r
+ <arg value="Importing necessary locationauthorities." />\r
+ </exec> \r
+ <java jar="./postdeploy/collectionspace-services-location-importer-jar-with-dependencies.jar"\r
+ fork="true"\r
+ failonerror="true">\r
+ </java> \r
+ </target>\r
+ \r
+\r
+</project>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.jaxb</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Mon Oct 05 17:07:09 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Mon Oct 05 17:07:08 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.location</artifactId>
+ <version>0.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.location.jaxb</artifactId>
+ <name>services.location.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>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-location-jaxb</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.collectionspace.services;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface LocationAuthorityJAXBSchema {\r
+ final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String REF_NAME = "refName";\r
+ final static String VOCAB_TYPE = "vocabType";\r
+ final static String CSID = "csid";\r
+}\r
+\r
+\r
--- /dev/null
+package org.collectionspace.services;\r
+\r
+public interface LocationAuthorityListItemJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String REF_NAME = "refName";\r
+ final static String VOCAB_TYPE = "vocabType";\r
+ final static String CSID = "csid";\r
+ final static String URI = "url";\r
+}\r
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.collectionspace.services;\r
+\r
+/**\r
+ * @author pschmitz\r
+ *\r
+ */\r
+public interface LocationJAXBSchema {\r
+ final static String LOCATIONS_COMMON = "locations_common";\r
+ final static String CSID = "csid";\r
+ final static String IN_AUTHORITY = "inAuthority";\r
+ final static String REF_NAME = "refName";\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
+ final static String NAME = "name";\r
+ final static String CONDITION_NOTE = "conditionNote";\r
+ final static String CONDITION_NOTE_DATE = "conditionNoteDate";\r
+ final static String SECURITY_NOTE = "securityNote";\r
+ final static String LOCATION_TYPE = "locationType";\r
+ final static String STATUS = "status";\r
+}\r
+\r
--- /dev/null
+package org.collectionspace.services;\r
+\r
+public interface LocationListItemJAXBSchema {\r
+ final static String DISPLAY_NAME = "displayName";\r
+ final static String REF_NAME = "refName";\r
+ final static String CSID = "csid";\r
+ final static String URI = "url";\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:ns="http://collectionspace.org/services/location"
+ xmlns="http://collectionspace.org/services/location"
+ targetNamespace="http://collectionspace.org/services/location"
+ version="0.1"
+ >
+
+
+ <!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Location+Service+Home -->
+
+ <!-- Location -->
+ <xs:element name="locations_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Common identifier -->
+ <xs:element name="csid" type="xs:string" />
+
+ <!-- Location Information Group -->
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="displayNameComputed" type="xs:boolean"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="conditionNote" type="xs:string"/>
+ <xs:element name="conditionNoteDate" type="xs:string"/>
+ <xs:element name="securityNote" type="xs:string"/>
+ <xs:element name="locationType" type="xs:string"/>
+ <xs:element name="status" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonListItem">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
+ <!-- Location instances, as in nuxeo repository -->
+ <xs:element name="locations-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonListItem">
+ <xs:sequence>
+ <xs:element name="location_list_item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve location details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="csid" type="xs:string"
+ minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ LocationAuthority schema (XSD)
+
+ Entity : LocationAuthority
+ Part : Common
+ Used for: JAXB binding between XML and Java objects
+
+ $LastChangedRevision: 1055 $
+ $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:ns="http://collectionspace.org/services/location"
+ xmlns="http://collectionspace.org/services/location"
+ targetNamespace="http://collectionspace.org/services/location"
+ 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/Location+Service+Home -->
+
+ <!-- LocationAuthority -->
+ <xs:element name="locationauthorities_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Common identifier -->
+ <xs:element name="csid" type="xs:string" />
+
+ <!-- LocationAuthority Information Group -->
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="vocabType" type="xs:string"/>
+
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- This is the base class for paginated lists -->
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
+
+ <!-- LocationAuthority instances, as in nuxeo repository -->
+ <xs:element name="locationauthorities-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="locationauthority-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="refName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="vocabType" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve locationauthority 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:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.main</artifactId>\r
+ <version>0.7-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location</artifactId>\r
+ <name>services.location</name>\r
+ <packaging>pom</packaging>\r
+\r
+ <modules>\r
+ <module>jaxb</module>\r
+ <module>service</module>\r
+ <module>3rdparty</module>\r
+ <module>client</module>\r
+ </modules>\r
+ \r
+ <profiles>\r
+ <profile>\r
+ <id>samples</id>\r
+ <modules>\r
+ <module>import</module>\r
+ <!-- <module>sample</module> -->\r
+ </modules>\r
+ </profile>\r
+ </profiles>\r
+ \r
+</project>\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.person.service</name>\r
+ <comment></comment>\r
+ <projects>\r
+ <project>org.collectionspace.services.common</project>\r
+ <project>org.collectionspace.services.jaxb</project>\r
+ <project>org.collectionspace.services.person.jaxb</project>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Mon Jan 04 16:43:19 PST 2010\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Mon Jan 04 16:40:35 PST 2010\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location</artifactId>\r
+ <version>0.7-SNAPSHOT</version>\r
+ </parent>\r
+ \r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.service</artifactId>\r
+ <name>services.location.service</name>\r
+ <packaging>jar</packaging>\r
+ \r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ </dependency>\r
+<!-- CollectionSpace dependencies --> \r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.location.jaxb</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.contact.service</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
+ <!-- External dependencies --> \r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.1</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>5.6</version>\r
+ </dependency>\r
+ \r
+ <!-- apache -->\r
+ <dependency>\r
+ <groupId>commons-beanutils</groupId>\r
+ <artifactId>commons-beanutils</artifactId>\r
+ <version>1.6.1</version>\r
+ </dependency>\r
+ <!-- use explict 1.1 version to prevent errors coming from Nuxeo client -->\r
+ <dependency>\r
+ <groupId>commons-logging</groupId>\r
+ <artifactId>commons-logging</artifactId>\r
+ <version>1.1</version>\r
+ </dependency>\r
+ <!-- javax -->\r
+\r
+\r
+ <dependency>\r
+ <groupId>javax.security</groupId>\r
+ <artifactId>jaas</artifactId>\r
+ <version>1.0.01</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>dom4j</groupId>\r
+ <artifactId>dom4j</artifactId>\r
+ <version>1.6.1</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ \r
+ <!-- jboss -->\r
+\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ </dependency>\r
+ \r
+ <!-- nuxeo -->\r
+\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-api</artifactId>\r
+ <version>${nuxeo.version.1.5}</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <artifactId>jboss-remoting</artifactId>\r
+ <groupId>jboss</groupId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.restlet</groupId>\r
+ <artifactId>org.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>collectionspace-services-location</finalName>\r
+ <plugins>\r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+/**
+ * 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.location;
+
+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.LocationAuthorityJAXBSchema;
+import org.collectionspace.services.LocationJAXBSchema;
+import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
+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.ServiceBindingUtils;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.BadRequestException;
+import org.collectionspace.services.common.document.DocumentException;
+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.repository.RepositoryClient;
+import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameUtils;
+import org.collectionspace.services.common.query.IQueryManager;
+import org.collectionspace.services.contact.ContactResource;
+import org.collectionspace.services.contact.ContactsCommon;
+import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.contact.ContactJAXBSchema;
+import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler;
+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 LocationAuthorityResource.
+ */
+@Path("/locationauthorities")
+@Consumes("multipart/mixed")
+@Produces("multipart/mixed")
+public class LocationAuthorityResource extends
+ AbstractMultiPartCollectionSpaceResourceImpl {
+
+ /** The Constant locationAuthorityServiceName. */
+ private final static String locationAuthorityServiceName = "locationauthorities";
+
+ /** The Constant locationServiceName. */
+ private final static String locationServiceName = "locations";
+
+ /** The logger. */
+ final Logger logger = LoggerFactory.getLogger(LocationAuthorityResource.class);
+ //FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
+ final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+ /**
+ * Instantiates a new location authority resource.
+ */
+ public LocationAuthorityResource() {
+ // do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
+ @Override
+ protected String getVersionString() {
+ /** The last change revision. */
+ final String lastChangeRevision = "$LastChangedRevision: 1850 $";
+ return lastChangeRevision;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
+ @Override
+ public String getServiceName() {
+ return locationAuthorityServiceName;
+ }
+
+ @Override
+ public Class<LocationauthoritiesCommon> getCommonPartClass() {
+ return LocationauthoritiesCommon.class;
+ }
+
+ /**
+ * Gets the item service name.
+ *
+ * @return the item service name
+ */
+ public String getItemServiceName() {
+ return locationServiceName;
+ }
+
+ /**
+ * Creates the item document handler.
+ *
+ * @param ctx the ctx
+ * @param inAuthority the in authority
+ *
+ * @return the document handler
+ *
+ * @throws Exception the exception
+ */
+ private DocumentHandler createItemDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx,
+ String inAuthority) throws Exception {
+ LocationDocumentModelHandler docHandler = (LocationDocumentModelHandler)createDocumentHandler(ctx,
+ ctx.getCommonPartLabel(getItemServiceName()),
+ LocationsCommon.class);
+ docHandler.setInAuthority(inAuthority);
+
+ return docHandler;
+ }
+
+ /**
+ * Creates the location authority.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+ @POST
+ public Response createLocationAuthority(MultipartInput input) {
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
+ DocumentHandler handler = createDocumentHandler(ctx);
+ String csid = getRepositoryClient(ctx).create(ctx, handler);
+ //locationAuthorityObject.setCsid(csid);
+ UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (BadRequestException bre) {
+ Response response = Response.status(
+ Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(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 createLocationAuthority", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ }
+
+ /**
+ * Gets the location authority by name.
+ *
+ * @param specifier the specifier
+ *
+ * @return the location authority by name
+ */
+ @GET
+ @Path("urn:cspace:name({specifier})")
+ public MultipartOutput getLocationAuthorityByName(@PathParam("specifier") String specifier) {
+ if (specifier == null) {
+ logger.error("getLocationAuthority: missing name!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "get failed on LocationAuthority (missing specifier)").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ String whereClause =
+ LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
+ ":"+LocationAuthorityJAXBSchema.DISPLAY_NAME+
+ "='"+specifier+"'";
+ // We only get a single doc - if there are multiple,
+ // it is an error in use.
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocationAuthority with name=" + specifier);
+ }
+ MultipartOutput result = null;
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ DocumentHandler handler = createDocumentHandler(ctx);
+ DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
+ handler.setDocumentFilter(myFilter);
+ getRepositoryClient(ctx).get(ctx, 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("getLocationAuthority", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed on LocationAuthority spec=" + specifier).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocationAuthority", 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 LocationAuthority spec:" + specifier + ": was not found.").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the entities referencing this Location instance. The service type
+ * can be passed as a query param "type", and must match a configured type
+ * for the service bindings. If not set, the type defaults to
+ * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
+ *
+ * @param csid the parent csid
+ * @param itemcsid the location csid
+ * @param ui the ui
+ *
+ * @return the info for the referencing objects
+ */
+ @GET
+ @Path("{csid}/items/{itemcsid}/refObjs")
+ @Produces("application/xml")
+ public AuthorityRefDocList getReferencingObjects(
+ @PathParam("csid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ @Context UriInfo ui) {
+ AuthorityRefDocList authRefDocList = null;
+ if (logger.isDebugEnabled()) {
+ logger.debug("getReferencingObjects with parentcsid="
+ + parentcsid + " and itemcsid=" + itemcsid);
+ }
+ if (parentcsid == null || "".equals(parentcsid)
+ || itemcsid == null || "".equals(itemcsid)) {
+ logger.error("getLocation: missing parentcsid or itemcsid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "get failed on Location with parentcsid="
+ + parentcsid + " and itemcsid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ try {
+ // Note that we have to create the service context for the Items, not the main service
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ RepositoryClient repoClient = getRepositoryClient(ctx);
+ DocumentFilter myFilter = handler.createDocumentFilter();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ myFilter.setPagination(queryParams);
+ String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
+ List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
+ if (list != null) {
+ serviceType = list.get(0);
+ }
+ DocumentWrapper<DocumentModel> docWrapper = repoClient.getDoc(ctx, itemcsid);
+ DocumentModel docModel = docWrapper.getWrappedObject();
+ String refName = (String)docModel.getPropertyValue(LocationJAXBSchema.REF_NAME);
+
+ authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(ctx, repoClient,
+ serviceType, refName,
+ myFilter.getPageSize(), myFilter.getStartPage(), true );
+ } 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("getReferencingObjects", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "GetReferencingObjects failed with parentcsid="
+ + parentcsid + " and itemcsid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) { // Includes DocumentException
+ if (logger.isDebugEnabled()) {
+ logger.debug("GetReferencingObjects", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (authRefDocList == null) {
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed, the requested Location CSID:" + itemcsid + ": was not found.").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return authRefDocList;
+ }
+
+ @GET
+ @Path("{csid}")
+ public MultipartOutput getLocationAuthority(@PathParam("csid") String csid) {
+ if (csid == null) {
+ logger.error("getLocationAuthority: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "get failed on LocationAuthority csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocationAuthority with path(id)=" + csid);
+ }
+ 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("getLocationAuthority", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed on LocationAuthority csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocationAuthority", 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 LocationAuthority CSID:" + csid + ": was not found.").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the location authority list.
+ *
+ * @param ui the ui
+ *
+ * @return the location authority list
+ */
+ @GET
+ @Produces("application/xml")
+ public LocationauthoritiesCommonList getLocationAuthorityList(@Context UriInfo ui) {
+ LocationauthoritiesCommonList locationAuthorityObjectList = new LocationauthoritiesCommonList();
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ DocumentHandler handler = createDocumentHandler(ctx);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME
+ String nameQ = queryParams.getFirst("refName");
+ if (nameQ != null) {
+ myFilter.setWhereClause("locationauthorities_common:refName='" + nameQ + "'");
+ }
+ handler.setDocumentFilter(myFilter);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ locationAuthorityObjectList = (LocationauthoritiesCommonList) 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 getLocationAuthorityList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return locationAuthorityObjectList;
+ }
+
+ /**
+ * Update location authority.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
+ @PUT
+ @Path("{csid}")
+ public MultipartOutput updateLocationAuthority(
+ @PathParam("csid") String csid,
+ MultipartInput theUpdate) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateLocationAuthority with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("updateLocationAuthority: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "update failed on LocationAuthority 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 (BadRequestException bre) {
+ Response response = Response.status(
+ Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caugth exception in updateLocationAuthority", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Update failed on LocationAuthority 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 location authority.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
+ @DELETE
+ @Path("{csid}")
+ public Response deleteLocationAuthority(@PathParam("csid") String csid) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteLocationAuthority with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("deleteLocationAuthority: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "delete failed on LocationAuthority 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 deleteLocationAuthority", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Delete failed on LocationAuthority 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);
+ }
+
+ }
+
+ /*************************************************************************
+ * Location parts - this is a sub-resource of LocationAuthority
+ *************************************************************************/
+ @POST
+ @Path("{csid}/items")
+ public Response createLocation(@PathParam("csid") String parentcsid, MultipartInput input) {
+ try {
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(), input);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
+ UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
+ path.path(parentcsid + "/items/" + itemcsid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (BadRequestException bre) {
+ Response response = Response.status(
+ Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(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 createLocation", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ }
+
+ /**
+ * Gets the location.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the location
+ */
+ @GET
+ @Path("{csid}/items/{itemcsid}")
+ public MultipartOutput getLocation(
+ @PathParam("csid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+ }
+ if (parentcsid == null || "".equals(parentcsid)
+ || itemcsid == null || "".equals(itemcsid)) {
+ logger.error("getLocation: missing parentcsid or itemcsid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "get failed on Location with parentcsid="
+ + parentcsid + " and itemcsid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ // Note that we have to create the service context for the Items, not the main service
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ getRepositoryClient(ctx).get(ctx, itemcsid, handler);
+ // TODO should we assert that the item is in the passed locationAuthority?
+ 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("getLocation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed on Location csid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLocation", 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 Location CSID:" + itemcsid + ": was not found.").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the location list.
+ *
+ * @param parentcsid the parentcsid
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the location list
+ */
+ @GET
+ @Path("{csid}/items")
+ @Produces("application/xml")
+ public LocationsCommonList getLocationList(
+ @PathParam("csid") String parentcsid,
+ @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
+ @Context UriInfo ui) {
+ LocationsCommonList locationObjectList = new LocationsCommonList();
+ try {
+ // Note that docType defaults to the ServiceName, so we're fine with that.
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ queryParams);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ DocumentFilter myFilter = handler.getDocumentFilter();
+
+ // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
+ myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
+ LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
+
+ // AND locations_common:displayName LIKE '%partialTerm%'
+ if (partialTerm != null && !partialTerm.isEmpty()) {
+ String ptClause =
+ LocationJAXBSchema.LOCATIONS_COMMON + ":" +
+ LocationJAXBSchema.DISPLAY_NAME +
+ " LIKE " +
+ "'%" + partialTerm + "%'";
+ myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ locationObjectList = (LocationsCommonList) 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 getLocationList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return locationObjectList;
+ }
+
+
+ /**
+ * Gets the location list by auth name.
+ *
+ * @param parentSpecifier the parent specifier
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the location list by auth name
+ */
+ @GET
+ @Path("urn:cspace:name({specifier})/items")
+ @Produces("application/xml")
+ public LocationsCommonList getLocationListByAuthName(
+ @PathParam("specifier") String parentSpecifier,
+ @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
+ @Context UriInfo ui) {
+ LocationsCommonList locationObjectList = new LocationsCommonList();
+ try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ String whereClause =
+ LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
+ ":"+LocationAuthorityJAXBSchema.DISPLAY_NAME+
+ "='"+parentSpecifier+"'";
+ // Need to get an Authority by name
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+ String parentcsid =
+ getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
+
+ ctx = createServiceContext(getItemServiceName(), queryParams);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
+ myFilter.setPagination(queryParams); //FIXME
+
+ // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
+ myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
+ LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
+
+ // AND locations_common:displayName LIKE '%partialTerm%'
+ if (partialTerm != null && !partialTerm.isEmpty()) {
+ String ptClause = // "AND " +
+ LocationJAXBSchema.LOCATIONS_COMMON + ":" +
+ LocationJAXBSchema.DISPLAY_NAME +
+ " LIKE " +
+ "'%" + partialTerm + "%'";
+ myFilter.appendWhereClause(ptClause, "AND");
+ }
+
+ handler.setDocumentFilter(myFilter);
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ locationObjectList = (LocationsCommonList) 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 getLocationList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return locationObjectList;
+ }
+
+ /**
+ * Update location.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
+ @PUT
+ @Path("{csid}/items/{itemcsid}")
+ public MultipartOutput updateLocation(
+ @PathParam("csid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid,
+ MultipartInput theUpdate) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+ }
+ if (parentcsid == null || "".equals(parentcsid)) {
+ logger.error("updateLocation: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "update failed on Location parentcsid=" + parentcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (itemcsid == null || "".equals(itemcsid)) {
+ logger.error("updateLocation: missing itemcsid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "update failed on Location=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ // Note that we have to create the service context for the Items, not the main service
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
+ theUpdate);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
+ getRepositoryClient(ctx).update(ctx, itemcsid, handler);
+ result = (MultipartOutput) ctx.getOutput();
+ } catch (BadRequestException bre) {
+ Response response = Response.status(
+ Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } 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 updateLocation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Update failed on Location csid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Delete location.
+ *
+ * @param parentcsid the parentcsid
+ * @param itemcsid the itemcsid
+ *
+ * @return the response
+ */
+ @DELETE
+ @Path("{csid}/items/{itemcsid}")
+ public Response deleteLocation(
+ @PathParam("csid") String parentcsid,
+ @PathParam("itemcsid") String itemcsid) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
+ }
+ if (parentcsid == null || "".equals(parentcsid)) {
+ logger.error("deleteLocation: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "delete failed on Location parentcsid=" + parentcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (itemcsid == null || "".equals(itemcsid)) {
+ logger.error("deleteLocation: missing itemcsid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "delete failed on Location=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ try {
+ // Note that we have to create the service context for the Items, not the main service
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
+ getRepositoryClient(ctx).delete(ctx, itemcsid);
+ return Response.status(HttpResponseCodes.SC_OK).build();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caught exception in deleteLocation", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Delete failed on Location itemcsid=" + itemcsid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+ }
+
+}
--- /dev/null
+/**
+ * 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.location.nuxeo;
+
+/**
+ * LocationAuthorityConstants processes CollectionObject document
+ *
+ */
+public class LocationAuthorityConstants {
+
+ public final static String NUXEO_DOCTYPE = "LocationAuthority";
+ public final static String NUXEO_SCHEMA_NAME = "locationauthority";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-LocationAuthority";
+}
--- /dev/null
+/**
+ * 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.location.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.collectionspace.services.LocationAuthorityJAXBSchema;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.location.LocationauthoritiesCommon;
+import org.collectionspace.services.location.LocationauthoritiesCommonList;
+import org.collectionspace.services.location.LocationauthoritiesCommonList.LocationauthorityListItem;
+
+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;
+
+/**
+ * LocationAuthorityDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class LocationAuthorityDocumentModelHandler
+ extends RemoteDocumentModelHandlerImpl<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
+
+ private final Logger logger = LoggerFactory.getLogger(LocationAuthorityDocumentModelHandler.class);
+ /**
+ * locationAuthority is used to stash JAXB object to use when handle is called
+ * for Action.CREATE, Action.UPDATE or Action.GET
+ */
+ private LocationauthoritiesCommon locationAuthority;
+ /**
+ * locationAuthorityList is stashed when handle is called
+ * for ACTION.GET_ALL
+ */
+ private LocationauthoritiesCommonList locationAuthorityList;
+
+
+ /**
+ * getCommonPart get associated locationAuthority
+ * @return
+ */
+ @Override
+ public LocationauthoritiesCommon getCommonPart() {
+ return locationAuthority;
+ }
+
+ /**
+ * setCommonPart set associated locationAuthority
+ * @param locationAuthority
+ */
+ @Override
+ public void setCommonPart(LocationauthoritiesCommon locationAuthority) {
+ this.locationAuthority = locationAuthority;
+ }
+
+ /**
+ * getCommonPartList get associated locationAuthority (for index/GET_ALL)
+ * @return
+ */
+ @Override
+ public LocationauthoritiesCommonList getCommonPartList() {
+ return locationAuthorityList;
+ }
+
+ @Override
+ public void setCommonPartList(LocationauthoritiesCommonList locationAuthorityList) {
+ this.locationAuthorityList = locationAuthorityList;
+ }
+
+ @Override
+ public LocationauthoritiesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+ throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void fillCommonPart(LocationauthoritiesCommon locationAuthorityObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ LocationauthoritiesCommonList coList = extractPagingInfo(new LocationauthoritiesCommonList(),
+ wrapDoc);
+
+ //FIXME: iterating over a long list of documents is not a long term
+ //strategy...need to change to more efficient iterating in future
+ List<LocationauthoritiesCommonList.LocationauthorityListItem> list = coList.getLocationauthorityListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ while(iter.hasNext()){
+ DocumentModel docModel = iter.next();
+ LocationauthorityListItem ilistItem = new LocationauthorityListItem();
+ ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+ LocationAuthorityJAXBSchema.DISPLAY_NAME));
+ ilistItem.setRefName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+ LocationAuthorityJAXBSchema.REF_NAME));
+ ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+ LocationAuthorityJAXBSchema.VOCAB_TYPE));
+ String id = NuxeoUtils.extractId(docModel.getPathAsString());
+ ilistItem.setUri(getServiceContextPath() + id);
+ ilistItem.setCsid(id);
+ list.add(ilistItem);
+ }
+
+ return coList;
+ }
+
+ /**
+ * getQProperty converts the given property to qualified schema property
+ * @param prop
+ * @return
+ */
+ @Override
+ public String getQProperty(String prop) {
+ return LocationAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+ }
+}
+
--- /dev/null
+/**
+ * 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.location.nuxeo;
+
+/**
+ * LocationConstants processes CollectionObject document
+ *
+ */
+public class LocationConstants {
+
+ public final static String NUXEO_DOCTYPE = "Location";
+ public final static String NUXEO_SCHEMA_NAME = "location";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-Location";
+}
--- /dev/null
+/**
+ * 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.location.nuxeo;
+
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.collectionspace.services.LocationJAXBSchema;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.collectionspace.services.location.LocationsCommon;
+import org.collectionspace.services.location.LocationsCommonList;
+import org.collectionspace.services.location.LocationsCommonList.LocationListItem;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * LocationDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+/**
+ * @author pschmitz
+ *
+ */
+public class LocationDocumentModelHandler
+ extends RemoteDocumentModelHandlerImpl<LocationsCommon, LocationsCommonList> {
+
+ /** The logger. */
+ private final Logger logger = LoggerFactory.getLogger(LocationDocumentModelHandler.class);
+ /**
+ * Common part schema label
+ */
+ private static final String COMMON_PART_LABEL = "locations_common";
+
+ /**
+ * location is used to stash JAXB object to use when handle is called
+ * for Action.CREATE, Action.UPDATE or Action.GET
+ */
+ private LocationsCommon location;
+ /**
+ * locationList is stashed when handle is called
+ * for ACTION.GET_ALL
+ */
+ private LocationsCommonList locationList;
+
+ /**
+ * inAuthority is the parent OrgAuthority for this context
+ */
+ private String inAuthority;
+
+ /**
+ * Gets the in authority.
+ *
+ * @return the in authority
+ */
+ public String getInAuthority() {
+ return inAuthority;
+ }
+
+ /**
+ * Sets the in authority.
+ *
+ * @param inAuthority the new in authority
+ */
+ public void setInAuthority(String inAuthority) {
+ this.inAuthority = inAuthority;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ // first fill all the parts of the document
+ super.handleCreate(wrapDoc);
+ handleDisplayName(wrapDoc.getWrappedObject());
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ super.handleUpdate(wrapDoc);
+ handleDisplayName(wrapDoc.getWrappedObject());
+ }
+
+ /**
+ * Handle display name.
+ *
+ * @param docModel the doc model
+ * @throws Exception the exception
+ */
+ private void handleDisplayName(DocumentModel docModel) throws Exception {
+ String commonPartLabel = getServiceContext().getCommonPartLabel("locations");
+ Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+ LocationJAXBSchema.DISPLAY_NAME_COMPUTED);
+ if (displayNameComputed) {
+ String displayName = prepareDefaultDisplayName(
+ (String)docModel.getProperty(commonPartLabel, LocationJAXBSchema.NAME ));
+ docModel.setProperty(commonPartLabel, LocationJAXBSchema.DISPLAY_NAME,
+ displayName);
+ }
+ }
+
+ /**
+ * Produces a default displayName from the basic name and dates fields.
+ * @see LocationAuthorityClientUtils.prepareDefaultDisplayName() which
+ * duplicates this logic, until we define a service-general utils package
+ * that is neither client nor service specific.
+ * @param foreName
+ * @param middleName
+ * @param surName
+ * @param birthDate
+ * @param deathDate
+ * @return
+ * @throws Exception
+ */
+ private static String prepareDefaultDisplayName(
+ String name ) throws Exception {
+ StringBuilder newStr = new StringBuilder();
+ newStr.append(name);
+ return newStr.toString();
+ }
+
+ /**
+ * getCommonPart get associated location
+ * @return
+ */
+ @Override
+ public LocationsCommon getCommonPart() {
+ return location;
+ }
+
+ /**
+ * setCommonPart set associated location
+ * @param location
+ */
+ @Override
+ public void setCommonPart(LocationsCommon location) {
+ this.location = location;
+ }
+
+ /**
+ * getCommonPartList get associated location (for index/GET_ALL)
+ * @return
+ */
+ @Override
+ public LocationsCommonList getCommonPartList() {
+ return locationList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
+ */
+ @Override
+ public void setCommonPartList(LocationsCommonList locationList) {
+ this.locationList = locationList;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
+ */
+ @Override
+ protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
+ throws Exception {
+ Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
+
+ // Add the CSID to the common part
+ if (partMeta.getLabel().equalsIgnoreCase(COMMON_PART_LABEL)) {
+ String csid = NuxeoUtils.extractId(docModel.getPathAsString());
+ unQObjectProperties.put("csid", csid);
+ }
+
+ return unQObjectProperties;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public LocationsCommon extractCommonPart(DocumentWrapper wrapDoc)
+ throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void fillCommonPart(LocationsCommon locationObject, DocumentWrapper wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public LocationsCommonList extractCommonPartList(
+ DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ LocationsCommonList coList = extractPagingInfo(new LocationsCommonList(), wrapDoc);
+ List<LocationsCommonList.LocationListItem> list = coList.getLocationListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ String commonPartLabel = getServiceContext().getCommonPartLabel(
+ "locations");
+ while (iter.hasNext()) {
+ DocumentModel docModel = iter.next();
+ LocationListItem ilistItem = new LocationListItem();
+ ilistItem.setDisplayName((String) docModel.getProperty(
+ commonPartLabel, LocationJAXBSchema.DISPLAY_NAME));
+ ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
+ LocationJAXBSchema.REF_NAME));
+ String id = NuxeoUtils.extractId(docModel.getPathAsString());
+ ilistItem.setUri("/locationauthorities/" + inAuthority + "/items/"
+ + 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 LocationConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+ }
+}
+
--- /dev/null
+/**
+ * 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.
+ *//**
+ * 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.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.collectionspace.services.location.nuxeo;
+
+import org.collectionspace.services.location.LocationsCommon;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+import org.collectionspace.services.common.document.ValidatorHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author
+ */
+public class LocationValidatorHandler implements ValidatorHandler {
+
+ final Logger logger = LoggerFactory.getLogger(LocationValidatorHandler.class);
+
+ @Override
+ public void validate(Action action, ServiceContext ctx)
+ throws InvalidDocumentException {
+ if(logger.isDebugEnabled()) {
+ logger.debug("validate() action=" + action.name());
+ }
+ try {
+ MultipartServiceContext mctx = (MultipartServiceContext) ctx;
+ LocationsCommon location = (LocationsCommon) mctx.getInputPart(mctx.getCommonPartLabel(),
+ LocationsCommon.class);
+ String msg = "";
+ boolean invalid = false;
+ if(!location.isDisplayNameComputed() && (location.getDisplayName()==null)) {
+ invalid = true;
+ msg += "displayName must be non-null if displayNameComputed is false!";
+ }
+ /*
+ if(action.equals(Action.CREATE)) {
+ //create specific validation here
+ } else if(action.equals(Action.UPDATE)) {
+ //update specific validation here
+ }
+ */
+
+ if (invalid) {
+ logger.error(msg);
+ throw new InvalidDocumentException(msg);
+ }
+ } catch (InvalidDocumentException ide) {
+ throw ide;
+ } catch (Exception e) {
+ throw new InvalidDocumentException(e);
+ }
+ }
+}
// AND persons_common:displayName LIKE '%partialTerm%'
if (partialTerm != null && !partialTerm.isEmpty()) {
- String ptClause = "AND " +
+ String ptClause =
PersonJAXBSchema.PERSONS_COMMON + ":" +
PersonJAXBSchema.DISPLAY_NAME +
" LIKE " +
"'%" + partialTerm + "%'";
// handler.getDocumentFilter().appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
- handler.getDocumentFilter().appendWhereClause(ptClause, "");
+ handler.getDocumentFilter().appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
}
getRepositoryClient(ctx).getFiltered(ctx, handler);
<module>intake</module>
<module>loanin</module>
<module>loanout</module>
+ <module>location</module>
<module>movement</module>
<module>dimension</module>
<module>contact</module>