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