]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a6a2356f77e9c9f33c70ee767701b0c9c8100b2a
[tmp/jakarta-migration.git] /
1 /**     
2  * PermissionRoleClient.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
32 import org.collectionspace.services.authorization.PermissionRole;
33 import org.jboss.resteasy.client.ProxyFactory;
34 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
35 import org.jboss.resteasy.client.ClientResponse;
36 import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
37 import org.jboss.resteasy.spi.ResteasyProviderFactory;
38
39 // TODO: Auto-generated Javadoc
40 /**
41  * A RolePermissionClient.
42
43  * @version $Revision:$
44  */
45 public class RolePermissionClient extends AbstractServiceClientImpl {
46
47     /** The role permission proxy. */
48     private RolePermissionProxy rolePermissionProxy;
49
50     @Override
51     public String getServiceName() { 
52         throw new UnsupportedOperationException(); //FIXME: REM - http://issues.collectionspace.org/browse/CSPACE-3498 }
53     }
54     
55     /* (non-Javadoc)
56      * @see 
57      */
58     public String getServicePathComponent() {
59         return "authorization/roles";
60     }
61
62     /**
63      *
64      * Default constructor for PermissionRoleClient class.
65      *
66      */
67     public RolePermissionClient() {
68         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
69         RegisterBuiltin.register(factory);
70         setProxy();
71     }
72
73     /* (non-Javadoc)
74      * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
75      */
76     @Override
77     public CollectionSpaceProxy getProxy() {
78         return this.rolePermissionProxy;
79     }
80
81     /**
82      * allow to reset proxy as per security needs.
83      */
84     public void setProxy() {
85         if (useAuth()) {
86             rolePermissionProxy = ProxyFactory.create(RolePermissionProxy.class,
87                     getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
88         } else {
89             rolePermissionProxy = ProxyFactory.create(RolePermissionProxy.class,
90                     getBaseURL());
91         }
92     }
93
94     /**
95      * Read.
96      *
97      * @param csid the csid
98      * @return the client response
99      * @see
100      */
101     public ClientResponse<PermissionRole> read(String csid) {
102         return rolePermissionProxy.read(csid);
103     }
104
105     /**
106      * Read.
107      *
108      * @param csid the csid
109      * @param prcsid the prcsid
110      * @return the client response
111      */
112     public ClientResponse<PermissionRole> read(String csid, String prcsid) {
113         return rolePermissionProxy.read(csid, prcsid);
114     }
115
116     /**
117      * Creates the relationships.
118      *
119      * @param csid the csid
120      * @param permRole the perm role
121      * @return the client response
122      * @see
123      */
124     public ClientResponse<Response> create(String csid, PermissionRole permRole) {
125         return rolePermissionProxy.create(csid, permRole);
126     }
127
128     /**
129      * delete given relationships between given role and permission(s).
130      *
131      * @param csid the csid
132      * @param permRole the perm role
133      * @return the client response
134      */
135     public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
136         return rolePermissionProxy.delete(csid, "delete", permRole);
137     }
138     
139     /**
140      * delete given relationships between given role and permission(s).
141      *
142      * @param csid the csid
143      * @return the client response
144      */
145     @Override
146     public ClientResponse<Response> delete(String csid) {
147         return rolePermissionProxy.delete(csid);
148     }
149 }