]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
eb1abf460825f7a303cfc4f4381359d152300247
[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 © 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
32 import org.collectionspace.services.collectionobject.CollectionobjectsCommonList;
33 import org.collectionspace.services.common.context.ServiceContext;
34 import org.jboss.resteasy.client.ProxyFactory;
35 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
36 import org.jboss.resteasy.client.ClientResponse;
37 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
38 import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
39 import org.jboss.resteasy.spi.ResteasyProviderFactory;
40
41 /**
42  * A CollectionObjectClient.
43
44  * @version $Revision:$
45  */
46 public class CollectionObjectClient extends BaseServiceClient {
47
48     /**
49      *
50      */
51     private CollectionObjectProxy collectionObjectProxy;
52     
53         /* (non-Javadoc)
54          * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent()
55          */
56         public String getServicePathComponent() {
57                 return "collectionobjects";
58         }
59
60     /**
61      *
62      * Default constructor for CollectionObjectClient class.
63      *
64      */
65     public CollectionObjectClient() {
66         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
67         RegisterBuiltin.register(factory);
68         setProxy();
69     }
70
71     /**
72      * allow to reset proxy as per security needs
73      */
74     public void setProxy() {
75         if(useAuth()){
76             collectionObjectProxy = ProxyFactory.create(CollectionObjectProxy.class,
77                     getBaseURL(), getHttpClient());
78         }else{
79             collectionObjectProxy = ProxyFactory.create(CollectionObjectProxy.class,
80                     getBaseURL());
81         }
82     }
83
84     /**
85      * @return
86      * @see org.collectionspace.hello.client.CollectionObjectProxy#readList()
87      */
88     public ClientResponse<CollectionobjectsCommonList> readList() {
89         return collectionObjectProxy.readList();
90
91     }
92
93     /**
94      * @param csid
95      * @return
96      * @see org.collectionspace.hello.client.CollectionObjectProxy#getCollectionObject(java.lang.String)
97      */
98     public ClientResponse<MultipartInput> read(String csid) {
99         return collectionObjectProxy.read(csid);
100     }
101
102     /**
103      * @param collectionobject
104      * @return
105      * @see org.collectionspace.hello.client.CollectionObjectProxy#create(org.collectionspace.services.collectionobject.CollectionobjectsCommon)
106      */
107     public ClientResponse<Response> create(MultipartOutput multipart) {
108         return collectionObjectProxy.create(multipart);
109     }
110
111     /**
112      * @param csid
113      * @param collectionobject
114      * @return
115      * @see org.collectionspace.hello.client.CollectionObjectProxy#updateCollectionObject(java.lang.Long, org.collectionspace.services.collectionobject.CollectionobjectsCommon)
116      */
117     public ClientResponse<MultipartInput> update(String csid, MultipartOutput multipart) {
118         return collectionObjectProxy.update(csid, multipart);
119     }
120
121     /**
122      * @param csid
123      * @return
124      * @see org.collectionspace.hello.client.CollectionObjectProxy#deleteCollectionObject(java.lang.Long)
125      */
126     public ClientResponse<Response> delete(String csid) {
127         return collectionObjectProxy.delete(csid);
128     }
129 }