Permission.java 1.71 KB
/*
 * 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)"),
    USER_MANAGEMENT("User has right to view all users(r), modify users(w), execute actions for user(x) "),
    ACCOUNT_MANAGEMENT("Manage users account events. view(r), modify(w) and create(x)"),
    BILL("View bills(r), Mark paid & modify(w), and create (buy) 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 shopped events(r), Modify AccountEvents() and Shop(x)"),
    GAME("View(r) own, write(w) modify, view all(X)");
    private String description;

    private static final Logger logger = LoggerFactory.getLogger(Permission.class);

    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;
    }
}