01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.repository.acl;
17:
18: /**
19: * Enumeration of all available ACL Permissions.
20: */
21: public enum AclPermission {
22: READ("read", 0), WRITE("write", 1), PUBLISH("publish", 2), DELETE(
23: "delete", 3);
24:
25: private String name;
26: private int pos;
27:
28: private AclPermission(String name, int pos) {
29: this .name = name;
30: this .pos = pos;
31: }
32:
33: /**
34: * Returns a number corresponding to the position in the {@link #ENUM} array.
35: *
36: * @deprecated This method will be removed in a future version. It has no purpose
37: * since moving to Java 1.5 enums.
38: */
39: public int getPos() {
40: return pos;
41: }
42:
43: public String toString() {
44: return name;
45: }
46:
47: public static AclPermission fromString(String value) {
48: if (value.equals("read"))
49: return AclPermission.READ;
50: else if (value.equals("write"))
51: return AclPermission.WRITE;
52: else if (value.equals("publish"))
53: return AclPermission.PUBLISH;
54: else if (value.equals("delete"))
55: return AclPermission.DELETE;
56: else
57: throw new RuntimeException("Unrecognized ACL permission: "
58: + value);
59: }
60:
61: /**
62: * @deprecated This member will be removed in a future version. It has no purpose
63: * since moving to Java 1.5 enums.
64: */
65: public static final AclPermission[] ENUM = { READ, WRITE, PUBLISH,
66: DELETE };
67: }
|