Permission.java
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.enums;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author tuukka
*/
public enum Permission {
// NOTE. add conversion Value to RoleRight
// PERMISSION("Description"),
LOGIN("User can see loginbutton(r), create new user(w), invite others (x)"),
USER_MANAGEMENT("View all users(r), modify users(w), execute actions for user(x) "),
ACCOUNT_MANAGEMENT("Manage others account events. view(r), modify(w) and create (shop)(x)"),
BILL("View all bills(r), Mark paid & modify(w), and create own bills (x)"),
MAP("view maps(r), Modify(w), reserve places from maps(x)"),
ROLE_MANAGEMENT("User has right to view(r), modify(w) and assign(x) roles"),
PRODUCT("View(r), modify(w), and shop(x) products"),
SHOP("View own shopped events(r), Modify own AccountEvents() and Shop(x)"),
GAME("View(r) own, modify(w), view all(X)"),
POLL("View answers(r), create polls (w), answer to polls(x)");
private String description;
private static final Logger logger = LoggerFactory.getLogger(Permission.class);
public static final String EXECUTE = "/EXECUTE";
public static final String READ = "/READ";
public static final String WRITE = "/WRITE";
public static Permission getPermission(String name) {
if (name == null || name.isEmpty()) {
logger.warn("Trying to get permission for empty name {}", name);
return null;
}
try {
return valueOf(name);
} catch (IllegalArgumentException x) {
throw x;
}
}
Permission(String description) {
this.description = description;
}
Permission() {
}
public String getName() {
return name();
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
public String append(RolePermission permission) {
return name() + "/" + permission.name();
}
}