]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
af2955e876b321846c085c20501a19239c0f5ca9
[tmp/jakarta-migration.git] /
1 /**     
2  * LocationAuthorityClient.java
3  *
4  * {Purpose of This Class}
5  *
6  * {Other Notes Relating to This Class (Optional)}
7  *
8  * $LastChangedBy: $
9  * $LastChangedRevision: $
10  * $LastChangedDate: $
11  *
12  * This document is a part of the source code and related artifacts
13  * for CollectionSpace, an open source collections management system
14  * for museums and related institutions:
15  *
16  * http://www.collectionspace.org
17  * http://wiki.collectionspace.org
18  *
19  * Copyright © 2009 {Contributing Institution}
20  *
21  * Licensed under the Educational Community License (ECL), Version 2.0.
22  * You may not use this file except in compliance with this License.
23  *
24  * You may obtain a copy of the ECL 2.0 License at
25  * https://source.collectionspace.org/collection-space/LICENSE.txt
26  */
27 package org.collectionspace.services.client;
28
29 import javax.ws.rs.PathParam;
30 import javax.ws.rs.core.Response;
31
32 //import org.collectionspace.services.common.authorityref.AuthorityRefList;
33 import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
34 import org.collectionspace.services.contact.ContactsCommonList;
35 import org.collectionspace.services.location.LocationauthoritiesCommonList;
36 import org.collectionspace.services.location.LocationsCommonList;
37 import org.collectionspace.services.client.LocationAuthorityProxy;
38
39 import org.jboss.resteasy.client.ClientResponse;
40 import org.jboss.resteasy.client.ProxyFactory;
41 import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
42 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
43 import org.jboss.resteasy.spi.ResteasyProviderFactory;
44
45 /**
46  * The Class LocationAuthorityClient.
47  */
48 public class LocationAuthorityClient extends AbstractServiceClientImpl {  //FIXME: REM - Client classes for Person, Org, Vocab, and Location should have a common base class
49         public static final String SERVICE_NAME = "locationauthorities";
50         public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
51         public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
52         public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
53         //
54         // Subitem constants
55         //
56         public static final String SERVICE_ITEM_NAME = "locations";
57         public static final String SERVICE_PATH_ITEMS_COMPONENT = "items";      //FIXME: REM - This should be defined in an AuthorityClient base class
58         public static final String SERVICE_ITEM_PAYLOAD_NAME = SERVICE_ITEM_NAME;
59         //
60         // Payload Part/Schema part names
61         //
62         public static final String SERVICE_COMMON_PART_NAME = SERVICE_NAME + 
63                 PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
64         public static final String SERVICE_ITEM_COMMON_PART_NAME = SERVICE_ITEM_NAME + 
65                 PART_LABEL_SEPARATOR + PART_COMMON_LABEL;
66         
67         @Override
68         public String getServiceName() {
69                 return SERVICE_NAME;
70         }
71
72     @Override
73     public String getServicePathComponent() {
74         return SERVICE_PATH_COMPONENT;
75     }
76
77     public String getItemCommonPartName() {
78         return getCommonPartName(SERVICE_ITEM_NAME);
79     }
80     
81     /**
82      *
83      */
84     private LocationAuthorityProxy locationAuthorityProxy;
85
86     /**
87      * Instantiates a new location authority client.
88      */
89     public LocationAuthorityClient() {
90         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
91         RegisterBuiltin.register(factory);
92         setProxy();
93     }
94
95     /* (non-Javadoc)
96      * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
97      */
98     @Override
99     public CollectionSpaceProxy getProxy() {
100         return this.locationAuthorityProxy;
101     }    
102
103     /**
104      * Sets the proxy.
105      */
106     public void setProxy() {
107         if (useAuth()) {
108             locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
109                     getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
110         } else {
111             locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
112                     getBaseURL());
113         }
114     }
115
116     /**
117      * Read list.
118      *
119      * @return the client response
120      */
121
122     /**
123      * @return list
124      * @see org.collectionspace.services.client.LocationAuthorityProxy#readList()
125      */
126     public ClientResponse<LocationauthoritiesCommonList> readList() {
127         return locationAuthorityProxy.readList();
128     }
129
130     /**
131      * Read.
132      *
133      * @param csid the csid
134      * @return the client response
135      */
136     public ClientResponse<String> read(String csid) {
137         return locationAuthorityProxy.read(csid);
138     }
139
140     /**
141      * Read by name.
142      *
143      * @param name the name
144      * @return the client response
145      */
146     public ClientResponse<String> readByName(String name) {
147         return locationAuthorityProxy.readByName(name);
148     }
149
150     /**
151      * Creates the.
152      *
153      * @param multipart the multipart
154      * @return the client response
155      */
156     public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {
157         return locationAuthorityProxy.create(xmlPayload.getBytes());
158     }
159
160     /**
161      * Update.
162      *
163      * @param csid the csid
164      * @param multipart the multipart
165      * @return the client response
166      */
167     public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload) {
168         return locationAuthorityProxy.update(csid, xmlPayload.getBytes());
169
170     }
171
172     /**
173      * Delete.
174      *
175      * @param csid the csid
176      * @return the client response
177      */
178     public ClientResponse<Response> delete(String csid) {
179         return locationAuthorityProxy.delete(csid);
180     }
181
182     /**
183      * Read item list, filtering by partial term match, or keywords. Only one of
184      * partialTerm or keywords should be specified. If both are specified, keywords
185      * will be ignored.
186      *
187      * @param inAuthority the parent authority
188      * @param partialTerm A partial term on which to match,
189      *     which will filter list results to return only matched resources.
190      * @param keywords A set of keywords on which to match,
191      *     which will filter list results to return only matched resources.
192      * @return the client response
193      */
194     public ClientResponse<LocationsCommonList> 
195                 readItemList(String inAuthority, String partialTerm, String keywords) {
196         return locationAuthorityProxy.readItemList(inAuthority, partialTerm, keywords);
197     }
198
199     /**
200      * Gets the referencing objects.
201      *
202      * @param parentcsid the parentcsid
203      * @param csid the csid
204      * @return the referencing objects
205      */
206     public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
207         return locationAuthorityProxy.getReferencingObjects(parentcsid, csid);
208     }
209
210     /**
211      * Read item list for named vocabulary, filtering by partial term match, or keywords. Only one of
212      * partialTerm or keywords should be specified. If both are specified, keywords
213      * will be ignored.
214      *
215      * @param specifier the specifier
216      * @param partialTerm A partial term on which to match,
217      *     which will filter list results to return only matched resources.
218      * @param keywords A set of keywords on which to match,
219      *     which will filter list results to return only matched resources.
220      * @return the client response
221      */
222     public ClientResponse<LocationsCommonList> 
223                 readItemListForNamedAuthority(String specifier, String partialTerm, String keywords) {
224         return locationAuthorityProxy.readItemListForNamedAuthority(specifier, partialTerm, keywords);
225     }
226
227     /**
228      * Read item.
229      *
230      * @param vcsid the vcsid
231      * @param csid the csid
232      * @return the client response
233      */
234     public ClientResponse<String> readItem(String vcsid, String csid) {
235         return locationAuthorityProxy.readItem(vcsid, csid);
236     }
237
238     /**
239      * Creates the item.
240      *
241      * @param vcsid the vcsid
242      * @param multipart the multipart
243      * @return the client response
244      */
245     public ClientResponse<Response> createItem(String vcsid, PoxPayloadOut xmlPayload) {
246         return locationAuthorityProxy.createItem(vcsid, xmlPayload.getBytes());
247     }
248
249     /**
250      * Update item.
251      *
252      * @param vcsid the vcsid
253      * @param csid the csid
254      * @param multipart the multipart
255      * @return the client response
256      */
257     public ClientResponse<String> updateItem(String vcsid, String csid, PoxPayloadOut xmlPayload) {
258         return locationAuthorityProxy.updateItem(vcsid, csid, xmlPayload.getBytes());
259
260     }
261
262     /**
263      * Delete item.
264      *
265      * @param vcsid the vcsid
266      * @param csid the csid
267      * @return the client response
268      */
269     public ClientResponse<Response> deleteItem(String vcsid, String csid) {
270         return locationAuthorityProxy.deleteItem(vcsid, csid);
271     }
272
273     /**
274      * Creates the contact.
275      *
276      * @param parentcsid the parentcsid
277      * @param itemcsid the itemcsid
278      * @param multipart the multipart
279      * @return the client response
280      */
281     public ClientResponse<Response> createContact(String parentcsid,
282             String itemcsid, PoxPayloadOut xmlPayload) {
283         return locationAuthorityProxy.createContact(parentcsid, itemcsid, xmlPayload.getBytes());
284     }
285
286     /**
287      * Read contact.
288      *
289      * @param parentcsid the parentcsid
290      * @param itemcsid the itemcsid
291      * @param csid the csid
292      * @return the client response
293      */
294     public ClientResponse<String> readContact(String parentcsid,
295             String itemcsid, String csid) {
296         return locationAuthorityProxy.readContact(parentcsid, itemcsid, csid);
297     }
298
299     /**
300      * Read contact list.
301      *
302      * @param parentcsid the parentcsid
303      * @param itemcsid the itemcsid
304      * @return the client response
305      */
306     public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
307             String itemcsid) {
308         return locationAuthorityProxy.readContactList(parentcsid, itemcsid);
309     }
310
311     /**
312      * Update contact.
313      *
314      * @param parentcsid the parentcsid
315      * @param itemcsid the itemcsid
316      * @param csid the csid
317      * @param multipart the multipart
318      * @return the client response
319      */
320     public ClientResponse<String> updateContact(String parentcsid,
321             String itemcsid, String csid, PoxPayloadOut xmlPayload) {
322         return locationAuthorityProxy.updateContact(parentcsid, itemcsid, csid, xmlPayload.getBytes());
323     }
324
325     /**
326      * Delete contact.
327      *
328      * @param parentcsid the parentcsid
329      * @param itemcsid the itemcsid
330      * @param csid the csid
331      * @return the client response
332      */
333     public ClientResponse<Response> deleteContact(String parentcsid,
334         String itemcsid, String csid) {
335         return locationAuthorityProxy.deleteContact(parentcsid,
336             itemcsid, csid);
337     }
338 }