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);
}
}
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;
}
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);
}
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;
}
}
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;
}
Aggregations