]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
e2fe04e30af1d9f53faaea85a76f0f8159af43ca
[tmp/jakarta-migration.git] /
1 /**     
2  * OrgAuthorityClient.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.AuthorityRefDocList;
33 import org.collectionspace.services.common.authorityref.AuthorityRefList;
34 import org.collectionspace.services.contact.ContactsCommonList;
35 import org.collectionspace.services.organization.OrgauthoritiesCommonList;
36 import org.collectionspace.services.organization.OrganizationsCommonList;
37
38 import org.jboss.resteasy.client.ClientResponse;
39 import org.jboss.resteasy.client.ProxyFactory;
40 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
41 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
42 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
43 import org.jboss.resteasy.spi.ResteasyProviderFactory;
44
45 /**
46  * The Class OrgAuthorityClient.
47  */
48 public class OrgAuthorityClient extends AbstractServiceClientImpl {
49
50     /* (non-Javadoc)
51      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
52      */
53     @Override
54     public String getServicePathComponent() {
55         return "orgauthorities";
56     }
57
58     /**
59      * Gets the item common part name.
60      *
61      * @return the item common part name
62      */
63     public String getItemCommonPartName() {
64         return getCommonPartName("organizations");
65     }
66     
67     /** The Constant instance. */  //FIXME: This is wrong.  There should NOT be a static instance of the OrgAuthorityClient class
68 //    private static final OrgAuthorityClient instance = new OrgAuthorityClient();
69     
70     /** The org authority proxy. */
71     private OrgAuthorityProxy orgAuthorityProxy;
72
73     /**
74      * Instantiates a new org authority client.
75      */
76     public OrgAuthorityClient() {
77         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
78         RegisterBuiltin.register(factory);
79         setProxy();
80     }
81
82     /* (non-Javadoc)
83      * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
84      */
85     @Override
86     public CollectionSpaceProxy getProxy() {
87         return this.orgAuthorityProxy;
88     }    
89
90     /**
91      * Sets the proxy.
92      */
93     public void setProxy() {
94         if (useAuth()) {
95             orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
96                     getBaseURL(), getHttpClient());
97         } else {
98             orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
99                     getBaseURL());
100         }
101     }
102
103     /**
104      * Gets the single instance of OrgAuthorityClient.
105      *
106      * @return single instance of OrgAuthorityClient //FIXME: This is wrong.  There should NOT be a static instance of the client
107      */
108 //    public static OrgAuthorityClient getInstance() {
109 //        return instance;
110 //    }
111
112     /**
113      * Read list.
114      *
115      * @return the client response
116      */
117     public ClientResponse<OrgauthoritiesCommonList> readList() {
118         return orgAuthorityProxy.readList();
119     }
120
121     /**
122      * Read.
123      *
124      * @param csid the csid
125      * @return the client response
126      */
127     public ClientResponse<MultipartInput> read(String csid) {
128         return orgAuthorityProxy.read(csid);
129     }
130
131     /**
132      * Read by name.
133      *
134      * @param name the name
135      * @return the client response
136      */
137     public ClientResponse<MultipartInput> readByName(String name) {
138         return orgAuthorityProxy.readByName(name);
139     }
140
141     /**
142      * Creates the.
143      *
144      * @param multipart the multipart
145      * @return the client response
146      */
147     public ClientResponse<Response> create(MultipartOutput multipart) {
148         return orgAuthorityProxy.create(multipart);
149     }
150
151     /**
152      * Update.
153      *
154      * @param csid the csid
155      * @param multipart the multipart
156      * @return the client response
157      */
158     public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
159         return orgAuthorityProxy.update(csid, multipart);
160
161     }
162
163     /**
164      * Delete.
165      *
166      * @param csid the csid
167      * @return the client response
168      */
169     @Override
170     public ClientResponse<Response> delete(String csid) {
171         return orgAuthorityProxy.delete(csid);
172     }
173
174     /**
175      * Read item list, filtering by partial term match, or keywords. Only one of
176      * partialTerm or keywords should be specified. If both are specified, keywords
177      * will be ignored.
178      *
179      * @param inAuthority the parent authority
180      * @param partialTerm A partial term on which to match,
181      *     which will filter list results to return only matched resources.
182      * @param keywords A set of keywords on which to match,
183      *     which will filter list results to return only matched resources.
184      * @return the client response
185      */
186     public ClientResponse<OrganizationsCommonList> 
187                 readItemList(String inAuthority, String partialTerm, String keywords) {
188         return orgAuthorityProxy.readItemList(inAuthority, partialTerm, keywords);
189     }
190     
191     /**
192      * Gets the referencing objects.
193      *
194      * @param parentcsid the parentcsid
195      * @param csid the csid
196      * @return the referencing objects
197      */
198     public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
199         return orgAuthorityProxy.getReferencingObjects(parentcsid, csid);
200     }
201     
202
203     /**
204      * Read item list for named vocabulary, filtering by partial term match, or keywords. Only one of
205      * partialTerm or keywords should be specified. If both are specified, keywords
206      * will be ignored.
207      *
208      * @param specifier the specifier
209      * @param partialTerm A partial term on which to match,
210      *     which will filter list results to return only matched resources.
211      * @param keywords A set of keywords on which to match,
212      *     which will filter list results to return only matched resources.
213      * @return the client response
214      */
215     public ClientResponse<OrganizationsCommonList> 
216                 readItemListForNamedAuthority(String specifier, String partialTerm, String keywords) {
217         return orgAuthorityProxy.readItemListForNamedAuthority(specifier, partialTerm, keywords);
218     }
219
220     /**
221      * Gets the item authority refs.
222      *
223      * @param parentcsid the parentcsid
224      * @param csid the csid
225      * @return the item authority refs
226      */
227     public ClientResponse<AuthorityRefList> getItemAuthorityRefs(String parentcsid, String csid) {
228         return orgAuthorityProxy.getItemAuthorityRefs(parentcsid, csid);
229     }
230
231     /**
232      * Read item.
233      *
234      * @param vcsid the vcsid
235      * @param csid the csid
236      * @return the client response
237      */
238     public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
239         return orgAuthorityProxy.readItem(vcsid, csid);
240     }
241
242     /**
243      * Read named item.
244      *
245      * @param vcsid the vcsid
246      * @param shortId the shortIdentifier
247      * @return the client response
248      */
249     public ClientResponse<MultipartInput> readNamedItem(String vcsid, String shortId) {
250         return orgAuthorityProxy.readNamedItem(vcsid, shortId);
251     }
252
253     /**
254      * Read item in Named Authority.
255      *
256      * @param authShortId the shortIdentifier for the Authority
257      * @param csid the csid
258      * @return the client response
259      */
260     public ClientResponse<MultipartInput> readItemInNamedAuthority(String authShortId, String csid) {
261         return orgAuthorityProxy.readItemInNamedAuthority(authShortId, csid);
262     }
263
264     /**
265      * Read named item in Named Authority.
266      *
267      * @param authShortId the shortIdentifier for the Authority
268      * @param itemShortId the shortIdentifier for the item
269      * @return the client response
270      */
271     public ClientResponse<MultipartInput> readNamedItemInNamedAuthority(String authShortId, String itemShortId) {
272         return orgAuthorityProxy.readNamedItemInNamedAuthority(authShortId, itemShortId);
273     }
274
275     /**
276      * Creates the item.
277      *
278      * @param vcsid the vcsid
279      * @param multipart the multipart
280      * @return the client response
281      */
282     public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
283         return orgAuthorityProxy.createItem(vcsid, multipart);
284     }
285
286     /**
287      * Update item.
288      *
289      * @param vcsid the vcsid
290      * @param csid the csid
291      * @param multipart the multipart
292      * @return the client response
293      */
294     public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
295         return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
296
297     }
298
299     /**
300      * Delete item.
301      *
302      * @param vcsid the vcsid
303      * @param csid the csid
304      * @return the client response
305      */
306     public ClientResponse<Response> deleteItem(String vcsid, String csid) {
307         return orgAuthorityProxy.deleteItem(vcsid, csid);
308     }
309
310     /**
311      * Creates the contact.
312      *
313      * @param parentcsid the parentcsid
314      * @param itemcsid the itemcsid
315      * @param multipart the multipart
316      * @return the client response
317      */
318     public ClientResponse<Response> createContact(String parentcsid,
319             String itemcsid, MultipartOutput multipart) {
320         return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
321     }
322
323     /**
324      * Read contact.
325      *
326      * @param parentcsid the parentcsid
327      * @param itemcsid the itemcsid
328      * @param csid the csid
329      * @return the client response
330      */
331     public ClientResponse<MultipartInput> readContact(String parentcsid,
332             String itemcsid, String csid) {
333         return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid);
334     }
335
336     /**
337      * Read contact list.
338      *
339      * @param parentcsid the parentcsid
340      * @param itemcsid the itemcsid
341      * @return the client response
342      */
343     public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
344             String itemcsid) {
345         return orgAuthorityProxy.readContactList(parentcsid, itemcsid);
346     }
347
348     /**
349      * Update contact.
350      *
351      * @param parentcsid the parentcsid
352      * @param itemcsid the itemcsid
353      * @param csid the csid
354      * @param multipart the multipart
355      * @return the client response
356      */
357     public ClientResponse<MultipartInput> updateContact(String parentcsid,
358             String itemcsid, String csid, MultipartOutput multipart) {
359         return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
360     }
361
362     /**
363      * Delete contact.
364      *
365      * @param parentcsid the parentcsid
366      * @param itemcsid the itemcsid
367      * @param csid the csid
368      * @return the client response
369      */
370     public ClientResponse<Response> deleteContact(String parentcsid,
371         String itemcsid, String csid) {
372         return orgAuthorityProxy.deleteContact(parentcsid,
373             itemcsid, csid);
374     }
375
376 }