<artifactId>org.collectionspace.services.intake.service</artifactId>\r
<version>${project.version}</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.loanin.service</artifactId>\r
+ <version>${project.version}</version>\r
+ </dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.dimension.service</artifactId>\r
import org.collectionspace.services.collectionobject.CollectionObjectResource;
import org.collectionspace.services.id.IDResource;
import org.collectionspace.services.intake.IntakeResource;
+import org.collectionspace.services.loanin.LoaninResource;
import org.collectionspace.services.relation.NewRelationResource;
import org.collectionspace.services.acquisition.AcquisitionResource;
import org.collectionspace.services.dimension.DimensionResource;
singletons.add(new CollectionObjectResource());
singletons.add(new IDResource());
singletons.add(new IntakeResource());
+ singletons.add(new LoaninResource());
singletons.add(new AcquisitionResource());
singletons.add(new NewRelationResource());
singletons.add(new VocabularyResource());
<ant antfile="id/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="deploy" inheritAll="false"/>\r
+ <ant antfile="loanin/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="vocabulary/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="organization/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="person/build.xml" target="deploy" inheritAll="false"/>\r
<ant antfile="contact/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="dimension/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="acquisition/build.xml" target="undeploy" inheritAll="false"/>\r
+ <ant antfile="loanin/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="id/build.xml" target="undeploy" inheritAll="false"/>\r
<ant antfile="id/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="collectionobject/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="dist" inheritAll="false"/>\r
+ <ant antfile="loanin/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="vocabulary/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="organization/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="person/build.xml" target="dist" inheritAll="false"/>\r
<ant antfile="authentication/build.xml" target="dist_installer" inheritAll="false"/>\r
<ant antfile="relation/build.xml" target="dist_installer" inheritAll="false"/>\r
<ant antfile="intake/build.xml" target="dist_installer" inheritAll="false"/>\r
+ <ant antfile="loanin/build.xml" target="dist_installer" inheritAll="false"/>\r
<ant antfile="acquisition/build.xml" target="dist_installer" inheritAll="false"/>\r
<ant antfile="JaxRsServiceProvider/build.xml" target="dist_installer" inheritAll="false"/>\r
--> \r
</service:object>
</tenant:serviceBindings>
<!-- end intake service meta-data -->
+ <!-- begin loanin service meta-data -->
+ <tenant:serviceBindings name="Loansin" type="procedure" version="0.1">
+ <service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
+ nuxeo-java
+ </service:repositoryClient>
+ <service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.loanin.nuxeo.LoaninDocumentModelHandler
+ </service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.loanin.nuxeo.LoaninValidatorHandler
+ </service:validatorHandler>
+ <service:object name="Loanin" version="0.1"
+ xmlns:service='http://collectionspace.org/services/common/service'>
+ <service:part id="0" control_group="Managed"
+ versionable="true" auditable="false"
+ label="loansin-system" updated="" order="0">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/common/system"
+ schemaLocation="http://collectionspace.org/services/common/system http://collectionspace.org/services/common/system/system-response.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ <service:part id="1" control_group="Managed"
+ versionable="true" auditable="false"
+ label="loansin_common" updated="" order="1">
+ <service:content contentType="application/xml">
+ <service:xmlContent
+ namespaceURI="http://collectionspace.org/services/loanin"
+ schemaLocation="http://collectionspace.org/services/loanin http://services.collectionspace.org/intake/loansin_common.xsd">
+ </service:xmlContent>
+ </service:content>
+ </service:part>
+ </service:object>
+ </tenant:serviceBindings>
+ <!-- end loanin service meta-data -->
<!-- begin vocabulary service meta-data -->
<tenant:serviceBindings name="Vocabularies" version="0.1">
<service:repositoryClient xmlns:service='http://collectionspace.org/services/common/service'>
--- /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.loanin</artifactId>
+ <groupId>org.collectionspace.services</groupId>
+ <version>0.6-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.loanin.jaxb</artifactId>
+ <name>services.loanin.jaxb</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2-commons</groupId>
+ <artifactId>property-listener-injector</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.4.1.4</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-loanin-jaxb</finalName>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <!-- javax.activation.DataSource provider is required by spec -->
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.9</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <args>
+ <arg>-XtoString</arg>
+ <arg>-Xinject-listener-code</arg>
+
+ <!-- <arg>-Xcollection-setter-injector</arg>
+ <arg>-Xfluent-api</arg> -->
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>
+ org.jvnet.jaxb2_commons
+ </groupId>
+ <artifactId>basic</artifactId>
+ <version>0.4.1</version>
+ </plugin>
+ <plugin>
+ <groupId>
+ org.jvnet.jaxb2-commons
+ </groupId>
+ <artifactId>
+ property-listener-injector
+ </artifactId>
+ <version>1.0</version>
+ </plugin>
+
+ </plugins>
+ <!--generatePackage>
+ org.collectionspace.hello
+ </generatePackage-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+/**
+ *
+ */
+package org.collectionspace.services;
+
+public interface LoaninJAXBSchema {
+ final static String LOAN_IN_NUMBER = "loanInNumber";
+ final static String LOAN_RETURN_DATE = "loanReturnDate";
+}
+
+
--- /dev/null
+package org.collectionspace.services;
+
+public interface LoaninListItemJAXBSchema {
+ final static String LOAN_IN_NUMBER = "loaninNumber";
+ final static String LOAN_RETURN_DATE = "loanReturnDate";
+ final static String CSID = "csid";
+ final static String URI = "url";
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ Loan In schema (XSD)
+
+ Entity : Loanin
+ Part : Common
+ Used for: JAXB binding between XML and Java objects
+
+ $LastChangedRevision$
+ $LastChangedDate$
+-->
+
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/services/loanin"
+ xmlns="http://collectionspace.org/services/loanin"
+ targetNamespace="http://collectionspace.org/services/loanin"
+ version="0.1"
+>
+
+<!--
+ Avoid XmlRootElement nightmare:
+ See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Loans+In+Schema -->
+
+ <!-- loanin -->
+ <xs:element name="loansin_common">
+ <xs:complexType>
+ <xs:sequence>
+ <!-- Loan In Information Group -->
+ <xs:element name="loanInNumber" type="xs:string"/>
+ <xs:element name="lenders" type="lenderList"/>
+ <xs:element name="lendersAuthorizer" type="xs:string"/>
+ <xs:element name="lendersAuthorizationDate" type="xs:string"/>
+ <xs:element name="lendersContact" type="xs:string"/>
+ <xs:element name="loanInContact" type="xs:string"/>
+ <xs:element name="loanInConditions" type="xs:string"/>
+ <xs:element name="loanInDate" type="xs:string"/>
+ <xs:element name="loanReturnDate" type="xs:string"/>
+ <xs:element name="loanRenewalApplicationDate" type="xs:string"/>
+ <xs:element name="loanInNote" type="xs:string"/>
+ <xs:element name="loanPurpose" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="lenderList">
+ <xs:sequence>
+ <xs:element name="lender" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- loansin records, as in nuxeo repository -->
+ <xs:element name="loansin-common-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="loanin-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="loanInNumber" type="xs:string"
+ minOccurs="1" />
+ <xs:element name="loanReturnDate" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="csid" type="xs:string"
+ minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
+
--- /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.loanin</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.loanin.service</artifactId>
+ <name>services.loanin.service</name>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.loanin.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.collectionobject.jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- External dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>5.6</version>
+ </dependency>
+
+ <!-- javax -->
+
+ <dependency>
+ <groupId>javax.security</groupId>
+ <artifactId>jaas</artifactId>
+ <version>1.0.01</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- jboss -->
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>1.0.2.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ <version>1.0.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-multipart-provider</artifactId>
+ <version>1.0.2.GA</version>
+ </dependency>
+
+ <!-- nuxeo -->
+
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-api</artifactId>
+ <version>1.5.1-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jboss-remoting</artifactId>
+ <groupId>jboss</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.restlet</groupId>
+ <artifactId>org.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ <dependency>
+ <groupId>com.noelios.restlet</groupId>
+ <artifactId>com.noelios.restlet</artifactId>
+ <version>1.0.7</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>collectionspace-services-loanin</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-maven-plugin</artifactId>
+ <configuration>
+ <jbossHome>${jboss.dir}</jbossHome>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <showDeprecation>true</showDeprecation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<profilesXml xmlns="http://maven.apache.org/PROFILES/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/PROFILES/1.0.0 http://maven.apache.org/xsd/profiles-1.0.0.xsd">
+</profilesXml>
\ No newline at end of file
--- /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.loanin;
+
+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.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ClientType;
+import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.context.MultipartServiceContext;
+import org.collectionspace.services.common.context.MultipartServiceContextFactory;
+import org.collectionspace.services.common.context.MultipartServiceContextImpl;
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentFilter;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.DocumentNotFoundException;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.query.IQueryManager;
+import org.collectionspace.services.common.query.QueryManager;
+import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.jboss.resteasy.util.HttpResponseCodes;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class LoaninResource.
+ */
+@Path("/loansin")
+@Consumes("multipart/mixed")
+@Produces("multipart/mixed")
+public class LoaninResource extends AbstractCollectionSpaceResourceImpl {
+
+ /** The Constant serviceName. */
+ private final static String serviceName = "loansin";
+
+ /** The logger. */
+ final Logger logger = LoggerFactory.getLogger(LoaninResource.class);
+ //FIXME retrieve client type from configuration
+ /** The Constant CLIENT_TYPE. */
+ final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
+
+ /**
+ * Instantiates a new loanin resource.
+ */
+ public LoaninResource() {
+ // do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
+ */
+ @Override
+ protected String getVersionString() {
+ /** The last change revision. */
+ final String lastChangeRevision = "$LastChangedRevision: 1627 $";
+ return lastChangeRevision;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
+ */
+ @Override
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#createDocumentHandler(org.collectionspace.services.common.context.ServiceContext)
+ */
+ @Override
+ public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception {
+ DocumentHandler docHandler = ctx.getDocumentHandler();
+ if (ctx.getInput() != null) {
+ Object obj = ((MultipartServiceContext) ctx).getInputPart(ctx.getCommonPartLabel(), LoansinCommon.class);
+ if (obj != null) {
+ docHandler.setCommonPart((LoansinCommon) obj);
+ }
+ }
+ return docHandler;
+ }
+
+ /**
+ * Creates the loanin.
+ *
+ * @param input the input
+ *
+ * @return the response
+ */
+ @POST
+ public Response createLoanin(MultipartInput input) {
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ String csid = getRepositoryClient(ctx).create(ctx, handler);
+ //loaninObject.setCsid(csid);
+ UriBuilder path = UriBuilder.fromResource(LoaninResource.class);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in createLoanin", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ }
+
+ /**
+ * Gets the loanin.
+ *
+ * @param csid the csid
+ *
+ * @return the loanin
+ */
+ @GET
+ @Path("{csid}")
+ public MultipartOutput getLoanin(
+ @PathParam("csid") String csid) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLoanin with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("getLoanin: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "get failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).get(ctx, csid, handler);
+ result = (MultipartOutput) ctx.getOutput();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLoanin", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLoanin", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (result == null) {
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed, the requested Loanin CSID:" + csid + ": was not found.").type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the loanin list.
+ *
+ * @param ui the ui
+ * @param keywords the keywords
+ *
+ * @return the loanin list
+ */
+ @GET
+ @Produces("application/xml")
+ public LoansinCommonList getLoaninList(@Context UriInfo ui,
+ @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords) {
+ LoansinCommonList result = null;
+
+ if (keywords != null) {
+ result = searchLoansin(keywords);
+ } else {
+ result = getLoaninList();
+ }
+
+ return result;
+ }
+
+ /**
+ * Gets the loanin list.
+ *
+ * @return the loanin list
+ */
+ private LoansinCommonList getLoaninList() {
+ LoansinCommonList loaninObjectList;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).getAll(ctx, handler);
+ loaninObjectList = (LoansinCommonList) handler.getCommonPartList();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in getLoaninList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return loaninObjectList;
+ }
+
+ /**
+ * Gets the authority refs.
+ *
+ * @param csid the csid
+ * @param ui the ui
+ *
+ * @return the authority refs
+ */
+ @GET
+ @Path("{csid}/authorityrefs")
+ @Produces("application/xml")
+ public AuthorityRefList getAuthorityRefs(
+ @PathParam("csid") String csid,
+ @Context UriInfo ui) {
+ AuthorityRefList authRefList = null;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ DocumentWrapper<DocumentModel> docWrapper =
+ getRepositoryClient(ctx).getDoc(ctx, csid);
+ RemoteDocumentModelHandlerImpl handler
+ = (RemoteDocumentModelHandlerImpl)createDocumentHandler(ctx);
+ List<String> authRefFields = ((MultipartServiceContextImpl)ctx).getCommonPartPropertyValues(RefNameServiceUtils.AUTH_REF_PROP);
+ authRefList = handler.getAuthorityRefs(docWrapper, authRefFields);
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in getAuthorityRefs", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return authRefList;
+ }
+
+ /**
+ * Gets the loanin list.
+ *
+ * @param csidList the csid list
+ *
+ * @return the loanin list
+ */
+ public LoansinCommonList getLoaninList(List<String> csidList) {
+ LoansinCommonList loaninObjectList = new LoansinCommonList();
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).get(ctx, csidList, handler);
+ loaninObjectList = (LoansinCommonList) handler.getCommonPartList();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in getLoaninList", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return loaninObjectList;
+ }
+
+ /**
+ * Update loanin.
+ *
+ * @param csid the csid
+ * @param theUpdate the the update
+ *
+ * @return the multipart output
+ */
+ @PUT
+ @Path("{csid}")
+ public MultipartOutput updateLoanin(
+ @PathParam("csid") String csid,
+ MultipartInput theUpdate) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateLoanin with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("updateLoanin: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "update failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ MultipartOutput result = null;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+ getRepositoryClient(ctx).update(ctx, csid, handler);
+ result = (MultipartOutput) ctx.getOutput();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caught exception in updateLoanin", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Update failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return result;
+ }
+
+ /**
+ * Delete loanin.
+ *
+ * @param csid the csid
+ *
+ * @return the response
+ */
+ @DELETE
+ @Path("{csid}")
+ public Response deleteLoanin(@PathParam("csid") String csid) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteLoanin with csid=" + csid);
+ }
+ if (csid == null || "".equals(csid)) {
+ logger.error("deleteLoanin: missing csid!");
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(
+ "delete failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ getRepositoryClient(ctx).delete(ctx, csid);
+ return Response.status(HttpResponseCodes.SC_OK).build();
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (DocumentNotFoundException dnfe) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("caught exception in deleteLoanin", dnfe);
+ }
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Delete failed on Loanin csid=" + csid).type(
+ "text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ }
+
+ /**
+ * Keywords search loansin.
+ *
+ * @param ui the ui
+ * @param keywords the keywords
+ *
+ * @return the loansin common list
+ */
+ @GET
+ @Path("/search")
+ @Produces("application/xml")
+ public LoansinCommonList keywordsSearchLoansin(@Context UriInfo ui,
+ @QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) {
+ return searchLoansin(keywords);
+ }
+
+ /**
+ * Search loansin.
+ *
+ * @param keywords the keywords
+ *
+ * @return the loansin common list
+ */
+ private LoansinCommonList searchLoansin(String keywords) {
+ LoansinCommonList loansinObjectList;
+ try {
+ ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName());
+ DocumentHandler handler = createDocumentHandler(ctx);
+
+ // perform a keyword search
+ if (keywords != null && !keywords.isEmpty()) {
+ String whereClause = QueryManager.createWhereClauseFromKeywords(keywords);
+ DocumentFilter documentFilter = handler.getDocumentFilter();
+ documentFilter.setWhereClause(whereClause);
+ if (logger.isDebugEnabled()) {
+ logger.debug("The WHERE clause is: " + documentFilter.getWhereClause());
+ }
+ getRepositoryClient(ctx).getFiltered(ctx, handler);
+ } else {
+ getRepositoryClient(ctx).getAll(ctx, handler);
+ }
+ loansinObjectList = (LoansinCommonList) handler.getCommonPartList();
+
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in search for Loansin", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ return loansinObjectList;
+ }
+
+}
--- /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.loanin.nuxeo;
+
+/**
+ * LoaninConstants specifies constants for the Loans In service
+ *
+ */
+public class LoaninConstants {
+
+ public final static String NUXEO_DOCTYPE = "Loanin";
+ public final static String NUXEO_SCHEMA_NAME = "loanin";
+ public final static String NUXEO_DC_TITLE = "CollectionSpace-Loanin";
+}
--- /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.loanin.nuxeo;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.collectionspace.services.LoaninJAXBSchema;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.loanin.LoansinCommon;
+import org.collectionspace.services.loanin.LoansinCommonList;
+import org.collectionspace.services.loanin.LoansinCommonList.LoaninListItem;
+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;
+
+/**
+ * LoaninDocumentModelHandler
+ *
+ * $LastChangedRevision: $
+ * $LastChangedDate: $
+ */
+public class LoaninDocumentModelHandler
+ extends RemoteDocumentModelHandlerImpl<LoansinCommon, LoansinCommonList> {
+
+ private final Logger logger = LoggerFactory.getLogger(LoaninDocumentModelHandler.class);
+ /**
+ * loanin is used to stash JAXB object to use when handle is called
+ * for Action.CREATE, Action.UPDATE or Action.GET
+ */
+ private LoansinCommon loanin;
+ /**
+ * loaninList is stashed when handle is called
+ * for ACTION.GET_ALL
+ */
+ private LoansinCommonList loaninList;
+
+
+ /**
+ * getCommonPart get associated loanin
+ * @return
+ */
+ @Override
+ public LoansinCommon getCommonPart() {
+ return loanin;
+ }
+
+ /**
+ * setCommonPart set associated loanin
+ * @param loanin
+ */
+ @Override
+ public void setCommonPart(LoansinCommon loanin) {
+ this.loanin = loanin;
+ }
+
+ /**
+ * getCommonPartList get associated loanin (for index/GET_ALL)
+ * @return
+ */
+ @Override
+ public LoansinCommonList getCommonPartList() {
+ return loaninList;
+ }
+
+ @Override
+ public void setCommonPartList(LoansinCommonList loaninList) {
+ this.loaninList = loaninList;
+ }
+
+ @Override
+ public LoansinCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
+ throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void fillCommonPart(LoansinCommon loaninObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public LoansinCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+ DocumentModelList docList = wrapDoc.getWrappedObject();
+
+ LoansinCommonList coList = new LoansinCommonList();
+ List<LoansinCommonList.LoaninListItem> list = coList.getLoaninListItem();
+
+ //FIXME: iterating over a long list of documents is not a long term
+ //strategy...need to change to more efficient iterating in future
+ Iterator<DocumentModel> iter = docList.iterator();
+ while(iter.hasNext()){
+ DocumentModel docModel = iter.next();
+ LoaninListItem ilistItem = new LoaninListItem();
+ ilistItem.setLoanInNumber((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+ LoaninJAXBSchema.LOAN_IN_NUMBER));
+ ilistItem.setLoanReturnDate((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
+ LoaninJAXBSchema.LOAN_RETURN_DATE));
+ String id = NuxeoUtils.extractId(docModel.getPathAsString());
+ ilistItem.setUri(getServiceContextPath() + id);
+ ilistItem.setCsid(id);
+ list.add(ilistItem);
+ }
+
+ return coList;
+ }
+
+ /**
+ * getQProperty converts the given property to qualified schema property
+ * @param prop
+ * @return
+ */
+ @Override
+ public String getQProperty(String prop) {
+ return LoaninConstants.NUXEO_SCHEMA_NAME + ":" + prop;
+ }
+
+}
+
--- /dev/null
+package org.collectionspace.services.loanin.nuxeo;
+
+import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.InvalidDocumentException;
+import org.collectionspace.services.common.document.ValidatorHandler;
+import org.collectionspace.services.common.document.DocumentHandler.Action;
+
+public class LoaninValidatorHandler implements ValidatorHandler {
+
+ @Override
+ public void validate(Action action, ServiceContext ctx)
+ throws InvalidDocumentException {
+ // TODO Auto-generated method stub
+ System.out.println("LoaninValidatorHandler executed.");
+
+ }
+
+}
--- /dev/null
+package org.collectionspace.services.test;
+
+//import org.collectionspace.services.loanin.Loanin;
+//import org.collectionspace.services.loanin.LoaninList;
+
+/**
+ * Placeholder for server-side testing of Loan In service code.
+ *
+ * @version $Revision:$
+ */
+public class LoaninServiceTest {
+ //empty
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.TTCCLayout">
+ <param name="DateFormat" value="ISO8601" />
+ </layout>
+ </appender>
+
+
+ <appender name="unit-tests"
+ class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="./target/unit-tests.log" />
+ <param name="MaxFileSize" value="10240KB" />
+ <param name="MaxBackupIndex" value="6" />
+ <layout class="org.apache.log4j.TTCCLayout">
+ <param name="DateFormat" value="ISO8601" />
+ </layout>
+ </appender>
+
+ <logger name="org.apache.commons.httpclient" additivity="false">
+ <level value="warn" />
+ <appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
+ </logger>
+
+ <logger name="httpclient.wire" additivity="false">
+ <level value="info" />
+ <appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
+ </logger>
+
+ <root>
+ <priority value="debug" />
+ <appender-ref ref="console" />
+ <appender-ref ref="unit-tests" />
+ </root>
+
+</log4j:configuration>
+
+
+
+
<module>id</module>
<module>collectionobject</module>
<module>intake</module>
+ <module>loanin</module>
<module>dimension</module>
<module>contact</module>
<module>JaxRsServiceProvider</module>
</dependency>
</dependencies>
</dependencyManagement>
-</project>
\ No newline at end of file
+</project>