Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2012 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kim.impl.identity;
 
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;

This is a description of what this class does - kellerj don't forget to fill this in.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class PersonServiceImpl implements PersonService {
 
 	private static Logger LOG = Logger.getLoggerPersonServiceImpl.class );
 	protected static final String ENTITY_EXT_ID_PROPERTY_PREFIX = "externalIdentifiers.";
 	protected static final String ENTITY_AFFILIATION_PROPERTY_PREFIX = "affiliations.";
 	protected static final String ENTITY_TYPE_PROPERTY_PREFIX = "entityTypeContactInfos.";
 	protected static final String ENTITY_EMAIL_PROPERTY_PREFIX = "entityTypeContactInfos.emailAddresses.";
 	protected static final String ENTITY_PHONE_PROPERTY_PREFIX = "entityTypeContactInfos.phoneNumbers.";
 	protected static final String ENTITY_ADDRESS_PROPERTY_PREFIX = "entityTypeContactInfos.addresses.";
 	protected static final String ENTITY_NAME_PROPERTY_PREFIX = "names.";
 	protected static final String PRINCIPAL_PROPERTY_PREFIX = "principals.";
 	protected static final String ENTITY_EMPLOYEE_ID_PROPERTY_PREFIX = "employmentInformation.";
 	// KULRICE-4442 Special handling for extension objects
 	protected static final String EXTENSION = "extension";
 	
 
 	protected List<StringpersonEntityTypeCodes = new ArrayList<String>( 4 );
 	// String that can be passed to the lookup framework to create an type = X OR type = Y criteria
     
 	{
 		// init the criteria which will need to be applied to every lookup against
 		// the identity data tables
 		
 		// create the field mappings between the Person object and the KimEntity object
		.put.."entityTypeContactInfos.emailAddresses.emailAddress" );
		.put.."entityTypeContactInfos.phoneNumbers.phoneNumber" );
		.put.."entityTypeContactInfos.addresses.line1" );
		.put.."entityTypeContactInfos.addresses.line2" );
		.put.."entityTypeContactInfos.addresses.line3" );
		.put.."entityTypeContactInfos.addresses.city" );
		.put.."entityTypeContactInfos.addresses.stateProvinceCode" );
		.put.."entityTypeContactInfos.addresses.postalCode" );
		.put.."entityTypeContactInfos.addresses.countryCode" );
		.put.."affiliations.affiliationTypeCode" );
		.put.."externalIdentifiers.externalIdentifierTypeCode" );
		.put.."externalIdentifiers.externalId" );		
		.put.."employmentInformation.employeeTypeCode" );
		.put.."employmentInformation.employeeStatusCode" );
		.put.."employmentInformation.employeeId" );
		.put.."employmentInformation.baseSalaryAmount" );
		.put.."employmentInformation.primaryDepartmentCode" );
	}


	public Person getPerson(String principalId) {
		if ( StringUtils.isBlank(principalId) ) {
			return null;
		}
		// get the corresponding principal
		final Principal principal = getIdentityService().getPrincipalprincipalId );
		// get the identity
		if ( principal != null ) {
         	// convert the principal and identity to a Person
            // skip if the person was created from the DB cache
            if (entity != null ) {
                return convertEntityToPersonentityprincipal );
            }
		}
		return null;
	}
	protected PersonImpl convertEntityToPersonEntityDefault entityPrincipal principal ) {
		try {
			// get the EntityEntityType for the EntityType corresponding to a Person
			for ( String entityTypeCode :  ) {
				EntityTypeContactInfoDefault entType = entity.getEntityTypeentityTypeCode );
				// if no "person" identity type present for the given principal, skip to the next type in the list
				if ( entType == null ) {
					continue;
				}
				// attach the principal and identity objects
				// PersonImpl has logic to pull the needed elements from the KimEntity-related classes
				return new PersonImplprincipalentityentityTypeCode );
			}
			return null;
catch ( Exception ex ) {
			// allow runtime exceptions to pass through
			if ( ex instanceof RuntimeException ) {
				throw (RuntimeException)ex;
			}
			throw new RuntimeException"Problem building person object"ex );
		}
	}


	public Person getPersonByPrincipalName(String principalName) {
		if ( StringUtils.isBlank(principalName) ) {
			return null;
		}
		// get the corresponding principal
		final Principal principal = getIdentityService().getPrincipalByPrincipalNameprincipalName );
		// get the identity
		if ( principal != null ) {
            final EntityDefault entity = getIdentityService().getEntityDefault(principal.getEntityId());
            // convert the principal and identity to a Person
            if ( entity != null ) {
                return convertEntityToPersonentityprincipal );
            }
		}
		return null;
	}
	public Person getPersonByEmployeeId(String employeeId) {
		if ( StringUtils.isBlankemployeeId  ) ) {
			return null;
		}
		final List<Personpeople = findPeople( Collections.singletonMap(..employeeId) );
		if ( !people.isEmpty() ) {
			return people.get(0);
		}
	    // If no person was found above, check for inactive records
        EntityDefault entity = getIdentityService().getEntityDefaultByEmployeeId(employeeId);
        if (entity != null) {
            if ( !entity.getPrincipals().isEmpty() ) {
                Principal principal = getIdentityService().getPrincipal(entity.getPrincipals().get(0).getPrincipalId());
                if (principal != null) {
                    return convertEntityToPersonentityprincipal );
                }  
            }
        }
		return null;
	}

	public List<PersonfindPeople(Map<StringStringcriteria) {
		return findPeople(criteriatrue);
	}

	public List<PersonfindPeople(Map<StringStringcriteriaboolean unbounded) {
		List<Personpeople = null;
		// protect from NPEs
		if ( criteria == null ) {
			criteria = Collections.emptyMap();
		}
		// make a copy so it can be modified safely in this method
		criteria = new HashMap<StringString>( criteria );
		// extract the role lookup parameters and then remove them since later code will not know what to do with them
		String roleName = criteria.get"lookupRoleName" );
		String namespaceCode = criteria.get"lookupRoleNamespaceCode" );
		criteria.remove("lookupRoleName");
		criteria.remove("lookupRoleNamespaceCode");
		if ( StringUtils.isNotBlank(namespaceCode) && StringUtils.isNotBlank(roleName) ) {
			Integer searchResultsLimit = org.kuali.rice.kns.lookup.LookupUtils.getSearchResultsLimit(PersonImpl.class);
			int searchResultsLimitInt = .;
			if (searchResultsLimit != null) {
				searchResultsLimitInt = searchResultsLimit.intValue();
			}
			if ( .isDebugEnabled() ) {
				.debug("Performing Person search including role filter: " + namespaceCode + "/" + roleName );
			}
			if ( criteria.size() == 1 && criteria.containsKey(..) ) { // if only active is specified
				if ( .isDebugEnabled() ) {
					.debug"Only active criteria specified, running role search first" );
				}
				// in this case, run the role lookup first and pass those results to the person lookup
				Collection<StringprincipalIds = getRoleService().getRoleMemberPrincipalIds(namespaceCoderoleName,  Collections.<StringString>emptyMap());
				StringBuffer sb = new StringBuffer(principalIds.size()*15);
				Iterator<Stringpi = principalIds.iterator();
				while ( pi.hasNext() ) {
					sb.appendpi.next() );
					if ( pi.hasNext() ) sb.append'|' );
				}
				// add the list of principal IDs to the lookup so that only matching Person objects are returned
				people = findPeopleInternal(criteriafalse); // can allow internal method to filter here since no more filtering necessary				
else if ( !criteria.isEmpty() ) { // i.e., person criteria are specified
				if ( .isDebugEnabled() ) {
					.debug"Person criteria also specified, running that search first" );
				}
				// run the person lookup first
				people = findPeopleInternal(criteriatrue); // get all, since may need to be filtered
				// TODO - now check if these people have the given role
				// build a principal list
				List<StringprincipalIds = peopleToPrincipalIdspeople );
				// get sublist of principals that have the given roles
				principalIds = getRoleService().getPrincipalIdSubListWithRole(principalIdsnamespaceCoderoleName,  Collections.<StringString>emptyMap());
				// re-convert into people objects, wrapping in CollectionIncomplete if needed
				if ( !unbounded && principalIds.size() > searchResultsLimitInt ) {
					int actualResultSize = principalIds.size();
					// trim the list down before converting to people
					principalIds = new ArrayList<String>(principalIds).subList(0, searchResultsLimitInt); // yes, this is a little wasteful
					people = getPeople(principalIds); // convert the results to people
					people = new CollectionIncomplete<Person>( people.subList(0, searchResultsLimitInt), new Long(actualResultSize) );
else {
					people = getPeople(principalIds);
				}
else { // only role criteria specified
				if ( .isDebugEnabled() ) {
					.debug"No Person criteria specified - only using role service." );
				}
				// run the role criteria to get the principals with the role
				Collection<StringprincipalIds = getRoleService().getRoleMemberPrincipalIds(namespaceCoderoleName,  Collections.<StringString>emptyMap());
				if ( !unbounded && principalIds.size() > searchResultsLimitInt ) {
					int actualResultSize = principalIds.size();
					// trim the list down before converting to people
					principalIds = new ArrayList<String>(principalIds).subList(0, searchResultsLimitInt); // yes, this is a little wasteful
					people = getPeople(principalIds); // convert the results to people
					people = new CollectionIncomplete<Person>( people.subList(0, searchResultsLimitInt), new Long(actualResultSize) );
else {
					people = getPeople(principalIds); // convert the results to people
				}
			}
else {
			if ( .isDebugEnabled() ) {
				.debug"No Role criteria specified, running person lookup as normal." );
			}
			people = findPeopleInternal(criteriaunbounded);
		}
		// The following change is for KULRICE-5694 - It prevents duplicate rows from being returned for the 
		// person inquiry (In this case, duplicate meaning same entityId, principalId, and principalNm).  
		// This allows for multiple rows to be returned if an entityID has more then one principal name
		// or more than one principal ID.  
        Set<StringpeopleNoDupsSet = new HashSet<String>();
        List<PersonpeopleNoDupsList = new ArrayList<Person>();
	    for (Iterator<Personiter = people.iterator(); iter.hasNext(); ) {
	        Person person = iter.next();
	        if (peopleNoDupsSet.add(person.getEntityId() + person.getPrincipalId() + person.getPrincipalName())) {
	            peopleNoDupsList.add(person);
	        }
	    }
	     
	    people.clear();
	    people.addAll(peopleNoDupsList);
	    return people;
	}
	@SuppressWarnings("unchecked")
	protected List<PersonfindPeopleInternal(Map<String,Stringcriteriaboolean unbounded ) {
		// convert the criteria to a form that can be used by the ORM layer
        //TODO convert this to the new criteria predicates
		Map<String,StringentityCriteria = convertPersonPropertiesToEntityPropertiescriteria );
        Predicate predicate = PredicateUtils.convertMapToPredicate(entityCriteria);
        QueryByCriteria.Builder queryBuilder = QueryByCriteria.Builder.create();
        queryBuilder.setPredicates(predicate);
		List<Personpeople = new ArrayList<Person>();
		for ( EntityDefault e : qr.getResults() ) {
			// get to get all principals for the identity as well
			for ( Principal p : e.getPrincipals() ) {
				people.addconvertEntityToPersonep ) );
			}
		}
		return people;
	}
		if ( .isDebugEnabled() ) {
			.debug"convertPersonPropertiesToEntityProperties: " + criteria );
		}
		boolean nameCriteria = false;
		boolean addressCriteria = false;
		boolean externalIdentifierCriteria = false;
		boolean affiliationCriteria = false;
		boolean affiliationDefaultOnlyCriteria = false;
		boolean phoneCriteria = false;
		boolean emailCriteria = false;
		boolean employeeIdCriteria = false;
		// add base lookups for all person lookups
		HashMap<String,StringnewCriteria = new HashMap<String,String>();
		newCriteria.putAll );
		newCriteria.put"entityTypeContactInfos.entityTypeCode" );
        if ( criteria != null ) {
			for ( String key : criteria.keySet() ) {
			    //check active radio button
	            if(key.equals(..)) {
	                newCriteria.put(..criteria.get(..));
	            } else {
	                // The following if statement enables the "both" button to work correctly.
	                if (!(criteria.containsKey(..))) {
	                    newCriteria.remove.. );
	                }
	            }
	            
				// if no value was passed, skip the entry in the Map
				if ( StringUtils.isEmptycriteria.get(key) ) ) {
					continue;
				}
				// check if the value needs to be encrypted
				// handle encrypted external identifiers
				if ( key.equals.. ) && StringUtils.isNotBlank(criteria.get(key)) ) {
					// look for a ext ID type property
						if ( StringUtils.isNotBlank(extIdTypeCode) ) {
							// if found, load that external ID Type via service
							// if that type needs to be encrypted, encrypt the value in the criteria map
							if ( extIdType != null && extIdType.isEncryptionRequired() ) {
								try {
									criteria.put(key
											CoreApiServiceLocator.getEncryptionService().encrypt(criteria.get(key))
											);
catch (GeneralSecurityException ex) {
									.error("Unable to encrypt value for external ID search of type " + extIdTypeCodeex );
								}								
							}
						}
					}
				}
				// convert the property to the Entity data model
				String entityProperty = .getkey );
				if ( entityProperty != null ) {
					newCriteria.putentityPropertycriteria.getkey ) );
else {
					entityProperty = key;
					// just pass it through if no translation present
					newCriteria.putkeycriteria.getkey ) );
				}
				// check if additional criteria are needed based on the types of properties specified
				if ( isNameEntityCriteriaentityProperty ) ) {
					nameCriteria = true;
				}
				if ( isExternalIdentifierEntityCriteriaentityProperty ) ) {
					externalIdentifierCriteria = true;
				}
				if ( isAffiliationEntityCriteriaentityProperty ) ) {
					affiliationCriteria = true;
				}
				if ( isAddressEntityCriteriaentityProperty ) ) {
					addressCriteria = true;
				}
				if ( isPhoneEntityCriteriaentityProperty ) ) {
					phoneCriteria = true;
				}
				if ( isEmailEntityCriteriaentityProperty ) ) {
					emailCriteria = true;
				}
				if ( isEmployeeIdEntityCriteriaentityProperty ) ) {
					employeeIdCriteria = true;
				}				
				// special handling for the campus code, since that forces the query to look
				// at the default affiliation record only
				if ( key.equals"campusCode" ) ) {
					affiliationDefaultOnlyCriteria = true;
				}
			if ( nameCriteria ) {
				newCriteria.put + "active""Y" );
				newCriteria.put + "defaultValue""Y" );
				//newCriteria.put(ENTITY_NAME_PROPERTY_PREFIX + "nameCode", "PRFR");//so we only display 1 result
			}
			if ( addressCriteria ) {
				newCriteria.put + "active""Y" );
				newCriteria.put + "defaultValue""Y" );
			}
			if ( phoneCriteria ) {
				newCriteria.put + "active""Y" );
				newCriteria.put + "defaultValue""Y" );
			}
			if ( emailCriteria ) {
				newCriteria.put + "active""Y" );
				newCriteria.put + "defaultValue""Y" );
			}
			if ( employeeIdCriteria ) {
				newCriteria.put + "active""Y" );
				newCriteria.put + "primary""Y" );
			}
			if ( affiliationCriteria ) {
				newCriteria.put + "active""Y" );
			}
			if ( affiliationDefaultOnlyCriteria ) {
				newCriteria.put + "defaultValue""Y" );
        }   
		if ( .isDebugEnabled() ) {
			.debug"Converted: " + newCriteria );
		}
		return newCriteria;		
	}
	protected boolean isNameEntityCriteriaString propertyName ) {
		return propertyName.startsWith );
	}
	protected boolean isAddressEntityCriteriaString propertyName ) {
		return propertyName.startsWith );
	}
	protected boolean isPhoneEntityCriteriaString propertyName ) {
		return propertyName.startsWith );
	}
	protected boolean isEmailEntityCriteriaString propertyName ) {
		return propertyName.startsWith );
	}
	protected boolean isEmployeeIdEntityCriteriaString propertyName ) {
	}
	protected boolean isAffiliationEntityCriteriaString propertyName ) {
	}
	protected boolean isExternalIdentifierEntityCriteriaString propertyName ) {
		return propertyName.startsWith );
	}

Get the entityTypeCode that can be associated with a Person. This will determine where EntityType-related data is pulled from within the KimEntity object. The codes in the list will be examined in the order present.
	}
	public void setPersonEntityTypeCodes(List<StringpersonEntityTypeCodes) {
		this. = personEntityTypeCodes;
		for ( String entityTypeCode : personEntityTypeCodes ) {
			if (  == null ) {
else {
			}
		}
	}
	protected List<PersongetPeopleCollection<StringprincipalIds ) {
		List<Personpeople = new ArrayList<Person>( principalIds.size() );
		for ( String principalId : principalIds ) {
			people.addgetPerson(principalId) );
		}
		return people;
	}
	protected List<StringpeopleToPrincipalIdsList<Personpeople ) {
		List<StringprincipalIds = new ArrayList<String>();
		for ( Person person : people ) {
			principalIds.addperson.getPrincipalId() );
		}
		return principalIds;
	}

	public List<PersongetPersonByExternalIdentifier(String externalIdentifierTypeCodeString externalId) {
		if (StringUtils.isBlankexternalIdentifierTypeCode ) || StringUtils.isBlankexternalId ) ) {
			return null;
		}
		Map<String,Stringcriteria = new HashMap<String,String>( 2 );
		criteria.put..externalIdentifierTypeCode );
		criteria.put..externalId );
		return findPeoplecriteria );
	}

    public Person updatePersonIfNecessary(String sourcePrincipalIdPerson currentPerson ) {
        if (currentPerson  == null // no person set
                || !StringUtils.equals(sourcePrincipalIdcurrentPerson.getPrincipalId() ) // principal ID mismatch
                || currentPerson.getEntityId() == null ) { // syntheticially created Person object
            Person person = getPersonsourcePrincipalId );
            // if a synthetically created person object is present, leave it - required for property derivation and the UI layer for
            // setting the principal name
            if ( person == null ) {
                if ( currentPerson != null && currentPerson.getEntityId() == null ) {
                    return currentPerson;
                }
            }
            // if both are null, create an empty object for property derivation
            if ( person == null && currentPerson == null ) {
            	try {
            		return new PersonImpl();
            	} catch ( Exception ex ) {
            		.error"unable to instantiate an object of type: " + getPersonImplementationClass() + " - returning null"ex );
            		return null;
            	}
            }
            return person;
        }
        // otherwise, no need to change the given object
        return currentPerson;
    }

    
Builds a map containing entries from the passed in Map that do NOT represent properties on an embedded Person object.
    private Map<String,StringgetNonPersonSearchCriteriaBusinessObject boMap<String,StringfieldValues) {
        Map<String,StringnonUniversalUserSearchCriteria = new HashMap<String,String>();
        for ( String propertyName : fieldValues.keySet() ) {
            if (!isPersonProperty(bopropertyName)) {
                nonUniversalUserSearchCriteria.put(propertyNamefieldValues.get(propertyName));
            }
        }
        return nonUniversalUserSearchCriteria;
    }
    private boolean isPersonProperty(BusinessObject boString propertyName) {
        try {
        	if ( ObjectUtils.isNestedAttributepropertyName ) // is a nested property
            		&& !StringUtils.contains(propertyName"add.") ) {// exclude add line properties (due to path parsing problems in PropertyUtils.getPropertyType)
        		Class<?> type = PropertyUtils.getPropertyType(bo, ObjectUtils.getNestedAttributePrefixpropertyName ));
        		// property type indicates a Person object
        		if ( type != null ) {
        			return Person.class.isAssignableFrom(type);
        		}
        		.warn"Unable to determine type of nested property: " + bo.getClass().getName() + " / " + propertyName );
        	}
        } catch (Exception ex) {
        	if ( .isDebugEnabled() ) {
        		.debug("Unable to determine if property on " + bo.getClass().getName() + " to a person object: " + propertyNameex );
        	}
        }
        return false;
    }
    
    
    @SuppressWarnings("unchecked")
    	if ( fieldValues == null ) {
    		return null;
    	}
    	if ( businessObject == null ) {
    		return fieldValues;
    	}
    	StringBuffer resolvedPrincipalIdPropertyName = new StringBuffer();
    	// save off all criteria which are not references to Person properties
    	// leave person properties out so they can be resolved and replaced by this method
        Map<String,StringprocessedFieldValues = getNonPersonSearchCriteria(businessObjectfieldValues);
        for ( String propertyName : fieldValues.keySet() ) {        	
            if (	!StringUtils.isBlank(fieldValues.get(propertyName))  // property has a value
            		&& isPersonProperty(businessObjectpropertyName// is a property on a Person object
            		) {
            	// strip off the prefix on the property
                String personPropertyName = ObjectUtils.getNestedAttributePrimitivepropertyName );
                // special case - the user ID 
                if ( StringUtils.equals..personPropertyName) ) {
                    Class targetBusinessObjectClass = null;
                    BusinessObject targetBusinessObject = null;
                    resolvedPrincipalIdPropertyName.setLength( 0 ); // clear the buffer without requiring a new object allocation on each iteration
                	// get the property name up until the ".principalName"
                	// this should be a reference to the Person object attached to the BusinessObject                	
                	String personReferenceObjectPropertyName = ObjectUtils.getNestedAttributePrefixpropertyName );
                	// check if the person was nested within another BO under the master BO.  If so, go up one more level
                	// otherwise, use the passed in BO class as the target class
                    if ( ObjectUtils.isNestedAttributepersonReferenceObjectPropertyName ) ) {
                        String targetBusinessObjectPropertyName = ObjectUtils.getNestedAttributePrefixpersonReferenceObjectPropertyName );
                        targetBusinessObject = (BusinessObject)ObjectUtils.getPropertyValuebusinessObjecttargetBusinessObjectPropertyName );
                        if (targetBusinessObject != null) {
                            targetBusinessObjectClass = targetBusinessObject.getClass();
                            resolvedPrincipalIdPropertyName.append(targetBusinessObjectPropertyName).append(".");
                        } else {
                            .error("Could not find target property '"+propertyName+"' in class "+businessObject.getClass().getName()+". Property value was null.");
                        }
                    } else { // not a nested Person property
                        targetBusinessObjectClass = businessObject.getClass();
                        targetBusinessObject = businessObject;
                    }
                    
                    if (targetBusinessObjectClass != null) {
                    	// use the relationship metadata in the KNS to determine the property on the
                    	// host business object to put back into the map now that the principal ID
                    	// (the value stored in application tables) has been resolved
                        String propName = ObjectUtils.getNestedAttributePrimitivepersonReferenceObjectPropertyName );
                        DataObjectRelationship rel = getBusinessObjectMetaDataService().getBusinessObjectRelationshiptargetBusinessObjectpropName );
                        if ( rel != null ) {
                            String sourcePrimitivePropertyName = rel.getParentAttributeForChildAttribute(..);
                            resolvedPrincipalIdPropertyName.append(sourcePrimitivePropertyName);
                        	// get the principal - for translation of the principalName to principalId
                            String principalName = fieldValues.getpropertyName );
                        	Principal principal = getIdentityService().getPrincipalByPrincipalNameprincipalName );
                            if (principal != null ) {
                                processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(), principal.getPrincipalId());
                            } else {
                                processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(), null);
                                try {
                                    // if the principalName is bad, then we need to clear out the Person object
                                    // and base principalId property
                                    // so that their values are no longer accidentally used or re-populate
                                    // the object
                                    ObjectUtils.setObjectProperty(targetBusinessObjectresolvedPrincipalIdPropertyName.toString(), null );
                                    ObjectUtils.setObjectProperty(targetBusinessObjectpropNamenull );
                                    ObjectUtils.setObjectProperty(targetBusinessObjectpropName + ".principalName"principalName );
                                } catch ( Exception ex ) {
                                    .error"Unable to blank out the person object after finding that the person with the given principalName does not exist."ex );
                                }
                            }
                        } else {
                        	.error"Missing relationship for " + propName + " on " + targetBusinessObjectClass.getName() );
                        }
                    } else { // no target BO class - the code below probably will not work
                        processedFieldValues.put(resolvedPrincipalIdPropertyName.toString(), null);
                    }
                }
            // if the property does not seem to match the definition of a Person property but it
            // does end in principalName then...
            // this is to handle the case where the user ID is on an ADD line - a case excluded from isPersonProperty()
            } else if (propertyName.endsWith("." + ..)){
                // if we're adding to a collection and we've got the principalName; let's populate universalUser
                String principalName = fieldValues.get(propertyName);
                if ( StringUtils.isNotEmptyprincipalName ) ) {
                    String containerPropertyName = propertyName;
                    if (containerPropertyName.startsWith(.)) {
                        containerPropertyName = StringUtils.substringAfterpropertyName. );
                    }
                    // get the class of the object that is referenced by the property name
                    // if this is not true then there's a principalName collection or primitive attribute 
                    // directly on the BO on the add line, so we just ignore that since something is wrong here
                    if ( ObjectUtils.isNestedAttributecontainerPropertyName ) ) {
                    	// the first part of the property is the collection name
                        String collectionName = StringUtils.substringBeforecontainerPropertyName"." );
                        // what is the class held by that collection?
                        // JHK: I don't like this.  This assumes that this method is only used by the maintenance
                        // document service.  If that will always be the case, this method should be moved over there.
                        Class<? extends BusinessObjectcollectionBusinessObjectClass = getMaintenanceDocumentDictionaryService()
                        		.getCollectionBusinessObjectClass(
                        				getMaintenanceDocumentDictionaryService()
                        						.getDocumentTypeName(businessObject.getClass()), collectionName);
                        if (collectionBusinessObjectClass != null) {
                            // we are adding to a collection; get the relationships for that object; 
                        	// is there one for personUniversalIdentifier?
                            List<DataObjectRelationshiprelationships =
                            		getBusinessObjectMetaDataService().getBusinessObjectRelationshipscollectionBusinessObjectClass );
                            // JHK: this seems like a hack - looking at all relationships for a BO does not guarantee that we get the right one
                            // JHK: why not inspect the objects like above?  Is it the property path problems because of the .add. portion?
                            for ( DataObjectRelationship rel : relationships ) {
                            	String parentAttribute = rel.getParentAttributeForChildAttribute.. );
                            	if ( parentAttribute == null ) {
                            		continue;
                            	}
                                // there is a relationship for personUserIdentifier; use that to find the universal user
                            	processedFieldValues.removepropertyName );
                        		String fieldPrefix = StringUtils.substringBeforeLast( StringUtils.substringBeforeLastpropertyName"." + .. ), "." );
                                String relatedPrincipalIdPropertyName = fieldPrefix + "." + parentAttribute;
                                // KR-683 Special handling for extension objects
                         	 	if(.equals(StringUtils.substringAfterLast(fieldPrefix".")) && .equals(StringUtils.substringBefore(parentAttribute".")))
                         	 	{
                         	 		relatedPrincipalIdPropertyName = fieldPrefix + "." + StringUtils.substringAfter(parentAttribute".");
                         	 	}
                                String currRelatedPersonPrincipalId = processedFieldValues.get(relatedPrincipalIdPropertyName);
                                if ( StringUtils.isBlankcurrRelatedPersonPrincipalId ) ) {
                                	Principal principal = getIdentityService().getPrincipalByPrincipalNameprincipalName );
                                	if ( principal != null ) {
                                		processedFieldValues.put(relatedPrincipalIdPropertyNameprincipal.getPrincipalId());
                                	} else {
                                		processedFieldValues.put(relatedPrincipalIdPropertyNamenull);
                                	}
                                }
                            } // relationship loop
                        } else {
                        	if ( .isDebugEnabled() ) {
                        		.debug"Unable to determine class for collection referenced as part of property: " + containerPropertyName + " on " + businessObject.getClass().getName() );
                        	}
                        }
                    } else {
                    	if ( .isDebugEnabled() ) {
                    		.debug"Non-nested property ending with 'principalName': " + containerPropertyName + " on " + businessObject.getClass().getName() );
                    	}
                    }
                }
            }
        }
        return processedFieldValues;
    }
	// OTHER METHODS
		if (  == null ) {
			 = KimApiServiceLocator.getIdentityService();
		}
	}
	protected RoleService getRoleService() {
		if (  == null ) {
			 = KimApiServiceLocator.getRoleService();
		}
		return ;
	}
	public Class<? extends PersongetPersonImplementationClass() {
		return PersonImpl.class;
	}
		if (  == null ) {
		}
	}
		}
	}
New to GrepCode? Check out our FAQ X