]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
5894be657a1110a31513fd548a3c85111cfeb7c9
[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.AuthorityRefList;
33 import org.collectionspace.services.contact.ContactsCommonList;
34 import org.collectionspace.services.organization.OrgauthoritiesCommonList;
35 import org.collectionspace.services.organization.OrganizationsCommonList;
36
37 import org.jboss.resteasy.client.ClientResponse;
38 import org.jboss.resteasy.client.ProxyFactory;
39 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
40 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
41 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
42 import org.jboss.resteasy.spi.ResteasyProviderFactory;
43
44 /**
45  * The Class OrgAuthorityClient.
46  */
47 public class OrgAuthorityClient extends AbstractServiceClientImpl {
48
49     /* (non-Javadoc)
50      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
51      */
52     @Override
53     public String getServicePathComponent() {
54         return "orgauthorities";
55     }
56
57     /**
58      * Gets the item common part name.
59      *
60      * @return the item common part name
61      */
62     public String getItemCommonPartName() {
63         return getCommonPartName("organizations");
64     }
65     
66     /** The Constant instance. */  //FIXME: This is wrong.  There should NOT be a static instance of the OrgAuthorityClient class
67 //    private static final OrgAuthorityClient instance = new OrgAuthorityClient();
68     
69     /** The org authority proxy. */
70     private OrgAuthorityProxy orgAuthorityProxy;
71
72     /**
73      * Instantiates a new org authority client.
74      */
75     public OrgAuthorityClient() {
76         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
77         RegisterBuiltin.register(factory);
78         setProxy();
79     }
80
81     /* (non-Javadoc)
82      * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
83      */
84     @Override
85     public CollectionSpaceProxy getProxy() {
86         return this.orgAuthorityProxy;
87     }    
88
89     /**
90      * Sets the proxy.
91      */
92     public void setProxy() {
93         if (useAuth()) {
94             orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
95                     getBaseURL(), getHttpClient());
96         } else {
97             orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
98                     getBaseURL());
99         }
100     }
101
102     /**
103      * Gets the single instance of OrgAuthorityClient.
104      *
105      * @return single instance of OrgAuthorityClient //FIXME: This is wrong.  There should NOT be a static instance of the client
106      */
107 //    public static OrgAuthorityClient getInstance() {
108 //        return instance;
109 //    }
110
111     /**
112      * Read list.
113      *
114      * @return the client response
115      */
116     public ClientResponse<OrgauthoritiesCommonList> readList() {
117         return orgAuthorityProxy.readList();
118     }
119
120     /**
121      * Read.
122      *
123      * @param csid the csid
124      * @return the client response
125      */
126     public ClientResponse<MultipartInput> read(String csid) {
127         return orgAuthorityProxy.read(csid);
128     }
129
130     /**
131      * Read by name.
132      *
133      * @param name the name
134      * @return the client response
135      */
136     public ClientResponse<MultipartInput> readByName(String name) {
137         return orgAuthorityProxy.readByName(name);
138     }
139
140     /**
141      * Creates the.
142      *
143      * @param multipart the multipart
144      * @return the client response
145      */
146     public ClientResponse<Response> create(MultipartOutput multipart) {
147         return orgAuthorityProxy.create(multipart);
148     }
149
150     /**
151      * Update.
152      *
153      * @param csid the csid
154      * @param multipart the multipart
155      * @return the client response
156      */
157     public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
158         return orgAuthorityProxy.update(csid, multipart);
159
160     }
161
162     /**
163      * Delete.
164      *
165      * @param csid the csid
166      * @return the client response
167      */
168     public ClientResponse<Response> delete(String csid) {
169         return orgAuthorityProxy.delete(csid);
170     }
171
172     /**
173      * Read item list.
174      *
175      * @param vcsid the vcsid
176      * @return the client response
177      */
178     public ClientResponse<OrganizationsCommonList> readItemList(String vcsid) {
179         return orgAuthorityProxy.readItemList(vcsid);
180     }
181
182     /**
183      * Read item list for named authority.
184      *
185      * @param specifier the specifier
186      * @return the client response
187      */
188     public ClientResponse<OrganizationsCommonList> readItemListForNamedAuthority(String specifier) {
189         return orgAuthorityProxy.readItemListForNamedAuthority(specifier);
190     }
191
192     /**
193      * Gets the item authority refs.
194      *
195      * @param parentcsid the parentcsid
196      * @param csid the csid
197      * @return the item authority refs
198      */
199     public ClientResponse<AuthorityRefList> getItemAuthorityRefs(String parentcsid, String csid) {
200         return orgAuthorityProxy.getItemAuthorityRefs(parentcsid, csid);
201     }
202
203     /**
204      * Read item.
205      *
206      * @param vcsid the vcsid
207      * @param csid the csid
208      * @return the client response
209      */
210     public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
211         return orgAuthorityProxy.readItem(vcsid, csid);
212     }
213
214     /**
215      * Creates the item.
216      *
217      * @param vcsid the vcsid
218      * @param multipart the multipart
219      * @return the client response
220      */
221     public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
222         return orgAuthorityProxy.createItem(vcsid, multipart);
223     }
224
225     /**
226      * Update item.
227      *
228      * @param vcsid the vcsid
229      * @param csid the csid
230      * @param multipart the multipart
231      * @return the client response
232      */
233     public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
234         return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
235
236     }
237
238     /**
239      * Delete item.
240      *
241      * @param vcsid the vcsid
242      * @param csid the csid
243      * @return the client response
244      */
245     public ClientResponse<Response> deleteItem(String vcsid, String csid) {
246         return orgAuthorityProxy.deleteItem(vcsid, csid);
247     }
248
249     /**
250      * Creates the contact.
251      *
252      * @param parentcsid the parentcsid
253      * @param itemcsid the itemcsid
254      * @param multipart the multipart
255      * @return the client response
256      */
257     public ClientResponse<Response> createContact(String parentcsid,
258             String itemcsid, MultipartOutput multipart) {
259         return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
260     }
261
262     /**
263      * Read contact.
264      *
265      * @param parentcsid the parentcsid
266      * @param itemcsid the itemcsid
267      * @param csid the csid
268      * @return the client response
269      */
270     public ClientResponse<MultipartInput> readContact(String parentcsid,
271             String itemcsid, String csid) {
272         return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid);
273     }
274
275     /**
276      * Read contact list.
277      *
278      * @param parentcsid the parentcsid
279      * @param itemcsid the itemcsid
280      * @return the client response
281      */
282     public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
283             String itemcsid) {
284         return orgAuthorityProxy.readContactList(parentcsid, itemcsid);
285     }
286
287     /**
288      * Update contact.
289      *
290      * @param parentcsid the parentcsid
291      * @param itemcsid the itemcsid
292      * @param csid the csid
293      * @param multipart the multipart
294      * @return the client response
295      */
296     public ClientResponse<MultipartInput> updateContact(String parentcsid,
297             String itemcsid, String csid, MultipartOutput multipart) {
298         return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
299     }
300
301     /**
302      * Delete contact.
303      *
304      * @param parentcsid the parentcsid
305      * @param itemcsid the itemcsid
306      * @param csid the csid
307      * @return the client response
308      */
309     public ClientResponse<Response> deleteContact(String parentcsid,
310         String itemcsid, String csid) {
311         return orgAuthorityProxy.deleteContact(parentcsid,
312             itemcsid, csid);
313     }
314
315 }