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();
}
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();
}
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 "";
}
}
Aggregations