]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
00bfe095867879a639f074db97455f0646e9f614
[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     /* (non-Javadoc)
51      * @see 
52      */
53     public String getServicePathComponent() {
54         return "authorization/roles";
55     }
56
57     /**
58      *
59      * Default constructor for PermissionRoleClient class.
60      *
61      */
62     public RolePermissionClient() {
63         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
64         RegisterBuiltin.register(factory);
65         setProxy();
66     }
67
68     /* (non-Javadoc)
69      * @see org.collectionspace.services.client.CollectionSpaceClient#getProxy()
70      */
71     @Override
72     public CollectionSpaceProxy getProxy() {
73         return this.rolePermissionProxy;
74     }
75
76     /**
77      * allow to reset proxy as per security needs.
78      */
79     public void setProxy() {
80         if (useAuth()) {
81             rolePermissionProxy = ProxyFactory.create(RolePermissionProxy.class,
82                     getBaseURL(), new ApacheHttpClientExecutor(getHttpClient()));
83         } else {
84             rolePermissionProxy = ProxyFactory.create(RolePermissionProxy.class,
85                     getBaseURL());
86         }
87     }
88
89     /**
90      * Read.
91      *
92      * @param csid the csid
93      * @return the client response
94      * @see
95      */
96     public ClientResponse<PermissionRole> read(String csid) {
97         return rolePermissionProxy.read(csid);
98     }
99
100     /**
101      * Read.
102      *
103      * @param csid the csid
104      * @param prcsid the prcsid
105      * @return the client response
106      */
107     public ClientResponse<PermissionRole> read(String csid, String prcsid) {
108         return rolePermissionProxy.read(csid, prcsid);
109     }
110
111     /**
112      * Creates the relationships.
113      *
114      * @param csid the csid
115      * @param permRole the perm role
116      * @return the client response
117      * @see
118      */
119     public ClientResponse<Response> create(String csid, PermissionRole permRole) {
120         return rolePermissionProxy.create(csid, permRole);
121     }
122
123     /**
124      * delete given relationships between given role and permission(s).
125      *
126      * @param csid the csid
127      * @param permRole the perm role
128      * @return the client response
129      */
130     public ClientResponse<Response> delete(String csid, PermissionRole permRole) {
131         return rolePermissionProxy.delete(csid, "delete", permRole);
132     }
133     
134     /**
135      * delete given relationships between given role and permission(s).
136      *
137      * @param csid the csid
138      * @return the client response
139      */
140     @Override
141     public ClientResponse<Response> delete(String csid) {
142         return rolePermissionProxy.delete(csid);
143     }
144 }