2 * OrgAuthorityClient.java
4 * {Purpose of This Class}
6 * {Other Notes Relating to This Class (Optional)}
9 * $LastChangedRevision$
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:
16 * http://www.collectionspace.org
17 * http://wiki.collectionspace.org
19 * Copyright © 2009 {Contributing Institution}
21 * Licensed under the Educational Community License (ECL), Version 2.0.
22 * You may not use this file except in compliance with this License.
24 * You may obtain a copy of the ECL 2.0 License at
25 * https://source.collectionspace.org/collection-space/LICENSE.txt
27 package org.collectionspace.services.client;
29 //import javax.ws.rs.PathParam;
30 import javax.ws.rs.core.Response;
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;
38 import org.jboss.resteasy.client.ClientResponse;
39 import org.jboss.resteasy.client.ProxyFactory;
40 import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
41 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
42 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
43 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
44 import org.jboss.resteasy.spi.ResteasyProviderFactory;
47 * The Class OrgAuthorityClient.
49 public class OrgAuthorityClient extends AbstractServiceClientImpl {
52 * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
55 public String getServicePathComponent() {
56 return "orgauthorities";
60 * Gets the item common part name.
62 * @return the item common part name
64 public String getItemCommonPartName() {
65 return getCommonPartName("organizations");
68 /** The Constant instance. */ //FIXME: This is wrong. There should NOT be a static instance of the OrgAuthorityClient class
69 // private static final OrgAuthorityClient instance = new OrgAuthorityClient();
71 /** The org authority proxy. */
72 private OrgAuthorityProxy orgAuthorityProxy;
75 * Instantiates a new org authority client.
77 public OrgAuthorityClient() {
78 ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
79 RegisterBuiltin.register(factory);
84 * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
87 public CollectionSpaceProxy getProxy() {
88 return this.orgAuthorityProxy;
94 public void setProxy() {
96 orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
97 getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
99 orgAuthorityProxy = ProxyFactory.create(OrgAuthorityProxy.class,
105 * Gets the single instance of OrgAuthorityClient.
107 * @return single instance of OrgAuthorityClient //FIXME: This is wrong. There should NOT be a static instance of the client
109 // public static OrgAuthorityClient getInstance() {
116 * @return the client response
118 public ClientResponse<OrgauthoritiesCommonList> readList() {
119 return orgAuthorityProxy.readList();
125 * @param csid the csid
126 * @return the client response
128 public ClientResponse<MultipartInput> read(String csid) {
129 return orgAuthorityProxy.read(csid);
135 * @param name the name
136 * @return the client response
138 public ClientResponse<MultipartInput> readByName(String name) {
139 return orgAuthorityProxy.readByName(name);
145 * @param multipart the multipart
146 * @return the client response
148 public ClientResponse<Response> create(MultipartOutput multipart) {
149 return orgAuthorityProxy.create(multipart);
155 * @param csid the csid
156 * @param multipart the multipart
157 * @return the client response
159 public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
160 return orgAuthorityProxy.update(csid, multipart);
167 * @param csid the csid
168 * @return the client response
171 public ClientResponse<Response> delete(String csid) {
172 return orgAuthorityProxy.delete(csid);
176 * Read item list, filtering by partial term match, or keywords. Only one of
177 * partialTerm or keywords should be specified. If both are specified, keywords
180 * @param inAuthority the parent authority
181 * @param partialTerm A partial term on which to match,
182 * which will filter list results to return only matched resources.
183 * @param keywords A set of keywords on which to match,
184 * which will filter list results to return only matched resources.
185 * @return the client response
187 public ClientResponse<OrganizationsCommonList>
188 readItemList(String inAuthority, String partialTerm, String keywords) {
189 return orgAuthorityProxy.readItemList(inAuthority, partialTerm, keywords);
193 * Gets the referencing objects.
195 * @param parentcsid the parentcsid
196 * @param csid the csid
197 * @return the referencing objects
199 public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
200 return orgAuthorityProxy.getReferencingObjects(parentcsid, csid);
205 * Read item list for named vocabulary, filtering by partial term match, or keywords. Only one of
206 * partialTerm or keywords should be specified. If both are specified, keywords
209 * @param specifier the specifier
210 * @param partialTerm A partial term on which to match,
211 * which will filter list results to return only matched resources.
212 * @param keywords A set of keywords on which to match,
213 * which will filter list results to return only matched resources.
214 * @return the client response
216 public ClientResponse<OrganizationsCommonList>
217 readItemListForNamedAuthority(String specifier, String partialTerm, String keywords) {
218 return orgAuthorityProxy.readItemListForNamedAuthority(specifier, partialTerm, keywords);
222 * Gets the item authority refs.
224 * @param parentcsid the parentcsid
225 * @param csid the csid
226 * @return the item authority refs
228 public ClientResponse<AuthorityRefList> getItemAuthorityRefs(String parentcsid, String csid) {
229 return orgAuthorityProxy.getItemAuthorityRefs(parentcsid, csid);
235 * @param vcsid the vcsid
236 * @param csid the csid
237 * @return the client response
239 public ClientResponse<MultipartInput> readItem(String vcsid, String csid) {
240 return orgAuthorityProxy.readItem(vcsid, csid);
246 * @param vcsid the vcsid
247 * @param shortId the shortIdentifier
248 * @return the client response
250 public ClientResponse<MultipartInput> readNamedItem(String vcsid, String shortId) {
251 return orgAuthorityProxy.readNamedItem(vcsid, shortId);
255 * Read item in Named Authority.
257 * @param authShortId the shortIdentifier for the Authority
258 * @param csid the csid
259 * @return the client response
261 public ClientResponse<MultipartInput> readItemInNamedAuthority(String authShortId, String csid) {
262 return orgAuthorityProxy.readItemInNamedAuthority(authShortId, csid);
266 * Read named item in Named Authority.
268 * @param authShortId the shortIdentifier for the Authority
269 * @param itemShortId the shortIdentifier for the item
270 * @return the client response
272 public ClientResponse<MultipartInput> readNamedItemInNamedAuthority(String authShortId, String itemShortId) {
273 return orgAuthorityProxy.readNamedItemInNamedAuthority(authShortId, itemShortId);
279 * @param vcsid the vcsid
280 * @param multipart the multipart
281 * @return the client response
283 public ClientResponse<Response> createItem(String vcsid, MultipartOutput multipart) {
284 return orgAuthorityProxy.createItem(vcsid, multipart);
290 * @param vcsid the vcsid
291 * @param csid the csid
292 * @param multipart the multipart
293 * @return the client response
295 public ClientResponse<MultipartInput> updateItem(String vcsid, String csid, MultipartOutput multipart) {
296 return orgAuthorityProxy.updateItem(vcsid, csid, multipart);
303 * @param vcsid the vcsid
304 * @param csid the csid
305 * @return the client response
307 public ClientResponse<Response> deleteItem(String vcsid, String csid) {
308 return orgAuthorityProxy.deleteItem(vcsid, csid);
311 /***************************************************************************
313 * Contact sub-resource interfaces
315 ***************************************************************************/
318 * Creates the contact.
320 * @param parentcsid the parentcsid
321 * @param itemcsid the itemcsid
322 * @param multipart the multipart
323 * @return the client response
325 public ClientResponse<Response> createContact(String parentcsid,
326 String itemcsid, MultipartOutput multipart) {
327 return orgAuthorityProxy.createContact(parentcsid, itemcsid, multipart);
331 * Creates the contact.
334 * @param itemspecifier (shortIdentifier)
336 * @return the client response
338 public ClientResponse<Response> createContactForNamedItem(
340 String itemspecifier,
341 MultipartOutput multipart) {
342 return orgAuthorityProxy.createContactForNamedItem(parentcsid, itemspecifier, multipart);
345 * Creates the contact.
347 * @param parentspecifier (shortIdentifier)
350 * @return the client response
352 public ClientResponse<Response> createContactForItemInNamedAuthority(
353 String parentspecifier,
355 MultipartOutput multipart) {
356 return orgAuthorityProxy.createContactForItemInNamedAuthority(parentspecifier, itemcsid, multipart);
359 * Creates the contact.
361 * @param parentspecifier (shortIdentifier)
362 * @param itemspecifier (shortIdentifier)
364 * @return the client response
366 public ClientResponse<Response> createContactForNamedItemInNamedAuthority(
367 String parentspecifier,
368 String itemspecifier,
369 MultipartOutput multipart) {
370 return orgAuthorityProxy.createContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, multipart);
376 * @param parentcsid the parentcsid
377 * @param itemcsid the itemcsid
378 * @param csid the csid
379 * @return the client response
381 public ClientResponse<MultipartInput> readContact(String parentcsid,
382 String itemcsid, String csid) {
383 return orgAuthorityProxy.readContact(parentcsid, itemcsid, csid);
390 * @param itemspecifier (shortIdentifier)
392 * @return the client response
394 public ClientResponse<MultipartInput> readContactForNamedItem(
396 String itemspecifier,
398 return orgAuthorityProxy.readContactForNamedItem(parentcsid, itemspecifier, csid);
404 * @param parentspecifier (shortIdentifier)
407 * @return the client response
409 public ClientResponse<MultipartInput> readContactInNamedAuthority(
410 String parentspecifier,
413 return orgAuthorityProxy.readContactInNamedAuthority(parentspecifier, itemcsid, csid);
419 * @param parentspecifier (shortIdentifier)
420 * @param itemspecifier (shortIdentifier)
422 * @return the client response
424 public ClientResponse<MultipartInput> readContactForNamedItemInNamedAuthority(
425 String parentspecifier,
426 String itemspecifier,
428 return orgAuthorityProxy.readContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, csid);
435 * @param parentcsid the parentcsid
436 * @param itemcsid the itemcsid
437 * @return the client response
439 public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
441 return orgAuthorityProxy.readContactList(parentcsid, itemcsid);
448 * @param itemspecifier (shortIdentifier)
449 * @return the client response
451 public ClientResponse<ContactsCommonList> readContactListForNamedItem(
453 String itemspecifier){
454 return orgAuthorityProxy.readContactList(parentcsid, itemspecifier);
460 * @param parentspecifier (shortIdentifier)
462 * @return the client response
464 public ClientResponse<ContactsCommonList> readContactListForItemInNamedAuthority(
465 String parentspecifier,
467 return orgAuthorityProxy.readContactList(parentspecifier, itemcsid);
473 * @param parentspecifier (shortIdentifier)
474 * @param itemspecifier (shortIdentifier)
475 * @return the client response
477 public ClientResponse<ContactsCommonList> readContactListForNamedItemInNamedAuthority(
478 String parentspecifier,
479 String itemspecifier){
480 return orgAuthorityProxy.readContactList(parentspecifier, itemspecifier);
487 * @param parentcsid the parentcsid
488 * @param itemcsid the itemcsid
489 * @param csid the csid
490 * @param multipart the multipart
491 * @return the client response
493 public ClientResponse<MultipartInput> updateContact(String parentcsid,
494 String itemcsid, String csid, MultipartOutput multipart) {
495 return orgAuthorityProxy.updateContact(parentcsid, itemcsid, csid, multipart);
501 * @param parentcsid the parentcsid
502 * @param itemspecifier (shortIdentifier)
503 * @param csid the csid
504 * @param multipart the multipart
505 * @return the client response
507 public ClientResponse<MultipartInput> updateContactForNamedItem(
509 String itemspecifier,
511 MultipartOutput multipart) {
512 return orgAuthorityProxy.updateContactForNamedItem(parentcsid, itemspecifier, csid, multipart);
518 * @param parentspecifier (shortIdentifier)
519 * @param itemcsid the itemcsid
520 * @param csid the csid
521 * @param multipart the multipart
522 * @return the client response
524 public ClientResponse<MultipartInput> updateContactInNamedAuthority(
525 String parentspecifier,
528 MultipartOutput multipart) {
529 return orgAuthorityProxy.updateContactInNamedAuthority(parentspecifier, itemcsid, csid, multipart);
535 * @param parentspecifier (shortIdentifier)
536 * @param itemspecifier (shortIdentifier)
537 * @param csid the csid
538 * @param multipart the multipart
539 * @return the client response
541 public ClientResponse<MultipartInput> updateContactForNamedItemInNamedAuthority(
542 String parentspecifier,
543 String itemspecifier,
545 MultipartOutput multipart) {
546 return orgAuthorityProxy.updateContactForNamedItemInNamedAuthority(parentspecifier, itemspecifier, csid, multipart);
553 * @param parentcsid the parentcsid
554 * @param itemcsid the itemcsid
555 * @param csid the csid
556 * @return the client response
558 public ClientResponse<Response> deleteContact(String parentcsid,
559 String itemcsid, String csid) {
560 return orgAuthorityProxy.deleteContact(parentcsid,
567 * @param parentcsid the parentcsid
568 * @param itemspecifier (shortIdentifier)
569 * @param csid the csid
570 * @return the client response
572 public ClientResponse<Response> deleteContactForNamedItem(
574 String itemspecifier,
576 return orgAuthorityProxy.deleteContactForNamedItem(parentcsid,
577 itemspecifier, csid);
583 * @param parentspecifier (shortIdentifier)
584 * @param itemcsid the itemcsid
585 * @param csid the csid
586 * @return the client response
588 public ClientResponse<Response> deleteContactInNamedAuthority(
589 String parentspecifier,
592 return orgAuthorityProxy.deleteContactInNamedAuthority(parentspecifier,
599 * @param parentspecifier (shortIdentifier)
600 * @param itemspecifier (shortIdentifier)
601 * @param csid the csid
602 * @return the client response
604 public ClientResponse<Response> deleteContactForNamedItemInNamedAuthority(
605 String parentspecifier,
606 String itemspecifier,
608 return orgAuthorityProxy.deleteContactForNamedItemInNamedAuthority(parentspecifier,
609 itemspecifier, csid);