use of org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess in project mycore by MyCoRe-Org.
the class MCRClassificationEditorResource method save.
@POST
@Path("save")
@MCRRestrictedAccess(MCRClassificationWritePermission.class)
@Consumes(MediaType.APPLICATION_JSON)
public Response save(String json) {
JsonStreamParser jsonStreamParser = new JsonStreamParser(json);
if (jsonStreamParser.hasNext()) {
JsonArray saveObjArray = jsonStreamParser.next().getAsJsonArray();
List<JsonObject> saveList = new ArrayList<>();
for (JsonElement jsonElement : saveObjArray) {
saveList.add(jsonElement.getAsJsonObject());
}
saveList.sort(new IndexComperator());
for (JsonObject jsonObject : saveList) {
String status = getStatus(jsonObject);
SaveElement categ = getCateg(jsonObject);
MCRJSONCategory parsedCateg = parseJson(categ.getJson());
if ("update".equals(status)) {
new UpdateOp(parsedCateg, jsonObject).run();
} else if ("delete".equals(status)) {
deleteCateg(categ.getJson());
} else {
return Response.status(Status.BAD_REQUEST).build();
}
}
// Status.CONFLICT
return Response.status(Status.OK).build();
} else {
return Response.status(Status.BAD_REQUEST).build();
}
}
use of org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess in project mycore by MyCoRe-Org.
the class MCRWebCLIResource method start.
@GET
@MCRRestrictedAccess(MCRWebCLIPermission.class)
@Produces(MediaType.TEXT_HTML)
public Response start() {
InputStream mainGui = getClass().getResourceAsStream("/META-INF/resources/modules/webcli/index.html");
MCRSession mcrSession = MCRSessionMgr.getCurrentSession();
LOGGER.info("MyCore Session REST ID: {}", mcrSession.getID());
LOGGER.info("REST ThreadID: {}", Thread.currentThread().getName());
return Response.ok(mainGui).build();
}
use of org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess in project mycore by MyCoRe-Org.
the class MCRAclEditorResource method addRule.
@POST
@Path("rule")
@MCRRestrictedAccess(MCRAclEditorPermission.class)
@Consumes(MediaType.APPLICATION_JSON)
public String addRule(String data) {
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
String ruleDesc = jsonObject.get("ruleDesc").getAsString();
String ruleText = jsonObject.get("ruleText").getAsString();
MCRAccessRule accessRule;
try {
accessRule = createAccessRule(ruleDesc, ruleText);
} catch (Exception e) {
return "";
}
RULE_STORE.createRule(accessRule);
return accessRule.getId();
}
use of org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess 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.frontend.jersey.filter.access.MCRRestrictedAccess in project mycore by MyCoRe-Org.
the class MCRAclEditorResource method removeRule.
@DELETE
@Path("rule")
@MCRRestrictedAccess(MCRAclEditorPermission.class)
@Consumes(MediaType.APPLICATION_JSON)
public Response removeRule(String data) {
JsonParser jsonParser = new JsonParser();
JsonObject jsonObject = jsonParser.parse(data).getAsJsonObject();
String ruleID = jsonObject.get("ruleID").getAsString();
if (!ACCESS_STORE.isRuleInUse(ruleID)) {
RULE_STORE.deleteRule(ruleID);
return Response.ok().build();
} else {
return Response.status(Status.CONFLICT).build();
}
}
Aggregations