]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
4e5b1d4f28270a735e5ca76b1e1161b8c0dd926c
[tmp/jakarta-migration.git] /
1 /**     \r
2  * AbstractMultiPartCollectionSpaceResourceImpl.java\r
3  *\r
4  * {Purpose of This Class}\r
5  *\r
6  * {Other Notes Relating to This Class (Optional)}\r
7  *\r
8  * $LastChangedBy: $\r
9  * $LastChangedRevision: $\r
10  * $LastChangedDate: $\r
11  *\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
15  *\r
16  * http://www.collectionspace.org\r
17  * http://wiki.collectionspace.org\r
18  *\r
19  * Copyright © 2009 {Contributing Institution}\r
20  *\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
23  *\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
26  */\r
27 package org.collectionspace.services.common;\r
28 \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
34 \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
39 \r
40 /**\r
41  * The Class AbstractMultiPartCollectionSpaceResourceImpl.\r
42  */\r
43 public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends\r
44                 AbstractCollectionSpaceResourceImpl<MultipartInput, MultipartOutput> {\r
45 \r
46     protected final Logger logger = LoggerFactory.getLogger(this.getClass());\r
47 \r
48     @Override\r
49     public ServiceContextFactory<MultipartInput, MultipartOutput> getServiceContextFactory() {\r
50         return MultipartServiceContextFactory.get();\r
51     }\r
52 \r
53     @Override\r
54     public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {\r
55         return createDocumentHandler(ctx, ctx.getCommonPartLabel(),getCommonPartClass());\r
56     }\r
57     \r
58     /**\r
59      * Creates the document handler.\r
60      * \r
61      * @param serviceContext the service context\r
62      * @param schemaName the schema name\r
63      * @param commonClass the common class\r
64      * \r
65      * @return the document handler\r
66      * \r
67      * @throws Exception the exception\r
68      */\r
69     public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> serviceContext,\r
70                 String schemaName, \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
76         }\r
77         return super.createDocumentHandler(ctx, commonPart);\r
78     }\r
79     \r
80     /**\r
81      * Creates the document handler.\r
82      * \r
83      * @param ctx the ctx\r
84      * @param commonClass the common class\r
85      * \r
86      * @return the document handler\r
87      * \r
88      * @throws Exception the exception\r
89      */\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
94     }\r
95     \r
96 }\r