]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a557ba7578931cadd4d29e5388687295d5cd18ec
[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.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
37 \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
42 \r
43 /**\r
44  * The Class AbstractMultiPartCollectionSpaceResourceImpl.\r
45  */\r
46 public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends\r
47                 AbstractCollectionSpaceResourceImpl<PoxPayloadIn, PoxPayloadOut> {\r
48 \r
49     protected final Logger logger = LoggerFactory.getLogger(this.getClass());\r
50 \r
51     @Override\r
52     public ServiceContextFactory<PoxPayloadIn, PoxPayloadOut> getServiceContextFactory() {\r
53         return MultipartServiceContextFactory.get();\r
54     }\r
55 \r
56     @Override\r
57     public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {\r
58         return createDocumentHandler(ctx, ctx.getCommonPartLabel(), getCommonPartClass());\r
59     }\r
60     \r
61     /**\r
62      * Creates the document handler.\r
63      * \r
64      * @param serviceContext the service context\r
65      * @param schemaName the schema name\r
66      * @param commonClass the common class\r
67      * \r
68      * @return the document handler\r
69      * \r
70      * @throws Exception the exception\r
71      */\r
72     public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> serviceContext,\r
73                 String schemaName, \r
74                 Class<?> commonClass) throws Exception {\r
75         DocumentHandler result = null;\r
76         \r
77         MultipartServiceContext ctx = (MultipartServiceContext)serviceContext;\r
78         Object commonPart = null;\r
79         if (ctx.getInput() != null) {\r
80                 commonPart = ctx.getInputPart(schemaName);\r
81         }\r
82         result = super.createDocumentHandler(ctx, commonPart);\r
83         \r
84         return result;\r
85     }\r
86     \r
87     /**\r
88      * Creates the document handler.\r
89      * \r
90      * @param ctx the ctx\r
91      * @param commonClass the common class\r
92      * \r
93      * @return the document handler\r
94      * \r
95      * @throws Exception the exception\r
96      */\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
101     }\r
102     \r
103 }\r