<artifactId>org.collectionspace.services.restrictedmedia.service</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.advancedsearch.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!--dependency>
<groupId>org.collectionspace.services</groupId>
import org.collectionspace.services.pottag.PottagResource;
import org.collectionspace.services.report.ReportResource;
import org.collectionspace.services.acquisition.AcquisitionResource;
+import org.collectionspace.services.advancedsearch.AdvancedSearch;
import org.collectionspace.services.dimension.DimensionResource;
import org.collectionspace.services.servicegroup.ServiceGroupResource;
import org.collectionspace.services.structureddate.StructuredDateResource;
import org.collectionspace.services.common.publicitem.PublicItemResource;
import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.common.security.SecurityInterceptor;
+import org.collectionspace.services.advancedsearch.AdvancedSearch;
/**
* CollectionSpaceJaxRsApplication, the root application
singletons.add(new IndexResource());
singletons.add(new LoginResource());
singletons.add(new LogoutResource());
+ singletons.add(new AdvancedSearch());
addResourceToMapAndSingletons(new VocabularyResource());
addResourceToMapAndSingletons(new PersonAuthorityResource());
--- /dev/null
+<project name="advancedsearch" default="package" basedir=".">
+ <description>
+ advancedsearch service
+ </description>
+ <!-- set global properties for this build -->
+ <property name="services.trunk" value="../.." />
+ <!-- environment should be declared before reading build.properties -->
+ <property environment="env" />
+ <property file="${services.trunk}/build.properties" />
+ <property name="mvn.opts" value="-V" />
+ <property name="src" location="src" />
+
+ <condition property="osfamily-unix">
+ <os family="unix" />
+ </condition>
+ <condition property="osfamily-windows">
+ <os family="windows" />
+ </condition>
+
+ <target name="package" depends="package-unix,package-windows"
+ description="Package CollectionSpace Services" />
+
+ <target name="package-unix" if="osfamily-unix">
+ <exec executable="mvn" failonerror="true">
+ <arg value="package" />
+ <arg value="-Dmaven.test.skip=true" />
+ <arg value="-f" />
+ <arg value="${basedir}/pom.xml" />
+ <arg value="-N" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="package-windows" if="osfamily-windows">
+ <exec executable="cmd" failonerror="true">
+ <arg value="/c" />
+ <arg value="mvn" />
+ <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" />
+ <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" />
+ <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" />
+ <arg value="test" />
+ <arg value="${mvn.opts}" />
+ </exec>
+ </target>
+
+ <target name="deploy" depends="install"
+ description="deploy advancedsearch in ${jee.server.nuxeo}">
+ <!-- This target is obsolete -->
+ </target>
+
+ <target name="undeploy"
+ description="undeploy advancedsearch from ${jee.server.nuxeo}">
+ <!-- This target is obsolete -->
+ </target>
+</project>
\ No newline at end of file
--- /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.advancedsearch</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.advancedsearch.client</artifactId>
+ <name>services.advancedsearch.client</name>
+
+ <dependencies>
+ <!-- CollectionSpace dependencies -->
+ <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.advancedsearch.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </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>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-advancedsearch-client</finalName>
+ </build>
+</project>
\ No newline at end of file
--- /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
+ *
+ * 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 org.collectionspace.services.advancedsearch.AdvancedsearchCommonList.AdvancedsearchListItem;
+
+/**
+ * ConsultationClient.java
+ */
+public class AdvancedSearchClient extends AbstractCommonListPoxServiceClientImpl<AdvancedSearchProxy, AdvancedsearchListItem> {
+
+ public static final String SERVICE_NAME = "advancedsearch";
+ public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
+ public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
+ public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";
+
+ public AdvancedSearchClient() throws Exception {
+ super();
+ }
+
+ public AdvancedSearchClient(String clientPropertiesFilename) throws Exception {
+ super(clientPropertiesFilename);
+ }
+
+ @Override
+ public String getServicePathComponent() {
+ return SERVICE_PATH_COMPONENT;
+ }
+
+ @Override
+ public String getServiceName() {
+ return SERVICE_NAME;
+ }
+
+ @Override
+ public Class<AdvancedSearchProxy> getProxyClass() {
+ return AdvancedSearchProxy.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
+ *
+ * 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.Consumes;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+/**
+ * ConsultationProxy.java
+ */
+@Path(AdvancedSearchClient.SERVICE_PATH_PROXY)
+@Produces({"application/xml"})
+@Consumes({"application/xml"})
+public interface AdvancedSearchProxy extends CollectionSpaceCommonListPoxProxy {}
--- /dev/null
+#
+# URL of the CollectionSpace server and user credentials
+#
+cspace.url=http://localhost:8180/cspace-services/
+cspace.ssl=false
+cspace.auth=true
+cspace.user=admin@core.collectionspace.org
+cspace.password=Administrator
+#
+# default tenant information
+#
+cspace.tenant=1
+cspace.tenantID=core.collectionspace.org
--- /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>
+ <artifactId>org.collectionspace.services.advancedsearch</artifactId>
+ <groupId>org.collectionspace.services</groupId>
+ <version>${revision}</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.advancedsearch.jaxb</artifactId>
+ <name>services.advancedsearch.jaxb</name>
+
+ <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.collectionobject.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-advancedsearch-jaxb</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
--- /dev/null
+package org.collectionspace.services.advancedsearch.model;
+
+import java.util.List;
+
+import org.collectionspace.services.collectionobject.BriefDescriptionList;
+
+public class BriefDescriptionListModel {
+ private static int DESCRIPTION_LENGTH = 55;
+ public static String briefDescriptionListToDisplayString(BriefDescriptionList bdList) {
+ List<String> bds = bdList.getBriefDescription();
+ String returnString = "";
+ // "Display first 55 (?) characters..." from https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ // FIXME the above business logic is inadequate because there are numerous brief descriptions
+ if(null != bds) {
+ if(!bds.isEmpty()) {
+ // get the 1st 55 characters of the 1st defined brief description if there is one
+ if(null != bds.get(0)) {
+ int length = bds.get(0).length();
+ returnString = bds.get(0).substring(0, (length >= DESCRIPTION_LENGTH) ? DESCRIPTION_LENGTH : length);
+ }
+
+ }
+ }
+ return returnString;
+ }
+}
--- /dev/null
+package org.collectionspace.services.advancedsearch.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.collectionspace.services.collectionobject.ContentConceptList;
+
+public class ContentConceptListModel {
+
+ public static String contentConceptListDisplayString(ContentConceptList conceptList) {
+ List<String> displayConcepts = new ArrayList<String>();
+ if(null != conceptList) {
+ List<String> concepts = conceptList.getContentConcept();
+ for (String conceptRefname : concepts) {
+ displayConcepts.add(displayNameFromRefName(conceptRefname));
+ }
+ }
+
+ return String.join(",", displayConcepts);
+ }
+
+ private static String displayNameFromRefName(String refname) {
+ // e.g.
+ // urn:cspace:core.collectionspace.org:conceptauthorities:name(concept):item:name(FooConcept1749234493809)'FooConcept'
+ // -> FooConcept
+ // TODO: there is probably code somewhere for doing this
+ String displayName = refname;
+ if(refname.indexOf("'") < refname.lastIndexOf("'")) {
+ displayName = refname.substring(refname.indexOf("'")+1, refname.lastIndexOf("'"));
+ }
+
+ return displayName;
+ }
+
+}
--- /dev/null
+package org.collectionspace.services.advancedsearch.model;
+
+import java.util.List;
+
+import org.collectionspace.services.collectionobject.ObjectNameGroup;
+import org.collectionspace.services.collectionobject.ObjectNameList;
+
+public class ObjectNameListModel {
+ public static String objectNameListToDisplayString(ObjectNameList onList) {
+ List<ObjectNameGroup> objectNameGroups = onList.getObjectNameGroup();
+ String returnString = "";
+ if(null != objectNameGroups ) {
+ if(!objectNameGroups.isEmpty()) {
+ ObjectNameGroup objectNameGroup = objectNameGroups.get(0);
+ if(null != objectNameGroup.getObjectName()) {
+ returnString = objectNameGroup.getObjectName();
+ }
+ }
+ }
+
+ return returnString;
+ }
+}
--- /dev/null
+package org.collectionspace.services.advancedsearch.model;
+
+import java.util.List;
+
+import org.collectionspace.services.advancedsearch.ObjectFactory;
+import org.collectionspace.services.advancedsearch.ResponsibleDepartment;
+import org.collectionspace.services.advancedsearch.ResponsibleDepartmentsList;
+import org.collectionspace.services.collectionobject.ResponsibleDepartmentList;
+
+public class ResponsibleDepartmentsListModel {
+ private static ObjectFactory objectFactory = new ObjectFactory();
+ public static ResponsibleDepartmentsList responsibleDepartmentListToResponsibleDepartmentsList(ResponsibleDepartmentList rdList) {
+ ResponsibleDepartmentsList responsibleDepartmentList = objectFactory.createResponsibleDepartmentsList();
+ // NOTE "Display all values separated by comma", from https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ List<String> responsibleDepartmentNames = rdList.getResponsibleDepartment();
+ if(null != responsibleDepartmentNames) {
+ for(String responsibleDepartmentName : responsibleDepartmentNames) {
+ ResponsibleDepartment responsibleDepartment = objectFactory.createResponsibleDepartment();
+ responsibleDepartment.setName(responsibleDepartmentName);
+ responsibleDepartmentList.getResponsibleDepartment().add(responsibleDepartment);
+ }
+ }
+
+ return responsibleDepartmentList;
+ }
+ public static String responsibleDepartmentsListDisplayString(ResponsibleDepartmentsList rdl) {
+ String rdlString = "";
+ if (null != rdl && null != rdl.getResponsibleDepartment() && rdl.getResponsibleDepartment().size() > 0) {
+ ResponsibleDepartment rd = rdl.getResponsibleDepartment().get(0);
+ rdlString = rd.getName();
+ }
+ return rdlString;
+ }
+}
--- /dev/null
+package org.collectionspace.services.advancedsearch.model;
+
+import java.util.List;
+
+import org.collectionspace.services.collectionobject.TitleGroup;
+import org.collectionspace.services.collectionobject.TitleGroupList;
+
+public class TitleGroupListModel {
+ public static String titleGroupListToDisplayString(TitleGroupList tlList) {
+ String returnString = "";
+ List<TitleGroup> titleGroups = tlList.getTitleGroup();
+ // "Title: Display 1st Title OR 1st Controlled Nomenclature combined with Uncontrolled Nomenclature OR 1st Taxon with Preservation Form" from https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ // FIXME: we are not fully implementing the above logic below
+ if(null != titleGroups) {
+ if(!titleGroups.isEmpty()) {
+ TitleGroup titleGroup = titleGroups.get(0);
+ if(null != titleGroup.getTitle()) {
+ returnString = titleGroup.getTitle();
+ }
+ }
+ }
+
+ return returnString;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ AdvancedSearch schema (XSD)
+
+ Entity : AdvancedSearch
+ Part : Common
+ Used for: JAXB binding between XML and Java objects
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ jaxb:version="2.0" elementFormDefault="unqualified"
+ xmlns="http://collectionspace.org/services/advancedsearch"
+ targetNamespace="http://collectionspace.org/services/advancedsearch"
+ version="0.1"
+>
+
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
+ <xs:complexType name="responsibleDepartment">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>
+ <xs:element name="csid" type="xs:string" minOccurs="1"/>
+ <xs:element name="refName" type="xs:string" minOccurs="1"/>
+ <xs:element name="name" type="xs:string" minOccurs="1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="responsibleDepartmentsList">
+ <xs:sequence>
+ <xs:element name="responsibleDepartment" type="responsibleDepartment" minOccurs="0" maxOccurs="unbounded" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="advancedsearch-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <xs:element name="advancedsearch-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
+ <xs:element name="csid" type="xs:string" minOccurs="1" />
+ <xs:element name="refName" type="xs:string" minOccurs="1" />
+ <xs:element name="blobCsid" type="xs:string" minOccurs="1" />
+ <xs:element name="updatedAt" type="xs:dateTime" minOccurs="1" />
+ <xs:element name="objectId" type="xs:string" minOccurs="1" />
+ <xs:element name="objectNumber" type="xs:string" minOccurs="1" />
+ <xs:element name="objectName" type="xs:string" minOccurs="1" />
+ <xs:element name="title" type="xs:string" minOccurs="1" />
+ <xs:element name="computedCurrentLocation" type="xs:string" minOccurs="1" />
+ <xs:element name="responsibleDepartments" type="responsibleDepartmentsList" minOccurs="1" />
+ <xs:element name="responsibleDepartment" type="xs:string" minOccurs="1" />
+ <xs:element name="contentConcepts" type="xs:string" minOccurs="1" />
+ <xs:element name="briefDescription" type="xs:string" minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
\ No newline at end of file
--- /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.main</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.advancedsearch</artifactId>
+ <name>services.advancedsearch</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <!-- spotless 2.30.0 is the last version that supports java 8 -->
+ <spotless.version>2.30.0</spotless.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.diffplug.spotless</groupId>
+ <artifactId>spotless-maven-plugin</artifactId>
+ <version>${spotless.version}</version>
+ <configuration>
+ <formats>
+ <!-- you can define as many formats as you want, each is independent -->
+ <format>
+ <includes>
+ <include>src/main/java/**/*.java</include>
+ <include>src/test/java/**/*.java</include>
+ </includes>
+ <trimTrailingWhitespace />
+ <endWithNewline />
+ <indent>
+ <spaces>true</spaces>
+ <spacesPerTab>4</spacesPerTab>
+ </indent>
+ </format>
+ </formats>
+ <!-- define a language-specific format -->
+ <java>
+ <palantirJavaFormat />
+ </java>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>jaxb</module>
+ <module>service</module>
+ <module>client</module>
+ </modules>
+
+</project>
\ No newline at end of file
--- /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.advancedsearch</artifactId>
+ <version>${revision}</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.collectionspace.services.advancedsearch.service</artifactId>
+ <name>services.advancedsearch.service</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.advancedsearch.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.advancedsearch.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.collectionobject.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.media.service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- javax -->
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</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.collectionspace.services</groupId>
+ <artifactId>
+ org.collectionspace.services.collectionobject.client
+ </artifactId>
+ <version>8.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>
+ org.collectionspace.services.media.service
+ </artifactId>
+ <version>8.3.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-advancedsearch</finalName>
+ </build>
+</project>
--- /dev/null
+package org.collectionspace.services.advancedsearch;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.collectionspace.services.advancedsearch.AdvancedsearchCommonList.AdvancedsearchListItem;
+import org.collectionspace.services.advancedsearch.model.BriefDescriptionListModel;
+import org.collectionspace.services.advancedsearch.model.ContentConceptListModel;
+import org.collectionspace.services.advancedsearch.model.ObjectNameListModel;
+import org.collectionspace.services.advancedsearch.model.ResponsibleDepartmentsListModel;
+import org.collectionspace.services.advancedsearch.model.TitleGroupListModel;
+import org.collectionspace.services.client.AdvancedSearchClient;
+import org.collectionspace.services.client.CollectionObjectClient;
+import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.IQueryManager;
+import org.collectionspace.services.client.PayloadInputPart;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.collectionobject.CollectionObjectResource;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
+import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ResourceMap;
+import org.collectionspace.services.common.UriInfoWrapper;
+import org.collectionspace.services.common.context.RemoteServiceContextFactory;
+import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList.ListItem;
+import org.collectionspace.services.media.MediaResource;
+import org.dom4j.DocumentException;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
+// FIXME: The *Client pattern should be deprecated; it's only really used in unit tests, and trying to use it in services creates authorization challenges. It's repeated here only to maintain parity with existing services.
+/**
+ * This class defines the advanced search endpoints.
+ */
+@Path(AdvancedSearchClient.SERVICE_PATH)
+@Consumes("application/xml")
+@Produces("application/xml")
+public class AdvancedSearch
+ extends AbstractCollectionSpaceResourceImpl<AdvancedsearchListItem, AdvancedsearchListItem> {
+ private static final String FIELDS_RETURNED = "uri|csid|refName|blobCsid|updatedAt|objectId|objectNumber|objectName|title|computedCurrentLocation|responsibleDepartments|responsibleDepartment|contentConcepts|briefDescription";
+ private static final String COMMON_PART_NAME = CollectionObjectClient.SERVICE_NAME + CollectionSpaceClient.PART_LABEL_SEPARATOR + CollectionSpaceClient.PART_COMMON_LABEL; // FIXME: it's not great to hardcode this here
+
+ private final Logger logger = LoggerFactory.getLogger(AdvancedSearch.class);
+ private final CollectionObjectResource cor = new CollectionObjectResource();
+ private final MediaResource mr = new MediaResource();
+
+ public AdvancedSearch() {
+ super();
+ }
+
+ /**
+ * Primary advanced search API endpoint.
+ *
+ * @param request The incoming request. Injected.
+ * @param uriInfo The URI info of the incoming request, including query parameters and other search control parameters. Injected.
+ * @return A possibly-empty AbstractCommonList of the advanced search results corresponding to the query
+ */
+ @GET
+ public AbstractCommonList getList(@Context Request request, @Context UriInfo uriInfo) {
+ logger.info("advancedsearch called with path: {}", uriInfo.getPath());
+ MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(true);
+ logger.info("advancedsearch called with query params: {}", queryParams);
+
+ // the list to return
+ ObjectFactory objectFactory = new ObjectFactory();
+ AdvancedsearchCommonList resultsList = objectFactory.createAdvancedsearchCommonList();
+ // FIXME: this shouldn't be necessary?
+ resultsList.advancedsearchListItem = new ArrayList<AdvancedsearchListItem>();
+
+ // the logic here is to use CollectionObjectResource to perform the search, then
+ // loop over the results retrieving corresponding CollectionobjectsCommon objects,
+ // which have more fields
+ AbstractCommonList collectionObjectList = cor.getList(uriInfo);
+ List<ListItem> collectionObjectListItems = collectionObjectList.getListItem();
+
+ HashMap<String, String> collectionObjectValuesMap = new HashMap<String, String>();
+ for (ListItem item : collectionObjectListItems) {
+ // FIXME: is there no better way to do this? We should at least abstract this logic out of here
+ List<Element> els = item.getAny();
+ for (Element el : els) {
+ String elementName = el.getTagName();
+ String elementText = el.getTextContent();
+ collectionObjectValuesMap.put(elementName, elementText);
+ }
+ String csid = collectionObjectValuesMap.get("csid");
+ UriInfoWrapper wrappedUriInfo = new UriInfoWrapper(uriInfo);
+ List<String> blobCsids = findBlobCsids(csid, wrappedUriInfo);
+
+ /*
+ * NOTE: code below is partly based on
+ * CollectionObjectServiceTest.readCollectionObjectCommonPart and
+ * AbstractPoxServiceTestImpl
+ */
+ ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
+ Response res = cor.get(request, resourceMap, uriInfo, csid);
+ int statusCode = res.getStatus();
+ logger.warn("advancedsearch: call to CollectionObjectResource for csid {} returned status {}", csid, statusCode);
+ CollectionobjectsCommon collectionObject = null;
+ // FIXME: is there no better way to do this? We should at least abstract this logic out of here
+ PoxPayloadIn input = null;
+ try {
+ String responseXml = new String((byte[]) res.getEntity(),StandardCharsets.UTF_8);
+ input = new PoxPayloadIn(responseXml);
+ } catch (DocumentException e) {
+ // TODO: need better error handling
+ logger.error("advancedsearch: could not create PoxPayloadIn", e);
+ continue;
+ }
+ if (null != input) {
+ PayloadInputPart payloadInputPart = input.getPart(COMMON_PART_NAME);
+ if (null != payloadInputPart) {
+ collectionObject = (CollectionobjectsCommon) payloadInputPart.getBody();
+ }
+ }
+ // build up a listitem for the result list using the additional fields in CollectionObjectsCommon
+ if (null != collectionObject) {
+ AdvancedsearchListItem listItem = objectFactory.createAdvancedsearchCommonListAdvancedsearchListItem();
+ listItem.setBriefDescription(BriefDescriptionListModel
+ .briefDescriptionListToDisplayString(collectionObject.getBriefDescriptions()));
+ // TODO: collectionObject.getComputedCurrentLocation() is (can be?) a refname.
+ // code below extracts display name. there's probably something in RefName or
+ // similar to do this kind of thing see also
+ // ContentConceptListModel.displayNameFromRefName
+ String currLoc = collectionObject.getComputedCurrentLocation();
+ String currLocDisplayName = currLoc;
+ if (null != currLoc && currLoc.indexOf("'") < currLoc.lastIndexOf("'")) {
+ currLocDisplayName = currLoc.substring(currLoc.indexOf("'") + 1, currLoc.lastIndexOf("'"));
+ }
+ listItem.setComputedCurrentLocation(currLocDisplayName); // "Computed Current
+ // Location: Display
+ // full string" from
+ // https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ listItem.setObjectName(
+ ObjectNameListModel.objectNameListToDisplayString(collectionObject.getObjectNameList()));
+ listItem.setTitle(
+ TitleGroupListModel.titleGroupListToDisplayString(collectionObject.getTitleGroupList()));
+ ResponsibleDepartmentsList rdl = ResponsibleDepartmentsListModel
+ .responsibleDepartmentListToResponsibleDepartmentsList(
+ collectionObject.getResponsibleDepartments());
+ listItem.setResponsibleDepartments(rdl);
+ listItem.setResponsibleDepartment(
+ ResponsibleDepartmentsListModel.responsibleDepartmentsListDisplayString(rdl));
+
+ listItem.setContentConcepts(
+ ContentConceptListModel.contentConceptListDisplayString(collectionObject.getContentConcepts()));
+
+ // from media resource
+ if (blobCsids.size() > 0) {
+ listItem.setBlobCsid(blobCsids.get(0));
+ }
+
+ // from collectionobject itself
+ listItem.setCsid(collectionObjectValuesMap.get("csid"));
+ listItem.setObjectId(collectionObjectValuesMap.get("objectId")); // "Identification Number: Display full
+ // string" from
+ // https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ listItem.setObjectNumber(collectionObjectValuesMap.get("objectNumber"));
+ listItem.setRefName(collectionObjectValuesMap.get("refName"));
+ listItem.setUri(collectionObjectValuesMap.get("uri"));
+ try {
+ XMLGregorianCalendar date = DatatypeFactory.newInstance()
+ .newXMLGregorianCalendar(collectionObjectValuesMap.get("updatedAt"));
+ listItem.setUpdatedAt(date); // "Last Updated Date: Display Date, if updated same day can we display
+ // x number of hours ago" from
+ // https://docs.google.com/spreadsheets/d/103jyxa2oCtt8U0IQ25xsOyIxqwKvPNXlcCtcjGlT5tQ/edit?gid=0#gid=0
+ } catch (DatatypeConfigurationException e) {
+ // FIXME need better error handling
+ logger.error("advancedsearch: could not create XMLGregorianCalendar for updatedAt ", e);
+ logger.error("advancedsearch: updatedAt: {}", collectionObjectValuesMap.get("updatedAt"));
+ }
+
+ // add the populated item to the results
+ resultsList.getAdvancedsearchListItem().add(listItem);
+ } else {
+ logger.warn("advancedsearch: could not find CollectionobjectsCommon associated with csid {}", csid);
+ }
+ res.close();
+ }
+
+ // NOTE: I think this is necessary for the front end to know what to do with
+ // what's returned (?)
+ AbstractCommonList abstractList = (AbstractCommonList) resultsList;
+ abstractList.setItemsInPage(collectionObjectList.getItemsInPage());
+ abstractList.setPageNum(collectionObjectList.getPageNum());
+ abstractList.setPageSize(collectionObjectList.getPageSize());
+ abstractList.setTotalItems(collectionObjectList.getTotalItems());
+ // FIXME: is there a way to generate this rather than hardcode it?
+ abstractList.setFieldsReturned(FIELDS_RETURNED);
+
+ return resultsList;
+ }
+
+ /**
+ * Retrieves the blob CSIDs associated with a given object's CSID
+ *
+ * @param csid The CSID of an object whose associated blobs (thumbnails) is desired
+ * @param wrappedUriInfo The wrapped (mutable) UriInfo of the incoming query that ultimately triggered this call
+ * @return A possibly-empty list of strings of the blob CSIDs associated with CSID
+ */
+ private List<String> findBlobCsids(String csid, UriInfoWrapper wrappedUriInfo) {
+ MultivaluedMap<String, String> wrappedQueryParams = wrappedUriInfo.getQueryParameters();
+ wrappedQueryParams.clear();
+ wrappedQueryParams.add(IQueryManager.SEARCH_RELATED_TO_CSID_AS_SUBJECT, csid);
+ wrappedQueryParams.add("pgSz", "1");
+ wrappedQueryParams.add("pgNum", "0");
+ wrappedQueryParams.add("sortBy", "media_common:title");
+ AbstractCommonList associatedMedia = mr.getList(wrappedUriInfo);
+ HashMap<String, String> mediaResourceValuesMap = new HashMap<String, String>();
+ ArrayList<String> blobCsids = new ArrayList<String>();
+ for (ListItem item : associatedMedia.getListItem()) {
+ // FIXME: is there no better way to do this? we should at least abstract out this logic
+ List<Element> els = item.getAny();
+ for (Element el : els) {
+ String elementName = el.getTagName();
+ String elementText = el.getTextContent();
+ mediaResourceValuesMap.put(elementName, elementText);
+ }
+ String blobCsid = mediaResourceValuesMap.get("blobCsid");
+ if (null != blobCsid) {
+ blobCsids.add(blobCsid);
+ }
+ }
+ return blobCsids;
+ }
+
+ @Override
+ public Class<?> getCommonPartClass() {
+ return null;
+ }
+
+ @Override
+ public ServiceContextFactory<AdvancedsearchListItem, AdvancedsearchListItem> getServiceContextFactory() {
+ return (ServiceContextFactory<AdvancedsearchListItem, AdvancedsearchListItem>) RemoteServiceContextFactory
+ .get();
+ }
+
+ @Override
+ public String getServiceName() {
+ return AdvancedSearchClient.SERVICE_NAME;
+ }
+
+ @Override
+ protected String getVersionString() {
+ return "0.01";
+ }
+}
\ No newline at end of file
<ant antfile="publicitem/build.xml" target="deploy" inheritAll="false"/>
<ant antfile="uoc/build.xml" target="deploy" inheritAll="false"/>
<ant antfile="transport/build.xml" target="deploy" inheritAll="false"/>
+ <ant antfile="advancedsearch/build.xml" target="deploy" inheritAll="false"/>
<ant antfile="JaxRsServiceProvider/build.xml" target="deploy" inheritAll="false"/>
</target>
<target name="undeploy"
description="undeploy services from ${jee.server.cspace}">
<ant antfile="JaxRsServiceProvider/build.xml" target="undeploy" inheritAll="false"/>
+ <ant antfile="advancedsearch/build.xml" target="undeploy" inheritAll="false"/>
<ant antfile="vocabulary/build.xml" target="undeploy" inheritAll="false"/>
<ant antfile="citation/build.xml" target="undeploy" inheritAll="false"/>
<ant antfile="organization/build.xml" target="undeploy" inheritAll="false"/>
<ant antfile="person/build.xml" target="dist" inheritAll="false"/>
<ant antfile="citation/build.xml" target="dist" inheritAll="false"/>
<ant antfile="acquisition/build.xml" target="dist" inheritAll="false"/>
+ <ant antfile="advancedsearch/build.xml" target="deploy" inheritAll="false"/>
<ant antfile="JaxRsServiceProvider/build.xml" target="dist" inheritAll="false"/>
<copy file="${basedir}/target/${javadoc.jar}"
todir="${services.trunk}/${dist.server.cspace}/cspace/services/docs"/>
version="1.0">
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
</tenant:serviceBindings>
+ <!-- end systeminfo service meta-data -->
+
+ <!-- begin advancedsearch service meta-data -->
+ <tenant:serviceBindings id="advancedsearch" merge:matcher="id" name="advancedsearch" requiresDocumentHandler="false" type="utility"
+ version="0.01">
+ <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
+ </tenant:serviceBindings>
<!-- end systeminfo service meta-data -->
<!-- begin blob service meta-data -->
<module>security</module>
<module>login</module>
<module>logout</module>
+ <module>advancedsearch</module>
<module>JaxRsServiceProvider</module>
</modules>