use of org.mycore.access.mcrimpl.MCRRuleMapping in project mycore by MyCoRe-Org.
the class MCRAclEditorResource method add.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@MCRRestrictedAccess(MCRAclEditorPermission.class)
public Response add(String data) {
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
String accessID = jsonObject.get("accessID").getAsString();
String accessPool = jsonObject.get("accessPool").getAsString();
String rule = jsonObject.get("rule").getAsString();
if (RULE_STORE.existsRule(rule) && !accessID.equals("") && !accessPool.equals("")) {
MCRRuleMapping accessRule = createRuleMap(accessID, accessPool, rule);
if (!ACCESS_STORE.existsRule(accessID, accessPool)) {
ACCESS_STORE.createAccessDefinition(accessRule);
return Response.ok().build();
} else {
return Response.status(Status.CONFLICT).build();
}
} else {
return Response.status(Status.CONFLICT).build();
}
}
use of org.mycore.access.mcrimpl.MCRRuleMapping in project mycore by MyCoRe-Org.
the class MCRAclEditorResource method createRuleMap.
private MCRRuleMapping createRuleMap(String accessID, String accessPool, String rule) {
String uid = MCRSessionMgr.getCurrentSession().getUserInformation().getUserID();
MCRRuleMapping accessRule = new MCRRuleMapping();
accessRule.setObjId(accessID);
accessRule.setPool(accessPool);
accessRule.setRuleId(rule);
accessRule.setCreationdate(new Date());
accessRule.setCreator(uid);
return accessRule;
}
Aggregations