]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
f8c8a02ef0ded1d899ca865ce831ecd59018f484
[tmp/jakarta-migration.git] /
1 /**\r
2  *  This document is a part of the source code and related artifacts\r
3  *  for CollectionSpace, an open source collections management system\r
4  *  for museums and related institutions:\r
5 \r
6  *  http://www.collectionspace.org\r
7  *  http://wiki.collectionspace.org\r
8 \r
9  *  Copyright 2009 University of California at Berkeley\r
10 \r
11  *  Licensed under the Educational Community License (ECL), Version 2.0.\r
12  *  You may not use this file except in compliance with this License.\r
13 \r
14  *  You may obtain a copy of the ECL 2.0 License at\r
15 \r
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt\r
17 \r
18  *  Unless required by applicable law or agreed to in writing, software\r
19  *  distributed under the License is distributed on an "AS IS" BASIS,\r
20  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
21  *  See the License for the specific language governing permissions and\r
22  *  limitations under the License.\r
23  */\r
24 package org.collectionspace.services.vocabulary;\r
25 \r
26 import javax.ws.rs.Consumes;\r
27 import javax.ws.rs.GET;\r
28 import javax.ws.rs.Path;\r
29 import javax.ws.rs.Produces;\r
30 import javax.ws.rs.DELETE;\r
31 import javax.ws.rs.POST;\r
32 import javax.ws.rs.PUT;\r
33 import javax.ws.rs.PathParam;\r
34 import javax.ws.rs.WebApplicationException;\r
35 import javax.ws.rs.core.Context;\r
36 import javax.ws.rs.core.Response;\r
37 import javax.ws.rs.core.UriBuilder;\r
38 import javax.ws.rs.core.UriInfo;\r
39 import javax.xml.bind.JAXBContext;\r
40 import javax.xml.bind.Marshaller;\r
41 \r
42 import org.collectionspace.services.common.vocabulary.VocabManager;\r
43 import org.slf4j.Logger;\r
44 import org.slf4j.LoggerFactory;\r
45 \r
46 @Path("/vocab")\r
47 @Consumes("application/xml")\r
48 @Produces("application/xml")\r
49 public class VocabResource {\r
50 \r
51     public final static String SERVICE_NAME = "vocab";\r
52     final Logger logger = LoggerFactory.getLogger(VocabResource.class);\r
53 \r
54     public VocabResource() {\r
55         // do nothing\r
56     }\r
57 \r
58     @GET\r
59     @Path("{csid}")\r
60     public void getVocab(\r
61             @PathParam("csid") String csid) {\r
62         if(logger.isDebugEnabled()){\r
63             verbose("getVocab with csid=" + csid);\r
64         }\r
65         if(csid == null || "".equals(csid)){\r
66             logger.error("getVocab: missing csid!");\r
67             Response response = Response.status(Response.Status.BAD_REQUEST).entity(\r
68                     "get failed on getVocab csid=" + csid).type(\r
69                     "text/plain").build();\r
70             throw new WebApplicationException(response);\r
71         }\r
72 \r
73         try {\r
74                 //\r
75                 // An example call to the Vocabulary manager\r
76                 //\r
77                 VocabManager.exampleMethod("someParam");\r
78         } catch(Exception e){\r
79             if(logger.isDebugEnabled()){\r
80                 logger.debug("getVocab", e);\r
81             }\r
82             Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
83                     "Get failed on vocab csid=" + csid).type(\r
84                     "text/plain").build();\r
85             throw new WebApplicationException(response);\r
86         }\r
87 \r
88         // an example of how to send a failed message\r
89         if(false){\r
90             Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
91                     "Get failed, the requested CSID:" + csid + ": was not found.").type(\r
92                     "text/plain").build();\r
93             throw new WebApplicationException(response);\r
94         }\r
95     }\r
96 \r
97     private void verbose(String msg) {\r
98         System.out.println("VocabResource. " + msg);\r
99     }\r
100 }\r