Search in sources :

Example 1 with MCRAccessStore

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

the class MCRWCMSAccessResource method createOrUpdate.

@POST
public String createOrUpdate(@QueryParam("webPageID") String webPageID, @QueryParam("perm") String perm, @QueryParam("ruleID") String ruleID) {
    MCRAccessStore accessStore = MCRAccessStore.getInstance();
    JsonObject returnObject = new JsonObject();
    if (MCRLayoutUtilities.hasRule(perm, webPageID)) {
        MCRRuleMapping ruleMap = accessStore.getAccessDefinition(perm, MCRLayoutUtilities.getWebpageACLID(webPageID));
        ruleMap.setRuleId(ruleID);
        accessStore.updateAccessDefinition(ruleMap);
    } else {
        MCRRuleMapping ruleMap = new MCRRuleMapping();
        ruleMap.setCreator(MCRSessionMgr.getCurrentSession().getUserInformation().getUserID());
        ruleMap.setCreationdate(new Date());
        ruleMap.setPool(perm);
        ruleMap.setRuleId(ruleID);
        ruleMap.setObjId(MCRLayoutUtilities.getWebpageACLID(webPageID));
        accessStore.createAccessDefinition(ruleMap);
    }
    JsonObject doneObject = new JsonObject();
    returnObject.addProperty("type", "editDone");
    returnObject.add("edit", doneObject);
    doneObject.addProperty("ruleId", MCRLayoutUtilities.getRuleID(perm, webPageID));
    doneObject.addProperty("ruleDes", MCRLayoutUtilities.getRuleDescr(perm, webPageID));
    return returnObject.toString();
}
Also used : MCRRuleMapping(org.mycore.access.mcrimpl.MCRRuleMapping) JsonObject(com.google.gson.JsonObject) MCRAccessStore(org.mycore.access.mcrimpl.MCRAccessStore) Date(java.util.Date) POST(javax.ws.rs.POST)

Example 2 with MCRAccessStore

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

the class MCRWCMSAccessResource method delete.

@DELETE
public String delete(@QueryParam("webPageID") String webPageID, @QueryParam("perm") String perm) {
    JsonObject returnObject = new JsonObject();
    if (!MCRLayoutUtilities.hasRule(perm, webPageID)) {
        throw new WebApplicationException(Status.NOT_FOUND);
    }
    MCRAccessStore accessStore = MCRAccessStore.getInstance();
    MCRRuleMapping ruleMap = accessStore.getAccessDefinition(perm, MCRLayoutUtilities.getWebpageACLID(webPageID));
    accessStore.deleteAccessDefinition(ruleMap);
    JsonObject doneObject = new JsonObject();
    returnObject.addProperty("type", "editDone");
    returnObject.add("edit", doneObject);
    return returnObject.toString();
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) MCRRuleMapping(org.mycore.access.mcrimpl.MCRRuleMapping) JsonObject(com.google.gson.JsonObject) MCRAccessStore(org.mycore.access.mcrimpl.MCRAccessStore) DELETE(javax.ws.rs.DELETE)

Example 3 with MCRAccessStore

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

the class MCRLayoutUtilities method getRuleID.

public static String getRuleID(String permission, String webpageID) {
    MCRAccessStore as = MCRAccessStore.getInstance();
    String ruleID = as.getRuleID(getWebpageACLID(webpageID), permission);
    if (ruleID != null) {
        return ruleID;
    } else {
        return "";
    }
}
Also used : MCRAccessStore(org.mycore.access.mcrimpl.MCRAccessStore)

Aggregations

MCRAccessStore (org.mycore.access.mcrimpl.MCRAccessStore)3 JsonObject (com.google.gson.JsonObject)2 MCRRuleMapping (org.mycore.access.mcrimpl.MCRRuleMapping)2 Date (java.util.Date)1 DELETE (javax.ws.rs.DELETE)1 POST (javax.ws.rs.POST)1 WebApplicationException (javax.ws.rs.WebApplicationException)1