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