Search in sources :

Example 6 with Principal

use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.

the class ActionTakenServiceImpl method validateActionTaken.

public void validateActionTaken(ActionTaken actionTaken) {
    LOG.debug("Enter validateActionTaken(..)");
    List<WorkflowServiceErrorImpl> errors = new ArrayList<WorkflowServiceErrorImpl>();
    String documentId = actionTaken.getDocumentId();
    if (documentId == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken documentid null.", "actiontaken.documentid.empty", actionTaken.getActionTakenId().toString()));
    } else if (getRouteHeaderService().getRouteHeader(documentId) == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken documentid invalid.", "actiontaken.documentid.invalid", actionTaken.getActionTakenId().toString()));
    }
    String principalId = actionTaken.getPrincipalId();
    if (StringUtils.isBlank(principalId)) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken personid null.", "actiontaken.personid.empty", actionTaken.getActionTakenId().toString()));
    } else {
        Principal principal = KimApiServiceLocator.getIdentityService().getPrincipal(principalId);
        if (principal == null) {
            errors.add(new WorkflowServiceErrorImpl("ActionTaken personid invalid.", "actiontaken.personid.invalid", actionTaken.getActionTakenId().toString()));
        }
    }
    String actionTakenCd = actionTaken.getActionTaken();
    if (actionTakenCd == null || actionTakenCd.trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken cd null.", "actiontaken.actiontaken.empty", actionTaken.getActionTakenId().toString()));
    } else if (!KewApiConstants.ACTION_TAKEN_CD.containsKey(actionTakenCd)) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken invalid.", "actiontaken.actiontaken.invalid", actionTaken.getActionTakenId().toString()));
    }
    if (actionTaken.getActionDate() == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken actiondate null.", "actiontaken.actiondate.empty", actionTaken.getActionTakenId().toString()));
    }
    if (actionTaken.getDocVersion() == null) {
        errors.add(new WorkflowServiceErrorImpl("ActionTaken docversion null.", "actiontaken.docverion.empty", actionTaken.getActionTakenId().toString()));
    }
    LOG.debug("Exit validateActionRequest(..) ");
    if (!errors.isEmpty()) {
        throw new WorkflowServiceErrorException("ActionRequest Validation Error", errors);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) ArrayList(java.util.ArrayList) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Example 7 with Principal

use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.

the class IdentityServiceImpl method getDefaultNamesForPrincipalId.

@Cacheable(cacheNames = EntityName.CACHE_NAME, key = "'{getDefaultNamesForPrincipalId}-principalId=' + #p0")
@Override
public EntityName getDefaultNamesForPrincipalId(String principalId) {
    Map<String, String> criteria = new HashMap<>();
    criteria.put(KIMPropertyConstants.Principal.PRINCIPAL_ID, principalId);
    Principal principal = businessObjectService.findByPrimaryKey(Principal.class, criteria);
    if (null != principal) {
        criteria.clear();
        criteria.put(KIMPropertyConstants.Entity.ENTITY_ID, principal.getEntityId());
        criteria.put("DFLT_IND", "Y");
        criteria.put("ACTV_IND", "Y");
        EntityName name = businessObjectService.findByPrimaryKey(EntityName.class, criteria);
        if (name == null) {
            // to make this simple for now, assume if there is no default name that this is a system entity we are
            // dealing with here
            name = new EntityName();
            name.setLastName(principal.getPrincipalName().toUpperCase(Locale.US));
        }
        return name;
    }
    return null;
}
Also used : EntityName(org.kuali.kfs.kim.impl.identity.name.EntityName) HashMap(java.util.HashMap) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 8 with Principal

use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.

the class RoleServiceImpl method createDelegateMember.

@CacheEvict(value = { Role.CACHE_NAME, RoleMembership.CACHE_NAME, RoleMember.CACHE_NAME, DelegateMember.CACHE_NAME, RoleResponsibility.CACHE_NAME, DelegateType.CACHE_NAME }, allEntries = true)
@Override
public DelegateMember createDelegateMember(DelegateMember delegateMember) throws IllegalArgumentException, IllegalStateException {
    // ensure object not empty
    incomingParamCheck(delegateMember, "delegateMember");
    // check key is null
    if (delegateMember.getDelegationMemberId() != null) {
        throw new IllegalStateException("the delegate member already exists: " + delegateMember.getDelegationMemberId());
    }
    // check delegate exists
    String delegationId = delegateMember.getDelegationId();
    incomingParamCheck(delegationId, "delegationId");
    DelegateType delegate = getKimDelegationImpl(delegationId);
    if (delegate == null) {
        throw new IllegalStateException("the delegate does not exist: " + delegationId);
    }
    // check member exists
    String memberId = delegateMember.getMemberId();
    incomingParamCheck(memberId, "memberId");
    Principal kPrincipal = KimApiServiceLocator.getIdentityService().getPrincipal(memberId);
    if (kPrincipal == null) {
        throw new IllegalStateException("the user does not exist: " + memberId);
    }
    // create member delegate
    String kimTypeId = getRoleLite(delegate.getRoleId()).getKimTypeId();
    List<DelegateMemberAttributeData> attrBos = KimAttributeData.createFrom(DelegateMemberAttributeData.class, delegateMember.getAttributes(), kimTypeId);
    delegateMember.setAttributeDetails(attrBos);
    return getResponsibilityInternalService().saveDelegateMember(delegateMember);
}
Also used : DelegateMemberAttributeData(org.kuali.kfs.kim.impl.common.delegate.DelegateMemberAttributeData) DelegateType(org.kuali.kfs.kim.impl.common.delegate.DelegateType) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 9 with Principal

use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method setAssignedUserPrincipalName.

public void setAssignedUserPrincipalName(String assignedUserPrincipalName) {
    this.assignedUserPrincipalName = assignedUserPrincipalName;
    // each time this field changes we need to update the assigned user ID and ref obj to keep consistent
    // this code can be moved to where PO is saved and with validation too, which may be more appropriate
    Principal assignedUser = null;
    if (assignedUserPrincipalName != null) {
        assignedUser = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(assignedUserPrincipalName);
    }
    if (assignedUser != null) {
        assignedUserPrincipalId = assignedUser.getPrincipalId();
    } else {
        assignedUserPrincipalId = null;
    }
}
Also used : Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Example 10 with Principal

use of org.kuali.kfs.kim.impl.identity.principal.Principal in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method getAssignedUserPrincipalName.

public String getAssignedUserPrincipalName() {
    // init this field when PO is first loaded and assigned user exists in PO
    if (assignedUserPrincipalName == null && assignedUserPrincipalId != null) {
        // extra caution in case ref obj didn't get refreshed
        // if (assignedUser == null)
        // this.refreshReferenceObject("assignedUser");
        Principal assignedUser = KimApiServiceLocator.getIdentityService().getPrincipal(assignedUserPrincipalId);
        this.assignedUserPrincipalName = assignedUser.getPrincipalName();
    }
    // otherwise return its current value directly
    return assignedUserPrincipalName;
}
Also used : Principal(org.kuali.kfs.kim.impl.identity.principal.Principal)

Aggregations

Principal (org.kuali.kfs.kim.impl.identity.principal.Principal)22 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)3 IWantDocUserOptions (edu.cornell.kfs.module.purap.businessobject.IWantDocUserOptions)2 List (java.util.List)2 EntityEmployment (org.kuali.kfs.kim.impl.identity.employment.EntityEmployment)2 EntityName (org.kuali.kfs.kim.impl.identity.name.EntityName)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)1 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)1 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)1 Map (java.util.Map)1 ActionForward (org.apache.struts.action.ActionForward)1 DateTime (org.joda.time.DateTime)1 Account (org.kuali.kfs.coa.businessobject.Account)1 KfsKimDocDelegateMember (org.kuali.kfs.coa.identity.KfsKimDocDelegateMember)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 KualiInteger (org.kuali.kfs.core.api.util.type.KualiInteger)1 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)1