use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class FormatAction method execute.
/**
* @see org.kuali.kfs.kns.web.struts.action.KualiAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PdpAuthorizationService authorizationService = SpringContext.getBean(PdpAuthorizationService.class);
Person kualiUser = GlobalVariables.getUserSession().getPerson();
String methodToCall = findMethodToCall(form, request);
if (!authorizationService.hasFormatPermission(kualiUser.getPrincipalId())) {
throw new AuthorizationException(kualiUser.getPrincipalName(), methodToCall, kualiUser.getCampusCode());
}
return super.execute(mapping, form, request, response);
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class AccountingLineAccessibleValidation method validate.
/**
* Validates that the given accounting line is accessible for editing by the current user.
* <strong>This method expects a document as the first parameter and an accounting line as the second</strong>
*
* @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[])
*/
@Override
public boolean validate(AttributedDocumentEvent event) {
final Person currentUser = GlobalVariables.getUserSession().getPerson();
if (accountingDocumentForValidation instanceof Correctable) {
final String errorDocumentNumber = ((FinancialSystemDocumentHeader) accountingDocumentForValidation.getDocumentHeader()).getFinancialDocumentInErrorNumber();
if (StringUtils.isNotBlank(errorDocumentNumber)) {
return true;
}
}
final AccountingLineAuthorizer accountingLineAuthorizer = lookupAccountingLineAuthorizer();
final Set<String> currentNodes = accountingDocumentForValidation.getDocumentHeader().getWorkflowDocument().getCurrentNodeNames();
final boolean lineIsAccessible = accountingLineAuthorizer.hasEditPermissionOnAccountingLine(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), currentUser, true, currentNodes);
final boolean isAccessible = accountingLineAuthorizer.hasEditPermissionOnField(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), KFSPropertyConstants.ACCOUNT_NUMBER, lineIsAccessible, true, currentUser, currentNodes);
boolean valid = true;
boolean isExceptionNode = isExceptionNode(event.getDocument());
if (!isAccessible) {
// if only object code changed and the user has edit permissions on object code, that's ok
if (event instanceof UpdateAccountingLineEvent) {
final boolean isObjectCodeAccessible = accountingLineAuthorizer.hasEditPermissionOnField(accountingDocumentForValidation, accountingLineForValidation, getAccountingLineCollectionProperty(), KFSPropertyConstants.FINANCIAL_OBJECT_CODE, lineIsAccessible, true, currentUser, currentNodes);
final boolean onlyObjectCodeChanged = onlyObjectCodeChanged(((UpdateAccountingLineEvent) event).getAccountingLine(), ((UpdateAccountingLineEvent) event).getUpdatedAccountingLine());
if (isObjectCodeAccessible && onlyObjectCodeChanged) {
return true;
}
}
if (isPreqDiscountRecreate(event)) {
return true;
}
// KFSPTS-2253
if (!isExceptionNode) {
final String principalName = currentUser.getPrincipalName();
final String[] chartErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE), accountingLineForValidation.getChartOfAccountsCode(), principalName };
// KFSPTS-1273 : fixing an exisiting issue. Limit to REQ and POA. Broader solution need more work.
if (event instanceof UpdateAccountingLineEvent) {
// if (CollectionUtils.isEmpty(GlobalVariables.getMessageMap().getErrorPath()) && event instanceof UpdateAccountingLineEvent) {
GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(event.getErrorPathPrefix() + "." + KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
} else {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
}
final String[] accountErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.ACCOUNT_NUMBER), accountingLineForValidation.getAccountNumber(), principalName };
// KFSPTS-1273 : fixing an exisiting issue. Limit to REQ and POA. Broader solution need more work.
if (event instanceof UpdateAccountingLineEvent) {
GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(event.getErrorPathPrefix() + "." + KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
} else {
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
}
}
// end KFSPTS-2253
} else if (event instanceof AddAccountingLineEvent && isAccountNode(event.getDocument()) && !isAccountingLineFo(event.getDocument()) && !isDiscountTradeInAccount()) {
final String principalName = currentUser.getPrincipalName();
final String[] chartErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE), accountingLineForValidation.getChartOfAccountsCode(), principalName };
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, convertEventToMessage(event), chartErrorParams);
final String[] accountErrorParams = new String[] { getDataDictionaryService().getAttributeLabel(accountingLineForValidation.getClass(), KFSPropertyConstants.ACCOUNT_NUMBER), accountingLineForValidation.getAccountNumber(), principalName };
GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, convertEventToMessage(event), accountErrorParams);
valid = false;
}
return (isAccessible || isExceptionNode) && valid;
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class PurchasingAccountsPayableDocumentPresentationController method canEdit.
/**
* None of the PURAP documents allowing editing by adhoc requests
*
* @see org.kuali.kfs.krad.document.authorization.DocumentPresentationControllerBase#canEdit(org.kuali.kfs.krad.document.Document)
*/
@Override
public boolean canEdit(Document document) {
Person currentUser = GlobalVariables.getUserSession().getPerson();
WorkflowDocument kwf = document.getDocumentHeader().getWorkflowDocument();
// Adding this check so that the initiator will always be able to edit the document (before initial submission)
if (kwf.getInitiatorPrincipalId().equals(currentUser.getPrincipalId()) && (kwf.isInitiated() || kwf.isSaved())) {
return true;
}
if (!document.getDocumentHeader().getWorkflowDocument().isCompletionRequested() && SpringContext.getBean(FinancialSystemWorkflowHelperService.class).isAdhocApprovalRequestedForPrincipal(document.getDocumentHeader().getWorkflowDocument(), GlobalVariables.getUserSession().getPrincipalId())) {
return false;
}
return super.canEdit(document);
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class LaborCalculatedSalaryFoundationTrackerLookupableHelperServiceImpl method getInquiryUrl.
/**
* @see org.kuali.kfs.kns.lookup.AbstractLookupableHelperServiceImpl#getInquiryUrl(org.kuali.kfs.kns.bo.BusinessObject,
* java.lang.String)
*/
@Override
public HtmlData getInquiryUrl(BusinessObject bo, String propertyName) {
if (KFSPropertyConstants.POSITION_NUMBER.equals(propertyName)) {
LaborCalculatedSalaryFoundationTracker CSFTracker = (LaborCalculatedSalaryFoundationTracker) bo;
AbstractPositionDataDetailsInquirableImpl positionDataDetailsInquirable = new PositionDataDetailsInquirableImpl();
// KUALI-1321 Gets the Person object via the employee ID and populates the name property.
Person person = SpringContext.getBean(PersonService.class).getPersonByEmployeeId(CSFTracker.getEmplid());
if (person != null) {
// CSFTracker.setName(person.getLastName() + ", " + person.getFirstName());
}
Map<String, String> fieldValues = new HashMap<String, String>();
fieldValues.put(propertyName, CSFTracker.getPositionNumber());
BusinessObject positionData = positionDataDetailsInquirable.getBusinessObject(fieldValues);
return positionData == null ? new AnchorHtmlData(KFSConstants.EMPTY_STRING, KFSConstants.EMPTY_STRING) : positionDataDetailsInquirable.getInquiryUrl(positionData, propertyName);
}
return (new LaborCalculatedSalaryFoundationTrackerInquirableImpl()).getInquiryUrl(bo, propertyName);
}
use of org.kuali.rice.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherAction method hasFullEdit.
protected boolean hasFullEdit(CuDisbursementVoucherDocument document) {
final Person user = GlobalVariables.getUserSession().getPerson();
final TransactionalDocumentPresentationController documentPresentationController = (TransactionalDocumentPresentationController) getDocumentHelperService().getDocumentPresentationController(document);
final TransactionalDocumentAuthorizer documentAuthorizer = (TransactionalDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(document);
Set<String> documentActions = documentPresentationController.getDocumentActions(document);
documentActions = documentAuthorizer.getDocumentActions(document, user, documentActions);
Set<String> editModes = documentPresentationController.getEditModes(document);
editModes = documentAuthorizer.getEditModes(document, user, editModes);
return documentActions.contains(KRADConstants.KUALI_ACTION_CAN_EDIT) && editModes.contains("fullEntry");
}
Aggregations