/** * @see * org.kuali.kra.proposaldevelopment.service.NarrativeAuthZService#getDefaultNarrativeRight(java.lang.String, * org.kuali.kra.proposaldevelopment.document.ProposalDevelopmentDocument) */ public NarrativeRight getDefaultNarrativeRight(String userId, ProposalDevelopmentDocument doc) { NarrativeRight right; if (kraAuthorizationService.hasPermission(userId, doc, PermissionConstants.MODIFY_NARRATIVE)) { right = NarrativeRight.MODIFY_NARRATIVE_RIGHT; } else if (kraAuthorizationService.hasPermission( userId, doc, PermissionConstants.VIEW_NARRATIVE)) { right = NarrativeRight.VIEW_NARRATIVE_RIGHT; } else { right = NarrativeRight.NO_NARRATIVE_RIGHT; } return right; }
/** * Initialize the Authorizations for a new proposal. The initiator/creator is assigned the * Aggregator role. * * @param document the proposal development document */ protected void initializeAuthorization(ProposalDevelopmentDocument document) { String userId = GlobalVariables.getUserSession().getPrincipalId(); KraAuthorizationService kraAuthService = KraServiceLocator.getService(KraAuthorizationService.class); kraAuthService.addRole(userId, RoleConstants.AGGREGATOR, document); }
/** * Does the given user have the given permission for the proposal? * * @param userId the user's username * @param doc the Proposal Development Document * @param permissionName the name of the permission * @return true if user has permission; otherwise false */ protected boolean hasPermission( String userId, ProposalDevelopmentDocument doc, String permissionName) { KraAuthorizationService kraAuthorizationService = KraServiceLocator.getService(KraAuthorizationService.class); return kraAuthorizationService.hasPermission(userId, doc, permissionName); }