]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
8c1acf1f427e1c88713a443ec8dba4c5074b1791
[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 \r
38 /**\r
39  * The Class AbstractMultiPartCollectionSpaceResourceImpl.\r
40  */\r
41 public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends\r
42                 AbstractCollectionSpaceResourceImpl<MultipartInput, MultipartOutput> {\r
43 \r
44     @Override\r
45     public ServiceContextFactory<MultipartInput, MultipartOutput> getServiceContextFactory() {\r
46         return (ServiceContextFactory<MultipartInput, MultipartOutput>)MultipartServiceContextFactory.get();\r
47     }\r
48 \r
49     @Override\r
50     public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {\r
51         DocumentHandler docHandler = createDocumentHandler(ctx, ctx.getCommonPartLabel(),\r
52                         getCommonPartClass());\r
53         return docHandler;\r
54     }\r
55     \r
56     /**\r
57      * Creates the document handler.\r
58      * \r
59      * @param serviceContext the service context\r
60      * @param schemaName the schema name\r
61      * @param commonClass the common class\r
62      * \r
63      * @return the document handler\r
64      * \r
65      * @throws Exception the exception\r
66      */\r
67     public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> serviceContext,\r
68                 String schemaName, \r
69                 Class<?> commonClass) throws Exception {\r
70         MultipartServiceContext ctx = (MultipartServiceContext)serviceContext;\r
71         Object commonPart = null;\r
72         if (ctx.getInput() != null) {\r
73                 commonPart = ctx.getInputPart(schemaName, commonClass);\r
74         }\r
75         DocumentHandler docHandler = super.createDocumentHandler(ctx, commonPart);\r
76         \r
77         return docHandler;\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