KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > security > Operation


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.security;
11
12 /**
13  * This class is somekinda enumeration of the operations possible within
14  * the security context
15  * @javadoc
16  * @author Eduard Witteveen
17  * @version $Id: Operation.java,v 1.11 2004/03/08 17:46:32 michiel Exp $
18  */

19 public final class Operation {
20     /** int value for the read Operation*/
21     public final static int READ_INT = 0;
22
23     /** int value for the write Operation*/
24     public final static int WRITE_INT = 1;
25
26     /** int value for the create Operation*/
27     public final static int CREATE_INT = 2;
28
29     /** int value for the change relation Operation */
30     public final static int CHANGE_RELATION_INT = 3;
31
32     /** int value for the remove Operation */
33     public final static int DELETE_INT = 4;
34
35     /**
36      * int value for change context operation
37      * @since MMBase-1.7
38      */

39     public final static int CHANGE_CONTEXT_INT = 6;
40
41     /**
42      * @deprecated use CHANGE_CONTEXT_INT
43      */

44     public final static int CHANGECONTEXT_INT = CHANGE_CONTEXT_INT;
45
46
47     /** Identifier for read operation, which is used for reading information*/
48     public final static Operation READ = new Operation(READ_INT, "read");
49
50     /** Identifier for write operation, which is used for writing information*/
51     public final static Operation WRITE = new Operation(WRITE_INT, "write");
52
53     /**
54      * Identifier for create operation, which is used for creating a new node.
55      * This only applies on NodeManagers (builders)
56      */

57     public final static Operation CREATE = new Operation(CREATE_INT, "create");
58
59     /**
60      * Identifier for changing the source and/or destination field of a
61      * relation.
62      */

63     public final static Operation CHANGE_RELATION = new Operation(CHANGE_RELATION_INT, "change relation");
64
65     /** Identifier for remove operation, which is used when removing a node */
66     public final static Operation DELETE = new Operation(DELETE_INT, "delete");
67
68     /**
69      * Identifier for change context operation, which is used when changing the context of a node
70      * @since MMBase-1.7
71      */

72     public final static Operation CHANGE_CONTEXT = new Operation(CHANGE_CONTEXT_INT, "change context");
73
74
75     /**
76      * Identifier for change context operation, which is used when changing the context of a node
77      * @deprecated Use CHANGE_CONTEXT
78      */

79     public final static Operation CHANGECONTEXT = CHANGE_CONTEXT;
80
81     /**
82      * Private constructor, to prevent creation of new Operations
83      */

84     private Operation(int level, String JavaDoc description) {
85         this.level = level;
86         this.description = description;
87     }
88
89     /**
90      * This method gives back the internal int value of the Operation,
91      * which can be used in switch statements
92      * @return the internal int value
93      */

94     public int getInt(){
95         return level;
96     }
97
98     /**
99      * @return a string containing the description of the operation
100      */

101     public String JavaDoc toString(){
102         return description;
103     }
104
105     /** the int value of the instance */
106     private int level;
107
108     /** the description of this operation */
109     private String JavaDoc description;
110     
111     /** retrieve a Operation by a given string */
112     public static Operation getOperation(String JavaDoc operationString) {
113         if(READ.toString().equals(operationString)) return READ;
114         if(WRITE.toString().equals(operationString)) return WRITE;
115         if(CREATE.toString().equals(operationString)) return CREATE;
116         if(CHANGE_RELATION.toString().equals(operationString)) return CHANGE_RELATION;
117         if(DELETE.toString().equals(operationString)) return DELETE;
118         if(CHANGE_CONTEXT.toString().equals(operationString)) return CHANGE_CONTEXT;
119         throw new org.mmbase.security.SecurityException("Could not find a operation for the operation with name:" + operationString);
120     }
121 }
122
Popular Tags