2 * AbstractMultiPartCollectionSpaceResourceImpl.java
\r
4 * {Purpose of This Class}
\r
6 * {Other Notes Relating to This Class (Optional)}
\r
9 * $LastChangedRevision: $
\r
10 * $LastChangedDate: $
\r
12 * This document is a part of the source code and related artifacts
\r
13 * for CollectionSpace, an open source collections management system
\r
14 * for museums and related institutions:
\r
16 * http://www.collectionspace.org
\r
17 * http://wiki.collectionspace.org
\r
19 * Copyright © 2009 {Contributing Institution}
\r
21 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
22 * You may not use this file except in compliance with this License.
\r
24 * You may obtain a copy of the ECL 2.0 License at
\r
25 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
27 package org.collectionspace.services.common;
\r
29 import org.collectionspace.services.client.PayloadInputPart;
\r
30 import org.collectionspace.services.client.PoxPayloadIn;
\r
31 import org.collectionspace.services.client.PoxPayloadOut;
\r
32 import org.collectionspace.services.common.context.MultipartServiceContext;
\r
33 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
\r
34 import org.collectionspace.services.common.context.ServiceContext;
\r
35 import org.collectionspace.services.common.context.ServiceContextFactory;
\r
36 import org.collectionspace.services.common.document.DocumentHandler;
\r
38 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
\r
39 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
\r
40 import org.slf4j.Logger;
\r
41 import org.slf4j.LoggerFactory;
\r
44 * The Class AbstractMultiPartCollectionSpaceResourceImpl.
\r
46 public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends
\r
47 AbstractCollectionSpaceResourceImpl<PoxPayloadIn, PoxPayloadOut> {
\r
49 protected final Logger logger = LoggerFactory.getLogger(this.getClass());
\r
52 public ServiceContextFactory<PoxPayloadIn, PoxPayloadOut> getServiceContextFactory() {
\r
53 return MultipartServiceContextFactory.get();
\r
57 public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {
\r
58 return createDocumentHandler(ctx, ctx.getCommonPartLabel(), getCommonPartClass());
\r
62 * Creates the document handler.
\r
64 * @param serviceContext the service context
\r
65 * @param schemaName the schema name
\r
66 * @param commonClass the common class
\r
68 * @return the document handler
\r
70 * @throws Exception the exception
\r
72 public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> serviceContext,
\r
74 Class<?> commonClass) throws Exception {
\r
75 DocumentHandler result = null;
\r
77 MultipartServiceContext ctx = (MultipartServiceContext)serviceContext;
\r
78 Object commonPart = null;
\r
79 if (ctx.getInput() != null) {
\r
80 commonPart = ctx.getInputPart(schemaName);
\r
82 result = super.createDocumentHandler(ctx, commonPart);
\r
88 * Creates the document handler.
\r
90 * @param ctx the ctx
\r
91 * @param commonClass the common class
\r
93 * @return the document handler
\r
95 * @throws Exception the exception
\r
97 public DocumentHandler createDocumentHandler(
\r
98 ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
\r
99 Class<Object> commonClass) throws Exception {
\r
100 return createDocumentHandler(ctx, ctx.getCommonPartLabel(), commonClass);
\r