Search in sources :

Example 1 with DecisionVerdict

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);
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DecisionVerdict

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));
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DecisionVerdict

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;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with DecisionVerdict

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;
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DecisionVerdict

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());
}
Also used : PostResult(org.collectiveone.common.dto.PostResult) UUID(java.util.UUID) DecisionVerdict(org.collectiveone.modules.governance.DecisionVerdict) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PostResult (org.collectiveone.common.dto.PostResult)5 DecisionVerdict (org.collectiveone.modules.governance.DecisionVerdict)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 UUID (java.util.UUID)3