]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
d98b520c96a7545776ee94f33c07afa821a92fa5
[tmp/jakarta-migration.git] /
1 /**     
2  * CollectionObjectClient.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 (C) 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.core.Response;
30
31 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
32 import org.collectionspace.services.common.authorityref.AuthorityRefList;
33 //import org.collectionspace.services.common.context.ServiceContext;
34 //import org.collectionspace.services.common.query.IQueryManager;
35 import org.jboss.resteasy.client.ProxyFactory;
36 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
37 import org.jboss.resteasy.client.ClientResponse;
38 import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
39 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
40 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
41 import org.jboss.resteasy.spi.ResteasyProviderFactory;
42
43 import org.slf4j.Logger;
44
45 /**
46  * The Class CollectionObjectClient.
47  * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
48  */
49 public class CollectionObjectClient extends AbstractServiceClientImpl {
50
51     /** The collection object proxy. */
52     private CollectionObjectProxy collectionObjectProxy;
53     
54         /* (non-Javadoc)
55          * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent()
56          */
57         @Override
58     public String getServicePathComponent() {
59                 return "collectionobjects";
60         }
61
62     /**
63      * Instantiates a new collection object client.
64      */
65     public CollectionObjectClient() {
66         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
67         RegisterBuiltin.register(factory);
68         setProxy();
69     }
70     
71     @Override
72     public CollectionSpaceProxy getProxy() {
73         return this.collectionObjectProxy;
74     }
75
76     /**
77      * Sets the proxy.
78      */
79     public void setProxy() {
80         if(useAuth()){
81             collectionObjectProxy = ProxyFactory.create(CollectionObjectProxy.class,
82                     getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
83         }else{
84             collectionObjectProxy = ProxyFactory.create(CollectionObjectProxy.class,
85                     getBaseURL());
86         }
87     }
88
89     /**
90      * Read list.
91      * 
92      * @see org.collectionspace.services.client.CollectionObjectProxy#readList()
93      * @return the client response< collectionobjects common list>
94      */
95     public ClientResponse<CollectionobjectsCommonList> readList() {
96         return collectionObjectProxy.readList();
97
98     }
99
100 //    @Override
101 //    public ClientResponse<CollectionobjectsCommonList> readList(String pageSize,
102 //              String pageNumber) {
103 //        return collectionObjectProxy.readList(pageSize, pageNumber);
104 //    }
105     
106     /**
107      * Roundtrip.
108      * 
109      * This is an intentionally empty method that is used for performance test 
110      * to get a rough time estimate of the client to server response-request overhead.
111      * 
112      * @see org.collectionspace.services.client.CollectionObjectProxy#roundtrip()
113      * @return the client response< response>
114      */
115     public ClientResponse<Response> roundtrip(int ms) {
116         getLogger().debug(">>>>Roundtrip start.");
117         ClientResponse<Response> result = collectionObjectProxy.roundtrip(ms);
118         getLogger().debug("<<<<Roundtrip stop.");
119         return result;
120     }
121     
122     /**
123      * Keyword search.
124      * 
125      * @param keywords the keywords
126      * 
127      * @see org.collectionspace.services.client.CollectionObjectProxy#keywordSearch()
128      * @return the client response< collectionobjects common list>
129      */
130     public ClientResponse<CollectionobjectsCommonList> keywordSearch(String keywords) {
131         return collectionObjectProxy.keywordSearch(keywords);
132
133     }
134     
135     /**
136      * Read.
137      * 
138      * @param csid the csid
139      * 
140      * @see org.collectionspace.services.client.CollectionObjectProxy#keywordSearch()
141      * @return the client response< multipart input>
142      */
143     public ClientResponse<MultipartInput> read(String csid) {
144         return collectionObjectProxy.read(csid);
145     }
146
147     /**
148      * @param csid
149      * @return response
150      * @see org.collectionspace.services.client.CollectionObjectProxy#getAuthorityRefs(java.lang.String)
151      */
152     public ClientResponse<AuthorityRefList> getAuthorityRefs(String csid) {
153         return collectionObjectProxy.getAuthorityRefs(csid);
154     }
155
156
157     /**
158      * Creates the.
159      * 
160      * @param multipart the multipart
161      * 
162      * @see org.collectionspace.services.client.CollectionObjectProxy#create()
163      * @return the client response< response>
164      */
165     public ClientResponse<Response> create(MultipartOutput multipart) {
166         return collectionObjectProxy.create(multipart);
167     }
168
169     /**
170      * Update.
171      * 
172      * @param csid the csid
173      * @param multipart the multipart
174      * 
175      * @see org.collectionspace.services.client.CollectionObjectProxy#update()
176      * @return the client response< multipart input>
177      */
178     public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
179         return collectionObjectProxy.update(csid, multipart);
180     }
181
182     /**
183      * Delete.
184      * 
185      * @param csid the csid
186      * 
187      * @see org.collectionspace.services.client.CollectionObjectProxy#delete()
188      * @return the client response< response>
189      */
190     @Override
191     public ClientResponse<Response> delete(String csid) {
192         return collectionObjectProxy.delete(csid);
193     }
194 }