KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.jahia.services.acl;
14
15 import java.io.Serializable JavaDoc;
16 import java.util.Vector JavaDoc;
17
18 import org.apache.log4j.Logger;
19 import org.jahia.exceptions.JahiaException;
20
21 /**
22  * This is the public class for an ACL, that will mostly be used when
23  * manipulating ACLs in the content API.
24  *
25  * @author Fulco Houkes
26  * @version 1.0
27  */

28 public class JahiaBaseACL extends JahiaAbstractACL implements Serializable JavaDoc {
29     // +--+- ... -+--+--+--+
30
// | n| | 2| 1| 0|
31
// +--+- ... -+--+--+--+
32
// | | |
33
// | | +--- READ_RIGHTS
34
// | +------ WRITE_RIGHTS
35
// +--------- ADMIN_RIGHTS
36

37     public static final int READ_RIGHTS = 0;
38
39     public static final int WRITE_RIGHTS = 1;
40
41     public static final int ADMIN_RIGHTS = 2;
42
43     public static final int RIGHTS_MAX_OFFSET = 3;
44
45     public static final int ALL_RIGHTS = 0x7; // 1 + 2 + 4
46

47     public static final int RIGHTS_INHERITANCE_FLAG = 1 << RIGHTS_MAX_OFFSET; // 1<<3;
48

49     private static final Logger logger = Logger.getLogger(JahiaAbstractACL.class);
50
51     /**
52      * Default Constructor
53      *
54      * @param aclID
55      * ACL ID to construct
56      * @throws ACLNotFoundException
57      * @throws JahiaException
58      */

59     public JahiaBaseACL(int aclID) throws ACLNotFoundException, JahiaException {
60         super(aclID);
61     }
62
63     // -------------------------------------------------------------------------
64
/**
65      * @throws JahiaException
66      */

67     public JahiaBaseACL() throws JahiaException {
68         super();
69     }
70
71     // -------------------------------------------------------------------------
72
/**
73      * @return A vector of string {"Read", "Write", "Admin"}
74      */

75     public Vector JavaDoc getBitdesc() {
76         return new Vector JavaDoc(getActionNames());
77     }
78
79     public static char[] getSymbols() {
80         int size = getActionNames().size();
81         if (size > getSharedActions().length)
82             size = getSharedActions().length;
83         char[] symbols = new char[size];
84         System.arraycopy(getSharedActions(), 0, symbols, 0, size);
85         return symbols;
86     }
87
88     // -------------------------------------------------------------------------
89
public final int size() {
90         return getActionNames().size();
91     }
92
93     /**
94      * Clone the current ACL.
95      *
96      * @return The new ACL cloned, null if unsuccessfull.
97      */

98     public Object JavaDoc clone() {
99
100         try {
101             JahiaBaseACL baseACL = new JahiaBaseACL();
102             baseACL.mACL = (JahiaACL) mACL.clone();
103             return baseACL;
104         } catch (JahiaException ex) {
105         }
106         return null;
107     }
108
109 }
110
Popular Tags