]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
442c23b88f7bb687a8837cab05bc6bae1bcf493c
[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 import org.apache.http.HttpStatus;
32 import org.collectionspace.services.authorization.perms.Permission;
33 import org.collectionspace.services.authorization.perms.PermissionsList;
34 import org.collectionspace.services.description.ServiceDescription;
35
36 /**
37  * A PermissionClient.
38
39  * @version $Revision:$
40  */
41 public class PermissionClient extends AbstractServiceClientImpl<PermissionsList, Permission, Permission, PermissionProxy> {
42         public static final String SERVICE_NAME = "authorization/permissions";
43         public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;       
44         public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
45         public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/";     
46     
47         public PermissionClient() throws Exception {
48                 super();
49         }
50
51         public PermissionClient(String clientPropertiesFilename) throws Exception {
52                 super(clientPropertiesFilename);
53         }
54
55         /* (non-Javadoc)
56      * @see org.collectionspace.services.client.AbstractServiceClientImpl#getServicePathComponent()
57      */
58     @Override
59         public String getServicePathComponent() {
60         return SERVICE_PATH_COMPONENT;
61     }
62
63         @Override
64         public String getServiceName() {
65                 return SERVICE_NAME;
66         }
67
68         @Override
69         public Class<PermissionProxy> getProxyClass() {
70                 return PermissionProxy.class;
71         }
72         
73         /*
74          * CRUD+L Methods
75          */
76         
77     /**
78      * @return
79      * @see org.collectionspace.hello.client.PermissionProxy#readList()
80      */
81         @Override
82     public Response readList() {
83         return getProxy().readList();
84
85     }
86
87     public Response readSearchList(String resourceName) {
88         return getProxy().readSearchList(resourceName);
89
90     }
91
92     /**
93      * @param csid
94      * @return
95      * @see org.collectionspace.hello.client.PermissionProxy#getAccount(java.lang.String)
96      */
97     @Override
98     public Response read(String csid) {
99         return getProxy().read(csid);
100     }
101
102     /**
103      * @param permission
104      * @return
105      * @see org.collectionspace.hello.client.PermissionProxy#create(org.collectionspace.services.permission.Permission)
106      */
107     @Override
108     public Response create(Permission permission) {
109         return getProxy().create(permission);
110     }
111
112     /**
113      * @param csid
114      * @param permission
115      * @return
116      * @see org.collectionspace.hello.client.PermissionProxy#updateAccount(java.lang.Long, org.collectionspace.services.permission.Permission)
117      */
118     @Override
119     public Response update(String csid, Permission permission) {
120         return getProxy().update(csid, permission);
121     }
122     
123         @Override
124         public ServiceDescription getServiceDescription() {
125                 ServiceDescription result = null;
126                 
127         Response res = getProxy().getServiceDescription();
128         if (res.getStatus() == HttpStatus.SC_OK) {
129                 result = (ServiceDescription) res.readEntity(ServiceDescription.class);
130         }
131         
132         return result;
133         }
134 }