use of org.collectiveone.modules.governance.DecisionVerdict in project CollectiveOneWebapp by CollectiveOne.
the class InitiativesController method addTagToInitiative.
@RequestMapping(path = "/initiative/{initiativeId}/tags", method = RequestMethod.POST)
public PostResult addTagToInitiative(@PathVariable("initiativeId") String initiativeIdStr, @RequestBody InitiativeTagDto tagDto) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
UUID initiativeId = UUID.fromString(initiativeIdStr);
DecisionVerdict verdict = governanceService.canEdit(initiativeId, getLoggedUser().getC1Id());
if (verdict == DecisionVerdict.DENIED) {
return new PostResult("error", "not authorized", "");
}
return initiativeService.addTagToInitiative(initiativeId, tagDto);
}
use of org.collectiveone.modules.governance.DecisionVerdict in project CollectiveOneWebapp by CollectiveOne.
the class InitiativesController method deleteTagFromInitiative.
@RequestMapping(path = "/initiative/{initiativeId}/tags/{tagId}", method = RequestMethod.DELETE)
public PostResult deleteTagFromInitiative(@PathVariable("initiativeId") String initiativeIdStr, @PathVariable("tagId") String tagIdStr) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
UUID initiativeId = UUID.fromString(initiativeIdStr);
DecisionVerdict verdict = governanceService.canEdit(initiativeId, getLoggedUser().getC1Id());
if (verdict == DecisionVerdict.DENIED) {
return new PostResult("error", "not authorized", "");
}
return initiativeService.deleteTagFromInitiative(initiativeId, UUID.fromString(tagIdStr));
}
use of org.collectiveone.modules.governance.DecisionVerdict in project CollectiveOneWebapp by CollectiveOne.
the class AssignationController method revertAssignation.
@RequestMapping(path = "/assignation/{assignationId}/revert", method = RequestMethod.PUT)
public PostResult revertAssignation(@PathVariable("assignationId") String assignationId) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
DecisionVerdict canRevert = governanceService.canRevertAssignation(assignationService.getInitiativeIdOf(UUID.fromString(assignationId)), getLoggedUser().getC1Id());
if (canRevert == DecisionVerdict.DENIED) {
return new PostResult("error", "revert of assignation not authorized", "");
}
PostResult result = assignationService.revertAssignation(UUID.fromString(assignationId), getLoggedUser().getC1Id());
return result;
}
use of org.collectiveone.modules.governance.DecisionVerdict in project CollectiveOneWebapp by CollectiveOne.
the class AssignationController method deleteAssignation.
@RequestMapping(path = "/assignation/{assignationId}/delete", method = RequestMethod.PUT)
public PostResult deleteAssignation(@PathVariable("assignationId") String assignationId) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
DecisionVerdict canDelete = governanceService.canDeleteAssignation(assignationService.getInitiativeIdOf(UUID.fromString(assignationId)), getLoggedUser().getC1Id());
if (canDelete == DecisionVerdict.DENIED) {
return new PostResult("error", "delete of assignation not authorized", "");
}
PostResult result = assignationService.deleteAssignation(UUID.fromString(assignationId), getLoggedUser().getC1Id());
return result;
}
use of org.collectiveone.modules.governance.DecisionVerdict in project CollectiveOneWebapp by CollectiveOne.
the class InitiativesController method deleteInitiative.
@RequestMapping(path = "/initiative/{initiativeId}", method = RequestMethod.DELETE)
public PostResult deleteInitiative(@PathVariable("initiativeId") String initiativeIdStr) {
if (getLoggedUser() == null) {
return new PostResult("error", "endpoint enabled users only", null);
}
UUID initiativeId = UUID.fromString(initiativeIdStr);
DecisionVerdict canRevert = governanceService.canDeleteInitiative(initiativeId, getLoggedUser().getC1Id());
if (canRevert == DecisionVerdict.DENIED) {
return new PostResult("error", "revert of assignation not authorized", "");
}
return initiativeService.delete(initiativeId, getLoggedUser().getC1Id());
}
Aggregations