2 * LocationAuthorityClient.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.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;
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;
46 * The Class LocationAuthorityClient.
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;
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;
60 // Payload Part/Schema part names
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;
68 public String getServiceName() {
73 public String getServicePathComponent() {
74 return SERVICE_PATH_COMPONENT;
77 public String getItemCommonPartName() {
78 return getCommonPartName(SERVICE_ITEM_NAME);
84 private LocationAuthorityProxy locationAuthorityProxy;
87 * Instantiates a new location authority client.
89 public LocationAuthorityClient() {
90 ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
91 RegisterBuiltin.register(factory);
96 * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
99 public CollectionSpaceProxy getProxy() {
100 return this.locationAuthorityProxy;
106 public void setProxy() {
108 locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
109 getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
111 locationAuthorityProxy = ProxyFactory.create(LocationAuthorityProxy.class,
119 * @return the client response
124 * @see org.collectionspace.services.client.LocationAuthorityProxy#readList()
126 public ClientResponse<LocationauthoritiesCommonList> readList() {
127 return locationAuthorityProxy.readList();
133 * @param csid the csid
134 * @return the client response
136 public ClientResponse<String> read(String csid) {
137 return locationAuthorityProxy.read(csid);
143 * @param name the name
144 * @return the client response
146 public ClientResponse<String> readByName(String name) {
147 return locationAuthorityProxy.readByName(name);
153 * @param multipart the multipart
154 * @return the client response
156 public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {
157 return locationAuthorityProxy.create(xmlPayload.getBytes());
163 * @param csid the csid
164 * @param multipart the multipart
165 * @return the client response
167 public ClientResponse<String> update(String csid, PoxPayloadOut xmlPayload) {
168 return locationAuthorityProxy.update(csid, xmlPayload.getBytes());
175 * @param csid the csid
176 * @return the client response
178 public ClientResponse<Response> delete(String csid) {
179 return locationAuthorityProxy.delete(csid);
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
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
194 public ClientResponse<LocationsCommonList>
195 readItemList(String inAuthority, String partialTerm, String keywords) {
196 return locationAuthorityProxy.readItemList(inAuthority, partialTerm, keywords);
200 * Gets the referencing objects.
202 * @param parentcsid the parentcsid
203 * @param csid the csid
204 * @return the referencing objects
206 public ClientResponse<AuthorityRefDocList> getReferencingObjects(String parentcsid, String csid) {
207 return locationAuthorityProxy.getReferencingObjects(parentcsid, csid);
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
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
222 public ClientResponse<LocationsCommonList>
223 readItemListForNamedAuthority(String specifier, String partialTerm, String keywords) {
224 return locationAuthorityProxy.readItemListForNamedAuthority(specifier, partialTerm, keywords);
230 * @param vcsid the vcsid
231 * @param csid the csid
232 * @return the client response
234 public ClientResponse<String> readItem(String vcsid, String csid) {
235 return locationAuthorityProxy.readItem(vcsid, csid);
241 * @param vcsid the vcsid
242 * @param multipart the multipart
243 * @return the client response
245 public ClientResponse<Response> createItem(String vcsid, PoxPayloadOut xmlPayload) {
246 return locationAuthorityProxy.createItem(vcsid, xmlPayload.getBytes());
252 * @param vcsid the vcsid
253 * @param csid the csid
254 * @param multipart the multipart
255 * @return the client response
257 public ClientResponse<String> updateItem(String vcsid, String csid, PoxPayloadOut xmlPayload) {
258 return locationAuthorityProxy.updateItem(vcsid, csid, xmlPayload.getBytes());
265 * @param vcsid the vcsid
266 * @param csid the csid
267 * @return the client response
269 public ClientResponse<Response> deleteItem(String vcsid, String csid) {
270 return locationAuthorityProxy.deleteItem(vcsid, csid);
274 * Creates the contact.
276 * @param parentcsid the parentcsid
277 * @param itemcsid the itemcsid
278 * @param multipart the multipart
279 * @return the client response
281 public ClientResponse<Response> createContact(String parentcsid,
282 String itemcsid, PoxPayloadOut xmlPayload) {
283 return locationAuthorityProxy.createContact(parentcsid, itemcsid, xmlPayload.getBytes());
289 * @param parentcsid the parentcsid
290 * @param itemcsid the itemcsid
291 * @param csid the csid
292 * @return the client response
294 public ClientResponse<String> readContact(String parentcsid,
295 String itemcsid, String csid) {
296 return locationAuthorityProxy.readContact(parentcsid, itemcsid, csid);
302 * @param parentcsid the parentcsid
303 * @param itemcsid the itemcsid
304 * @return the client response
306 public ClientResponse<ContactsCommonList> readContactList(String parentcsid,
308 return locationAuthorityProxy.readContactList(parentcsid, itemcsid);
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
320 public ClientResponse<String> updateContact(String parentcsid,
321 String itemcsid, String csid, PoxPayloadOut xmlPayload) {
322 return locationAuthorityProxy.updateContact(parentcsid, itemcsid, csid, xmlPayload.getBytes());
328 * @param parentcsid the parentcsid
329 * @param itemcsid the itemcsid
330 * @param csid the csid
331 * @return the client response
333 public ClientResponse<Response> deleteContact(String parentcsid,
334 String itemcsid, String csid) {
335 return locationAuthorityProxy.deleteContact(parentcsid,