]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
b6b954d33f432ef0f79b27f8ff60f3b62b034203
[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.
176      *
177      * @param vcsid the vcsid
178      * @return the client response
179      */
180     public ClientResponse<OrganizationsCommonList> readItemList(String vcsid) {
181         return orgAuthorityProxy.readItemList(vcsid);
182     }
183     
184     /**
185      * Gets the referencing objects.
186      *
187      * @param parentcsid the parentcsid
188      * @param csid the csid
189      * @return the referencing objects
190      */
191     public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
192         return orgAuthorityProxy.getReferencingObjects(parentcsid, csid);
193     }
194     
195
196     /**
197      * Read item list for named authority.
198      *
199      * @param specifier the specifier
200      * @return the client response
201      */
202     public ClientResponse<OrganizationsCommonList> readItemListForNamedAuthority(String specifier) {
203         return orgAuthorityProxy.readItemListForNamedAuthority(specifier);
204     }
205
206     /**
207      * Gets the item authority refs.
208      *
209      * @param parentcsid the parentcsid
210      * @param csid the csid
211      * @return the item authority refs
212      */
213     public ClientResponse<AuthorityRefList> getItemAuthorityRefs(String parentcsid, String csid) {
214         return orgAuthorityProxy.getItemAuthorityRefs(parentcsid, csid);
215     }
216
217     /**
218      * Read item.
219      *
220      * @param vcsid the vcsid
221      * @param csid the csid
222      * @return the client response
223      */
224     public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
225         return orgAuthorityProxy.readItem(vcsid, csid);
226     }
227
228     /**
229      * Creates the item.
230      *
231      * @param vcsid the vcsid
232      * @param multipart the multipart
233      * @return the client response
234      */
235     public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
236         return orgAuthorityProxy.createItem(vcsid, multipart);
237     }
238
239     /**
240      * Update item.
241      *
242      * @param vcsid the vcsid
243      * @param csid the csid
244      * @param multipart the multipart
245      * @return the client response
246      */
247     public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
248         return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
249
250     }
251
252     /**
253      * Delete item.
254      *
255      * @param vcsid the vcsid
256      * @param csid the csid
257      * @return the client response
258      */
259     public ClientResponse<Response> deleteItem(String vcsid, String csid) {
260         return orgAuthorityProxy.deleteItem(vcsid, csid);
261     }
262
263     /**
264      * Creates the contact.
265      *
266      * @param parentcsid the parentcsid
267      * @param itemcsid the itemcsid
268      * @param multipart the multipart
269      * @return the client response
270      */
271     public ClientResponse<Response> createContact(String parentcsid,
272             String itemcsid, MultipartOutput multipart) {
273         return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
274     }
275
276     /**
277      * Read contact.
278      *
279      * @param parentcsid the parentcsid
280      * @param itemcsid the itemcsid
281      * @param csid the csid
282      * @return the client response
283      */
284     public ClientResponse<MultipartInput> readContact(String parentcsid,
285             String itemcsid, String csid) {
286         return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid);
287     }
288
289     /**
290      * Read contact list.
291      *
292      * @param parentcsid the parentcsid
293      * @param itemcsid the itemcsid
294      * @return the client response
295      */
296     public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
297             String itemcsid) {
298         return orgAuthorityProxy.readContactList(parentcsid, itemcsid);
299     }
300
301     /**
302      * Update contact.
303      *
304      * @param parentcsid the parentcsid
305      * @param itemcsid the itemcsid
306      * @param csid the csid
307      * @param multipart the multipart
308      * @return the client response
309      */
310     public ClientResponse<MultipartInput> updateContact(String parentcsid,
311             String itemcsid, String csid, MultipartOutput multipart) {
312         return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
313     }
314
315     /**
316      * Delete contact.
317      *
318      * @param parentcsid the parentcsid
319      * @param itemcsid the itemcsid
320      * @param csid the csid
321      * @return the client response
322      */
323     public ClientResponse<Response> deleteContact(String parentcsid,
324         String itemcsid, String csid) {
325         return orgAuthorityProxy.deleteContact(parentcsid,
326             itemcsid, csid);
327     }
328
329 }