KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > acl > ACLResourceWrapper


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
//
14
// NK 24.01.2002 - added in Jahia
15
//
16

17 package org.jahia.services.acl;
18
19 import org.jahia.services.usermanager.JahiaUser;
20
21
22 /**
23  * This is a wrapper to manipulate any resource that implements the ACLResourceInterface.
24  *
25  * @author Khue Nguyen
26  * @version 1.0
27  * @see ACLResourceInterface
28  */

29 public final class ACLResourceWrapper {
30
31     // the resource
32
private ACLResourceInterface res;
33
34
35     //--------------------------------------------------------------------------
36
public ACLResourceWrapper (ACLResourceInterface res) {
37         this.res = res;
38     }
39
40     //--------------------------------------------------------------------------
41
/**
42      * Returns the res' ACL
43      *
44      * @return Return the ACL.
45      */

46     public JahiaBaseACL getACL () {
47         return res.getACL ();
48     }
49
50     //--------------------------------------------------------------------------
51
/**
52      * Returns the res' ACL id
53      *
54      * @return Return the res' ACL id.
55      */

56     public int getAclID () {
57         int id = -1;
58         try {
59             id = getACL ().getID ();
60         } catch (JahiaACLException ex) {
61             // This exception should not happen ... :)
62
}
63         return id;
64     }
65
66     //--------------------------------------------------------------------------
67
/**
68      * Check if the user has administration access on the specified resource.
69      *
70      * @param user Reference to the user.
71      *
72      * @return Return true if the user has admin access for the specified res,
73      * or false in any other case.
74      */

75     public final boolean checkAdminAccess (JahiaUser user) {
76         return ACLResource.checkAdminAccess (res, user);
77     }
78
79
80     //--------------------------------------------------------------------------
81
/**
82      * Check if the user has read access on the specified res.
83      *
84      * @param user Reference to the user.
85      *
86      * @return Return true if the user has read access for the specified res,
87      * or false in any other case.
88      */

89     public final boolean checkReadAccess (JahiaUser user) {
90         return ACLResource.checkReadAccess (res, user);
91     }
92
93
94     //--------------------------------------------------------------------------
95
/**
96      * Check if the user has Write access on the specified res.
97      *
98      * @param user Reference to the user.
99      *
100      * @return Return true if the user has read access for the specified res,
101      * or false in any other case.
102      */

103     public final boolean checkWriteAccess (JahiaUser user) {
104         return ACLResource.checkWriteAccess (res, user);
105     }
106
107
108 }
109
110
Popular Tags