Coverage Report - org.kuali.rice.kim.service.impl.LdapUiDocumentServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LdapUiDocumentServiceImpl
0%
0/226
0%
0/130
6.583
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kim.service.impl;
 17  
 
 18  
 import org.apache.commons.collections.CollectionUtils;
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.membership.MemberType;
 21  
 import org.kuali.rice.kim.api.KimConstants;
 22  
 import org.kuali.rice.kim.api.group.Group;
 23  
 import org.kuali.rice.kim.api.identity.address.EntityAddress;
 24  
 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
 25  
 import org.kuali.rice.kim.api.identity.email.EntityEmail;
 26  
 import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
 27  
 import org.kuali.rice.kim.api.identity.entity.Entity;
 28  
 import org.kuali.rice.kim.api.identity.name.EntityName;
 29  
 import org.kuali.rice.kim.api.identity.phone.EntityPhone;
 30  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 31  
 import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
 32  
 import org.kuali.rice.kim.api.role.Role;
 33  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 34  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember;
 35  
 import org.kuali.rice.kim.bo.ui.PersonDocumentAddress;
 36  
 import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation;
 37  
 import org.kuali.rice.kim.bo.ui.PersonDocumentEmail;
 38  
 import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo;
 39  
 import org.kuali.rice.kim.bo.ui.PersonDocumentName;
 40  
 import org.kuali.rice.kim.bo.ui.PersonDocumentPhone;
 41  
 import org.kuali.rice.kim.document.IdentityManagementPersonDocument;
 42  
 import org.kuali.rice.kim.document.IdentityManagementRoleDocument;
 43  
 import org.kuali.rice.kim.framework.services.KimFrameworkServiceLocator;
 44  
 import org.kuali.rice.kim.framework.type.KimTypeService;
 45  
 import org.kuali.rice.kim.impl.common.delegate.DelegateTypeBo;
 46  
 import org.kuali.rice.kim.impl.group.GroupBo;
 47  
 import org.kuali.rice.kim.impl.group.GroupMemberBo;
 48  
 import org.kuali.rice.kim.impl.identity.entity.EntityBo;
 49  
 import org.kuali.rice.kim.impl.identity.principal.PrincipalBo;
 50  
 import org.kuali.rice.kim.impl.role.RoleBo;
 51  
 import org.kuali.rice.kim.impl.role.RoleMemberAttributeDataBo;
 52  
 import org.kuali.rice.kim.impl.role.RoleMemberBo;
 53  
 import org.kuali.rice.kim.impl.role.RoleResponsibilityActionBo;
 54  
 import org.kuali.rice.kim.impl.services.KimImplServiceLocator;
 55  
 import org.kuali.rice.kim.util.KimCommonUtilsInternal;
 56  
 import org.kuali.rice.krad.bo.BusinessObject;
 57  
 import org.kuali.rice.krad.bo.PersistableBusinessObject;
 58  
 import org.kuali.rice.krad.document.Document;
 59  
 import org.kuali.rice.krad.util.ObjectUtils;
 60  
 
 61  
 import java.sql.Timestamp;
 62  
 import java.util.ArrayList;
 63  
 import java.util.Collections;
 64  
 import java.util.HashMap;
 65  
 import java.util.List;
 66  
 import java.util.Map;
 67  
 
 68  
 /** 
 69  
  * Customized version of the UiDocumentServiceImpl to support LDAP communcation
 70  
  *
 71  
  * @author Leo Przybylski (przybyls@arizona.edu)
 72  
  */
 73  0
 public class LdapUiDocumentServiceImpl extends org.kuali.rice.kim.service.impl.UiDocumentServiceImpl {
 74  
 
 75  
         /**
 76  
          *
 77  
          * @see org.kuali.rice.kim.service.UiDocumentService#loadEntityToPersonDoc(IdentityManagementPersonDocument, String)
 78  
          */
 79  
         public void loadEntityToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId) {
 80  0
                 Principal principal = this.getIdentityService().getPrincipal(principalId);
 81  0
         if(principal==null) {
 82  0
                 throw new RuntimeException("Principal does not exist for principal id:"+principalId);
 83  
         }
 84  
 
 85  0
         identityManagementPersonDocument.setPrincipalId(principal.getPrincipalId());
 86  0
         identityManagementPersonDocument.setPrincipalName(principal.getPrincipalName());
 87  0
         identityManagementPersonDocument.setPassword(principal.getPassword());
 88  0
         identityManagementPersonDocument.setActive(principal.isActive());
 89  0
         Entity kimEntity = this.getIdentityService().getEntity(principal.getEntityId());
 90  0
                 identityManagementPersonDocument.setEntityId(kimEntity.getId());
 91  0
                 if ( ObjectUtils.isNotNull( kimEntity.getPrivacyPreferences() ) ) {
 92  0
                         identityManagementPersonDocument.setPrivacy(loadPrivacyReferences(kimEntity.getPrivacyPreferences()));
 93  
                 }
 94  
                 //identityManagementPersonDocument.setActive(kimEntity.isActive());
 95  0
                 identityManagementPersonDocument.setAffiliations(loadAffiliations(kimEntity.getAffiliations(),kimEntity.getEmploymentInformation()));
 96  0
                 identityManagementPersonDocument.setNames(loadNames( identityManagementPersonDocument, principalId, kimEntity.getNames(), identityManagementPersonDocument.getPrivacy().isSuppressName() ));
 97  0
                 EntityTypeContactInfo entityType = null;
 98  0
                 for (EntityTypeContactInfo type : kimEntity.getEntityTypeContactInfos()) {
 99  0
                         if (KimConstants.EntityTypes.PERSON.equals(type.getEntityTypeCode())) {
 100  0
                                 entityType = EntityTypeContactInfo.Builder.create(type).build();
 101  
                         }
 102  
                 }
 103  
 
 104  0
                 if(entityType!=null){
 105  0
                         identityManagementPersonDocument.setEmails(loadEmails(identityManagementPersonDocument, principalId, entityType.getEmailAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressEmail()));
 106  0
                         identityManagementPersonDocument.setPhones(loadPhones(identityManagementPersonDocument, principalId, entityType.getPhoneNumbers(), identityManagementPersonDocument.getPrivacy().isSuppressPhone()));
 107  0
                         identityManagementPersonDocument.setAddrs(loadAddresses(identityManagementPersonDocument, principalId, entityType.getAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressAddress()));
 108  
                 }
 109  
 
 110  0
                 List<Group> groups = getGroupService().getGroups(getGroupService().getDirectGroupIdsByPrincipalId(
 111  
                 identityManagementPersonDocument.getPrincipalId()));
 112  0
                 loadGroupToPersonDoc(identityManagementPersonDocument, groups);
 113  0
                 loadRoleToPersonDoc(identityManagementPersonDocument);
 114  0
                 loadDelegationsToPersonDoc(identityManagementPersonDocument);
 115  0
         }
 116  
 
 117  
         protected String getInitiatorPrincipalId(Document document){
 118  
                 try{
 119  0
                         return document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId();
 120  0
                 } catch(Exception ex){
 121  0
                         return null;
 122  
                 }
 123  
         }
 124  
 
 125  
         /**
 126  
          * @see org.kuali.rice.kim.service.UiDocumentService#saveEntityPerson(IdentityManagementPersonDocument)
 127  
          */
 128  
     public void saveEntityPerson(IdentityManagementPersonDocument identityManagementPersonDocument) {
 129  0
         final Entity kimEntity = getIdentityService().getEntity(identityManagementPersonDocument.getEntityId());
 130  0
                 boolean creatingNew = false;
 131  
 
 132  0
                 String initiatorPrincipalId = getInitiatorPrincipalId(identityManagementPersonDocument);
 133  0
                 boolean inactivatingPrincipal = false;
 134  
 
 135  0
                 List <GroupMemberBo>  groupPrincipals = populateGroupMembers(identityManagementPersonDocument);
 136  0
                 List <RoleMemberBo>  rolePrincipals = populateRoleMembers(identityManagementPersonDocument);
 137  0
                 List <DelegateTypeBo> personDelegations = populateDelegations(identityManagementPersonDocument);
 138  0
                 List <PersistableBusinessObject> bos = new ArrayList<PersistableBusinessObject>();
 139  0
                 List <RoleResponsibilityActionBo> roleRspActions = populateRoleRspActions(identityManagementPersonDocument);
 140  0
                 List <RoleMemberAttributeDataBo> blankRoleMemberAttrs = getBlankRoleMemberAttrs(rolePrincipals);
 141  
                 //if(ObjectUtils.isNotNull(kimEntity.getPrivacyPreferences()))
 142  
                 //        bos.add(kimEntity.getPrivacyPreferences());
 143  0
                 bos.addAll(groupPrincipals);
 144  0
                 bos.addAll(rolePrincipals);
 145  0
                 bos.addAll(roleRspActions);
 146  0
                 bos.addAll(personDelegations);
 147  
                 // boservice.save(bos) does not handle deleteawarelist
 148  0
                 getBusinessObjectService().save(bos);
 149  
 
 150  0
                 if (!blankRoleMemberAttrs.isEmpty()) {
 151  0
                         getBusinessObjectService().delete(blankRoleMemberAttrs);
 152  
                 }
 153  0
                 if ( inactivatingPrincipal ) {
 154  
                         //when a person is inactivated, inactivate their group, role, and delegation memberships
 155  0
                         KimImplServiceLocator.getRoleInternalService().principalInactivated(identityManagementPersonDocument.getPrincipalId());
 156  
                 }
 157  0
         }
 158  
 
 159  
     protected boolean setupPrincipal(IdentityManagementPersonDocument identityManagementPersonDocument,EntityBo kimEntity, List<PrincipalBo> origPrincipals) {
 160  0
             boolean inactivatingPrincipal = false;
 161  0
                 List<PrincipalBo> principals = new ArrayList<PrincipalBo>();
 162  0
                 Principal.Builder principal = Principal.Builder.create(identityManagementPersonDocument.getPrincipalName());
 163  0
                 principal.setPrincipalId(identityManagementPersonDocument.getPrincipalId());
 164  0
                 principal.setPassword(identityManagementPersonDocument.getPassword());
 165  0
                 principal.setActive(identityManagementPersonDocument.isActive());
 166  0
                 principal.setEntityId(identityManagementPersonDocument.getEntityId());
 167  0
                 if(ObjectUtils.isNotNull(origPrincipals)){
 168  0
                         for (PrincipalBo prncpl : origPrincipals) {
 169  0
                                 if (prncpl.getPrincipalId()!=null && StringUtils.equals(prncpl.getPrincipalId(), principal.getPrincipalId())) {
 170  0
                                         principal.setVersionNumber(prncpl.getVersionNumber());
 171  0
                     principal.setObjectId(prncpl.getObjectId());
 172  
                                         // check if inactivating the principal
 173  0
                                         if ( prncpl.isActive() && !principal.isActive() ) {
 174  0
                                                 inactivatingPrincipal = true;
 175  
                                         }
 176  
                                 }
 177  
                         }
 178  
                 }
 179  0
                 principals.add(PrincipalBo.from(principal.build()));
 180  
 
 181  0
                 kimEntity.setPrincipals(principals);
 182  0
                 return inactivatingPrincipal;
 183  
         }
 184  
 
 185  
         protected List<PersonDocumentAffiliation> loadAffiliations(List <EntityAffiliation> affiliations, List<EntityEmployment> empInfos) {
 186  0
                 List<PersonDocumentAffiliation> docAffiliations = new ArrayList<PersonDocumentAffiliation>();
 187  0
                 if(ObjectUtils.isNotNull(affiliations)){
 188  0
                         for (EntityAffiliation affiliation: affiliations) {
 189  0
                                 if(affiliation.isActive()){
 190  0
                                         PersonDocumentAffiliation docAffiliation = new PersonDocumentAffiliation();
 191  0
                                         docAffiliation.setAffiliationTypeCode(affiliation.getAffiliationType().getCode());
 192  0
                                         docAffiliation.setCampusCode(affiliation.getCampusCode());
 193  0
                                         docAffiliation.setActive(affiliation.isActive());
 194  0
                                         docAffiliation.setDflt(affiliation.isDefaultValue());
 195  0
                                         docAffiliation.setEntityAffiliationId(affiliation.getId());
 196  0
                                         docAffiliation.refreshReferenceObject("affiliationType");
 197  
                                         // EntityAffiliationImpl does not define empinfos as collection
 198  0
                                         docAffiliations.add(docAffiliation);
 199  0
                                         docAffiliation.setEdit(true);
 200  
                                         // employment informations
 201  0
                                         List<PersonDocumentEmploymentInfo> docEmploymentInformations = new ArrayList<PersonDocumentEmploymentInfo>();
 202  0
                                         if(ObjectUtils.isNotNull(empInfos)){
 203  0
                                                 for (EntityEmployment empInfo: empInfos) {
 204  0
                                                         if (empInfo.isActive()
 205  
                                     && StringUtils.equals(docAffiliation.getEntityAffiliationId(),
 206  
                                                           (empInfo.getEntityAffiliation() != null ? empInfo.getEntityAffiliation().getId() : null))) {
 207  0
                                                                 PersonDocumentEmploymentInfo docEmpInfo = new PersonDocumentEmploymentInfo();
 208  0
                                                                 docEmpInfo.setEntityEmploymentId(empInfo.getEmployeeId());
 209  0
                                                                 docEmpInfo.setEmployeeId(empInfo.getEmployeeId());
 210  0
                                                                 docEmpInfo.setEmploymentRecordId(empInfo.getEmploymentRecordId());
 211  0
                                                                 docEmpInfo.setBaseSalaryAmount(empInfo.getBaseSalaryAmount());
 212  0
                                                                 docEmpInfo.setPrimaryDepartmentCode(empInfo.getPrimaryDepartmentCode());
 213  0
                                                                 docEmpInfo.setEmploymentStatusCode(empInfo.getEmployeeStatus() != null ? empInfo.getEmployeeStatus().getCode() : null);
 214  0
                                                                 docEmpInfo.setEmploymentTypeCode(empInfo.getEmployeeType() != null ? empInfo.getEmployeeType().getCode() : null);
 215  0
                                                                 docEmpInfo.setActive(empInfo.isActive());
 216  0
                                                                 docEmpInfo.setPrimary(empInfo.isPrimary());
 217  0
                                                                 docEmpInfo.setEntityAffiliationId(empInfo.getEntityAffiliation() != null ? empInfo.getEntityAffiliation().getId() : null);
 218  
                                                                 // there is no version number on KimEntityEmploymentInformationInfo
 219  
                                                                 //docEmpInfo.setVersionNumber(empInfo.getVersionNumber());
 220  0
                                                                 docEmpInfo.setEdit(true);
 221  0
                                                                 docEmpInfo.refreshReferenceObject("employmentType");
 222  0
                                                                 docEmploymentInformations.add(docEmpInfo);
 223  0
                                                         }
 224  
                                                 }
 225  
                                         }
 226  0
                                         docAffiliation.setEmpInfos(docEmploymentInformations);
 227  0
                                 }
 228  
                         }
 229  
                 }
 230  0
                 return docAffiliations;
 231  
 
 232  
         }
 233  
 
 234  
     
 235  
     protected List<PersonDocumentName> loadNames( IdentityManagementPersonDocument personDoc, String principalId, List <EntityName> names, boolean suppressDisplay ) {
 236  0
                 List<PersonDocumentName> docNames = new ArrayList<PersonDocumentName>();
 237  0
                 if(ObjectUtils.isNotNull(names)){
 238  0
                         for (EntityName name: names) {
 239  0
                                 if(name.isActive()){
 240  0
                                         PersonDocumentName docName = new PersonDocumentName();
 241  0
                     if (name.getNameType() != null) {
 242  0
                                             docName.setNameCode(name.getNameType().getCode());
 243  
                     }
 244  
 
 245  
                                         //We do not need to check the privacy setting here - The UI should care of it
 246  0
                                         docName.setFirstName(name.getFirstNameUnmasked());
 247  0
                                         docName.setLastName(name.getLastNameUnmasked());
 248  0
                                         docName.setMiddleName(name.getMiddleNameUnmasked());
 249  0
                                         docName.setNamePrefix(name.getNamePrefixUnmasked());
 250  0
                                         docName.setNameSuffix(name.getNameSuffixUnmasked());
 251  
 
 252  0
                                         docName.setActive(name.isActive());
 253  0
                                         docName.setDflt(name.isDefaultValue());
 254  0
                                         docName.setEdit(true);
 255  0
                                         docName.setEntityNameId(name.getId());
 256  0
                                         docNames.add(docName);
 257  0
                                 }
 258  
                         }
 259  
                 }
 260  0
                 return docNames;
 261  
         }
 262  
 
 263  
     protected List<PersonDocumentAddress> loadAddresses(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityAddress> entityAddresses, boolean suppressDisplay ) {
 264  0
                 List<PersonDocumentAddress> docAddresses = new ArrayList<PersonDocumentAddress>();
 265  0
                 if(ObjectUtils.isNotNull(entityAddresses)){
 266  0
                         for (EntityAddress address: entityAddresses) {
 267  0
                                 if(address.isActive()){
 268  0
                                         PersonDocumentAddress docAddress = new PersonDocumentAddress();
 269  0
                                         docAddress.setEntityTypeCode(address.getEntityTypeCode());
 270  0
                                         docAddress.setAddressTypeCode(address.getAddressType().getCode());
 271  
 
 272  
                                         //We do not need to check the privacy setting here - The UI should care of it
 273  0
                                         docAddress.setLine1(address.getLine1Unmasked());
 274  0
                                         docAddress.setLine2(address.getLine2Unmasked());
 275  0
                                         docAddress.setLine3(address.getLine3Unmasked());
 276  0
                                         docAddress.setStateProvinceCode(address.getStateProvinceCodeUnmasked());
 277  0
                                         docAddress.setPostalCode(address.getPostalCodeUnmasked());
 278  0
                                         docAddress.setCountryCode(address.getCountryCodeUnmasked());
 279  0
                                         docAddress.setCity(address.getCityUnmasked());
 280  
 
 281  0
                                         docAddress.setActive(address.isActive());
 282  0
                                         docAddress.setDflt(address.isDefaultValue());
 283  0
                                         docAddress.setEntityAddressId(address.getId());
 284  0
                                         docAddress.setEdit(true);
 285  0
                                         docAddresses.add(docAddress);
 286  0
                                 }
 287  
                         }
 288  
                 }
 289  0
                 return docAddresses;
 290  
         }
 291  
 
 292  
     protected List<PersonDocumentEmail> loadEmails(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityEmail> entityEmails, boolean suppressDisplay ) {
 293  0
                 List<PersonDocumentEmail> emails = new ArrayList<PersonDocumentEmail>();
 294  0
                 if(ObjectUtils.isNotNull(entityEmails)){
 295  0
                         for (EntityEmail email: entityEmails) {
 296  0
                                 if(email.isActive()){
 297  0
                                         PersonDocumentEmail docEmail = new PersonDocumentEmail();
 298  
                                         //docEmail.setEntityId(email.getEntityId());
 299  0
                                         docEmail.setEntityTypeCode(email.getEntityTypeCode());
 300  0
                     if (email.getEmailType() != null) {
 301  0
                                             docEmail.setEmailTypeCode(email.getEmailType().getCode());
 302  
                     }
 303  
                                         // EmailType not on info object.
 304  
                                         //docEmail.setEmailType(((KimEntityEmailImpl)email).getEmailType());
 305  
                                         //We do not need to check the privacy setting here - The UI should care of it
 306  0
                                         docEmail.setEmailAddress(email.getEmailAddressUnmasked());
 307  
 
 308  0
                                         docEmail.setActive(email.isActive());
 309  0
                                         docEmail.setDflt(email.isDefaultValue());
 310  0
                                         docEmail.setEntityEmailId(email.getId());
 311  0
                                         docEmail.setEdit(true);
 312  0
                                         emails.add(docEmail);
 313  0
                                 }
 314  
                         }
 315  
                 }
 316  0
                 return emails;
 317  
         }
 318  
 
 319  
     protected List<PersonDocumentPhone> loadPhones(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityPhone> entityPhones, boolean suppressDisplay ) {
 320  0
                 List<PersonDocumentPhone> docPhones = new ArrayList<PersonDocumentPhone>();
 321  0
                 if(ObjectUtils.isNotNull(entityPhones)){
 322  0
                         for (EntityPhone phone: entityPhones) {
 323  0
                                 if(phone.isActive()){
 324  0
                                         PersonDocumentPhone docPhone = new PersonDocumentPhone();
 325  0
                     if (phone.getPhoneType() != null) {
 326  0
                                             docPhone.setPhoneTypeCode(phone.getPhoneType().getCode());
 327  
                     }
 328  
                                         //docPhone.setPhoneType(((KimEntityPhoneImpl)phone).getPhoneType());
 329  0
                                         docPhone.setEntityTypeCode(phone.getEntityTypeCode());
 330  
                                         //We do not need to check the privacy setting here - The UI should care of it
 331  0
                                         docPhone.setPhoneNumber(phone.getPhoneNumberUnmasked());
 332  0
                                         docPhone.setCountryCode(phone.getCountryCodeUnmasked());
 333  0
                                         docPhone.setExtensionNumber(phone.getExtensionNumberUnmasked());
 334  
 
 335  0
                                         docPhone.setActive(phone.isActive());
 336  0
                                         docPhone.setDflt(phone.isDefaultValue());
 337  0
                                         docPhone.setEntityPhoneId(phone.getId());
 338  0
                                         docPhone.setEdit(true);
 339  0
                                         docPhones.add(docPhone);
 340  0
                                 }
 341  
                         }
 342  
                 }
 343  0
                 return docPhones;
 344  
 
 345  
         }
 346  
 
 347  
     public BusinessObject getMember(String memberTypeCode, String memberId){
 348  0
         Class<? extends BusinessObject> roleMemberTypeClass = null;
 349  0
         String roleMemberIdName = "";
 350  0
             if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)){
 351  0
                 roleMemberTypeClass = PrincipalBo.class;
 352  0
                 roleMemberIdName = KimConstants.PrimaryKeyConstants.PRINCIPAL_ID;
 353  0
                           Principal principalInfo = getIdentityService().getPrincipal(memberId);
 354  0
                           if (principalInfo != null) {
 355  
                                   
 356  
                           }
 357  0
         } else if(MemberType.GROUP.getCode().equals(memberTypeCode)){
 358  0
                 roleMemberTypeClass = GroupBo.class;
 359  0
                 roleMemberIdName = KimConstants.PrimaryKeyConstants.GROUP_ID;
 360  0
                 Group groupInfo = null;
 361  0
                           groupInfo = getGroupService().getGroup(memberId);
 362  0
                           if (groupInfo != null) {
 363  
                                   
 364  
                           }
 365  0
         } else if(MemberType.ROLE.getCode().equals(memberTypeCode)){
 366  0
                 roleMemberTypeClass = RoleBo.class;
 367  0
                 roleMemberIdName = KimConstants.PrimaryKeyConstants.ROLE_ID;
 368  0
                           Role role = getRoleService().getRole(memberId);
 369  0
                           if (role != null) {
 370  
                                   
 371  
                           }
 372  
         }
 373  0
         Map<String, String> criteria = new HashMap<String, String>();
 374  0
         criteria.put(roleMemberIdName, memberId);
 375  0
         return getBusinessObjectService().findByPrimaryKey(roleMemberTypeClass, criteria);
 376  
     }
 377  
 
 378  
     /**
 379  
      * Overridden to only check permission - users should not be able to edit themselves.
 380  
      * 
 381  
      * @see org.kuali.rice.kim.service.impl.UiDocumentServiceImpl#canModifyEntity(java.lang.String, java.lang.String)
 382  
      */
 383  
     @Override
 384  
         public boolean canModifyEntity( String currentUserPrincipalId, String toModifyPrincipalId ){
 385  0
                 return (StringUtils.isNotBlank(currentUserPrincipalId) && StringUtils.isNotBlank(toModifyPrincipalId) &&
 386  
                                 currentUserPrincipalId.equals(toModifyPrincipalId)) ||
 387  
                                 getPermissionService().isAuthorized(
 388  
                                                 currentUserPrincipalId,
 389  
                                                 KimConstants.NAMESPACE_CODE,
 390  
                                                 KimConstants.PermissionNames.MODIFY_ENTITY,
 391  
                                                 Collections.<String, String>emptyMap(),
 392  
                                                 Collections.singletonMap(KimConstants.AttributeConstants.PRINCIPAL_ID, currentUserPrincipalId));
 393  
         }
 394  
     
 395  
     protected List<RoleMemberBo> getRoleMembers(IdentityManagementRoleDocument identityManagementRoleDocument, List<RoleMemberBo> origRoleMembers){
 396  0
         List<RoleMemberBo> roleMembers = new ArrayList<RoleMemberBo>();
 397  
         RoleMemberBo newRoleMember;
 398  
         RoleMemberBo origRoleMemberImplTemp;
 399  
         List<RoleMemberAttributeDataBo> origAttributes;
 400  0
         boolean activatingInactive = false;
 401  0
         String newRoleMemberIdAssigned = "";
 402  
 
 403  0
         identityManagementRoleDocument.setKimType(KimApiServiceLocator.getKimTypeInfoService().getKimType(identityManagementRoleDocument.getRoleTypeId()));
 404  0
         KimTypeService kimTypeService = KimFrameworkServiceLocator.getKimTypeService(identityManagementRoleDocument.getKimType());
 405  
 
 406  0
         if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getMembers())){
 407  0
             for(KimDocumentRoleMember documentRoleMember: identityManagementRoleDocument.getMembers()){
 408  0
                 origRoleMemberImplTemp = null;
 409  
 
 410  0
                 newRoleMember = new RoleMemberBo();
 411  0
                 KimCommonUtilsInternal.copyProperties(newRoleMember, documentRoleMember);
 412  0
                 newRoleMember.setRoleId(identityManagementRoleDocument.getRoleId());
 413  0
                 if(ObjectUtils.isNotNull(origRoleMembers)){
 414  0
                     for(RoleMemberBo origRoleMemberImpl: origRoleMembers){
 415  0
                         if((origRoleMemberImpl.getRoleId()!=null && StringUtils.equals(origRoleMemberImpl.getRoleId(), newRoleMember.getRoleId())) &&
 416  
                             (origRoleMemberImpl.getMemberId()!=null && StringUtils.equals(origRoleMemberImpl.getMemberId(), newRoleMember.getMemberId())) &&
 417  
                             (origRoleMemberImpl.getMemberType()!=null && org.apache.commons.lang.ObjectUtils.equals(origRoleMemberImpl.getMemberType(), newRoleMember.getMemberType())) &&
 418  
                             !origRoleMemberImpl.isActive(new Timestamp(System.currentTimeMillis())) &&
 419  
                             !kimTypeService.validateAttributesAgainstExisting(identityManagementRoleDocument.getKimType().getId(),
 420  
                                     documentRoleMember.getQualifierAsMap(), origRoleMemberImpl.getAttributes()).isEmpty()) {
 421  
 
 422  
                             //TODO: verify if you want to add  && newRoleMember.isActive() condition to if...
 423  
 
 424  0
                             newRoleMemberIdAssigned = newRoleMember.getRoleMemberId();
 425  0
                             newRoleMember.setRoleMemberId(origRoleMemberImpl.getRoleMemberId());
 426  0
                             activatingInactive = true;
 427  
                         }
 428  0
                         if(origRoleMemberImpl.getRoleMemberId()!=null && StringUtils.equals(origRoleMemberImpl.getRoleMemberId(), newRoleMember.getRoleMemberId())){
 429  0
                             newRoleMember.setVersionNumber(origRoleMemberImpl.getVersionNumber());
 430  0
                             origRoleMemberImplTemp = origRoleMemberImpl;
 431  
                         }
 432  
                     }
 433  
                 }
 434  0
                 origAttributes = (origRoleMemberImplTemp==null || origRoleMemberImplTemp.getAttributes()==null)?
 435  
                                     new ArrayList<RoleMemberAttributeDataBo>():origRoleMemberImplTemp.getAttributeDetails();
 436  0
                 newRoleMember.setActiveFromDateValue(documentRoleMember.getActiveFromDate());
 437  0
                 newRoleMember.setActiveToDateValue(documentRoleMember.getActiveToDate());
 438  0
                 newRoleMember.setAttributeDetails(getRoleMemberAttributeData(documentRoleMember.getQualifiers(), origAttributes, activatingInactive, newRoleMemberIdAssigned));
 439  0
                 newRoleMember.setRoleRspActions(getRoleMemberResponsibilityActions(documentRoleMember, origRoleMemberImplTemp, activatingInactive, newRoleMemberIdAssigned));
 440  0
                 roleMembers.add(newRoleMember);
 441  0
                 activatingInactive = false;
 442  
             }
 443  
         }
 444  0
         return roleMembers;
 445  
     }
 446  
 }