]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
bea5c333b3459ef88444bc11646e8dbc878a8f79
[tmp/jakarta-migration.git] /
1 /**     
2  * PermissionClient.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.Permission;
33 import org.collectionspace.services.authorization.PermissionsList;
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.spi.ResteasyProviderFactory;
38
39 /**
40  * A PermissionClient.
41
42  * @version $Revision:$
43  */
44 public class PermissionClient extends AbstractServiceClientImpl {
45
46     /**
47      *
48      */
49     private PermissionProxy permissionProxy;
50
51     /* (non-Javadoc)
52      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
53      */
54     public String getServicePathComponent() {
55         return "authorization/permissions";
56     }
57
58     /**
59      *
60      * Default constructor for PermissionClient class.
61      *
62      */
63     public PermissionClient() {
64         ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
65         RegisterBuiltin.register(factory);
66         setProxy();
67     }
68
69     /**
70      * allow to reset proxy as per security needs
71      */
72     public void setProxy() {
73         if (useAuth()) {
74             permissionProxy = ProxyFactory.create(PermissionProxy.class,
75                     getBaseURL(), getHttpClient());
76         } else {
77             permissionProxy = ProxyFactory.create(PermissionProxy.class,
78                     getBaseURL());
79         }
80     }
81
82     /**
83      * @return
84      * @see org.collectionspace.hello.client.PermissionProxy#readList()
85      */
86     public ClientResponse<PermissionsList> readList() {
87         return permissionProxy.readList();
88
89     }
90
91     public ClientResponse<PermissionsList> readSearchList(String resourceName) {
92         return permissionProxy.readSearchList(resourceName);
93
94     }
95
96     /**
97      * @param csid
98      * @return
99      * @see org.collectionspace.hello.client.PermissionProxy#getAccount(java.lang.String)
100      */
101     public ClientResponse<Permission> read(String csid) {
102         return permissionProxy.read(csid);
103     }
104
105     /**
106      * @param permission
107      * @return
108      * @see org.collectionspace.hello.client.PermissionProxy#create(org.collectionspace.services.permission.Permission)
109      */
110     public ClientResponse<Response> create(Permission permission) {
111         return permissionProxy.create(permission);
112     }
113
114     /**
115      * @param csid
116      * @param permission
117      * @return
118      * @see org.collectionspace.hello.client.PermissionProxy#updateAccount(java.lang.Long, org.collectionspace.services.permission.Permission)
119      */
120     public ClientResponse<Permission> update(String csid, Permission permission) {
121         return permissionProxy.update(csid, permission);
122     }
123
124     /**
125      * @param csid
126      * @return
127      * @see org.collectionspace.hello.client.PermissionProxy#deleteAccount(java.lang.Long)
128      */
129     public ClientResponse<Response> delete(String csid) {
130         return permissionProxy.delete(csid);
131     }
132 }