Search in sources :

Example 6 with MCRAccessRule

use of org.mycore.access.mcrimpl.MCRAccessRule in project mycore by MyCoRe-Org.

the class MCRAclEditorResource method list.

@GET
@MCRRestrictedAccess(MCRAclEditorPermission.class)
public String list() {
    Collection<String> ruleIDs = RULE_STORE.retrieveAllIDs();
    JsonArray jsonARules = new JsonArray();
    JsonObject jsonObj = new JsonObject();
    for (String id : ruleIDs) {
        MCRAccessRule rule = RULE_STORE.getRule(id);
        JsonObject jsonO = new JsonObject();
        jsonO.addProperty("ruleID", id);
        jsonO.addProperty("desc", rule.getDescription());
        jsonO.addProperty("ruleSt", rule.getRuleString());
        jsonARules.add(jsonO);
    }
    jsonObj.add("rules", jsonARules);
    JsonArray jsonAAccess = new JsonArray();
    Collection<String> ids = ACCESS_STORE.getDistinctStringIDs();
    for (String id : ids) {
        Collection<String> pools = ACCESS_STORE.getPoolsForObject(id);
        for (String pool : pools) {
            JsonObject jsonO = new JsonObject();
            jsonO.addProperty("accessID", id);
            jsonO.addProperty("accessPool", pool);
            jsonO.addProperty("rule", ACCESS_STORE.getRuleID(id, pool));
            jsonAAccess.add(jsonO);
        }
    }
    jsonObj.add("access", jsonAAccess);
    return jsonObj.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) MCRAccessRule(org.mycore.access.mcrimpl.MCRAccessRule) GET(javax.ws.rs.GET) MCRRestrictedAccess(org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess)

Aggregations

MCRAccessRule (org.mycore.access.mcrimpl.MCRAccessRule)6 JsonObject (com.google.gson.JsonObject)4 Date (java.util.Date)3 MCRRestrictedAccess (org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess)3 JsonParser (com.google.gson.JsonParser)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 JsonArray (com.google.gson.JsonArray)1 UnknownHostException (java.net.UnknownHostException)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 MCRAccessControlSystem (org.mycore.access.mcrimpl.MCRAccessControlSystem)1 MCRIPAddress (org.mycore.access.mcrimpl.MCRIPAddress)1 MCRRuleStore (org.mycore.access.mcrimpl.MCRRuleStore)1 MCRUserInformation (org.mycore.common.MCRUserInformation)1 MCRRestAPIError (org.mycore.restapi.v1.errors.MCRRestAPIError)1 MCRRestAPIException (org.mycore.restapi.v1.errors.MCRRestAPIException)1