--- /dev/null
+
+<project name="taxonomy.3rdparty" default="package" basedir=".">
+ <description>
+ taxonomy service 3rdparty
+ </description>
+ <!-- set global properties for this build -->
+ <property name="services.trunk" value="../../.."/>
+ <!-- environment should be declared before reading build.properties -->
+ <property environment="env" />
+ <property file="${services.trunk}/build.properties" />
+ <property name="mvn.opts" value="" />
+ <property name="src" taxonomy="src"/>
+
+ <condition property="osfamily-unix">
+ <os family="unix" />
+ </condition>
+ <condition property="osfamily-windows">
+ <os family="windows" />
+ </condition>
+
+ <target name="init" >
+ <!-- Create the time stamp -->
+ <tstamp/>
+ </target>
+
+ <target name="package" depends="package-unix,package-windows"
+ description="Package CollectionSpace Services" />
+ <target name="package-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="package" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="package-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="package" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="install" depends="install-unix,install-windows"
+ description="Install" />
+ <target name="install-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="install" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="install-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="install" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="clean" depends="clean-unix,clean-windows"
+ description="Delete target directories" >
+ <delete dir="${build}"/>
+ </target>
+ <target name="clean-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="clean" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="clean-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="clean" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="test" depends="test-unix,test-windows" description="Run tests" />
+ <target name="test-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="test" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="test-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="test" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="deploy" depends="install"
+ description="deploy taxonomy in ${jboss.server.nuxeo}">
+ <ant antfile="nuxeo-platform-cs-taxonomy/build.xml" target="deploy" inheritall="false"/>
+ </target>
+
+ <target name="undeploy"
+ description="undeploy taxonomy from ${jboss.server.nuxeo}">
+ <ant antfile="nuxeo-platform-cs-taxonomy/build.xml" target="undeploy" inheritall="false"/>
+ </target>
+
+ <target name="dist"
+ description="generate distribution for taxonomy" depends="package">
+ <ant antfile="nuxeo-platform-cs-taxonomy/build.xml" target="dist" inheritall="false"/>
+ </target>
+
+ <target name="dist_installer"
+ description="generate distribution for taxonomy" depends="package">
+ <ant antfile="nuxeo-platform-cs-taxonomy/build.xml" target="dist_installer" inheritall="false"/>
+ </target>
+
+</project>
--- /dev/null
+
+<project name="nuxeo-platform-cs-taxonomy" default="package" basedir=".">
+ <description>
+ taxonomy 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" taxonomy="src"/>
+ <property name="nuxeo.taxonomy.jar"
+ value="org.collectionspace.services.taxonomy.3rdparty.nuxeo-${cspace.release}.jar"/>
+ <property name="nuxeo.taxonomy.jars.all"
+ value="org.collectionspace.services.taxonomy.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 taxonomy doctype in ${jboss.server.nuxeo}">
+ <copy file="${basedir}/target/${nuxeo.taxonomy.jar}"
+ todir="${jboss.deploy.nuxeo.plugins}"/>
+ </target>
+
+ <target name="undeploy"
+ description="undeploy taxonomy doctype from ${jboss.server.nuxeo}">
+ <delete>
+ <fileset dir="${jboss.deploy.nuxeo.plugins}">
+ <include name="${nuxeo.taxonomy.jars.all}"/>
+ </fileset>
+ <!-- Legacy deployment taxonomy through release 0.6 -->
+ <fileset dir="${jboss.deploy.nuxeo.system}">
+ <include name="${nuxeo.taxonomy.jars.all}"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <target name="dist"
+ description="generate distribution for taxonomy doctype" depends="package">
+ <copy todir="${services.trunk}/${dist.deploy.nuxeo.plugins}">
+ <fileset file="${basedir}/target/${nuxeo.taxonomy.jar}"/>
+ </copy>
+ </target>
+
+ <target name="dist_installer"
+ description="Creates an installer distribution for taxonomy doctype" depends="package">
+ <copy todir="${services.trunk}/${dist.installer.services}/taxonomy/nuxeo">
+ <fileset file="${basedir}/target/${nuxeo.taxonomy.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.taxonomy.3rdparty</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.3rdparty.nuxeo</artifactId>
+ <name>services.taxonomy.3rdparty.nuxeo</name>
+ <packaging>jar</packaging>
+ <description>
+ Taxonomy 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
+Bundle-ManifestVersion: 1
+Bundle-Name: NuxeoCS
+Bundle-SymbolicName: org.collectionspace.taxonomy;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Vendor: Nuxeo
+Require-Bundle: org.nuxeo.runtime,
+ org.nuxeo.ecm.core.api,
+ org.nuxeo.ecm.core,
+ org.nuxeo.ecm.core.api,
+ org.nuxeo.ecm.platform.types.api,
+ org.nuxeo.ecm.platform.versioning.api,
+ org.nuxeo.ecm.platform.ui,
+ org.nuxeo.ecm.platform.forms.layout.client,
+ org.nuxeo.ecm.platform.ws,
+ org.collectionspace.collectionspace_core
+Provide-Package: org.collectionspace.taxonomy
+Nuxeo-Component: OSGI-INF/core-types-contrib.xml,
+ OSGI-INF/life-cycle-contrib.xml,
+ OSGI-INF/ecm-types-contrib.xml,
+ OSGI-INF/layouts-contrib.xml
+
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.taxonomy.coreTypes">
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+ <schema name="taxonomyauthority_common" prefix="taxonomyauthority_common" src="schemas/taxonomyauthority_common.xsd"/>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+ <schema name="taxonomy_common" prefix="taxonomy_common" src="schemas/taxonomy_common.xsd"/>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+ <doctype name="Taxonomyauthority" extends="Document">
+ <schema name="common"/>
+ <schema name="collectionspace_core"/>
+ <schema name="dublincore"/>
+ <schema name="taxonomyauthority_common"/>
+ </doctype>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+ <doctype name="Taxonomyitem" extends="Document">
+ <schema name="common"/>
+ <schema name="collectionspace_core"/>
+ <schema name="dublincore"/>
+ <schema name="taxonomy_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.taxonomy.ecm.types">
+ <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+ <type id="Taxonomyauthority" coretype="Taxonomyauthority">
+ <label>org.collectionspace.taxonomyauthority</label>
+ <!--icon>/icons/file.gif</icon-->
+ <default-view>view_documents</default-view>
+
+ <layouts mode="any">
+ <layout>heading</layout>
+ <layout>cstaxonomyauthority</layout>
+ </layouts>
+ </type>
+
+ <type id="Folder" coretype="Folder">
+ <subtypes>
+ <type>Taxonomyauthority</type>
+ </subtypes>
+ </type>
+
+ <type id="Workspace" coretype="Workspace">
+ <subtypes>
+ <type>Taxonomyauthority</type>
+ </subtypes>
+ </type>
+
+ </extension>
+ <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+ <type id="Taxonomyitem" coretype="Taxonomyitem">
+ <label>org.collectionspace.taxonomy</label>
+ <!--icon>/icons/file.gif</icon-->
+ <default-view>view_documents</default-view>
+
+ <layouts mode="any">
+ <layout>heading</layout>
+ <layout>taxonomy</layout>
+ </layouts>
+ </type>
+
+ <type id="Folder" coretype="Folder">
+ <subtypes>
+ <type>Taxonomy</type>
+ </subtypes>
+ </type>
+
+ <type id="Workspace" coretype="Workspace">
+ <subtypes>
+ <type>Taxonomy</type>
+ </subtypes>
+ </type>
+
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+
+<component name="org.collectionspace.taxonomy.layouts.webapp">
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="layouts">
+
+ <layout name="cstaxonomyauthority">
+ <templates>
+ <template mode="any">/layouts/layout_default_template.xhtml</template>
+ </templates>
+ <rows>
+ <row><widget>displayName</widget></row>
+ <row><widget>shortIdentifier</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="taxonomyauthority_common">displayName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="shortIdentifier" type="text">
+ <labels>
+ <label mode="any">Short Identifier</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="taxonomyauthority_common">shortIdentifier</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="taxonomyauthority_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="taxonomyauthority_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="taxonomy">
+ <templates>
+ <template mode="any">/layouts/layout_default_template.xhtml</template>
+ </templates>
+ <rows>
+ <row><widget>inAuthority</widget></row>
+ <row><widget>shortIdentifier</widget></row>
+ <row><widget>refName</widget></row>
+ <row><widget>displayName</widget></row>
+ <row><widget>displayNameComputed</widget></row>
+ <row><widget>taxonFullName</widget></row>
+ <row><widget>taxonRank</widget></row>
+ </rows>
+
+ <widget name="inAuthority" type="text">
+ <labels>
+ <label mode="any">inAuthority (TaxonomyAuthority)</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="taxonomy_common">inAuthority</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="shortIdentifier" type="text">
+ <labels>
+ <label mode="any">Short Identifier</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="taxonomy_common">shortIdentifier</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="taxonomy_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="taxonomyauthority_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="taxonomyauthority_common">displayNameComputed</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="taxonFullName" type="text">
+ <labels>
+ <label mode="any">taxonFullName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="taxonomy_common">taxonFullName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="taxonRank" type="text">
+ <labels>
+ <label mode="any">taxonRank</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="taxonomy_common">taxonRank</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ </layout>
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.ecm.platform.location.LifeCycleManagerExtensions">
+
+ <extension target="org.nuxeo.ecm.core.lifecycle.LifeCycleService"
+ point="types">
+ <types>
+ <type name="Taxonomyauthority">default</type>
+ <type name="Taxonomyitem">default</type>
+ </types>
+ </extension>
+
+</component>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ Taxonomy schema (XSD)
+
+ Entity : Taxonomy
+ Part : Common
+ Used for: Nuxeo EP core document type
+
+ $LastChangedRevision$
+ $LastChangedDate$
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/taxonomy"
+ xmlns="http://collectionspace.org/services/taxonomy"
+ targetNamespace="http://collectionspace.org/services/taxonomy"
+ version="0.1"
+>
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Taxonomy+Service+Home -->
+
+ <!-- Taxonomy Information Group -->
+ <!-- inAuthority is the csid of the owning TaxonomyAuthority -->
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="shortIdentifier" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="displayNameComputed" type="xs:boolean"/>
+ <xs:element name="shortDisplayName" type="xs:string"/>
+ <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
+ <xs:element name="taxonFullName" type="xs:string"/>
+ <xs:element name="taxonRank" type="xs:string"/>
+ <xs:element name="taxonCurrency" type="xs:string"/>
+ <xs:element name="taxonAuthorGroupList" type="taxonAuthorGroupList"/>
+ <xs:element name="taxonCitationList" type="taxonCitationList"/>
+ <xs:element name="taxonomicStatus" type="xs:string"/>
+ <xs:element name="taxonNameSource" type="xs:string"/>
+ <xs:element name="taxonNameSourceCode" type="xs:string"/>
+ <xs:element name="taxonGUID" type="xs:string"/>
+ <xs:element name="taxonNote" type="xs:string"/>
+ <xs:element name="taxonIsNamedHybrid" type="xs:boolean"/>
+
+ <xs:complexType name="taxonAuthorGroupList">
+ <xs:sequence>
+ <xs:element name="taxonAuthorGroup" type="taxonAuthorGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="taxonAuthorGroup">
+ <xs:sequence>
+ <xs:element name="taxonAuthor" type="xs:string"/>
+ <xs:element name="taxonAuthorType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="taxonCitationList">
+ <xs:sequence>
+ <xs:element name="taxonCitation" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ TaxonomyAuthority schema (XSD)
+
+ Entity : TaxonomyAuthority
+ Part : Common
+ Used for: Nuxeo EP core document type
+
+ $LastChangedRevision$
+ $LastChangedDate$
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/taxonomy"
+ xmlns="http://collectionspace.org/services/taxonomy"
+ targetNamespace="http://collectionspace.org/services/taxonomy"
+ version="0.1"
+>
+
+ <!-- Flattened version of jaxb schema for nuxeo -->
+ <!-- See http://wiki.collectionspace.org/display/collectionspace/Taxonomy+Service+Home -->
+
+ <!-- TaxonomyAuthority Information Group -->
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="shortIdentifier" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="vocabType" type="xs:string"/>
+
+</xs:schema>
+
--- /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.taxonomy</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.3rdparty</artifactId>
+ <name>services.taxonomy.3rdparty</name>
+ <packaging>pom</packaging>
+ <description>
+ 3rd party build for taxonomy service
+ </description>
+
+ <modules>
+ <module>nuxeo-platform-cs-taxonomy</module>
+ </modules>
+</project>
--- /dev/null
+
+<project name="taxonomy" default="package" basedir=".">
+ <description>
+ Taxonomy Authority service
+ </description>
+ <!-- set global properties for this build -->
+ <property name="services.trunk" value="../.."/>
+ <!-- enviornment should be declared before reading build.properties -->
+ <property environment="env" />
+ <property file="${services.trunk}/build.properties" />
+ <property name="mvn.opts" value="" />
+ <property name="src" taxonomy="src"/>
+
+ <condition property="osfamily-unix">
+ <os family="unix" />
+ </condition>
+ <condition property="osfamily-windows">
+ <os family="windows" />
+ </condition>
+
+ <target name="package" depends="package-unix,package-windows"
+ description="Package CollectionSpace Services" />
+
+ <target name="package-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="package" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="package-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="package" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="install" depends="install-unix,install-windows"
+ description="Install" />
+ <target name="install-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="install" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="install-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="install" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="clean" depends="clean-unix,clean-windows"
+ description="Delete target directories" >
+ <delete dir="${build}"/>
+ </target>
+ <target name="clean-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="clean" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="clean-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="clean" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="test" depends="test-unix,test-windows" description="Run tests" />
+ <target name="test-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="test" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+ <target name="test-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn.bat" />
+ <arg value="test" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="deploy" depends="install"
+ description="deploy taxonomy service">
+ <ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>
+ </target>
+
+ <target name="undeploy"
+ description="undeploy taxonomy service">
+ <ant antfile="3rdparty/build.xml" target="undeploy" inheritall="false"/>
+ </target>
+
+ <target name="dist" depends="package"
+ description="distribute taxonomy service">
+ <ant antfile="3rdparty/build.xml" target="dist" inheritall="false"/>
+ <ant antfile="import/build.xml" target="dist" inheritall="false"/>
+ </target>
+
+ <target name="dist_installer" depends="package"
+ description="distribute taxonomy service">
+ <!-- copy install scripts, etc. -->
+ <copy todir="${services.trunk}/${dist.installer.services}/taxonomy">
+ <fileset dir="${basedir}/installer/"/>
+ </copy>
+ <ant antfile="3rdparty/build.xml" target="dist_installer" inheritall="false"/>
+ <ant antfile="import/build.xml" target="dist_installer" inheritall="false"/>
+ </target>
+
+</project>
--- /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.taxonomy</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.client</artifactId>
+ <name>services.taxonomy.client</name>
+
+ <dependencies>
+ <!-- keep slf4j dependencies on the top -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <!-- CollectionSpace dependencies -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <optional>true</optional>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.contact.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <!-- filter out unwanted jars -->
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-taxonomy-client</finalName>
+ <plugins>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+/**
+ * TaxonomyAuthorityClient.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.taxonomy.TaxonomyauthoritiesCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyCommonList;
+import org.collectionspace.services.client.TaxonomyAuthorityProxy;
+
+import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ProxyFactory;
+import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+
+/**
+ * The Class TaxonomyAuthorityClient.
+ */
+public class TaxonomyAuthorityClient extends AuthorityClientImpl<TaxonomyauthoritiesCommonList, TaxonomyCommonList, TaxonomyAuthorityProxy> {
+ public static final String SERVICE_NAME = "taxonomyauthorities";
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+ public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
+ //
+ // Subitem constants
+ //
+ public static final String SERVICE_ITEM_NAME = "taxon";
+ public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME;
+ //
+ // Payload Part/Schema part names
+ //
+ public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME +
+ PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+ public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME +
+ PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
+
+ @Override
+ public String getServiceName() {
+ return SERVICE_NAME;
+ }
+
+ @Override
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
+ }
+
+ @Override
+ public String getItemCommonPartName() {
+ return getCommonPartName(SERVICE_ITEM_NAME);
+ }
+
+ @Override
+ public Class<TaxonomyAuthorityProxy> getProxyClass() {
+ return TaxonomyAuthorityProxy.class;
+ }
+
+ /*
+ * Proxied service calls.
+ */
+
+ /**
+ * @return list
+ * @see org.collectionspace.services.client.TaxonomyAuthorityProxy#readList()
+ */
+ public ClientResponse<TaxonomyauthoritiesCommonList> readList() {
+ return getProxy().readList();
+ }
+}
--- /dev/null
+package org.collectionspace.services.client;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+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.commons.io.FileUtils;
+import org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.client.test.ServiceRequestType;
+import org.collectionspace.services.taxonomy.TaxonomyCommon;
+import org.collectionspace.services.taxonomy.ConditionGroupList;
+import org.collectionspace.services.taxonomy.ConditionGroup;
+import org.collectionspace.services.taxonomy.TaxonomyauthoritiesCommon;
+import org.dom4j.DocumentException;
+import org.jboss.resteasy.client.ClientResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+
+public class TaxonomyAuthorityClientUtils {
+ private static final Logger logger =
+ LoggerFactory.getLogger(TaxonomyAuthorityClientUtils.class);
+
+ /**
+ * Creates a new Taxonomy Authority
+ * @param displayName The displayName used in UI, etc.
+ * @param refName The proper refName for this authority
+ * @param headerLabel The common part label
+ * @return The PoxPayloadOut payload for the create call
+ */
+ public static PoxPayloadOut createTaxonomyAuthorityInstance(
+ String displayName, String shortIdentifier, String headerLabel ) {
+ TaxonomyauthoritiesCommon taxonomyAuthority = new TaxonomyauthoritiesCommon();
+ taxonomyAuthority.setDisplayName(displayName);
+ taxonomyAuthority.setShortIdentifier(shortIdentifier);
+ String refName = createTaxonomyAuthRefName(shortIdentifier, displayName);
+ taxonomyAuthority.setRefName(refName);
+ taxonomyAuthority.setVocabType("TaxonomyAuthority"); //FIXME: REM - Should this really be hard-coded?
+ PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(taxonomyAuthority, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(headerLabel);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, taxonomyAuthority common ",
+ taxonomyAuthority, TaxonomyauthoritiesCommon.class);
+ }
+
+ return multipart;
+ }
+
+ /**
+ * @param taxonomyRefName The proper refName for this authority
+ * @param taxonomyInfo the properties for the new Taxonomy. Can pass in one condition
+ * note and date string.
+ * @param headerLabel The common part label
+ * @return The PoxPayloadOut payload for the create call
+ */
+ public static PoxPayloadOut createTaxonomyInstance(
+ String taxonomyAuthRefName, Map<String, String> taxonomyInfo,
+ String headerLabel){
+ TaxonomyCommon taxonomy = new TaxonomyCommon();
+ String shortId = taxonomyInfo.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER);
+ String displayName = taxonomyInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME);
+ taxonomy.setShortIdentifier(shortId);
+ String taxonomyRefName = createTaxonomyRefName(taxonomyAuthRefName, shortId, displayName);
+ taxonomy.setRefName(taxonomyRefName);
+ String value = null;
+ value = taxonomyInfo.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
+ boolean displayNameComputed = (value==null) || value.equalsIgnoreCase("true");
+ taxonomy.setDisplayNameComputed(displayNameComputed);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.NAME))!=null)
+ taxonomy.setName(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.CONDITION_NOTE))!=null) {
+ ConditionGroupList conditionGroupList = new ConditionGroupList();
+ List<ConditionGroup> conditionGroups = conditionGroupList.getConditionGroup();
+ ConditionGroup conditionGroup = new ConditionGroup();
+ conditionGroup.setConditionNote(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.CONDITION_NOTE_DATE))!=null)
+ conditionGroup.setConditionNoteDate(value);
+ conditionGroups.add(conditionGroup);
+ taxonomy.setConditionGroupList(conditionGroupList);
+ }
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.SECURITY_NOTE))!=null)
+ taxonomy.setSecurityNote(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.ACCESS_NOTE))!=null)
+ taxonomy.setAccessNote(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.LOCATION_TYPE))!=null)
+ taxonomy.setTaxonomyType(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.ADDRESS))!=null)
+ taxonomy.setAddress(value);
+ if((value = (String)taxonomyInfo.get(TaxonomyJAXBSchema.TERM_STATUS))!=null)
+ taxonomy.setTermStatus(value);
+
+ PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(taxonomy,
+ MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(headerLabel);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, taxonomy common ", taxonomy, TaxonomyCommon.class);
+ }
+
+ return multipart;
+ }
+
+ /**
+ * @param vcsid CSID of the authority to create a new taxonomy in
+ * @param taxonomyAuthorityRefName The refName for the authority
+ * @param taxonomyMap the properties for the new Taxonomy
+ * @param client the service client
+ * @return the CSID of the new item
+ */
+ public static String createItemInAuthority(String vcsid,
+ String taxonomyAuthorityRefName, Map<String,String> taxonomyMap,
+ TaxonomyAuthorityClient client ) {
+ // Expected status code: 201 Created
+ int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+ // Type of service request being tested
+ ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+ String displayName = taxonomyMap.get(TaxonomyJAXBSchema.DISPLAY_NAME);
+ String displayNameComputedStr = taxonomyMap.get(TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
+ boolean displayNameComputed = (displayNameComputedStr==null) || displayNameComputedStr.equalsIgnoreCase("true");
+ if( displayName == null ) {
+ if(!displayNameComputed) {
+ throw new RuntimeException(
+ "CreateItem: Must supply a displayName if displayNameComputed is set to false.");
+ }
+ displayName =
+ prepareDefaultDisplayName(
+ taxonomyMap.get(TaxonomyJAXBSchema.NAME));
+ }
+
+ if(logger.isDebugEnabled()){
+ logger.debug("Import: Create Item: \""+displayName
+ +"\" in taxonomyAuthority: \"" + taxonomyAuthorityRefName +"\"");
+ }
+ PoxPayloadOut multipart =
+ createTaxonomyInstance( taxonomyAuthorityRefName,
+ taxonomyMap, client.getItemCommonPartName() );
+ String newID = null;
+ ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ try {
+ int statusCode = res.getStatus();
+
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create Item: \""
+ +taxonomyMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER)
+ +"\" in taxonomyAuthority: \"" + taxonomyAuthorityRefName
+ +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ }
+ if(statusCode != EXPECTED_STATUS_CODE) {
+ throw new RuntimeException("Unexpected Status when creating Item: \""
+ +taxonomyMap.get(TaxonomyJAXBSchema.SHORT_IDENTIFIER)
+ +"\" in taxonomyAuthority: \"" + taxonomyAuthorityRefName +"\", Status:"+ statusCode);
+ }
+ newID = extractId(res);
+ } finally {
+ res.releaseConnection();
+ }
+
+ return newID;
+ }
+
+ public static PoxPayloadOut createTaxonomyInstance(
+ String commonPartXML, String headerLabel) throws DocumentException {
+ PoxPayloadOut multipart = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = multipart.addPart(commonPartXML,
+ MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(headerLabel);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("to be created, taxonomy common ", commonPartXML);
+ }
+
+ return multipart;
+ }
+
+ public static String createItemInAuthority(String vcsid,
+ String commonPartXML,
+ TaxonomyAuthorityClient client ) throws DocumentException {
+ // Expected status code: 201 Created
+ int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+ // Type of service request being tested
+ ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+ PoxPayloadOut multipart =
+ createTaxonomyInstance(commonPartXML, client.getItemCommonPartName());
+ String newID = null;
+ ClientResponse<Response> res = client.createItem(vcsid, multipart);
+ try {
+ int statusCode = res.getStatus();
+
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create Item: \""+commonPartXML
+ +"\" in taxonomyAuthority: \"" + vcsid
+ +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ }
+ if(statusCode != EXPECTED_STATUS_CODE) {
+ throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML
+ +"\" in taxonomyAuthority: \"" + vcsid +"\", Status:"+ statusCode);
+ }
+ newID = extractId(res);
+ } finally {
+ res.releaseConnection();
+ }
+
+ return newID;
+ }
+
+ /**
+ * Creates the from xml file.
+ *
+ * @param fileName the file name
+ * @return new CSID as string
+ * @throws Exception the exception
+ */
+ private String createItemInAuthorityFromXmlFile(String vcsid, String commonPartFileName,
+ TaxonomyAuthorityClient client) throws Exception {
+ byte[] b = FileUtils.readFileToByteArray(new File(commonPartFileName));
+ String commonPartXML = new String(b);
+ return createItemInAuthority(vcsid, commonPartXML, client );
+ }
+
+ /**
+ * Creates the taxonomyAuthority ref name.
+ *
+ * @param shortId the taxonomyAuthority shortIdentifier
+ * @param displaySuffix displayName to be appended, if non-null
+ * @return the string
+ */
+ public static String createTaxonomyAuthRefName(String shortId, String displaySuffix) {
+ String refName = "urn:cspace:org.collectionspace.demo:taxonomyauthority:name("
+ +shortId+")";
+ if(displaySuffix!=null&&!displaySuffix.isEmpty())
+ refName += "'"+displaySuffix+"'";
+ return refName;
+ }
+
+ /**
+ * Creates the taxonomy ref name.
+ *
+ * @param taxonomyAuthRefName the taxonomyAuthority ref name
+ * @param shortId the taxonomy shortIdentifier
+ * @param displaySuffix displayName to be appended, if non-null
+ * @return the string
+ */
+ public static String createTaxonomyRefName(
+ String taxonomyAuthRefName, String shortId, String displaySuffix) {
+ String refName = taxonomyAuthRefName+":taxonomy:name("+shortId+")";
+ if(displaySuffix!=null&&!displaySuffix.isEmpty())
+ refName += "'"+displaySuffix+"'";
+ return refName;
+ }
+
+ public static String extractId(ClientResponse<Response> res) {
+ MultivaluedMap<String, Object> mvm = res.getMetadata();
+ String uri = (String) ((ArrayList<Object>) mvm.get("Taxonomy")).get(0);
+ if(logger.isDebugEnabled()){
+ logger.debug("extractId:uri=" + uri);
+ }
+ String[] segments = uri.split("/");
+ String id = segments[segments.length - 1];
+ if(logger.isDebugEnabled()){
+ logger.debug("id=" + id);
+ }
+ return id;
+ }
+
+ /**
+ * Returns an error message indicating that the status code returned by a
+ * specific call to a service does not fall within a set of valid status
+ * codes for that service.
+ *
+ * @param serviceRequestType A type of service request (e.g. CREATE, DELETE).
+ *
+ * @param statusCode The invalid status code that was returned in the response,
+ * from submitting that type of request to the service.
+ *
+ * @return An error message.
+ */
+ public static String invalidStatusCodeMessage(ServiceRequestType requestType, int statusCode) {
+ return "Status code '" + statusCode + "' in response is NOT within the expected set: " +
+ requestType.validStatusCodesAsString();
+ }
+
+
+
+ /**
+ * Produces a default displayName from the basic name and dates fields.
+ * @see TaxonomyDocumentModelHandler.prepareDefaultDisplayName() which
+ * duplicates this logic, until we define a service-general utils package
+ * that is neither client nor service specific.
+ * @param name
+ * @return
+ */
+ public static String prepareDefaultDisplayName(
+ String name ) {
+ StringBuilder newStr = new StringBuilder();
+ newStr.append(name);
+ return newStr.toString();
+ }
+
+
+
+}
--- /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 org.collectionspace.services.TaxonomyJAXBSchema;
+import org.collectionspace.services.client.AuthorityClient;
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.ContactClient;
+import org.collectionspace.services.client.ContactClientUtils;
+import org.collectionspace.services.client.PayloadOutputPart;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.contact.ContactsCommon;
+import org.collectionspace.services.contact.ContactsCommonList;
+import org.collectionspace.services.client.TaxonomyAuthorityClient;
+import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyauthoritiesCommon;
+import org.collectionspace.services.taxonomy.TaxonomyauthoritiesCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyCommon;
+import org.collectionspace.services.taxonomy.TaxonomyCommonList;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.jboss.resteasy.client.ClientResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * TaxonomyAuthorityServiceTest, carries out tests against a
+ * deployed and running TaxonomyAuthority Service.
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ */
+public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: Test classes for Vocab, Person, Org, and Taxonomy should have a base class!
+
+ /** The logger. */
+ private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName();
+ private final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityServiceTest.class);
+
+ @Override
+ public String getServicePathComponent() {
+ return TaxonomyAuthorityClient.SERVICE_PATH_COMPONENT;
+ }
+
+ @Override
+ protected String getServiceName() {
+ return TaxonomyAuthorityClient.SERVICE_NAME;
+ }
+
+ public String getItemServicePathComponent() {
+ return AuthorityClient.ITEMS;
+ }
+
+ // Instance variables specific to this test.
+
+// /** The SERVICE path component. */
+// final String SERVICE_PATH_COMPONENT = "taxonomyauthorities";
+//
+// /** The ITEM service path component. */
+// final String ITEM_SERVICE_PATH_COMPONENT = "items";
+//
+// /** The CONTACT service path component. */
+// final String CONTACT_SERVICE_PATH_COMPONENT = "contacts";
+
+ final String TEST_NAME = "Shelf 1";
+ final String TEST_SHORTID = "shelf1";
+ final String TEST_CONDITION_NOTE = "Basically clean";
+ final String TEST_CONDITION_NOTE_DATE = "June 11, 1979";
+ final String TEST_SECURITY_NOTE = "Kind of safe";
+ final String TEST_ACCESS_NOTE = "Only right-thinkers may see";
+ final String TEST_ADDRESS = "123 Main Street, Anytown USA";
+ // TODO Make loc type be a controlled vocab term.
+ final String TEST_LOCATION_TYPE = "Shelf";
+ // TODO Make status type be a controlled vocab term.
+ final String TEST_STATUS = "Approved";
+
+ /** The known resource id. */
+ private String knownResourceId = null;
+ private String knownResourceShortIdentifer = null;
+ private String knownResourceRefName = null;
+ private String knownTaxonomyTypeRefName = null;
+ private String knownItemResourceId = null;
+ private String knownItemResourceShortIdentifer = null;
+ 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>();
+
+ protected void setKnownResource( String id, String shortIdentifer,
+ String refName ) {
+ knownResourceId = id;
+ knownResourceShortIdentifer = shortIdentifer;
+ knownResourceRefName = refName;
+ }
+
+ protected void setKnownItemResource( String id, String shortIdentifer ) {
+ knownItemResourceId = id;
+ knownItemResourceShortIdentifer = shortIdentifer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
+ */
+ @Override
+ protected CollectionSpaceClient getClientInstance() {
+ return new TaxonomyAuthorityClient();
+ }
+
+ /* (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(TaxonomyCommonList.class);
+ }
+
+ @Override
+ protected PoxPayloadOut createInstance(String identifier) {
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ String shortId = identifier;
+ String displayName = "displayName-" + shortId;
+ String baseRefName =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
+ PoxPayloadOut multipart =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
+ return multipart;
+ }
+
+ // ---------------------------------------------------------------
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // 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();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ String shortId = createIdentifier();
+ String displayName = "displayName-" + shortId;
+ String baseRefName =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthRefName(shortId, null);
+
+ PoxPayloadOut multipart =
+ TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
+ String newID = null;
+ ClientResponse<Response> res = client.create(multipart);
+ try {
+ 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);
+
+ newID = TaxonomyAuthorityClientUtils.extractId(res);
+ } finally {
+ res.releaseConnection();
+ }
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (knownResourceId == null){
+ setKnownResource( newID, shortId, baseRefName );
+ 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) {
+ if(logger.isDebugEnabled()){
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ setupCreate();
+ 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("+vcsid+","+authRefName+")";
+ if(logger.isDebugEnabled()){
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ Map<String, String> shelf1Map = new HashMap<String,String>();
+ // TODO Make loc type and status be controlled vocabs.
+ shelf1Map.put(TaxonomyJAXBSchema.NAME, TEST_NAME);
+ shelf1Map.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, TEST_SHORTID);
+ shelf1Map.put(TaxonomyJAXBSchema.CONDITION_NOTE, TEST_CONDITION_NOTE);
+ shelf1Map.put(TaxonomyJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
+ shelf1Map.put(TaxonomyJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
+ shelf1Map.put(TaxonomyJAXBSchema.ACCESS_NOTE, TEST_ACCESS_NOTE);
+ shelf1Map.put(TaxonomyJAXBSchema.ADDRESS, TEST_ADDRESS);
+ shelf1Map.put(TaxonomyJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ shelf1Map.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS);
+
+ String newID = TaxonomyAuthorityClientUtils.createItemInAuthority(vcsid,
+ authRefName, shelf1Map, client );
+
+ // Store the ID returned from the first item resource created
+ // for additional tests below.
+ if (knownItemResourceId == null){
+ setKnownItemResource(newID, TEST_SHORTID);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownItemResourceId=" + newID);
+ }
+ }
+
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ String newID = null;
+ ClientResponse<String> res = client.read(knownResourceId);
+ try {
+ 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 {
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyauthoritiesCommon taxonomyAuthority =
+ (TaxonomyauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), TaxonomyauthoritiesCommon.class);
+ Assert.assertNotNull(taxonomyAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName+"("+knownResourceShortIdentifer+")", CLASS_NAME));
+ }
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
+ try {
+ 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 {
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyauthoritiesCommon taxonomyAuthority = (TaxonomyauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), TaxonomyauthoritiesCommon.class);
+ Assert.assertNotNull(taxonomyAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupRead();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ try {
+ 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 taxonomy.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon taxonomy = (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(taxonomy);
+ boolean showFull = true;
+ if(showFull && logger.isDebugEnabled()){
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(taxonomy, TaxonomyCommon.class));
+ }
+ Assert.assertEquals(taxonomy.getInAuthority(), knownResourceId);
+ } finally {
+ res.releaseConnection();
+ }
+
+ }
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdate();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ try {
+ 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 taxonomy has expected displayName.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon taxonomy = (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(taxonomy);
+ String displayName = taxonomy.getDisplayName();
+ // Make sure displayName matches computed form
+ String expectedDisplayName =
+ TaxonomyAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
+ Assert.assertNotNull(displayName, expectedDisplayName);
+
+ // Update the shortName and verify the computed name is updated.
+ taxonomy.setCsid(null);
+ taxonomy.setDisplayNameComputed(true);
+ taxonomy.setName("updated-" + TEST_NAME);
+ expectedDisplayName =
+ TaxonomyAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ 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 = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon updatedTaxonomy =
+ (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(updatedTaxonomy);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxonomy.getName(), taxonomy.getName(),
+ "Updated ForeName in Taxonomy did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedTaxonomy.getDisplayName(), expectedDisplayName,
+ "Updated ForeName in Taxonomy not reflected in computed DisplayName.");
+
+ // Now Update the displayName, not computed and verify the computed name is overriden.
+ taxonomy.setDisplayNameComputed(false);
+ expectedDisplayName = "TestName";
+ taxonomy.setDisplayName(expectedDisplayName);
+
+ // Submit the updated resource to the service and store the response.
+ output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ 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 = new PoxPayloadIn(res.getEntity());
+ updatedTaxonomy =
+ (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(updatedTaxonomy);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxonomy.isDisplayNameComputed(), false,
+ "Updated displayNameComputed in Taxonomy did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedTaxonomy.getDisplayName(),
+ expectedDisplayName,
+ "Updated DisplayName (not computed) in Taxonomy not stored.");
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ // FIXME: create a setup configuration for this operation.
+ setupUpdateWithWrongXmlSchema();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+ try {
+ 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 Taxonomy has expected displayName.
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon taxonomy = (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(taxonomy);
+ // Try to Update with computed false and no displayName
+ taxonomy.setDisplayNameComputed(false);
+ taxonomy.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+
+ // 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) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupReadNonExistent();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.read(NON_EXISTENT_ID);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * Read item non existent.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"read"}, dependsOnMethods = {"readItem"})
+ public void readItemNonExistent(String testName) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupReadNonExistent();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+
+ // ---------------------------------------------------------------
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupReadList();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<TaxonomyauthoritiesCommonList> res = client.readList();
+ try {
+ TaxonomyauthoritiesCommonList 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<TaxonomyauthoritiesCommonList.TaxonomyauthorityListItem> items =
+ list.getTaxonomyauthorityListItem();
+ int i = 0;
+ for (TaxonomyauthoritiesCommonList.TaxonomyauthorityListItem 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++;
+ }
+ }
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * Read item list.
+ */
+ @Test(groups = {"readList"}, dependsOnMethods = {"readList"})
+ public void readItemList() {
+ String testName = "readItemList";
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ readItemList(knownResourceId, null);
+ }
+
+ /**
+ * Read item list by authority name.
+ */
+ @Test(groups = {"readList"}, dependsOnMethods = {"readItemList"})
+ public void readItemListByAuthorityName() {
+ String testName = "readItemListByAuthorityName";
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ readItemList(null, knownResourceShortIdentifer);
+ }
+
+ /**
+ * Read item list.
+ *
+ * @param vcsid the vcsid
+ * @param name the name
+ */
+ private void readItemList(String vcsid, String shortId) {
+
+ String testName = "readItemList";
+
+ // Perform setup.
+ setupReadList();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<TaxonomyCommonList> res = null;
+ if(vcsid!= null) {
+ res = client.readItemList(vcsid, null, null);
+ } else if(shortId!= null) {
+ res = client.readItemListForNamedAuthority(shortId, null, null);
+ } else {
+ Assert.fail("readItemList passed null csid and name!");
+ }
+ try {
+ TaxonomyCommonList 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<TaxonomyCommonList.TaxonomyListItem> items =
+ list.getTaxonomyListItem();
+ 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 (TaxonomyCommonList.TaxonomyListItem 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++;
+ }
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdate();
+
+ // Retrieve the contents of a resource to update.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res = client.read(knownResourceId);
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got TaxonomyAuthority to update with ID: " + knownResourceId);
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyauthoritiesCommon taxonomyAuthority = (TaxonomyauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), TaxonomyauthoritiesCommon.class);
+ Assert.assertNotNull(taxonomyAuthority);
+
+ // Update the contents of this resource.
+ taxonomyAuthority.setDisplayName("updated-" + taxonomyAuthority.getDisplayName());
+ taxonomyAuthority.setVocabType("updated-" + taxonomyAuthority.getVocabType());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated TaxonomyAuthority");
+ logger.debug(objectAsXmlString(taxonomyAuthority, TaxonomyauthoritiesCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(taxonomyAuthority, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getCommonPartName());
+ res.releaseConnection();
+ 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 = new PoxPayloadIn(res.getEntity());
+ TaxonomyauthoritiesCommon updatedTaxonomyAuthority =
+ (TaxonomyauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), TaxonomyauthoritiesCommon.class);
+ Assert.assertNotNull(updatedTaxonomyAuthority);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxonomyAuthority.getDisplayName(),
+ taxonomyAuthority.getDisplayName(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdate();
+
+ // Retrieve the contents of a resource to update.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<String> res =
+ client.readItem(knownResourceId, knownItemResourceId);
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got Taxonomy to update with ID: " +
+ knownItemResourceId +
+ " in TaxonomyAuthority: " + knownResourceId );
+ }
+ PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon taxonomy = (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(taxonomy);
+
+ // Update the contents of this resource.
+ taxonomy.setCsid(null);
+ taxonomy.setName("updated-" + taxonomy.getName());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated Taxonomy");
+ logger.debug(objectAsXmlString(taxonomy,
+ TaxonomyCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ PoxPayloadOut output = new PoxPayloadOut(TaxonomyAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
+ PayloadOutputPart commonPart = output.addPart(taxonomy, MediaType.APPLICATION_XML_TYPE);
+ commonPart.setLabel(client.getItemCommonPartName());
+ res.releaseConnection();
+ 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 = new PoxPayloadIn(res.getEntity());
+ TaxonomyCommon updatedTaxonomy =
+ (TaxonomyCommon) extractPart(input,
+ client.getItemCommonPartName(), TaxonomyCommon.class);
+ Assert.assertNotNull(updatedTaxonomy);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedTaxonomy.getName(), taxonomy.getName(),
+ "Data in updated Taxonomy did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdateNonExistent();
+
+ // 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.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ String displayName = "displayName-NON_EXISTENT_ID";
+ PoxPayloadOut multipart = TaxonomyAuthorityClientUtils.createTaxonomyAuthorityInstance(
+ displayName, "nonEx", client.getCommonPartName());
+ ClientResponse<String> res =
+ client.update(NON_EXISTENT_ID, multipart);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupUpdateNonExistent();
+
+ // 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.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ Map<String, String> nonexMap = new HashMap<String,String>();
+ nonexMap.put(TaxonomyJAXBSchema.NAME, TEST_NAME);
+ nonexMap.put(TaxonomyJAXBSchema.SHORT_IDENTIFIER, "nonEx");
+ nonexMap.put(TaxonomyJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
+ nonexMap.put(TaxonomyJAXBSchema.TERM_STATUS, TEST_STATUS);
+ PoxPayloadOut multipart =
+ TaxonomyAuthorityClientUtils.createTaxonomyInstance(
+ TaxonomyAuthorityClientUtils.createTaxonomyRefName(knownResourceRefName, "nonEx", "Non Existent"),
+ nonexMap, client.getItemCommonPartName() );
+ ClientResponse<String> res =
+ client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupDelete();
+
+ if(logger.isDebugEnabled()){
+ logger.debug("parentcsid =" + knownResourceId +
+ " itemcsid = " + knownItemResourceId);
+ }
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<Response> res =
+ client.deleteItem(knownResourceId, knownItemResourceId);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /* (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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupDelete();
+
+ if(logger.isDebugEnabled()){
+ logger.debug("parentcsid =" + knownResourceId);
+ }
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<Response> res = client.delete(knownResourceId);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ // 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 {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupDeleteNonExistent();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ /**
+ * Delete non existent item.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"delete"}, dependsOnMethods = {"deleteItem"})
+ public void deleteNonExistentItem(String testName) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ // Perform setup.
+ setupDeleteNonExistent();
+
+ // Submit the request to the service and store the response.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
+ try {
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // 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.
+ TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
+ 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);
+ res.releaseConnection();
+ }
+ // 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);
+ res.releaseConnection();
+ }
+ }
+
+ // ---------------------------------------------------------------
+ // Utility methods used by tests above
+ // ---------------------------------------------------------------
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
+ */
+
+ /**
+ * 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
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=target/test-client.log
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
+
+#packages
+log4j.logger.org.collectionspace=DEBUG
+log4j.logger.org.apache=INFO
+log4j.logger.httpclient=INFO
+log4j.logger.org.jboss.resteasy=INFO
--- /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.taxonomy</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.jaxb</artifactId>
+ <name>services.taxonomy.jaxb</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <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-taxonomy-jaxb</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+/**
+ *
+ */
+package org.collectionspace.services;
+import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+
+/**
+ * @author pschmitz
+ *
+ */
+public interface TaxonomyJAXBSchema extends AuthorityItemJAXBSchema {
+ final static String LOCATIONS_COMMON = "taxonomy_common";
+ final static String FULL_NAME = "fullName";
+
+}
+
--- /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/taxonomy"
+ xmlns="http://collectionspace.org/services/taxonomy"
+ targetNamespace="http://collectionspace.org/services/taxonomy"
+ 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/Taxonomy+Service+Home -->
+
+ <!-- Taxonomy -->
+ <xs:element name="taxonomies_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Common identifier -->
+ <xs:element name="csid" type="xs:string" />
+
+ <!-- Taxonomy Information Group -->
+ <!-- inAuthority is the csid of the owning TaxonomyAuthority -->
+ <xs:element name="inAuthority" type="xs:string" />
+ <xs:element name="shortIdentifier" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="displayNameComputed" type="xs:boolean"/>
+ <xs:element name="shortDisplayName" type="xs:string"/>
+ <xs:element name="shortDisplayNameComputed" type="xs:boolean"/>
+ <xs:element name="taxonFullName" type="xs:string"/>
+ <xs:element name="taxonRank" type="xs:string"/>
+ <xs:element name="taxonCurrency" type="xs:string"/>
+ <xs:element name="taxonAuthorGroupList" type="taxonAuthorGroupList"/>
+ <xs:element name="taxonCitationList" type="taxonCitationList"/>
+ <xs:element name="taxonomicStatus" type="xs:string"/>
+ <xs:element name="taxonNameSource" type="xs:string"/>
+ <xs:element name="taxonNameSourceCode" type="xs:string"/>
+ <xs:element name="taxonGUID" type="xs:string"/>
+ <xs:element name="taxonNote" type="xs:string"/>
+ <xs:element name="taxonIsNamedHybrid" type="xs:boolean"/>
+
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="taxonAuthorGroupList">
+ <xs:sequence>
+ <xs:element name="taxonAuthorGroup" type="taxonAuthorGroup" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="taxonAuthorGroup">
+ <xs:sequence>
+ <xs:element name="taxonAuthor" type="xs:string"/>
+ <xs:element name="taxonAuthorType" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="taxonCitationList">
+ <xs:sequence>
+ <xs:element name="taxonCitation" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- 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>
+
+ <!-- Taxonomy instances, as in nuxeo repository -->
+ <xs:element name="taxonomies-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonListItem">
+ <xs:sequence>
+ <xs:element name="taxonomy_list_item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="displayName" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="shortIdentifier" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve taxonomy 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"?>
+
+<!--
+ TaxonomyAuthority schema (XSD)
+
+ Entity : TaxonomyAuthority
+ Part : Common
+ Used for: JAXB binding between XML and Java objects
+
+ $LastChangedRevision$
+ $LastChangedDate$
+-->
+
+<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/taxonomy"
+ xmlns="http://collectionspace.org/services/taxonomy"
+ targetNamespace="http://collectionspace.org/services/taxonomy"
+ 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/Taxonomy+Service+Home -->
+
+ <!-- TaxonomyAuthority -->
+ <xs:element name="taxonomyauthority_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Common identifier -->
+ <xs:element name="csid" type="xs:string" />
+
+ <!-- TaxonomyAuthority Information Group -->
+ <xs:element name="displayName" type="xs:string"/>
+ <xs:element name="shortIdentifier" 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>
+
+
+ <!-- TaxonomyAuthority instances, as in nuxeo repository -->
+ <xs:element name="taxonomyauthority-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="taxonomyauthority-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="shortIdentifier" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="vocabType" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrieve taxonomyauthority 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"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemataxonomy="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.main</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy</artifactId>
+ <name>services.taxonomy</name>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.authority</artifactId>
+ <optional>true</optional>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <modules>
+ <module>jaxb</module>
+ <module>service</module>
+ <module>3rdparty</module>
+ <module>client</module>
+ </modules>
+
+</project>
+
--- /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.taxonomy</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.service</artifactId>
+ <name>services.taxonomy.service</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <!-- CollectionSpace dependencies -->
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.taxonomy.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.contact.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.6</version>
+ </dependency>
+
+ <!-- apache -->
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <!-- use explict 1.1 version to prevent errors coming from Nuxeo client -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <!-- javax -->
+
+
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- jboss -->
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ </dependency>
+
+ <!-- nuxeo -->
+
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-remoting</artifactId>
+ <groupId>jboss</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.restlet</groupId>
+ <artifactId>org.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-taxonomy</finalName>
+ <plugins>
+ </plugins>
+ </build>
+</project>
+
--- /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.taxonomy;
+
+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.client.TaxonomyAuthorityClient;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.TaxonomyJAXBSchema;
+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.AuthorityResource;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameUtils;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.taxonomy.nuxeo.TaxonomyDocumentModelHandler;
+import org.jboss.resteasy.util.HttpResponseCodes;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class TaxonomyAuthorityResource.
+ */
+@Path(TaxonomyAuthorityClient.SERVICE_PATH)
+@Consumes("application/xml")
+@Produces("application/xml")
+public class TaxonomyAuthorityResource
+ extends AuthorityResource<TaxonomyauthoritiesCommon, TaxonomyauthoritiesCommonList,
+ TaxonomyCommon, TaxonomyDocumentModelHandler> {
+
+ private final static String taxonomyAuthorityServiceName = "taxonomyauthorities";
+ private final static String LOCATIONAUTHORITIES_COMMON = "taxonomyauthority_common";
+
+ private final static String taxonomyServiceName = "taxonomy";
+ private final static String LOCATIONS_COMMON = "taxonomy_common";
+
+ /** The logger. */
+ final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityResource.class);
+ //FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
+ final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+ /**
+ * Instantiates a new taxonomy authority resource.
+ */
+ public TaxonomyAuthorityResource() {
+ super(TaxonomyauthoritiesCommon.class, TaxonomyAuthorityResource.class,
+ LOCATIONAUTHORITIES_COMMON, LOCATIONS_COMMON);
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
+ @Override
+ public String getServiceName() {
+ return taxonomyAuthorityServiceName;
+ }
+
+ /**
+ * Gets the item service name.
+ *
+ * @return the item service name
+ */
+ public String getItemServiceName() {
+ return taxonomyServiceName;
+ }
+
+ @Override
+ public Class<TaxonomyauthoritiesCommon> getCommonPartClass() {
+ return TaxonomyauthoritiesCommon.class;
+ }
+}
--- /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.taxonomy.nuxeo;
+
+/**
+ * TaxonomyAuthorityConstants processes CollectionObject document
+ *
+ */
+public class TaxonomyAuthorityConstants {
+
+ public final static String NUXEO_DOCTYPE = "TaxonomyAuthority";
+ public final static String NUXEO_SCHEMA_NAME = "taxonomyauthority";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-TaxonomyAuthority";
+}
--- /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.taxonomy.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+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.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
+import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList.TaxonomyauthorityListItem;
+
+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;
+
+/**
+ * TaxonomyAuthorityDocumentModelHandler
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ */
+public class TaxonomyAuthorityDocumentModelHandler
+ extends AuthorityDocumentModelHandler<TaxonomyauthorityCommon, TaxonomyauthorityCommonList> {
+
+ /**
+ * Common part schema label
+ */
+ private static final String COMMON_PART_LABEL = "taxonomyauthority_common";
+
+ public TaxonomyAuthorityDocumentModelHandler() {
+ super(COMMON_PART_LABEL);
+ }
+
+ @Override
+ public TaxonomyauthorityCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ TaxonomyauthorityCommonList coList = extractPagingInfo(new TaxonomyauthorityCommonList(),
+ wrapDoc);
+ AbstractCommonList commonList = (AbstractCommonList) coList;
+ commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
+
+ //FIXME: iterating over a long list of documents is not a long term
+ //strategy...need to change to more efficient iterating in future
+ List<TaxonomyauthorityCommonList.TaxonomyauthorityListItem> list = coList.getTaxonomyauthorityListItem();
+ String label = getServiceContext().getCommonPartLabel();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ while(iter.hasNext()){
+ DocumentModel docModel = iter.next();
+ TaxonomyauthorityListItem ilistItem = new TaxonomyauthorityListItem();
+ ilistItem.setDisplayName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.DISPLAY_NAME));
+ ilistItem.setRefName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.REF_NAME));
+ ilistItem.setShortIdentifier((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.SHORT_IDENTIFIER));
+ ilistItem.setVocabType((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.VOCAB_TYPE));
+ String id = getCsid(docModel);//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 TaxonomyAuthorityConstants.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.taxonomy.nuxeo;
+
+/**
+ * TaxonomyConstants provides constants for Taxonomy documents
+ *
+ */
+public class TaxonomyConstants {
+
+ public final static String NUXEO_DOCTYPE = "Taxonomy";
+ public final static String NUXEO_SCHEMA_NAME = "taxonomy";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-Taxonomy";
+}
--- /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.taxonomy.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.TaxonomyJAXBSchema;
+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.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyCommon;
+import org.collectionspace.services.taxonomy.TaxonomyCommonList;
+import org.collectionspace.services.taxonomy.TaxonomyCommonList.TaxonomyListItem;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TaxonomyDocumentModelHandler
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ */
+/**
+ * @author pschmitz
+ *
+ */
+public class TaxonomyDocumentModelHandler
+ extends AuthorityItemDocumentModelHandler<TaxonomyCommon, TaxonomyCommonList> {
+
+ /** The logger. */
+ private final Logger logger = LoggerFactory.getLogger(TaxonomyDocumentModelHandler.class);
+ /**
+ * Common part schema label
+ */
+ private static final String COMMON_PART_LABEL = "taxonomy_common";
+
+ public TaxonomyDocumentModelHandler() {
+ super(COMMON_PART_LABEL);
+ }
+
+ /* (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);
+ handleDisplayNames(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);
+ handleDisplayNames(wrapDoc.getWrappedObject());
+ }
+
+ /**
+ * Handle display name.
+ *
+ * @param docModel the doc model
+ * @throws Exception the exception
+ */
+ private void handleDisplayNames(DocumentModel docModel) throws Exception {
+ String commonPartLabel = getServiceContext().getCommonPartLabel("taxonomy");
+ Boolean displayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+ TaxonomyJAXBSchema.DISPLAY_NAME_COMPUTED);
+ Boolean shortDisplayNameComputed = (Boolean) docModel.getProperty(commonPartLabel,
+ TaxonomyJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED);
+ if(displayNameComputed==null)
+ displayNameComputed = true;
+ if(shortDisplayNameComputed==null)
+ shortDisplayNameComputed = true;
+ if (displayNameComputed || shortDisplayNameComputed) {
+ String displayName = prepareDefaultDisplayName(
+ (String)docModel.getProperty(commonPartLabel, TaxonomyJAXBSchema.NAME ));
+ if (displayNameComputed) {
+ docModel.setProperty(commonPartLabel, TaxonomyJAXBSchema.DISPLAY_NAME,
+ displayName);
+ }
+ if (shortDisplayNameComputed) {
+ docModel.setProperty(commonPartLabel, TaxonomyJAXBSchema.SHORT_DISPLAY_NAME,
+ displayName);
+ }
+ }
+ }
+
+ /**
+ * Produces a default displayName from the basic name and dates fields.
+ * @see TaxonomyAuthorityClientUtils.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();
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public TaxonomyCommonList extractCommonPartList(
+ DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ TaxonomyCommonList coList = extractPagingInfo(new TaxonomyCommonList(), wrapDoc);
+ AbstractCommonList commonList = (AbstractCommonList) coList;
+ commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
+ List<TaxonomyCommonList.TaxonomyListItem> list = coList.getTaxonomyListItem();
+ Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
+ String commonPartLabel = getServiceContext().getCommonPartLabel(
+ "taxonomy");
+ while (iter.hasNext()) {
+ DocumentModel docModel = iter.next();
+ TaxonomyListItem ilistItem = new TaxonomyListItem();
+ ilistItem.setDisplayName((String) docModel.getProperty(
+ commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
+ ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
+ AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
+ ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
+ AuthorityItemJAXBSchema.REF_NAME));
+ String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
+ ilistItem.setUri("/taxonomyauthorities/" + 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 TaxonomyConstants.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.taxonomy.nuxeo;
+
+import org.collectionspace.services.taxonomy.TaxonomyCommon;
+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 TaxonomyValidatorHandler implements ValidatorHandler {
+
+ final Logger logger = LoggerFactory.getLogger(TaxonomyValidatorHandler.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;
+ TaxonomyCommon taxonomy = (TaxonomyCommon) mctx.getInputPart(mctx.getCommonPartLabel(),
+ TaxonomyCommon.class);
+ String msg = "";
+ boolean invalid = false;
+ if(!taxonomy.isDisplayNameComputed() && (taxonomy.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);
+ }
+ }
+}