01: package org.objectweb.salome_tmf.api;
02:
03: public class Permission {
04:
05: public static int ALLOW_CREATE_TEST = 2;
06: public static int ALLOW_UPDATE_TEST = 4;
07: public static int ALLOW_DELETE_TEST = 8;
08:
09: public static int ALLOW_CREATE_CAMP = 16;
10: public static int ALLOW_UPDATE_CAMP = 32;
11: public static int ALLOW_DELETE_CAMP = 64;
12: public static int ALLOW_EXECUT_CAMP = 128;
13:
14: public static int permission = 0;
15:
16: public static void setPermission(int perm) {
17: permission = perm;
18: if (Api.isDEBUG()) {
19: Util.log("[Permission->setPermission] : " + perm);
20: Util.log("[Permission->setPermission] canDeleteTest : "
21: + canDeleteTest());
22: Util.log("[Permission->setPermission] canCreateTest : "
23: + canCreateTest());
24: Util.log("[Permission->setPermission] canUpdateTest : "
25: + canUpdateTest());
26: Util.log("[Permission->setPermission] canDeleteCamp : "
27: + canDeleteCamp());
28: Util.log("[Permission->setPermission] canCreateCamp : "
29: + canCreateCamp());
30: Util.log("[Permission->setPermission] canUpdateCamp : "
31: + canUpdateCamp());
32: Util.log("[Permission->setPermission] canExecutCamp : "
33: + canExecutCamp());
34: }
35: }
36:
37: static public boolean canCreateTest() {
38: return (((permission & ALLOW_CREATE_TEST) == ALLOW_CREATE_TEST) || canDeleteTest());
39: }
40:
41: static public boolean canUpdateTest() {
42: return (((permission & ALLOW_UPDATE_TEST) == ALLOW_UPDATE_TEST) || canCreateTest());
43: }
44:
45: static public boolean canDeleteTest() {
46: return ((permission & ALLOW_DELETE_TEST) == ALLOW_DELETE_TEST);
47: }
48:
49: static public boolean canCreateCamp() {
50: return (((permission & ALLOW_CREATE_CAMP) == ALLOW_CREATE_CAMP) || canDeleteCamp());
51: }
52:
53: static public boolean canUpdateCamp() {
54: return (((permission & ALLOW_UPDATE_CAMP) == ALLOW_UPDATE_CAMP) || canCreateCamp());
55: }
56:
57: static public boolean canDeleteCamp() {
58: return ((permission & ALLOW_DELETE_CAMP) == ALLOW_DELETE_CAMP);
59: }
60:
61: static public boolean canExecutCamp() {
62: return ((permission & ALLOW_EXECUT_CAMP) == ALLOW_EXECUT_CAMP);
63: }
64:
65: }
|