public boolean isAuthorizedToDeleteNarrative(Narrative narrative, Person user) { final ProposalDevelopmentDocument pdDocument = (ProposalDevelopmentDocument) narrative.getDevelopmentProposal().getDocument(); // First, the user must have the MODIFY_NARRATIVE permission. This is really // a sanity check. If they have the MODIFY_NARRATIVE_RIGHT, then they are // required to have the MODIFY_NARRATIVE permission. KcDocumentRejectionService documentRejectionService = getKcDocumentRejectionService(); boolean rejectedDocument = documentRejectionService.isDocumentOnInitialNode( pdDocument.getDocumentHeader().getWorkflowDocument()); boolean hasPermission = false; boolean inWorkflow = getKcWorkflowService().isInWorkflow(pdDocument); if ((!inWorkflow || rejectedDocument) && !pdDocument.getDevelopmentProposal().getSubmitFlag()) { if (getModifyNarrativePermission(pdDocument, user)) { hasPermission = hasNarrativeRight( user.getPrincipalId(), narrative, NarrativeRight.MODIFY_NARRATIVE_RIGHT); } } return hasPermission; }
protected boolean isAuthorizedToViewNarrative(Narrative narrative, Person user) { final ProposalDevelopmentDocument pdDocument = (ProposalDevelopmentDocument) narrative.getDevelopmentProposal().getDocument(); // First, the user must have the VIEW_NARRATIVE permission. This is really // a sanity check. If they have the VIEW or MODIFY_NARRATIVE_RIGHT, then they are // required to have the VIEW_NARRATIVE permission. boolean hasPermission = false; if (getKcAuthorizationService() .hasPermission(user.getPrincipalId(), pdDocument, PermissionConstants.VIEW_NARRATIVE)) { hasPermission = hasNarrativeRight(user.getPrincipalId(), narrative, NarrativeRight.VIEW_NARRATIVE_RIGHT) || hasNarrativeRight( user.getPrincipalId(), narrative, NarrativeRight.MODIFY_NARRATIVE_RIGHT); } if (!hasPermission) { hasPermission = getUnitAuthorizationService() .hasPermission( user.getPrincipalId(), pdDocument.getDevelopmentProposal().getOwnedByUnitNumber(), Constants.MODULE_NAMESPACE_PROPOSAL_DEVELOPMENT, PermissionConstants.VIEW_NARRATIVE) || getKcWorkflowService().hasWorkflowPermission(user.getPrincipalId(), pdDocument); } return hasPermission; }
protected boolean isAuthorizedToReplaceNarrative(Narrative narrative, Person user) { final ProposalDevelopmentDocument pdDocument = (ProposalDevelopmentDocument) narrative.getDevelopmentProposal().getDocument(); boolean hasPermission = false; if (!pdDocument.getDevelopmentProposal().getSubmitFlag() && getModifyNarrativePermission(pdDocument, user)) { hasPermission = hasNarrativeRight(user.getPrincipalId(), narrative, NarrativeRight.MODIFY_NARRATIVE_RIGHT) || isAuthorizedToAlterProposalData(pdDocument, user); } return hasPermission; }
protected boolean isAuthorizedToModifyNarrative(Narrative narrative, Person user) { final ProposalDevelopmentDocument pdDocument = (ProposalDevelopmentDocument) narrative.getDevelopmentProposal().getDocument(); boolean rejectedDocument = getKcDocumentRejectionService() .isDocumentOnInitialNode(pdDocument.getDocumentHeader().getWorkflowDocument()); boolean hasPermission = false; boolean inWorkflow = getKcWorkflowService().isInWorkflow(pdDocument); if ((!inWorkflow || rejectedDocument) && !pdDocument.getDevelopmentProposal().getSubmitFlag()) { hasPermission = getModifyNarrativePermission(pdDocument, user); } else if (inWorkflow && !rejectedDocument && !pdDocument.getDevelopmentProposal().getSubmitFlag()) { if (getModifyNarrativePermission(pdDocument, user)) { hasPermission = getModifyNarrativePermission(pdDocument, user); } } return hasPermission; }