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.common.context.MultipartServiceContext;
\r
30 import org.collectionspace.services.common.context.MultipartServiceContextFactory;
\r
31 import org.collectionspace.services.common.context.ServiceContext;
\r
32 import org.collectionspace.services.common.context.ServiceContextFactory;
\r
33 import org.collectionspace.services.common.document.DocumentHandler;
\r
35 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
\r
36 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
\r
37 import org.slf4j.Logger;
\r
38 import org.slf4j.LoggerFactory;
\r
41 * The Class AbstractMultiPartCollectionSpaceResourceImpl.
\r
43 public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends
\r
44 AbstractCollectionSpaceResourceImpl<MultipartInput, MultipartOutput> {
\r
46 protected final Logger logger = LoggerFactory.getLogger(this.getClass());
\r
49 public ServiceContextFactory<MultipartInput, MultipartOutput> getServiceContextFactory() {
\r
50 return MultipartServiceContextFactory.get();
\r
54 public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {
\r
55 return createDocumentHandler(ctx, ctx.getCommonPartLabel(),getCommonPartClass());
\r
59 * Creates the document handler.
\r
61 * @param serviceContext the service context
\r
62 * @param schemaName the schema name
\r
63 * @param commonClass the common class
\r
65 * @return the document handler
\r
67 * @throws Exception the exception
\r
69 public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> serviceContext,
\r
71 Class<?> commonClass) throws Exception {
\r
72 MultipartServiceContext ctx = (MultipartServiceContext)serviceContext;
\r
73 Object commonPart = null;
\r
74 if (ctx.getInput() != null) {
\r
75 commonPart = ctx.getInputPart(schemaName, commonClass);
\r
77 return super.createDocumentHandler(ctx, commonPart);
\r
81 * Creates the document handler.
\r
83 * @param ctx the ctx
\r
84 * @param commonClass the common class
\r
86 * @return the document handler
\r
88 * @throws Exception the exception
\r
90 public DocumentHandler createDocumentHandler(
\r
91 ServiceContext<MultipartInput, MultipartOutput> ctx,
\r
92 Class<Object> commonClass) throws Exception {
\r
93 return createDocumentHandler(ctx, ctx.getCommonPartLabel(), commonClass);
\r