1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kim.service.impl; |
18 | |
|
19 | |
import org.apache.commons.collections.CollectionUtils; |
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.apache.log4j.Logger; |
22 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
23 | |
import org.kuali.rice.core.api.mo.common.Attributes; |
24 | |
import org.kuali.rice.core.util.AttributeSet; |
25 | |
import org.kuali.rice.kim.api.common.attribute.KimAttributeData; |
26 | |
import org.kuali.rice.kim.api.entity.address.EntityAddress; |
27 | |
import org.kuali.rice.kim.api.entity.address.EntityAddressContract; |
28 | |
import org.kuali.rice.kim.api.entity.email.EntityEmail; |
29 | |
import org.kuali.rice.kim.api.entity.email.EntityEmailContract; |
30 | |
import org.kuali.rice.kim.api.entity.phone.EntityPhone; |
31 | |
import org.kuali.rice.kim.api.entity.phone.EntityPhoneContract; |
32 | |
import org.kuali.rice.kim.api.entity.principal.Principal; |
33 | |
import org.kuali.rice.kim.api.entity.privacy.EntityPrivacyPreferences; |
34 | |
import org.kuali.rice.kim.api.entity.services.IdentityService; |
35 | |
import org.kuali.rice.kim.api.entity.type.EntityTypeData; |
36 | |
import org.kuali.rice.kim.api.group.Group; |
37 | |
import org.kuali.rice.kim.api.group.GroupMember; |
38 | |
import org.kuali.rice.kim.api.group.GroupService; |
39 | |
import org.kuali.rice.kim.api.responsibility.ResponsibilityService; |
40 | |
import org.kuali.rice.kim.api.services.IdentityManagementService; |
41 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
42 | |
import org.kuali.rice.kim.api.type.KimType; |
43 | |
import org.kuali.rice.kim.api.type.KimTypeAttribute; |
44 | |
import org.kuali.rice.kim.api.type.KimTypeInfoService; |
45 | |
import org.kuali.rice.kim.bo.Person; |
46 | |
import org.kuali.rice.kim.bo.Role; |
47 | |
import org.kuali.rice.kim.bo.entity.KimEntityAffiliation; |
48 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityAffiliationInfo; |
49 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityEmploymentInformationInfo; |
50 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityInfo; |
51 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityNameInfo; |
52 | |
import org.kuali.rice.kim.bo.entity.impl.KimEntityAffiliationImpl; |
53 | |
import org.kuali.rice.kim.bo.entity.impl.KimEntityEmploymentInformationImpl; |
54 | |
import org.kuali.rice.kim.bo.entity.impl.KimEntityImpl; |
55 | |
import org.kuali.rice.kim.bo.entity.impl.KimEntityNameImpl; |
56 | |
import org.kuali.rice.kim.bo.impl.RoleImpl; |
57 | |
import org.kuali.rice.kim.bo.role.dto.KimRoleInfo; |
58 | |
import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo; |
59 | |
import org.kuali.rice.kim.bo.role.impl.KimDelegationImpl; |
60 | |
import org.kuali.rice.kim.bo.role.impl.KimDelegationMemberAttributeDataImpl; |
61 | |
import org.kuali.rice.kim.bo.role.impl.KimDelegationMemberImpl; |
62 | |
import org.kuali.rice.kim.bo.role.impl.RoleMemberAttributeDataImpl; |
63 | |
import org.kuali.rice.kim.bo.role.impl.RoleMemberImpl; |
64 | |
import org.kuali.rice.kim.bo.role.impl.RolePermissionImpl; |
65 | |
import org.kuali.rice.kim.bo.role.impl.RoleResponsibilityActionImpl; |
66 | |
import org.kuali.rice.kim.bo.role.impl.RoleResponsibilityImpl; |
67 | |
import org.kuali.rice.kim.bo.types.dto.AttributeDefinitionMap; |
68 | |
import org.kuali.rice.kim.bo.ui.GroupDocumentMember; |
69 | |
import org.kuali.rice.kim.bo.ui.GroupDocumentQualifier; |
70 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember; |
71 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRolePermission; |
72 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier; |
73 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleResponsibility; |
74 | |
import org.kuali.rice.kim.bo.ui.KimDocumentRoleResponsibilityAction; |
75 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentAddress; |
76 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation; |
77 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentEmail; |
78 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo; |
79 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentGroup; |
80 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentName; |
81 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentPhone; |
82 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentPrivacy; |
83 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentRole; |
84 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegation; |
85 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember; |
86 | |
import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier; |
87 | |
import org.kuali.rice.kim.document.IdentityManagementGroupDocument; |
88 | |
import org.kuali.rice.kim.document.IdentityManagementPersonDocument; |
89 | |
import org.kuali.rice.kim.document.IdentityManagementRoleDocument; |
90 | |
import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo; |
91 | |
import org.kuali.rice.kim.impl.entity.address.EntityAddressBo; |
92 | |
import org.kuali.rice.kim.impl.entity.email.EntityEmailBo; |
93 | |
import org.kuali.rice.kim.impl.entity.phone.EntityPhoneBo; |
94 | |
import org.kuali.rice.kim.impl.entity.principal.PrincipalBo; |
95 | |
import org.kuali.rice.kim.impl.entity.privacy.EntityPrivacyPreferencesBo; |
96 | |
import org.kuali.rice.kim.impl.entity.type.EntityTypeDataBo; |
97 | |
import org.kuali.rice.kim.impl.group.GroupAttributeBo; |
98 | |
import org.kuali.rice.kim.impl.group.GroupBo; |
99 | |
import org.kuali.rice.kim.impl.group.GroupMemberBo; |
100 | |
import org.kuali.rice.kim.impl.responsibility.ResponsibilityInternalService; |
101 | |
import org.kuali.rice.kim.impl.type.KimTypeBo; |
102 | |
import org.kuali.rice.kim.service.IdentityManagementNotificationService; |
103 | |
import org.kuali.rice.kim.service.KIMServiceLocatorInternal; |
104 | |
import org.kuali.rice.kim.service.KIMServiceLocatorWeb; |
105 | |
import org.kuali.rice.kim.service.RoleManagementService; |
106 | |
import org.kuali.rice.kim.service.RoleService; |
107 | |
import org.kuali.rice.kim.service.UiDocumentService; |
108 | |
import org.kuali.rice.kim.service.support.KimTypeService; |
109 | |
import org.kuali.rice.kim.util.KIMPropertyConstants; |
110 | |
import org.kuali.rice.kim.util.KimCommonUtilsInternal; |
111 | |
import org.kuali.rice.kim.util.KimConstants; |
112 | |
import org.kuali.rice.kim.util.KimConstants.KimGroupMemberTypes; |
113 | |
import org.kuali.rice.kns.bo.BusinessObject; |
114 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
115 | |
import org.kuali.rice.kns.datadictionary.AttributeDefinition; |
116 | |
import org.kuali.rice.kns.datadictionary.KimDataDictionaryAttributeDefinition; |
117 | |
import org.kuali.rice.kns.datadictionary.KimNonDataDictionaryAttributeDefinition; |
118 | |
import org.kuali.rice.kns.datadictionary.control.ControlDefinition; |
119 | |
import org.kuali.rice.kns.datadictionary.control.TextControlDefinition; |
120 | |
import org.kuali.rice.kns.document.Document; |
121 | |
import org.kuali.rice.kns.service.BusinessObjectService; |
122 | |
import org.kuali.rice.kns.service.DocumentHelperService; |
123 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
124 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
125 | |
import org.kuali.rice.kns.util.ObjectUtils; |
126 | |
import org.kuali.rice.ksb.api.KsbApiServiceLocator; |
127 | |
|
128 | |
import javax.xml.namespace.QName; |
129 | |
import java.sql.Timestamp; |
130 | |
import java.util.ArrayList; |
131 | |
import java.util.Collection; |
132 | |
import java.util.Collections; |
133 | |
import java.util.Comparator; |
134 | |
import java.util.HashMap; |
135 | |
import java.util.HashSet; |
136 | |
import java.util.List; |
137 | |
import java.util.Map; |
138 | |
import java.util.Set; |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | 0 | public class UiDocumentServiceImpl implements UiDocumentService { |
147 | 0 | private static final Logger LOG = Logger.getLogger(UiDocumentServiceImpl.class); |
148 | |
private static final String SHOW_BLANK_QUALIFIERS = "kim.show.blank.qualifiers"; |
149 | |
|
150 | |
private RoleService roleService; |
151 | |
private RoleManagementService roleManagementService; |
152 | |
private BusinessObjectService businessObjectService; |
153 | |
private IdentityService identityService; |
154 | |
private IdentityManagementService identityManagementService; |
155 | |
private GroupService groupService; |
156 | |
private ResponsibilityService responsibilityService; |
157 | |
private ResponsibilityInternalService responsibilityInternalService; |
158 | |
private KimTypeInfoService kimTypeInfoService; |
159 | |
private DocumentHelperService documentHelperService; |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
public void saveEntityPerson( |
166 | |
IdentityManagementPersonDocument identityManagementPersonDocument) { |
167 | 0 | KimEntityImpl kimEntity = new KimEntityImpl(); |
168 | 0 | KimEntityImpl origEntity = getEntityImpl(identityManagementPersonDocument.getEntityId()); |
169 | 0 | boolean creatingNew = true; |
170 | 0 | if (origEntity == null) { |
171 | 0 | origEntity = new KimEntityImpl(); |
172 | 0 | kimEntity.setActive(true); |
173 | |
} else { |
174 | |
|
175 | |
|
176 | |
|
177 | 0 | kimEntity.setActive(origEntity.isActive()); |
178 | 0 | kimEntity.setVersionNumber(origEntity.getVersionNumber()); |
179 | 0 | creatingNew = false; |
180 | |
} |
181 | |
|
182 | 0 | kimEntity.setEntityId(identityManagementPersonDocument.getEntityId()); |
183 | 0 | String initiatorPrincipalId = getInitiatorPrincipalId(identityManagementPersonDocument); |
184 | 0 | boolean inactivatingPrincipal = false; |
185 | 0 | if(canModifyEntity(initiatorPrincipalId, identityManagementPersonDocument.getPrincipalId())){ |
186 | 0 | inactivatingPrincipal = setupPrincipal(identityManagementPersonDocument, kimEntity, origEntity.getPrincipals()); |
187 | 0 | setupAffiliation(identityManagementPersonDocument, kimEntity, origEntity.getAffiliations(), origEntity.getEmploymentInformation()); |
188 | 0 | setupName(identityManagementPersonDocument, kimEntity, origEntity.getNames()); |
189 | |
|
190 | 0 | List<EntityTypeDataBo> entityTypes = new ArrayList<EntityTypeDataBo>(); |
191 | 0 | EntityTypeDataBo entityType = new EntityTypeDataBo(); |
192 | 0 | entityType.setEntityId(identityManagementPersonDocument.getEntityId()); |
193 | 0 | entityType.setEntityTypeCode(KimConstants.EntityTypes.PERSON); |
194 | 0 | entityType.setActive(true); |
195 | 0 | entityTypes.add(entityType); |
196 | 0 | EntityTypeDataBo origEntityType = new EntityTypeDataBo(); |
197 | 0 | for (EntityTypeDataBo type : origEntity.getEntityTypes()) { |
198 | |
|
199 | 0 | if (type.getEntityTypeCode()!=null && StringUtils.equals(type.getEntityTypeCode(), entityType.getEntityTypeCode())) { |
200 | 0 | origEntityType = type; |
201 | 0 | entityType.setVersionNumber(type.getVersionNumber()); |
202 | 0 | entityType.setActive(type.isActive()); |
203 | |
} |
204 | |
} |
205 | 0 | setupPhone(identityManagementPersonDocument, entityType, origEntityType.getPhoneNumbers()); |
206 | 0 | setupEmail(identityManagementPersonDocument, entityType, origEntityType.getEmailAddresses()); |
207 | 0 | setupAddress(identityManagementPersonDocument, entityType, origEntityType.getAddresses()); |
208 | 0 | kimEntity.setEntityTypes(entityTypes); |
209 | 0 | } else{ |
210 | 0 | if(ObjectUtils.isNotNull(origEntity.getExternalIdentifiers())) |
211 | 0 | kimEntity.setExternalIdentifiers(origEntity.getExternalIdentifiers()); |
212 | 0 | if(ObjectUtils.isNotNull(origEntity.getEmploymentInformation())) |
213 | 0 | kimEntity.setEmploymentInformation(origEntity.getEmploymentInformation()); |
214 | 0 | if(ObjectUtils.isNotNull(origEntity.getAffiliations())) |
215 | 0 | kimEntity.setAffiliations(origEntity.getAffiliations()); |
216 | 0 | if(ObjectUtils.isNotNull(origEntity.getNames())) |
217 | 0 | kimEntity.setNames(origEntity.getNames()); |
218 | 0 | if(ObjectUtils.isNotNull(origEntity.getEntityTypes())) |
219 | 0 | kimEntity.setEntityTypes(origEntity.getEntityTypes()); |
220 | |
} |
221 | 0 | if(creatingNew || canOverrideEntityPrivacyPreferences(getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId())) { |
222 | 0 | setupPrivacy(identityManagementPersonDocument, kimEntity, origEntity.getPrivacyPreferences()); |
223 | |
} else { |
224 | 0 | if(ObjectUtils.isNotNull(origEntity.getPrivacyPreferences())) { |
225 | 0 | kimEntity.setPrivacyPreferences(origEntity.getPrivacyPreferences()); |
226 | |
} |
227 | |
} |
228 | 0 | List <GroupMemberBo> groupPrincipals = populateGroupMembers(identityManagementPersonDocument); |
229 | 0 | List <RoleMemberImpl> rolePrincipals = populateRoleMembers(identityManagementPersonDocument); |
230 | 0 | List <KimDelegationImpl> personDelegations = populateDelegations(identityManagementPersonDocument); |
231 | 0 | List <PersistableBusinessObject> bos = new ArrayList<PersistableBusinessObject>(); |
232 | 0 | List <RoleResponsibilityActionImpl> roleRspActions = populateRoleRspActions(identityManagementPersonDocument); |
233 | 0 | List <RoleMemberAttributeDataImpl> blankRoleMemberAttrs = getBlankRoleMemberAttrs(rolePrincipals); |
234 | 0 | bos.add(kimEntity); |
235 | |
|
236 | |
|
237 | 0 | bos.addAll(groupPrincipals); |
238 | 0 | bos.addAll(rolePrincipals); |
239 | 0 | bos.addAll(roleRspActions); |
240 | 0 | bos.addAll(personDelegations); |
241 | |
|
242 | 0 | getBusinessObjectService().save(bos); |
243 | |
|
244 | |
|
245 | 0 | IdentityManagementNotificationService service = (IdentityManagementNotificationService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(new QName("KIM", "kimIdentityManagementNotificationService")); |
246 | 0 | service.principalUpdated(); |
247 | |
|
248 | 0 | if (!blankRoleMemberAttrs.isEmpty()) { |
249 | 0 | getBusinessObjectService().delete(blankRoleMemberAttrs); |
250 | |
} |
251 | 0 | if ( inactivatingPrincipal ) { |
252 | |
|
253 | 0 | KimApiServiceLocator.getRoleManagementService().principalInactivated(identityManagementPersonDocument.getPrincipalId()); |
254 | |
} |
255 | 0 | } |
256 | |
|
257 | |
private String getInitiatorPrincipalId(Document document){ |
258 | |
try{ |
259 | 0 | return document.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId(); |
260 | 0 | } catch(Exception ex){ |
261 | 0 | return null; |
262 | |
} |
263 | |
} |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
public Map<String,Object> getAttributeEntries( AttributeDefinitionMap definitions ) { |
269 | 0 | Map<String,Object> attributeEntries = new HashMap<String,Object>(); |
270 | 0 | if(definitions!=null){ |
271 | 0 | for (String key : definitions.keySet()) { |
272 | 0 | AttributeDefinition definition = definitions.get(key); |
273 | 0 | Map<String,Object> attribute = new HashMap<String,Object>(); |
274 | 0 | if (definition instanceof KimDataDictionaryAttributeDefinition) { |
275 | |
|
276 | |
|
277 | 0 | ControlDefinition control = definition.getControl(); |
278 | 0 | if (control.isSelect() |
279 | |
|| control.isRadio()) { |
280 | 0 | Map<String,Object> controlMap = new HashMap<String,Object>(); |
281 | 0 | if (control.isSelect()) { |
282 | 0 | controlMap.put("select", "true"); |
283 | |
} else { |
284 | 0 | controlMap.put("radio", "true"); |
285 | |
} |
286 | 0 | controlMap.put("valuesFinder", control.getValuesFinderClass()); |
287 | 0 | if (control.getBusinessObjectClass() != null) { |
288 | 0 | controlMap.put("businessObject", control.getBusinessObjectClass()); |
289 | |
} |
290 | 0 | if (StringUtils.isNotEmpty(control.getKeyAttribute())) { |
291 | 0 | controlMap.put("keyAttribute", control.getKeyAttribute()); |
292 | |
} |
293 | 0 | if (StringUtils.isNotEmpty(control.getLabelAttribute())) { |
294 | 0 | controlMap.put("labelAttribute", control.getLabelAttribute()); |
295 | |
} |
296 | 0 | if (control.getIncludeKeyInLabel() != null) { |
297 | 0 | controlMap.put("includeKeyInLabel", control.getIncludeKeyInLabel().toString()); |
298 | |
} |
299 | 0 | attribute.put("control", controlMap); |
300 | 0 | } else { |
301 | |
|
302 | |
|
303 | 0 | attribute.put("control", definition.getControl()); |
304 | |
} |
305 | 0 | attribute.put("name", definition.getName()); |
306 | 0 | attribute.put("label", definition.getLabel()); |
307 | 0 | attribute.put("shortLabel", definition.getShortLabel()); |
308 | 0 | attribute.put("maxLength", definition.getMaxLength()); |
309 | 0 | attribute.put("required", definition.isRequired()); |
310 | 0 | attributeEntries.put(definition.getName(),attribute); |
311 | 0 | } else { |
312 | 0 | TextControlDefinition control = new TextControlDefinition(); |
313 | 0 | control.setSize(10); |
314 | 0 | attribute.put("name", definition.getName()); |
315 | 0 | attribute.put("control", control); |
316 | 0 | attribute.put("label", definition.getLabel()); |
317 | 0 | attribute.put("maxLength", 20); |
318 | 0 | attribute.put("required", true); |
319 | 0 | attribute.put("shortLabel", definition.getLabel()); |
320 | 0 | attributeEntries.put(definition.getName(),attribute); |
321 | |
} |
322 | 0 | } |
323 | |
} |
324 | 0 | return attributeEntries; |
325 | |
} |
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
public void loadEntityToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId) { |
333 | 0 | Principal principal = this.getIdentityService().getPrincipal(principalId); |
334 | 0 | if(principal==null) |
335 | 0 | throw new RuntimeException("Principal does not exist for principal id:"+principalId); |
336 | |
|
337 | 0 | identityManagementPersonDocument.setPrincipalId(principal.getPrincipalId()); |
338 | 0 | identityManagementPersonDocument.setPrincipalName(principal.getPrincipalName()); |
339 | 0 | identityManagementPersonDocument.setPassword(principal.getPassword()); |
340 | 0 | identityManagementPersonDocument.setActive(principal.isActive()); |
341 | 0 | KimEntityInfo kimEntity = this.getIdentityService().getEntityInfo(principal.getEntityId()); |
342 | 0 | identityManagementPersonDocument.setEntityId(kimEntity.getEntityId()); |
343 | 0 | if ( ObjectUtils.isNotNull( kimEntity.getPrivacyPreferences() ) ) { |
344 | 0 | identityManagementPersonDocument.setPrivacy(loadPrivacyReferences(kimEntity.getPrivacyPreferences())); |
345 | |
} |
346 | |
|
347 | 0 | identityManagementPersonDocument.setAffiliations(loadAffiliations(kimEntity.getAffiliations(),kimEntity.getEmploymentInformation())); |
348 | 0 | identityManagementPersonDocument.setNames(loadNames( identityManagementPersonDocument, principalId, kimEntity.getNames(), identityManagementPersonDocument.getPrivacy().isSuppressName() )); |
349 | 0 | EntityTypeData entityType = null; |
350 | 0 | for (EntityTypeData type : kimEntity.getEntityTypes()) { |
351 | 0 | if (KimConstants.EntityTypes.PERSON.equals(type.getEntityTypeCode())) { |
352 | 0 | entityType = EntityTypeData.Builder.create(type).build(); |
353 | |
} |
354 | |
} |
355 | |
|
356 | 0 | if(entityType!=null){ |
357 | 0 | identityManagementPersonDocument.setEmails(loadEmails(identityManagementPersonDocument, principalId, entityType.getEmailAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressEmail())); |
358 | 0 | identityManagementPersonDocument.setPhones(loadPhones(identityManagementPersonDocument, principalId, entityType.getPhoneNumbers(), identityManagementPersonDocument.getPrivacy().isSuppressPhone())); |
359 | 0 | identityManagementPersonDocument.setAddrs(loadAddresses(identityManagementPersonDocument, principalId, entityType.getAddresses(), identityManagementPersonDocument.getPrivacy().isSuppressAddress())); |
360 | |
} |
361 | |
|
362 | 0 | List<? extends Group> groups = getGroupsByIds(getGroupService().getDirectGroupIdsForPrincipal(identityManagementPersonDocument.getPrincipalId())); |
363 | 0 | loadGroupToPersonDoc(identityManagementPersonDocument, groups); |
364 | 0 | loadRoleToPersonDoc(identityManagementPersonDocument); |
365 | 0 | loadDelegationsToPersonDoc(identityManagementPersonDocument); |
366 | 0 | } |
367 | |
|
368 | |
@SuppressWarnings("unchecked") |
369 | |
public List<KimDelegationImpl> getPersonDelegations(String principalId){ |
370 | 0 | if(principalId==null) |
371 | 0 | return new ArrayList<KimDelegationImpl>(); |
372 | 0 | Map<String,String> criteria = new HashMap<String,String>(1); |
373 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.MEMBER_ID, principalId); |
374 | 0 | criteria.put( KIMPropertyConstants.DelegationMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE ); |
375 | 0 | List<KimDelegationMemberImpl> delegationMembers = (List<KimDelegationMemberImpl>)getBusinessObjectService().findMatching(KimDelegationMemberImpl.class, criteria); |
376 | 0 | List<KimDelegationImpl> delegations = new ArrayList<KimDelegationImpl>(); |
377 | 0 | List<String> delegationIds = new ArrayList<String>(); |
378 | 0 | if(ObjectUtils.isNotNull(delegationMembers)){ |
379 | 0 | for(KimDelegationMemberImpl delegationMember: delegationMembers){ |
380 | 0 | if(!delegationIds.contains(delegationMember.getDelegationId())){ |
381 | 0 | delegationIds.add(delegationMember.getDelegationId()); |
382 | 0 | criteria = new HashMap<String,String>(1); |
383 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.DELEGATION_ID, delegationMember.getDelegationId()); |
384 | 0 | delegations.add((KimDelegationImpl)getBusinessObjectService().findByPrimaryKey(KimDelegationImpl.class, criteria)); |
385 | |
} |
386 | |
} |
387 | |
} |
388 | 0 | return delegations; |
389 | |
} |
390 | |
|
391 | |
|
392 | |
protected void loadDelegationsToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument){ |
393 | 0 | List<RoleDocumentDelegation> delList = new ArrayList<RoleDocumentDelegation>(); |
394 | |
RoleDocumentDelegation documentDelegation; |
395 | 0 | List<KimDelegationImpl> origDelegations = getPersonDelegations(identityManagementPersonDocument.getPrincipalId()); |
396 | 0 | if(ObjectUtils.isNotNull(origDelegations)){ |
397 | 0 | for(KimDelegationImpl del: origDelegations){ |
398 | 0 | if(del.isActive()){ |
399 | 0 | documentDelegation = new RoleDocumentDelegation(); |
400 | 0 | documentDelegation.setActive(del.isActive()); |
401 | 0 | documentDelegation.setDelegationId(del.getDelegationId()); |
402 | 0 | documentDelegation.setDelegationTypeCode(del.getDelegationTypeCode()); |
403 | 0 | documentDelegation.setKimTypeId(del.getKimTypeId()); |
404 | 0 | documentDelegation.setMembers( |
405 | |
loadDelegationMembers(identityManagementPersonDocument, |
406 | |
del.getMembers(), (RoleImpl)getMember(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE, del.getRoleId()))); |
407 | 0 | documentDelegation.setRoleId(del.getRoleId()); |
408 | 0 | documentDelegation.setEdit(true); |
409 | 0 | delList.add(documentDelegation); |
410 | |
} |
411 | |
} |
412 | |
} |
413 | 0 | identityManagementPersonDocument.setDelegations(delList); |
414 | 0 | setDelegationMembersInDocument(identityManagementPersonDocument); |
415 | 0 | } |
416 | |
|
417 | |
public void setDelegationMembersInDocument(IdentityManagementPersonDocument identityManagementPersonDocument){ |
418 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getDelegations())){ |
419 | 0 | for(RoleDocumentDelegation delegation: identityManagementPersonDocument.getDelegations()){ |
420 | 0 | if(CollectionUtils.isNotEmpty(delegation.getMembers())){ |
421 | 0 | for(RoleDocumentDelegationMember member: delegation.getMembers()){ |
422 | 0 | if (StringUtils.equals(member.getMemberId(), identityManagementPersonDocument.getPrincipalId())) |
423 | |
{ |
424 | 0 | member.setDelegationTypeCode(delegation.getDelegationTypeCode()); |
425 | 0 | identityManagementPersonDocument.getDelegationMembers().add(member); |
426 | |
} |
427 | |
} |
428 | |
} |
429 | |
} |
430 | |
} |
431 | 0 | } |
432 | |
|
433 | |
protected List<RoleDocumentDelegationMember> loadDelegationMembers( |
434 | |
IdentityManagementPersonDocument identityManagementPersonDocument, List<KimDelegationMemberImpl> members, RoleImpl roleImpl){ |
435 | 0 | List<RoleDocumentDelegationMember> pndMembers = new ArrayList<RoleDocumentDelegationMember>(); |
436 | 0 | RoleDocumentDelegationMember pndMember = new RoleDocumentDelegationMember(); |
437 | |
RoleMemberImpl roleMember; |
438 | 0 | if(ObjectUtils.isNotNull(members)){ |
439 | 0 | for(KimDelegationMemberImpl member: members){ |
440 | 0 | pndMember = new RoleDocumentDelegationMember(); |
441 | 0 | pndMember.setActiveFromDate(member.getActiveFromDate()); |
442 | 0 | pndMember.setActiveToDate(member.getActiveToDate()); |
443 | 0 | pndMember.setActive(member.isActive()); |
444 | 0 | pndMember.setRoleImpl(roleImpl); |
445 | 0 | if(pndMember.isActive()){ |
446 | 0 | KimCommonUtilsInternal.copyProperties(pndMember, member); |
447 | 0 | pndMember.setRoleMemberId(member.getRoleMemberId()); |
448 | 0 | roleMember = getRoleMemberForRoleMemberId(member.getRoleMemberId()); |
449 | 0 | if(roleMember!=null){ |
450 | 0 | pndMember.setRoleMemberName(getMemberName(roleMember.getMemberTypeCode(), roleMember.getMemberId())); |
451 | 0 | pndMember.setRoleMemberNamespaceCode(getMemberNamespaceCode(roleMember.getMemberTypeCode(), roleMember.getMemberId())); |
452 | |
} |
453 | 0 | pndMember.setMemberNamespaceCode(getMemberNamespaceCode(member.getMemberTypeCode(), member.getMemberId())); |
454 | 0 | pndMember.setMemberName(getMemberName(member.getMemberTypeCode(), member.getMemberId())); |
455 | 0 | pndMember.setEdit(true); |
456 | 0 | pndMember.setQualifiers(loadDelegationMemberQualifiers(identityManagementPersonDocument, pndMember.getAttributesHelper().getDefinitions(), member.getAttributes())); |
457 | 0 | pndMembers.add(pndMember); |
458 | |
} |
459 | |
} |
460 | |
} |
461 | 0 | return pndMembers; |
462 | |
} |
463 | |
|
464 | |
protected List<RoleDocumentDelegationMemberQualifier> loadDelegationMemberQualifiers(IdentityManagementPersonDocument identityManagementPersonDocument, |
465 | |
AttributeDefinitionMap origAttributeDefinitions, List<KimDelegationMemberAttributeDataImpl> attributeDataList){ |
466 | 0 | List<RoleDocumentDelegationMemberQualifier> pndMemberRoleQualifiers = new ArrayList<RoleDocumentDelegationMemberQualifier>(); |
467 | 0 | RoleDocumentDelegationMemberQualifier pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
468 | 0 | boolean attributePresent = false; |
469 | |
String origAttributeId; |
470 | 0 | if(origAttributeDefinitions!=null){ |
471 | 0 | for(String key: origAttributeDefinitions.keySet()) { |
472 | 0 | origAttributeId = identityManagementPersonDocument.getKimAttributeDefnId(origAttributeDefinitions.get(key)); |
473 | 0 | if(ObjectUtils.isNotNull(attributeDataList)){ |
474 | 0 | for(KimDelegationMemberAttributeDataImpl memberRoleQualifier: attributeDataList){ |
475 | 0 | if(StringUtils.equals(origAttributeId, memberRoleQualifier.getKimAttribute().getId())){ |
476 | 0 | pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
477 | 0 | pndMemberRoleQualifier.setAttrDataId(memberRoleQualifier.getId()); |
478 | 0 | pndMemberRoleQualifier.setAttrVal(memberRoleQualifier.getAttributeValue()); |
479 | 0 | pndMemberRoleQualifier.setDelegationMemberId(memberRoleQualifier.getAssignedToId()); |
480 | 0 | pndMemberRoleQualifier.setKimTypId(memberRoleQualifier.getKimTypeId()); |
481 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(memberRoleQualifier.getKimAttributeId()); |
482 | 0 | pndMemberRoleQualifier.setKimAttribute(memberRoleQualifier.getKimAttribute()); |
483 | 0 | pndMemberRoleQualifiers.add(pndMemberRoleQualifier); |
484 | 0 | attributePresent = true; |
485 | |
} |
486 | |
} |
487 | |
} |
488 | 0 | if(!attributePresent){ |
489 | 0 | pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
490 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(origAttributeId); |
491 | 0 | pndMemberRoleQualifiers.add(pndMemberRoleQualifier); |
492 | |
} |
493 | 0 | attributePresent = false; |
494 | |
} |
495 | |
} |
496 | 0 | return pndMemberRoleQualifiers; |
497 | |
} |
498 | |
|
499 | |
|
500 | |
|
501 | |
|
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
protected void loadGroupToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument, List<? extends Group> groups) { |
507 | 0 | List <PersonDocumentGroup> docGroups = new ArrayList <PersonDocumentGroup>(); |
508 | 0 | if(ObjectUtils.isNotNull(groups)){ |
509 | |
List<String> directMemberPrincipalIds; |
510 | |
Collection<GroupMember> groupMemberships; |
511 | 0 | for (Group group: groups) { |
512 | 0 | directMemberPrincipalIds = getGroupService().getDirectMemberPrincipalIds(group.getId()); |
513 | 0 | if(ObjectUtils.isNotNull(directMemberPrincipalIds)){ |
514 | 0 | directMemberPrincipalIds = new ArrayList<String>(new HashSet<String>(directMemberPrincipalIds)); |
515 | 0 | for (String memberId: directMemberPrincipalIds) { |
516 | |
|
517 | |
|
518 | 0 | if (StringUtils.equals(memberId, identityManagementPersonDocument.getPrincipalId())) { |
519 | 0 | List<String> groupIds = new ArrayList<String>(); |
520 | 0 | groupIds.add(group.getId()); |
521 | 0 | groupMemberships = getGroupService().getMembers(groupIds); |
522 | 0 | if(ObjectUtils.isNotNull(groupMemberships)){ |
523 | 0 | for (GroupMember groupMember: groupMemberships) { |
524 | 0 | if (groupMember.isActive() && StringUtils.equals(groupMember.getMemberId(), identityManagementPersonDocument.getPrincipalId()) && |
525 | |
StringUtils.equals(groupMember.getTypeCode(), KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE)) { |
526 | |
|
527 | 0 | PersonDocumentGroup docGroup = new PersonDocumentGroup(); |
528 | 0 | docGroup.setGroupId(group.getId()); |
529 | 0 | docGroup.setGroupName(group.getName()); |
530 | 0 | docGroup.setNamespaceCode(group.getNamespaceCode()); |
531 | 0 | docGroup.setPrincipalId(memberId); |
532 | 0 | docGroup.setGroupMemberId(groupMember.getId()); |
533 | 0 | if (groupMember.getActiveFromDate() != null) { |
534 | 0 | docGroup.setActiveFromDate(new Timestamp(groupMember.getActiveFromDate().getTime())); |
535 | |
} |
536 | 0 | if (groupMember.getActiveToDate() != null) { |
537 | 0 | docGroup.setActiveToDate(new Timestamp(groupMember.getActiveToDate().getTime())); |
538 | |
} |
539 | 0 | docGroup.setEdit(true); |
540 | 0 | docGroups.add(docGroup); |
541 | 0 | } |
542 | |
} |
543 | |
} |
544 | 0 | } |
545 | |
} |
546 | |
} |
547 | |
} |
548 | |
} |
549 | 0 | identityManagementPersonDocument.setGroups(docGroups); |
550 | 0 | } |
551 | |
|
552 | |
protected void loadRoleToPersonDoc(IdentityManagementPersonDocument identityManagementPersonDocument) { |
553 | 0 | List <PersonDocumentRole> docRoles = new ArrayList <PersonDocumentRole>(); |
554 | 0 | List<RoleImpl> roles = getRolesForPrincipal(identityManagementPersonDocument.getPrincipalId()); |
555 | 0 | List<String> roleIds = new ArrayList<String>(); |
556 | 0 | if(ObjectUtils.isNotNull(roles)){ |
557 | 0 | for (RoleImpl role : roles) { |
558 | 0 | if (!roleIds.contains(role.getRoleId())) { |
559 | 0 | PersonDocumentRole docRole = new PersonDocumentRole(); |
560 | 0 | docRole.setKimTypeId(role.getKimTypeId()); |
561 | 0 | docRole.setActive(role.isActive()); |
562 | 0 | docRole.setNamespaceCode(role.getNamespaceCode()); |
563 | 0 | docRole.setEdit(true); |
564 | 0 | docRole.setRoleId(role.getRoleId()); |
565 | 0 | docRole.setRoleName(role.getRoleName()); |
566 | 0 | docRole.setRolePrncpls(populateDocRolePrncpl(role.getMembers(), identityManagementPersonDocument.getPrincipalId(), getAttributeDefinitionsForRole(docRole))); |
567 | 0 | docRole.refreshReferenceObject("assignedResponsibilities"); |
568 | 0 | if(docRole.getRolePrncpls()!=null && !docRole.getRolePrncpls().isEmpty()){ |
569 | 0 | docRoles.add(docRole); |
570 | 0 | roleIds.add(role.getRoleId()); |
571 | |
} |
572 | 0 | } |
573 | |
} |
574 | |
} |
575 | 0 | for (PersonDocumentRole role : docRoles) { |
576 | 0 | role.setDefinitions(getAttributeDefinitionsForRole(role)); |
577 | |
|
578 | 0 | role.setNewRolePrncpl(new KimDocumentRoleMember()); |
579 | 0 | if(role.getDefinitions()!=null){ |
580 | 0 | for (String key : role.getDefinitions().keySet()) { |
581 | 0 | KimDocumentRoleQualifier qualifier = new KimDocumentRoleQualifier(); |
582 | |
|
583 | 0 | setAttrDefnIdForQualifier(qualifier,role.getDefinitions().get(key)); |
584 | 0 | role.getNewRolePrncpl().getQualifiers().add(qualifier); |
585 | 0 | } |
586 | |
} |
587 | 0 | loadRoleRstAction(role); |
588 | 0 | role.setAttributeEntry( getAttributeEntries( role.getDefinitions() ) ); |
589 | |
} |
590 | |
|
591 | |
|
592 | 0 | identityManagementPersonDocument.setRoles(docRoles); |
593 | 0 | } |
594 | |
|
595 | |
protected AttributeDefinitionMap getAttributeDefinitionsForRole(PersonDocumentRole role) { |
596 | 0 | KimTypeService kimTypeService = KIMServiceLocatorWeb.getKimTypeService(KimTypeBo.to(role.getKimRoleType())); |
597 | |
|
598 | |
|
599 | |
try { |
600 | 0 | if ( kimTypeService != null ) { |
601 | 0 | return kimTypeService.getAttributeDefinitions(role.getKimTypeId()); |
602 | |
} |
603 | 0 | } catch (Exception ex) { |
604 | 0 | LOG.warn("Not able to retrieve KimTypeService from remote system for KIM Role Type: " + role.getKimRoleType(), ex); |
605 | 0 | } |
606 | 0 | return new AttributeDefinitionMap(); |
607 | |
} |
608 | |
|
609 | |
protected void loadRoleRstAction(PersonDocumentRole role) { |
610 | 0 | if(role!=null && CollectionUtils.isNotEmpty(role.getRolePrncpls())){ |
611 | 0 | for (KimDocumentRoleMember roleMbr : role.getRolePrncpls()) { |
612 | 0 | List<RoleResponsibilityActionImpl> actions = getRoleRspActions( roleMbr.getRoleMemberId()); |
613 | 0 | if(ObjectUtils.isNotNull(actions)){ |
614 | 0 | for (RoleResponsibilityActionImpl entRoleRspAction :actions) { |
615 | 0 | KimDocumentRoleResponsibilityAction roleRspAction = new KimDocumentRoleResponsibilityAction(); |
616 | 0 | roleRspAction.setRoleResponsibilityId(entRoleRspAction.getRoleResponsibilityId()); |
617 | 0 | roleRspAction.setActionTypeCode(entRoleRspAction.getActionTypeCode()); |
618 | 0 | roleRspAction.setActionPolicyCode(entRoleRspAction.getActionPolicyCode()); |
619 | 0 | roleRspAction.setPriorityNumber(entRoleRspAction.getPriorityNumber()); |
620 | 0 | roleRspAction.setRoleResponsibilityActionId(entRoleRspAction.getRoleResponsibilityActionId()); |
621 | 0 | roleRspAction.refreshReferenceObject("roleResponsibility"); |
622 | 0 | roleMbr.getRoleRspActions().add(roleRspAction); |
623 | 0 | } |
624 | |
} |
625 | 0 | } |
626 | |
} |
627 | 0 | } |
628 | |
|
629 | |
protected void setAttrDefnIdForQualifier(KimDocumentRoleQualifier qualifier, AttributeDefinition definition) { |
630 | 0 | qualifier.setKimAttrDefnId(getAttributeDefnId(definition)); |
631 | 0 | qualifier.refreshReferenceObject("kimAttribute"); |
632 | 0 | } |
633 | |
|
634 | |
protected String getAttributeDefnId(AttributeDefinition definition) { |
635 | 0 | if (definition instanceof KimDataDictionaryAttributeDefinition) { |
636 | 0 | return ((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
637 | |
} |
638 | 0 | return ((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
639 | |
} |
640 | |
|
641 | |
private PrincipalBo getPrincipalImpl(String principalId) { |
642 | 0 | Map<String,String> criteria = new HashMap<String,String>(1); |
643 | 0 | criteria.put(KIMPropertyConstants.Principal.PRINCIPAL_ID, principalId); |
644 | 0 | return (PrincipalBo)getBusinessObjectService().findByPrimaryKey(PrincipalBo.class, criteria); |
645 | |
} |
646 | |
|
647 | |
public List<KimEntityEmploymentInformationInfo> getEntityEmploymentInformationInfo(String entityId) { |
648 | 0 | KimEntityImpl entityImpl = getEntityImpl(entityId); |
649 | 0 | List<KimEntityEmploymentInformationInfo> empInfos = new ArrayList<KimEntityEmploymentInformationInfo>(); |
650 | |
KimEntityEmploymentInformationInfo empInfo; |
651 | 0 | if(ObjectUtils.isNotNull(entityImpl) && CollectionUtils.isNotEmpty(entityImpl.getEmploymentInformation())){ |
652 | 0 | for(KimEntityEmploymentInformationImpl empImpl: entityImpl.getEmploymentInformation()){ |
653 | 0 | empInfo = new KimEntityEmploymentInformationInfo(empImpl); |
654 | 0 | empInfos.add(empInfo); |
655 | |
} |
656 | |
} |
657 | 0 | return empInfos; |
658 | |
} |
659 | |
|
660 | |
private KimEntityImpl getEntityImpl(String entityId) { |
661 | 0 | KimEntityImpl entityImpl = (KimEntityImpl)getBusinessObjectService().findBySinglePrimaryKey(KimEntityImpl.class, entityId); |
662 | |
|
663 | 0 | if(entityImpl!=null && entityImpl.getEntityTypes() != null) { |
664 | 0 | for (EntityTypeDataBo et : entityImpl.getEntityTypes()) { |
665 | 0 | et.refresh(); |
666 | |
} |
667 | |
} |
668 | 0 | return entityImpl; |
669 | |
} |
670 | |
|
671 | |
@SuppressWarnings("unchecked") |
672 | |
protected List<RoleImpl> getRolesForPrincipal(String principalId) { |
673 | 0 | if ( principalId == null ) { |
674 | 0 | return new ArrayList<RoleImpl>(); |
675 | |
} |
676 | 0 | Map<String,String> criteria = new HashMap<String,String>( 2 ); |
677 | 0 | criteria.put("members.memberId", principalId); |
678 | 0 | criteria.put("members.memberTypeCode", RoleImpl.PRINCIPAL_MEMBER_TYPE); |
679 | 0 | return (List<RoleImpl>)getBusinessObjectService().findMatching(RoleImpl.class, criteria); |
680 | |
} |
681 | |
|
682 | |
@SuppressWarnings("unchecked") |
683 | |
protected List<RoleMemberImpl> getRoleMembersForPrincipal(String principalId) { |
684 | 0 | if ( principalId == null ) { |
685 | 0 | return new ArrayList<RoleMemberImpl>(); |
686 | |
} |
687 | 0 | Map<String,String> criteria = new HashMap<String,String>( 2 ); |
688 | 0 | criteria.put("memberId", principalId); |
689 | 0 | criteria.put("memberTypeCode", RoleImpl.PRINCIPAL_MEMBER_TYPE); |
690 | 0 | return (List<RoleMemberImpl>)getBusinessObjectService().findMatching(RoleMemberImpl.class, criteria); |
691 | |
} |
692 | |
|
693 | |
public RoleMemberImpl getRoleMember(String roleMemberId) { |
694 | 0 | if ( roleMemberId == null ) { |
695 | 0 | return null; |
696 | |
} |
697 | 0 | Map<String,String> criteria = new HashMap<String,String>( 2 ); |
698 | 0 | criteria.put("roleMemberId", roleMemberId); |
699 | 0 | return (RoleMemberImpl)getBusinessObjectService().findByPrimaryKey(RoleMemberImpl.class, criteria); |
700 | |
} |
701 | |
|
702 | |
@SuppressWarnings("unchecked") |
703 | |
protected List<RoleResponsibilityActionImpl> getRoleRspActions(String roleMemberId) { |
704 | 0 | Map<String,String> criteria = new HashMap<String,String>( 1 ); |
705 | 0 | criteria.put(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId); |
706 | 0 | return (List<RoleResponsibilityActionImpl>)getBusinessObjectService().findMatching(RoleResponsibilityActionImpl.class, criteria); |
707 | |
} |
708 | |
|
709 | |
protected List<KimDocumentRoleMember> populateDocRolePrncpl(List <RoleMemberImpl> roleMembers, String principalId, AttributeDefinitionMap definitions) { |
710 | 0 | List <KimDocumentRoleMember> docRoleMembers = new ArrayList <KimDocumentRoleMember>(); |
711 | 0 | if(ObjectUtils.isNotNull(roleMembers)){ |
712 | 0 | for (RoleMemberImpl rolePrincipal : roleMembers) { |
713 | 0 | if (rolePrincipal.isActive() && RoleImpl.PRINCIPAL_MEMBER_TYPE.equals(rolePrincipal.getMemberTypeCode()) && |
714 | |
StringUtils.equals(rolePrincipal.getMemberId(), principalId)) { |
715 | 0 | KimDocumentRoleMember docRolePrncpl = new KimDocumentRoleMember(); |
716 | 0 | docRolePrncpl.setMemberId(rolePrincipal.getMemberId()); |
717 | 0 | docRolePrncpl.setRoleMemberId(rolePrincipal.getRoleMemberId()); |
718 | 0 | docRolePrncpl.setActive(rolePrincipal.isActive()); |
719 | 0 | docRolePrncpl.setRoleId(rolePrincipal.getRoleId()); |
720 | 0 | docRolePrncpl.setActiveFromDate(rolePrincipal.getActiveFromDate()); |
721 | 0 | docRolePrncpl.setActiveToDate(rolePrincipal.getActiveToDate()); |
722 | 0 | docRolePrncpl.setQualifiers(populateDocRoleQualifier(rolePrincipal.getAttributes(), definitions)); |
723 | 0 | docRolePrncpl.setEdit(true); |
724 | 0 | docRoleMembers.add(docRolePrncpl); |
725 | 0 | } |
726 | |
} |
727 | |
} |
728 | 0 | return docRoleMembers; |
729 | |
} |
730 | |
|
731 | |
|
732 | |
|
733 | |
|
734 | |
protected List<KimDocumentRoleQualifier> populateDocRoleQualifier(List <RoleMemberAttributeDataImpl> qualifiers, AttributeDefinitionMap definitions) { |
735 | 0 | List <KimDocumentRoleQualifier> docRoleQualifiers = new ArrayList <KimDocumentRoleQualifier>(); |
736 | 0 | if(definitions!=null){ |
737 | 0 | for (String key : definitions.keySet()) { |
738 | 0 | AttributeDefinition definition = definitions.get(key); |
739 | 0 | String attrDefId=null; |
740 | 0 | if (definition instanceof KimDataDictionaryAttributeDefinition) { |
741 | 0 | attrDefId = ((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
742 | |
} else { |
743 | 0 | attrDefId = ((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
744 | |
} |
745 | 0 | boolean qualifierFound = false; |
746 | 0 | if(ObjectUtils.isNotNull(qualifiers)){ |
747 | 0 | for (RoleMemberAttributeDataImpl qualifier : qualifiers) { |
748 | 0 | if (attrDefId!=null && StringUtils.equals(attrDefId, qualifier.getKimAttributeId())) { |
749 | 0 | KimDocumentRoleQualifier docRoleQualifier = new KimDocumentRoleQualifier(); |
750 | 0 | docRoleQualifier.setAttrDataId(qualifier.getId()); |
751 | 0 | docRoleQualifier.setAttrVal(qualifier.getAttributeValue()); |
752 | 0 | docRoleQualifier.setKimAttrDefnId(qualifier.getKimAttributeId()); |
753 | 0 | docRoleQualifier.setKimAttribute(qualifier.getKimAttribute()); |
754 | 0 | docRoleQualifier.setKimTypId(qualifier.getKimTypeId()); |
755 | 0 | docRoleQualifier.setRoleMemberId(qualifier.getAssignedToId()); |
756 | 0 | docRoleQualifier.setEdit(true); |
757 | 0 | formatAttrValIfNecessary(docRoleQualifier); |
758 | 0 | docRoleQualifiers.add(docRoleQualifier); |
759 | 0 | qualifierFound = true; |
760 | 0 | break; |
761 | |
} |
762 | |
} |
763 | |
} |
764 | 0 | if (!qualifierFound) { |
765 | 0 | KimDocumentRoleQualifier docRoleQualifier = new KimDocumentRoleQualifier(); |
766 | 0 | docRoleQualifier.setAttrVal(""); |
767 | 0 | docRoleQualifier.setKimAttrDefnId(attrDefId); |
768 | 0 | docRoleQualifier.refreshReferenceObject("kimAttribute"); |
769 | 0 | docRoleQualifiers.add(docRoleQualifier); |
770 | |
} |
771 | 0 | } |
772 | |
|
773 | |
|
774 | |
|
775 | 0 | if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(SHOW_BLANK_QUALIFIERS))) { |
776 | 0 | int qualCount = 0; |
777 | 0 | for (KimDocumentRoleQualifier qual : docRoleQualifiers){ |
778 | 0 | if (StringUtils.isEmpty(qual.getAttrVal())){ |
779 | 0 | qualCount++; |
780 | |
} |
781 | |
} |
782 | 0 | if (qualCount == docRoleQualifiers.size()){ |
783 | 0 | return new ArrayList <KimDocumentRoleQualifier>(); |
784 | |
} |
785 | |
} |
786 | |
} |
787 | 0 | return docRoleQualifiers; |
788 | |
} |
789 | |
|
790 | |
protected List<PersonDocumentName> loadNames( IdentityManagementPersonDocument personDoc, String principalId, List <KimEntityNameInfo> names, boolean suppressDisplay ) { |
791 | 0 | List<PersonDocumentName> docNames = new ArrayList<PersonDocumentName>(); |
792 | 0 | if(ObjectUtils.isNotNull(names)){ |
793 | 0 | for (KimEntityNameInfo name: names) { |
794 | 0 | if(name.isActive()){ |
795 | 0 | PersonDocumentName docName = new PersonDocumentName(); |
796 | 0 | docName.setNameTypeCode(name.getNameTypeCode()); |
797 | |
|
798 | |
|
799 | 0 | docName.setFirstName(name.getFirstNameUnmasked()); |
800 | 0 | docName.setLastName(name.getLastNameUnmasked()); |
801 | 0 | docName.setMiddleName(name.getMiddleNameUnmasked()); |
802 | 0 | docName.setTitle(name.getTitleUnmasked()); |
803 | 0 | docName.setSuffix(name.getSuffixUnmasked()); |
804 | |
|
805 | 0 | docName.setActive(name.isActive()); |
806 | 0 | docName.setDflt(name.isDefaultValue()); |
807 | 0 | docName.setEdit(true); |
808 | 0 | docName.setEntityNameId(name.getEntityNameId()); |
809 | 0 | docNames.add(docName); |
810 | 0 | } |
811 | |
} |
812 | |
} |
813 | 0 | return docNames; |
814 | |
} |
815 | |
|
816 | |
public boolean canModifyEntity( String currentUserPrincipalId, String toModifyPrincipalId ){ |
817 | 0 | return (StringUtils.isNotBlank(currentUserPrincipalId) && StringUtils.isNotBlank(toModifyPrincipalId) && |
818 | |
currentUserPrincipalId.equals(toModifyPrincipalId)) || |
819 | |
getIdentityManagementService().isAuthorized( |
820 | |
currentUserPrincipalId, |
821 | |
KimConstants.NAMESPACE_CODE, |
822 | |
KimConstants.PermissionNames.MODIFY_ENTITY, |
823 | |
null, |
824 | |
new AttributeSet(KimConstants.AttributeConstants.PRINCIPAL_ID, currentUserPrincipalId)); |
825 | |
} |
826 | |
|
827 | |
public boolean canOverrideEntityPrivacyPreferences( String currentUserPrincipalId, String toModifyPrincipalId ){ |
828 | 0 | return (StringUtils.isNotBlank(currentUserPrincipalId) && StringUtils.isNotBlank(toModifyPrincipalId) && |
829 | |
currentUserPrincipalId.equals(toModifyPrincipalId)) || |
830 | |
getIdentityManagementService().isAuthorized( |
831 | |
currentUserPrincipalId, |
832 | |
KimConstants.NAMESPACE_CODE, |
833 | |
KimConstants.PermissionNames.OVERRIDE_ENTITY_PRIVACY_PREFERENCES, |
834 | |
null, |
835 | |
new AttributeSet(KimConstants.AttributeConstants.PRINCIPAL_ID, currentUserPrincipalId) ); |
836 | |
} |
837 | |
|
838 | |
protected boolean canAssignToRole(IdentityManagementRoleDocument document, String initiatorPrincipalId){ |
839 | 0 | boolean rulePassed = true; |
840 | 0 | Map<String,String> additionalPermissionDetails = new HashMap<String,String>(); |
841 | 0 | additionalPermissionDetails.put(KimConstants.AttributeConstants.NAMESPACE_CODE, document.getRoleNamespace()); |
842 | 0 | additionalPermissionDetails.put(KimConstants.AttributeConstants.ROLE_NAME, document.getRoleName()); |
843 | 0 | if(!getDocumentHelperService().getDocumentAuthorizer(document).isAuthorizedByTemplate( |
844 | |
document, KimConstants.NAMESPACE_CODE, KimConstants.PermissionTemplateNames.ASSIGN_ROLE, |
845 | |
initiatorPrincipalId, additionalPermissionDetails, null)){ |
846 | 0 | rulePassed = false; |
847 | |
} |
848 | 0 | return rulePassed; |
849 | |
} |
850 | |
|
851 | |
protected List<PersonDocumentAffiliation> loadAffiliations(List <KimEntityAffiliationInfo> affiliations, List<KimEntityEmploymentInformationInfo> empInfos) { |
852 | 0 | List<PersonDocumentAffiliation> docAffiliations = new ArrayList<PersonDocumentAffiliation>(); |
853 | 0 | if(ObjectUtils.isNotNull(affiliations)){ |
854 | 0 | for (KimEntityAffiliation affiliation: affiliations) { |
855 | 0 | if(affiliation.isActive()){ |
856 | 0 | PersonDocumentAffiliation docAffiliation = new PersonDocumentAffiliation(); |
857 | 0 | docAffiliation.setAffiliationTypeCode(affiliation.getAffiliationTypeCode()); |
858 | 0 | docAffiliation.setCampusCode(affiliation.getCampusCode()); |
859 | 0 | docAffiliation.setActive(affiliation.isActive()); |
860 | 0 | docAffiliation.setDflt(affiliation.isDefaultValue()); |
861 | 0 | docAffiliation.setEntityAffiliationId(affiliation.getEntityAffiliationId()); |
862 | 0 | docAffiliation.refreshReferenceObject("affiliationType"); |
863 | |
|
864 | 0 | docAffiliations.add(docAffiliation); |
865 | 0 | docAffiliation.setEdit(true); |
866 | |
|
867 | 0 | List<PersonDocumentEmploymentInfo> docEmploymentInformations = new ArrayList<PersonDocumentEmploymentInfo>(); |
868 | 0 | if(ObjectUtils.isNotNull(empInfos)){ |
869 | 0 | for (KimEntityEmploymentInformationInfo empInfo: empInfos) { |
870 | 0 | if (empInfo.isActive() && StringUtils.equals(docAffiliation.getEntityAffiliationId(), empInfo.getEntityAffiliationId())) { |
871 | 0 | PersonDocumentEmploymentInfo docEmpInfo = new PersonDocumentEmploymentInfo(); |
872 | 0 | docEmpInfo.setEntityEmploymentId(empInfo.getEntityEmploymentId()); |
873 | 0 | docEmpInfo.setEmployeeId(empInfo.getEmployeeId()); |
874 | 0 | docEmpInfo.setEmploymentRecordId(empInfo.getEmploymentRecordId()); |
875 | 0 | docEmpInfo.setBaseSalaryAmount(empInfo.getBaseSalaryAmount()); |
876 | 0 | docEmpInfo.setPrimaryDepartmentCode(empInfo.getPrimaryDepartmentCode()); |
877 | 0 | docEmpInfo.setEmploymentStatusCode(empInfo.getEmployeeStatusCode()); |
878 | 0 | docEmpInfo.setEmploymentTypeCode(empInfo.getEmployeeTypeCode()); |
879 | 0 | docEmpInfo.setActive(empInfo.isActive()); |
880 | 0 | docEmpInfo.setPrimary(empInfo.isPrimary()); |
881 | 0 | docEmpInfo.setEntityAffiliationId(empInfo.getEntityAffiliationId()); |
882 | |
|
883 | |
|
884 | 0 | docEmpInfo.setEdit(true); |
885 | 0 | docEmpInfo.refreshReferenceObject("employmentType"); |
886 | 0 | docEmploymentInformations.add(docEmpInfo); |
887 | 0 | } |
888 | |
} |
889 | |
} |
890 | 0 | docAffiliation.setEmpInfos(docEmploymentInformations); |
891 | 0 | } |
892 | |
} |
893 | |
} |
894 | 0 | return docAffiliations; |
895 | |
|
896 | |
} |
897 | |
|
898 | |
protected boolean setupPrincipal(IdentityManagementPersonDocument identityManagementPersonDocument, KimEntityImpl kimEntity, List<PrincipalBo> origPrincipals) { |
899 | 0 | boolean inactivatingPrincipal = false; |
900 | 0 | List<PrincipalBo> principals = new ArrayList<PrincipalBo>(); |
901 | 0 | Principal.Builder principal = Principal.Builder.create(identityManagementPersonDocument.getPrincipalName()); |
902 | 0 | principal.setPrincipalId(identityManagementPersonDocument.getPrincipalId()); |
903 | 0 | principal.setPassword(identityManagementPersonDocument.getPassword()); |
904 | 0 | principal.setActive(identityManagementPersonDocument.isActive()); |
905 | 0 | principal.setEntityId(identityManagementPersonDocument.getEntityId()); |
906 | 0 | if(ObjectUtils.isNotNull(origPrincipals)){ |
907 | 0 | for (PrincipalBo prncpl : origPrincipals) { |
908 | 0 | if (prncpl.getPrincipalId()!=null && StringUtils.equals(prncpl.getPrincipalId(), principal.getPrincipalId())) { |
909 | 0 | principal.setVersionNumber(prncpl.getVersionNumber()); |
910 | 0 | principal.setObjectId(prncpl.getObjectId()); |
911 | |
|
912 | 0 | if ( prncpl.isActive() && !principal.isActive() ) { |
913 | 0 | inactivatingPrincipal = true; |
914 | |
} |
915 | |
} |
916 | |
} |
917 | |
} |
918 | 0 | principals.add(PrincipalBo.from(principal.build())); |
919 | |
|
920 | 0 | kimEntity.setPrincipals(principals); |
921 | 0 | return inactivatingPrincipal; |
922 | |
} |
923 | |
|
924 | |
protected void setupPrivacy(IdentityManagementPersonDocument identityManagementPersonDocument, KimEntityImpl kimEntity, EntityPrivacyPreferencesBo origPrivacy) { |
925 | 0 | EntityPrivacyPreferencesBo privacyPreferences = new EntityPrivacyPreferencesBo(); |
926 | 0 | privacyPreferences.setEntityId(identityManagementPersonDocument.getEntityId()); |
927 | 0 | privacyPreferences.setSuppressAddress(identityManagementPersonDocument.getPrivacy().isSuppressAddress()); |
928 | 0 | privacyPreferences.setSuppressEmail(identityManagementPersonDocument.getPrivacy().isSuppressEmail()); |
929 | 0 | privacyPreferences.setSuppressName(identityManagementPersonDocument.getPrivacy().isSuppressName()); |
930 | 0 | privacyPreferences.setSuppressPhone(identityManagementPersonDocument.getPrivacy().isSuppressPhone()); |
931 | 0 | privacyPreferences.setSuppressPersonal(identityManagementPersonDocument.getPrivacy().isSuppressPersonal()); |
932 | 0 | if (ObjectUtils.isNotNull(origPrivacy)) { |
933 | 0 | privacyPreferences.setVersionNumber(origPrivacy.getVersionNumber()); |
934 | 0 | privacyPreferences.setObjectId(origPrivacy.getObjectId()); |
935 | |
} |
936 | 0 | kimEntity.setPrivacyPreferences(privacyPreferences); |
937 | 0 | } |
938 | |
protected PersonDocumentPrivacy loadPrivacyReferences(EntityPrivacyPreferences privacyPreferences) { |
939 | 0 | PersonDocumentPrivacy docPrivacy = new PersonDocumentPrivacy(); |
940 | 0 | docPrivacy.setSuppressAddress(privacyPreferences.isSuppressAddress()); |
941 | 0 | docPrivacy.setSuppressEmail(privacyPreferences.isSuppressEmail()); |
942 | 0 | docPrivacy.setSuppressName(privacyPreferences.isSuppressName()); |
943 | 0 | docPrivacy.setSuppressPhone(privacyPreferences.isSuppressPhone()); |
944 | 0 | docPrivacy.setSuppressPersonal(privacyPreferences.isSuppressPersonal()); |
945 | 0 | docPrivacy.setEdit(true); |
946 | 0 | return docPrivacy; |
947 | |
} |
948 | |
|
949 | |
protected void setupName(IdentityManagementPersonDocument identityManagementPersonDocument, KimEntityImpl kimEntity, List<KimEntityNameImpl> origNames) { |
950 | 0 | if ( !identityManagementPersonDocument.getPrivacy().isSuppressName() || |
951 | |
canOverrideEntityPrivacyPreferences( getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId() ) ) { |
952 | 0 | List<KimEntityNameImpl> entityNames = new ArrayList<KimEntityNameImpl>(); |
953 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getNames())){ |
954 | 0 | for (PersonDocumentName name : identityManagementPersonDocument.getNames()) { |
955 | 0 | KimEntityNameImpl entityName = new KimEntityNameImpl(); |
956 | 0 | entityName.setNameTypeCode(name.getNameTypeCode()); |
957 | 0 | entityName.setFirstName(name.getFirstName()); |
958 | 0 | entityName.setLastName(name.getLastName()); |
959 | 0 | entityName.setMiddleName(name.getMiddleName()); |
960 | 0 | entityName.setTitle(name.getTitle()); |
961 | 0 | entityName.setSuffix(name.getSuffix()); |
962 | 0 | entityName.setActive(name.isActive()); |
963 | 0 | entityName.setDefaultValue(name.isDflt()); |
964 | 0 | entityName.setEntityNameId(name.getEntityNameId()); |
965 | 0 | entityName.setEntityId(identityManagementPersonDocument.getEntityId()); |
966 | 0 | if(ObjectUtils.isNotNull(origNames)){ |
967 | 0 | for (KimEntityNameImpl origName : origNames) { |
968 | 0 | if (origName.getEntityNameId()!=null && StringUtils.equals(origName.getEntityNameId(), entityName.getEntityNameId())) { |
969 | 0 | entityName.setVersionNumber(origName.getVersionNumber()); |
970 | |
} |
971 | |
|
972 | |
} |
973 | |
} |
974 | 0 | entityNames.add(entityName); |
975 | 0 | } |
976 | |
} |
977 | 0 | kimEntity.setNames(entityNames); |
978 | |
} |
979 | 0 | } |
980 | |
|
981 | |
protected void setupAffiliation(IdentityManagementPersonDocument identityManagementPersonDocument, KimEntityImpl kimEntity,List<KimEntityAffiliationImpl> origAffiliations, List<KimEntityEmploymentInformationImpl> origEmpInfos) { |
982 | 0 | List<KimEntityAffiliationImpl> entityAffiliations = new ArrayList<KimEntityAffiliationImpl>(); |
983 | |
|
984 | 0 | List<KimEntityEmploymentInformationImpl> entityEmploymentInformations = new ArrayList<KimEntityEmploymentInformationImpl>(); |
985 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getAffiliations())){ |
986 | 0 | for (PersonDocumentAffiliation affiliation : identityManagementPersonDocument.getAffiliations()) { |
987 | 0 | KimEntityAffiliationImpl entityAffiliation = new KimEntityAffiliationImpl(); |
988 | 0 | entityAffiliation.setAffiliationTypeCode(affiliation.getAffiliationTypeCode()); |
989 | 0 | entityAffiliation.setCampusCode(affiliation.getCampusCode()); |
990 | 0 | entityAffiliation.setActive(affiliation.isActive()); |
991 | 0 | entityAffiliation.setDefaultValue(affiliation.isDflt()); |
992 | 0 | entityAffiliation.setEntityId(identityManagementPersonDocument.getEntityId()); |
993 | 0 | entityAffiliation.setEntityAffiliationId(affiliation.getEntityAffiliationId()); |
994 | 0 | if(ObjectUtils.isNotNull(origAffiliations)){ |
995 | |
|
996 | 0 | for (KimEntityAffiliationImpl origAffiliation : origAffiliations) { |
997 | 0 | if(isSameAffiliation(origAffiliation, entityAffiliation)){ |
998 | 0 | entityAffiliation.setEntityAffiliationId(origAffiliation.getEntityAffiliationId()); |
999 | |
} |
1000 | 0 | if (origAffiliation.getEntityAffiliationId()!=null && StringUtils.equals(origAffiliation.getEntityAffiliationId(), entityAffiliation.getEntityAffiliationId())) { |
1001 | 0 | entityAffiliation.setVersionNumber(origAffiliation.getVersionNumber()); |
1002 | |
} |
1003 | |
} |
1004 | |
} |
1005 | 0 | entityAffiliations.add(entityAffiliation); |
1006 | 0 | int employeeRecordCounter = origEmpInfos==null?0:origEmpInfos.size(); |
1007 | 0 | if(CollectionUtils.isNotEmpty(affiliation.getEmpInfos())){ |
1008 | 0 | for (PersonDocumentEmploymentInfo empInfo : affiliation.getEmpInfos()) { |
1009 | 0 | KimEntityEmploymentInformationImpl entityEmpInfo = new KimEntityEmploymentInformationImpl(); |
1010 | 0 | entityEmpInfo.setEntityEmploymentId(empInfo.getEntityEmploymentId()); |
1011 | 0 | entityEmpInfo.setEmployeeId(empInfo.getEmployeeId()); |
1012 | 0 | entityEmpInfo.setEmploymentRecordId(empInfo.getEmploymentRecordId()); |
1013 | 0 | entityEmpInfo.setBaseSalaryAmount(empInfo.getBaseSalaryAmount()); |
1014 | 0 | entityEmpInfo.setPrimaryDepartmentCode(empInfo.getPrimaryDepartmentCode()); |
1015 | 0 | entityEmpInfo.setEmployeeStatusCode(empInfo.getEmploymentStatusCode()); |
1016 | 0 | entityEmpInfo.setEmployeeTypeCode(empInfo.getEmploymentTypeCode()); |
1017 | 0 | entityEmpInfo.setActive(empInfo.isActive()); |
1018 | 0 | entityEmpInfo.setPrimary(empInfo.isPrimary()); |
1019 | 0 | entityEmpInfo.setEntityId(identityManagementPersonDocument.getEntityId()); |
1020 | 0 | entityEmpInfo.setEntityAffiliationId(empInfo.getEntityAffiliationId()); |
1021 | 0 | if(ObjectUtils.isNotNull(origEmpInfos)){ |
1022 | 0 | for (KimEntityEmploymentInformationImpl origEmpInfo : origEmpInfos) { |
1023 | 0 | if(isSameEmpInfo(origEmpInfo, entityEmpInfo)){ |
1024 | 0 | entityEmpInfo.setEntityEmploymentId(entityEmpInfo.getEntityEmploymentId()); |
1025 | |
} |
1026 | |
|
1027 | 0 | if (origEmpInfo.getEntityEmploymentId()!=null && StringUtils.equals(origEmpInfo.getEntityEmploymentId(), entityEmpInfo.getEntityEmploymentId())) { |
1028 | 0 | entityEmpInfo.setVersionNumber(origEmpInfo.getVersionNumber()); |
1029 | 0 | entityEmpInfo.setEmploymentRecordId(empInfo.getEmploymentRecordId()); |
1030 | |
} |
1031 | |
} |
1032 | |
} |
1033 | 0 | if(StringUtils.isEmpty(entityEmpInfo.getEmploymentRecordId())){ |
1034 | 0 | employeeRecordCounter++; |
1035 | 0 | entityEmpInfo.setEmploymentRecordId(employeeRecordCounter+""); |
1036 | |
} |
1037 | 0 | entityEmploymentInformations.add(entityEmpInfo); |
1038 | 0 | } |
1039 | |
} |
1040 | 0 | } |
1041 | |
} |
1042 | 0 | kimEntity.setEmploymentInformation(entityEmploymentInformations); |
1043 | 0 | kimEntity.setAffiliations(entityAffiliations); |
1044 | 0 | } |
1045 | |
|
1046 | |
private boolean isSameAffiliation(KimEntityAffiliationImpl origAffiliation, KimEntityAffiliationImpl entityAffiliation){ |
1047 | |
|
1048 | |
|
1049 | |
|
1050 | 0 | return (origAffiliation!=null && entityAffiliation!=null) && |
1051 | |
(StringUtils.isNotEmpty(origAffiliation.getCampusCode()) && StringUtils.equals(origAffiliation.getCampusCode(), entityAffiliation.getCampusCode())) |
1052 | |
&& |
1053 | |
(StringUtils.isNotEmpty(origAffiliation.getAffiliationTypeCode()) && StringUtils.equals(origAffiliation.getAffiliationTypeCode(), entityAffiliation.getAffiliationTypeCode())) |
1054 | |
&& |
1055 | |
(StringUtils.isNotEmpty(origAffiliation.getEntityId()) && StringUtils.equals(origAffiliation.getEntityId(), entityAffiliation.getEntityId())); |
1056 | |
} |
1057 | |
|
1058 | |
private boolean isSameEmpInfo(KimEntityEmploymentInformationImpl origEmpInfo, KimEntityEmploymentInformationImpl entityEmpInfo){ |
1059 | |
|
1060 | |
|
1061 | |
|
1062 | |
|
1063 | 0 | return (origEmpInfo!=null && entityEmpInfo!=null) |
1064 | |
&& (StringUtils.isNotEmpty(origEmpInfo.getEmploymentRecordId()) |
1065 | |
&& StringUtils.equals(origEmpInfo.getEmploymentRecordId(), entityEmpInfo.getEmploymentRecordId() ) |
1066 | |
) |
1067 | |
&& StringUtils.equals( origEmpInfo.getEntityId(),entityEmpInfo.getEntityId()); |
1068 | |
} |
1069 | |
|
1070 | |
protected void setupPhone(IdentityManagementPersonDocument identityManagementPersonDocument, EntityTypeDataBo entityType, List<EntityPhoneBo> origPhones) { |
1071 | 0 | if ( !identityManagementPersonDocument.getPrivacy().isSuppressPhone() || canOverrideEntityPrivacyPreferences(getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId()) ) { |
1072 | 0 | List<EntityPhoneBo> entityPhones = new ArrayList<EntityPhoneBo>(); |
1073 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getPhones())){ |
1074 | 0 | for (PersonDocumentPhone phone : identityManagementPersonDocument.getPhones()) { |
1075 | 0 | EntityPhoneBo entityPhone = new EntityPhoneBo(); |
1076 | 0 | entityPhone.setPhoneTypeCode(phone.getPhoneTypeCode()); |
1077 | 0 | entityPhone.setEntityId(identityManagementPersonDocument.getEntityId()); |
1078 | 0 | entityPhone.setId(phone.getEntityPhoneId()); |
1079 | 0 | entityPhone.setEntityTypeCode(entityType.getEntityTypeCode()); |
1080 | 0 | entityPhone.setPhoneNumber(phone.getPhoneNumber()); |
1081 | 0 | entityPhone.setCountryCode(phone.getCountryCode()); |
1082 | 0 | entityPhone.setExtension(phone.getExtension()); |
1083 | 0 | entityPhone.setExtensionNumber(phone.getExtensionNumber()); |
1084 | 0 | entityPhone.setActive(phone.isActive()); |
1085 | 0 | entityPhone.setDefaultValue(phone.isDflt()); |
1086 | 0 | if(ObjectUtils.isNotNull(origPhones)){ |
1087 | 0 | for (EntityPhoneContract origPhone : origPhones) { |
1088 | 0 | if (origPhone.getId()!=null && StringUtils.equals(origPhone.getId(), entityPhone.getId())) { |
1089 | 0 | entityPhone.setVersionNumber(origPhone.getVersionNumber()); |
1090 | |
} |
1091 | |
} |
1092 | |
} |
1093 | 0 | entityPhone.setId(phone.getEntityPhoneId()); |
1094 | 0 | entityPhones.add(entityPhone); |
1095 | 0 | } |
1096 | |
} |
1097 | 0 | entityType.setPhoneNumbers(entityPhones); |
1098 | |
} |
1099 | 0 | } |
1100 | |
|
1101 | |
protected List<PersonDocumentPhone> loadPhones(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityPhone> entityPhones, boolean suppressDisplay ) { |
1102 | 0 | List<PersonDocumentPhone> docPhones = new ArrayList<PersonDocumentPhone>(); |
1103 | 0 | if(ObjectUtils.isNotNull(entityPhones)){ |
1104 | 0 | for (EntityPhone phone: entityPhones) { |
1105 | 0 | if(phone.isActive()){ |
1106 | 0 | PersonDocumentPhone docPhone = new PersonDocumentPhone(); |
1107 | 0 | if (phone.getPhoneType() != null) { |
1108 | 0 | docPhone.setPhoneTypeCode(phone.getPhoneType().getCode()); |
1109 | |
} |
1110 | |
|
1111 | 0 | docPhone.setEntityTypeCode(phone.getEntityTypeCode()); |
1112 | |
|
1113 | 0 | docPhone.setPhoneNumber(phone.getPhoneNumberUnmasked()); |
1114 | 0 | docPhone.setCountryCode(phone.getCountryCodeUnmasked()); |
1115 | 0 | docPhone.setExtensionNumber(phone.getExtensionNumberUnmasked()); |
1116 | |
|
1117 | 0 | docPhone.setActive(phone.isActive()); |
1118 | 0 | docPhone.setDflt(phone.isDefaultValue()); |
1119 | 0 | docPhone.setEntityPhoneId(phone.getId()); |
1120 | 0 | docPhone.setEdit(true); |
1121 | 0 | docPhones.add(docPhone); |
1122 | 0 | } |
1123 | |
} |
1124 | |
} |
1125 | 0 | return docPhones; |
1126 | |
|
1127 | |
} |
1128 | |
|
1129 | |
protected void setupEmail( |
1130 | |
IdentityManagementPersonDocument identityManagementPersonDocument, |
1131 | |
EntityTypeDataBo entityType, List<EntityEmailBo> origEmails) { |
1132 | 0 | if ( !identityManagementPersonDocument.getPrivacy().isSuppressEmail() || canOverrideEntityPrivacyPreferences(getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId()) ) { |
1133 | 0 | List<EntityEmailBo> entityEmails = new ArrayList<EntityEmailBo>(); |
1134 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getEmails())){ |
1135 | 0 | for (PersonDocumentEmail email : identityManagementPersonDocument.getEmails()) { |
1136 | 0 | EntityEmailBo entityEmail = new EntityEmailBo(); |
1137 | 0 | entityEmail.setEntityId(identityManagementPersonDocument.getEntityId()); |
1138 | 0 | entityEmail.setEntityTypeCode(entityType.getEntityTypeCode()); |
1139 | 0 | entityEmail.setEmailTypeCode(email.getEmailTypeCode()); |
1140 | 0 | entityEmail.setEmailAddress(email.getEmailAddress()); |
1141 | 0 | entityEmail.setActive(email.isActive()); |
1142 | 0 | entityEmail.setDefaultValue(email.isDflt()); |
1143 | 0 | entityEmail.setId(email.getEntityEmailId()); |
1144 | 0 | if(ObjectUtils.isNotNull(origEmails)){ |
1145 | 0 | for (EntityEmailContract origEmail : origEmails) { |
1146 | 0 | if (origEmail.getId()!=null && StringUtils.equals(origEmail.getId(), entityEmail.getId())) { |
1147 | 0 | entityEmail.setVersionNumber(origEmail.getVersionNumber()); |
1148 | |
} |
1149 | |
} |
1150 | |
} |
1151 | 0 | entityEmails.add(entityEmail); |
1152 | 0 | } |
1153 | |
} |
1154 | 0 | entityType.setEmailAddresses(entityEmails); |
1155 | |
} |
1156 | 0 | } |
1157 | |
protected List<PersonDocumentEmail> loadEmails(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityEmail> entityEmails, boolean suppressDisplay ) { |
1158 | 0 | List<PersonDocumentEmail> emails = new ArrayList<PersonDocumentEmail>(); |
1159 | 0 | if(ObjectUtils.isNotNull(entityEmails)){ |
1160 | 0 | for (EntityEmail email: entityEmails) { |
1161 | 0 | if(email.isActive()){ |
1162 | 0 | PersonDocumentEmail docEmail = new PersonDocumentEmail(); |
1163 | |
|
1164 | 0 | docEmail.setEntityTypeCode(email.getEntityTypeCode()); |
1165 | 0 | if (email.getEmailType() != null) { |
1166 | 0 | docEmail.setEmailTypeCode(email.getEmailType().getCode()); |
1167 | |
} |
1168 | |
|
1169 | |
|
1170 | |
|
1171 | 0 | docEmail.setEmailAddress(email.getEmailAddressUnmasked()); |
1172 | |
|
1173 | 0 | docEmail.setActive(email.isActive()); |
1174 | 0 | docEmail.setDflt(email.isDefaultValue()); |
1175 | 0 | docEmail.setEntityEmailId(email.getId()); |
1176 | 0 | docEmail.setEdit(true); |
1177 | 0 | emails.add(docEmail); |
1178 | 0 | } |
1179 | |
} |
1180 | |
} |
1181 | 0 | return emails; |
1182 | |
} |
1183 | |
|
1184 | |
protected void setupAddress( |
1185 | |
IdentityManagementPersonDocument identityManagementPersonDocument, |
1186 | |
EntityTypeDataBo entityType, List<EntityAddressBo> origAddresses) { |
1187 | 0 | if ( !identityManagementPersonDocument.getPrivacy().isSuppressAddress() || canOverrideEntityPrivacyPreferences(getInitiatorPrincipalId(identityManagementPersonDocument), identityManagementPersonDocument.getPrincipalId()) ) { |
1188 | 0 | List<EntityAddressBo> entityAddresses = new ArrayList<EntityAddressBo>(); |
1189 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getAddrs())){ |
1190 | 0 | for (PersonDocumentAddress address : identityManagementPersonDocument.getAddrs()) { |
1191 | 0 | EntityAddressBo entityAddress = new EntityAddressBo(); |
1192 | 0 | entityAddress.setEntityId(identityManagementPersonDocument.getEntityId()); |
1193 | 0 | entityAddress.setEntityTypeCode(entityType.getEntityTypeCode()); |
1194 | 0 | entityAddress.setAddressTypeCode(address.getAddressTypeCode()); |
1195 | 0 | entityAddress.setLine1(address.getLine1()); |
1196 | 0 | entityAddress.setLine2(address.getLine2()); |
1197 | 0 | entityAddress.setLine3(address.getLine3()); |
1198 | 0 | entityAddress.setStateCode(address.getStateCode()); |
1199 | 0 | entityAddress.setPostalCode(address.getPostalCode()); |
1200 | 0 | entityAddress.setCountryCode(address.getCountryCode()); |
1201 | 0 | entityAddress.setCityName(address.getCityName()); |
1202 | 0 | entityAddress.setActive(address.isActive()); |
1203 | 0 | entityAddress.setDefaultValue(address.isDflt()); |
1204 | 0 | entityAddress.setId(address.getEntityAddressId()); |
1205 | 0 | if(ObjectUtils.isNotNull(origAddresses)){ |
1206 | 0 | for (EntityAddressContract origAddress : origAddresses) { |
1207 | 0 | if (origAddress.getId()!=null && StringUtils.equals(origAddress.getId(), entityAddress.getId())) { |
1208 | 0 | entityAddress.setVersionNumber(origAddress.getVersionNumber()); |
1209 | |
} |
1210 | |
} |
1211 | |
} |
1212 | 0 | entityAddresses.add(entityAddress); |
1213 | 0 | } |
1214 | |
} |
1215 | 0 | entityType.setAddresses(entityAddresses); |
1216 | |
} |
1217 | 0 | } |
1218 | |
|
1219 | |
protected List<PersonDocumentAddress> loadAddresses(IdentityManagementPersonDocument identityManagementPersonDocument, String principalId, List<EntityAddress> entityAddresses, boolean suppressDisplay ) { |
1220 | 0 | List<PersonDocumentAddress> docAddresses = new ArrayList<PersonDocumentAddress>(); |
1221 | 0 | if(ObjectUtils.isNotNull(entityAddresses)){ |
1222 | 0 | for (EntityAddress address: entityAddresses) { |
1223 | 0 | if(address.isActive()){ |
1224 | 0 | PersonDocumentAddress docAddress = new PersonDocumentAddress(); |
1225 | 0 | docAddress.setEntityTypeCode(address.getEntityTypeCode()); |
1226 | 0 | docAddress.setAddressTypeCode(address.getAddressType().getCode()); |
1227 | |
|
1228 | |
|
1229 | 0 | docAddress.setLine1(address.getLine1Unmasked()); |
1230 | 0 | docAddress.setLine2(address.getLine2Unmasked()); |
1231 | 0 | docAddress.setLine3(address.getLine3Unmasked()); |
1232 | 0 | docAddress.setStateCode(address.getStateCodeUnmasked()); |
1233 | 0 | docAddress.setPostalCode(address.getPostalCodeUnmasked()); |
1234 | 0 | docAddress.setCountryCode(address.getCountryCodeUnmasked()); |
1235 | 0 | docAddress.setCityName(address.getCityNameUnmasked()); |
1236 | |
|
1237 | 0 | docAddress.setActive(address.isActive()); |
1238 | 0 | docAddress.setDflt(address.isDefaultValue()); |
1239 | 0 | docAddress.setEntityAddressId(address.getId()); |
1240 | 0 | docAddress.setEdit(true); |
1241 | 0 | docAddresses.add(docAddress); |
1242 | 0 | } |
1243 | |
} |
1244 | |
} |
1245 | 0 | return docAddresses; |
1246 | |
} |
1247 | |
|
1248 | |
|
1249 | |
protected List <GroupMemberBo> populateGroupMembers(IdentityManagementPersonDocument identityManagementPersonDocument) { |
1250 | 0 | List <GroupMemberBo> groupPrincipals = new ArrayList<GroupMemberBo>(); |
1251 | |
|
1252 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getGroups())){ |
1253 | 0 | for (PersonDocumentGroup group : identityManagementPersonDocument.getGroups()) { |
1254 | 0 | GroupMember.Builder groupPrincipalImpl = GroupMember.Builder.create(group.getGroupId(), identityManagementPersonDocument.getPrincipalId(), KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE); |
1255 | 0 | if (group.getActiveFromDate() != null) { |
1256 | 0 | groupPrincipalImpl.setActiveFromDate(new java.sql.Timestamp(group.getActiveFromDate().getTime())); |
1257 | |
} |
1258 | 0 | if (group.getActiveToDate() != null) { |
1259 | 0 | groupPrincipalImpl.setActiveToDate(new java.sql.Timestamp(group.getActiveToDate().getTime())); |
1260 | |
} |
1261 | 0 | groupPrincipalImpl.setId(group.getGroupMemberId()); |
1262 | |
|
1263 | |
|
1264 | |
|
1265 | |
|
1266 | |
|
1267 | |
|
1268 | 0 | Collection<GroupMember> currGroupMembers = getGroupService().getMembers(Collections.singletonList(group.getGroupId())); |
1269 | 0 | if(ObjectUtils.isNotNull(currGroupMembers)){ |
1270 | 0 | for (GroupMember origGroupMember: currGroupMembers) { |
1271 | 0 | if (origGroupMember.isActive() |
1272 | |
&& origGroupMember.getTypeCode().equals(KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE)) { |
1273 | 0 | if(origGroupMember.getId()!=null && StringUtils.equals(origGroupMember.getId(), group.getGroupMemberId())){ |
1274 | 0 | groupPrincipalImpl.setObjectId(origGroupMember.getObjectId()); |
1275 | 0 | groupPrincipalImpl.setVersionNumber(origGroupMember.getVersionNumber()); |
1276 | |
} |
1277 | |
} |
1278 | |
} |
1279 | |
} |
1280 | |
|
1281 | 0 | groupPrincipals.add(GroupMemberBo.from(groupPrincipalImpl.build())); |
1282 | |
|
1283 | 0 | } |
1284 | |
} |
1285 | 0 | return groupPrincipals; |
1286 | |
} |
1287 | |
|
1288 | |
protected List<RoleMemberImpl> populateRoleMembers(IdentityManagementPersonDocument identityManagementPersonDocument) { |
1289 | 0 | List<RoleImpl> origRoles = getRolesForPrincipal(identityManagementPersonDocument.getPrincipalId()); |
1290 | |
|
1291 | 0 | List <RoleMemberImpl> roleMembers = new ArrayList<RoleMemberImpl>(); |
1292 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getRoles())){ |
1293 | 0 | for (PersonDocumentRole role : identityManagementPersonDocument.getRoles()) { |
1294 | |
|
1295 | 0 | List<RoleMemberImpl> origRoleMembers = new ArrayList<RoleMemberImpl>(); |
1296 | 0 | if(ObjectUtils.isNotNull(origRoles)){ |
1297 | 0 | for (RoleImpl origRole : origRoles) { |
1298 | 0 | if (origRole.getRoleId()!=null && StringUtils.equals(origRole.getRoleId(), role.getRoleId())) { |
1299 | 0 | origRoleMembers = origRole.getMembers(); |
1300 | 0 | break; |
1301 | |
} |
1302 | |
} |
1303 | |
} |
1304 | 0 | if (role.getRolePrncpls().isEmpty()) { |
1305 | 0 | if (!role.getDefinitions().isEmpty()) { |
1306 | 0 | RoleMemberImpl roleMemberImpl = new RoleMemberImpl(); |
1307 | 0 | roleMemberImpl.setRoleId(role.getRoleId()); |
1308 | 0 | roleMemberImpl.setMemberId(identityManagementPersonDocument.getPrincipalId()); |
1309 | 0 | roleMemberImpl.setMemberTypeCode(Role.PRINCIPAL_MEMBER_TYPE); |
1310 | 0 | roleMembers.add(roleMemberImpl); |
1311 | 0 | } |
1312 | |
} else { |
1313 | 0 | for (KimDocumentRoleMember roleMember : role.getRolePrncpls()) { |
1314 | 0 | RoleMemberImpl roleMemberImpl = new RoleMemberImpl(); |
1315 | 0 | roleMemberImpl.setRoleId(role.getRoleId()); |
1316 | |
|
1317 | 0 | roleMemberImpl.setMemberId(identityManagementPersonDocument.getPrincipalId()); |
1318 | 0 | roleMemberImpl.setMemberTypeCode(Role.PRINCIPAL_MEMBER_TYPE); |
1319 | 0 | roleMemberImpl.setRoleMemberId(roleMember.getRoleMemberId()); |
1320 | 0 | if (roleMember.getActiveFromDate() != null) { |
1321 | 0 | roleMemberImpl.setActiveFromDate(new java.sql.Timestamp(roleMember.getActiveFromDate().getTime())); |
1322 | |
} |
1323 | 0 | if (roleMember.getActiveToDate() != null) { |
1324 | 0 | roleMemberImpl.setActiveToDate(new java.sql.Timestamp(roleMember.getActiveToDate().getTime())); |
1325 | |
} |
1326 | 0 | List<RoleMemberAttributeDataImpl> origAttributes = new ArrayList<RoleMemberAttributeDataImpl>(); |
1327 | 0 | if(ObjectUtils.isNotNull(origRoleMembers)){ |
1328 | 0 | for (RoleMemberImpl origMember : origRoleMembers) { |
1329 | 0 | if (origMember.getRoleMemberId()!=null && StringUtils.equals(origMember.getRoleMemberId(), roleMember.getRoleMemberId())) { |
1330 | 0 | origAttributes = origMember.getAttributes(); |
1331 | 0 | roleMemberImpl.setVersionNumber(origMember.getVersionNumber()); |
1332 | |
} |
1333 | |
} |
1334 | |
} |
1335 | 0 | List<RoleMemberAttributeDataImpl> attributes = new ArrayList<RoleMemberAttributeDataImpl>(); |
1336 | 0 | if(CollectionUtils.isNotEmpty(roleMember.getQualifiers())){ |
1337 | 0 | for (KimDocumentRoleQualifier qualifier : roleMember.getQualifiers()) { |
1338 | |
|
1339 | 0 | RoleMemberAttributeDataImpl attribute = new RoleMemberAttributeDataImpl(); |
1340 | 0 | attribute.setId(qualifier.getAttrDataId()); |
1341 | 0 | attribute.setAttributeValue(qualifier.getAttrVal()); |
1342 | 0 | attribute.setKimAttributeId(qualifier.getKimAttrDefnId()); |
1343 | 0 | attribute.setAssignedToId(qualifier.getRoleMemberId()); |
1344 | 0 | attribute.setKimTypeId(qualifier.getKimTypId()); |
1345 | |
|
1346 | 0 | updateAttrValIfNecessary(attribute); |
1347 | |
|
1348 | 0 | if(ObjectUtils.isNotNull(origAttributes)){ |
1349 | 0 | for (RoleMemberAttributeDataImpl origAttribute : origAttributes) { |
1350 | 0 | if (origAttribute.getId()!=null && StringUtils.equals(origAttribute.getId(), qualifier.getAttrDataId())) { |
1351 | 0 | attribute.setVersionNumber(origAttribute.getVersionNumber()); |
1352 | |
} |
1353 | |
} |
1354 | |
} |
1355 | 0 | if (attribute.getVersionNumber() != null || StringUtils.isNotBlank(qualifier.getAttrVal())) { |
1356 | 0 | attributes.add(attribute); |
1357 | |
} |
1358 | |
|
1359 | 0 | } |
1360 | |
} |
1361 | 0 | roleMemberImpl.setAttributes(attributes); |
1362 | 0 | roleMembers.add(roleMemberImpl); |
1363 | 0 | } |
1364 | |
} |
1365 | |
|
1366 | 0 | } |
1367 | |
} |
1368 | 0 | return roleMembers; |
1369 | |
} |
1370 | |
|
1371 | |
protected List<KimDelegationImpl> populateDelegations(IdentityManagementPersonDocument identityManagementPersonDocument){ |
1372 | 0 | List<KimDelegationImpl> origDelegations = getPersonDelegations(identityManagementPersonDocument.getPrincipalId()); |
1373 | 0 | List<KimDelegationImpl> kimDelegations = new ArrayList<KimDelegationImpl>(); |
1374 | |
KimDelegationImpl newKimDelegation; |
1375 | 0 | KimDelegationImpl origDelegationImplTemp = null; |
1376 | 0 | List<KimDelegationMemberImpl> origMembers = new ArrayList<KimDelegationMemberImpl>(); |
1377 | 0 | boolean activatingInactive = false; |
1378 | 0 | String newDelegationIdAssigned = ""; |
1379 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getDelegations())){ |
1380 | 0 | for(RoleDocumentDelegation roleDocumentDelegation: identityManagementPersonDocument.getDelegations()){ |
1381 | 0 | newKimDelegation = new KimDelegationImpl(); |
1382 | 0 | KimCommonUtilsInternal.copyProperties(newKimDelegation, roleDocumentDelegation); |
1383 | 0 | newKimDelegation.setRoleId(roleDocumentDelegation.getRoleId()); |
1384 | 0 | if(ObjectUtils.isNotNull(origDelegations)){ |
1385 | 0 | for(KimDelegationImpl origDelegationImpl: origDelegations){ |
1386 | 0 | if((origDelegationImpl.getRoleId()!=null && StringUtils.equals(origDelegationImpl.getRoleId(), newKimDelegation.getRoleId())) && |
1387 | |
(origDelegationImpl.getDelegationId()!=null && StringUtils.equals(origDelegationImpl.getDelegationId(), newKimDelegation.getDelegationId()))){ |
1388 | |
|
1389 | 0 | newDelegationIdAssigned = newKimDelegation.getDelegationId(); |
1390 | 0 | newKimDelegation.setDelegationId(origDelegationImpl.getDelegationId()); |
1391 | 0 | activatingInactive = true; |
1392 | |
} |
1393 | 0 | if(origDelegationImpl.getDelegationId()!=null && StringUtils.equals(origDelegationImpl.getDelegationId(), newKimDelegation.getDelegationId())){ |
1394 | 0 | newKimDelegation.setVersionNumber(origDelegationImpl.getVersionNumber()); |
1395 | 0 | origDelegationImplTemp = origDelegationImpl; |
1396 | |
} |
1397 | |
} |
1398 | |
} |
1399 | 0 | origMembers = (origDelegationImplTemp==null || origDelegationImplTemp.getMembers()==null)? |
1400 | |
new ArrayList<KimDelegationMemberImpl>():origDelegationImplTemp.getMembers(); |
1401 | 0 | newKimDelegation.setMembers(getDelegationMembers(roleDocumentDelegation.getMembers(), origMembers, activatingInactive, newDelegationIdAssigned)); |
1402 | 0 | kimDelegations.add(newKimDelegation); |
1403 | 0 | activatingInactive = false; |
1404 | |
} |
1405 | |
} |
1406 | 0 | return kimDelegations; |
1407 | |
} |
1408 | |
|
1409 | |
protected List <RoleMemberAttributeDataImpl> getBlankRoleMemberAttrs(List <RoleMemberImpl> rolePrncpls) { |
1410 | |
|
1411 | 0 | List <RoleMemberAttributeDataImpl> blankRoleMemberAttrs = new ArrayList<RoleMemberAttributeDataImpl>(); |
1412 | 0 | if(ObjectUtils.isNotNull(rolePrncpls)){ |
1413 | 0 | for (RoleMemberImpl roleMbr : rolePrncpls) { |
1414 | 0 | List <RoleMemberAttributeDataImpl> roleMemberAttrs = new ArrayList<RoleMemberAttributeDataImpl>(); |
1415 | 0 | if (CollectionUtils.isNotEmpty(roleMbr.getAttributes())) { |
1416 | 0 | for (RoleMemberAttributeDataImpl attr : roleMbr.getAttributes()) { |
1417 | 0 | if (StringUtils.isBlank(attr.getAttributeValue())) { |
1418 | 0 | roleMemberAttrs.add(attr); |
1419 | |
} |
1420 | |
} |
1421 | 0 | if (!roleMemberAttrs.isEmpty()) { |
1422 | 0 | roleMbr.getAttributes().removeAll(roleMemberAttrs); |
1423 | 0 | blankRoleMemberAttrs.addAll(roleMemberAttrs); |
1424 | |
} |
1425 | |
|
1426 | |
} |
1427 | 0 | } |
1428 | |
} |
1429 | |
|
1430 | 0 | return blankRoleMemberAttrs; |
1431 | |
|
1432 | |
} |
1433 | |
|
1434 | |
protected List <RoleResponsibilityActionImpl> populateRoleRspActions(IdentityManagementPersonDocument identityManagementPersonDocument) { |
1435 | |
|
1436 | |
|
1437 | 0 | List <RoleResponsibilityActionImpl> roleRspActions = new ArrayList<RoleResponsibilityActionImpl>(); |
1438 | 0 | if(CollectionUtils.isNotEmpty(identityManagementPersonDocument.getRoles())){ |
1439 | 0 | for (PersonDocumentRole role : identityManagementPersonDocument.getRoles()) { |
1440 | 0 | if(CollectionUtils.isNotEmpty(role.getRolePrncpls())){ |
1441 | 0 | for (KimDocumentRoleMember roleMbr : role.getRolePrncpls()) { |
1442 | 0 | if(CollectionUtils.isNotEmpty(roleMbr.getRoleRspActions())){ |
1443 | 0 | for (KimDocumentRoleResponsibilityAction roleRspAction : roleMbr.getRoleRspActions()) { |
1444 | 0 | RoleResponsibilityActionImpl entRoleRspAction = new RoleResponsibilityActionImpl(); |
1445 | 0 | entRoleRspAction.setRoleResponsibilityActionId(roleRspAction.getRoleResponsibilityActionId()); |
1446 | 0 | entRoleRspAction.setActionPolicyCode(roleRspAction.getActionPolicyCode()); |
1447 | 0 | entRoleRspAction.setActionTypeCode(roleRspAction.getActionTypeCode()); |
1448 | 0 | entRoleRspAction.setPriorityNumber(roleRspAction.getPriorityNumber()); |
1449 | 0 | entRoleRspAction.setRoleMemberId(roleRspAction.getRoleMemberId()); |
1450 | 0 | entRoleRspAction.setRoleResponsibilityActionId(roleRspAction.getRoleResponsibilityActionId()); |
1451 | 0 | entRoleRspAction.setRoleResponsibilityId(roleRspAction.getRoleResponsibilityId()); |
1452 | 0 | List<RoleResponsibilityActionImpl> actions = getRoleRspActions( roleMbr.getRoleMemberId()); |
1453 | 0 | if(ObjectUtils.isNotNull(actions)){ |
1454 | 0 | for(RoleResponsibilityActionImpl orgRspAction : actions) { |
1455 | 0 | if (orgRspAction.getRoleResponsibilityActionId()!=null && StringUtils.equals(orgRspAction.getRoleResponsibilityActionId(), roleRspAction.getRoleResponsibilityActionId())) { |
1456 | 0 | entRoleRspAction.setVersionNumber(orgRspAction.getVersionNumber()); |
1457 | |
} |
1458 | |
} |
1459 | |
} |
1460 | 0 | roleRspActions.add(entRoleRspAction); |
1461 | 0 | } |
1462 | |
} |
1463 | |
} |
1464 | |
} |
1465 | |
} |
1466 | |
} |
1467 | 0 | return roleRspActions; |
1468 | |
|
1469 | |
} |
1470 | |
|
1471 | |
protected BusinessObjectService getBusinessObjectService() { |
1472 | 0 | if ( businessObjectService == null ) { |
1473 | 0 | businessObjectService = KNSServiceLocator.getBusinessObjectService(); |
1474 | |
} |
1475 | 0 | return businessObjectService; |
1476 | |
} |
1477 | |
|
1478 | |
protected IdentityManagementService getIdentityManagementService() { |
1479 | 0 | if ( identityManagementService == null ) { |
1480 | 0 | identityManagementService = KimApiServiceLocator.getIdentityManagementService(); |
1481 | |
} |
1482 | 0 | return identityManagementService; |
1483 | |
} |
1484 | |
|
1485 | |
protected IdentityService getIdentityService() { |
1486 | 0 | if ( identityService == null ) { |
1487 | 0 | identityService = KimApiServiceLocator.getIdentityService(); |
1488 | |
} |
1489 | 0 | return identityService; |
1490 | |
} |
1491 | |
|
1492 | |
protected GroupService getGroupService() { |
1493 | 0 | if ( groupService == null ) { |
1494 | 0 | groupService = KimApiServiceLocator.getGroupService(); |
1495 | |
} |
1496 | 0 | return groupService; |
1497 | |
} |
1498 | |
|
1499 | |
protected DocumentHelperService getDocumentHelperService() { |
1500 | 0 | if ( documentHelperService == null ) { |
1501 | 0 | documentHelperService = KNSServiceLocatorWeb.getDocumentHelperService(); |
1502 | |
} |
1503 | 0 | return this.documentHelperService; |
1504 | |
} |
1505 | |
|
1506 | |
protected RoleService getRoleService() { |
1507 | 0 | if(roleService == null){ |
1508 | 0 | roleService = KimApiServiceLocator.getRoleService(); |
1509 | |
} |
1510 | 0 | return roleService; |
1511 | |
} |
1512 | |
|
1513 | |
protected RoleManagementService getRoleManagementService() { |
1514 | 0 | if(roleManagementService == null){ |
1515 | 0 | roleManagementService = KimApiServiceLocator.getRoleManagementService(); |
1516 | |
} |
1517 | 0 | return roleManagementService; |
1518 | |
} |
1519 | |
|
1520 | |
public void setRoleService(RoleService roleService) { |
1521 | 0 | this.roleService = roleService; |
1522 | 0 | } |
1523 | |
|
1524 | |
protected ResponsibilityService getResponsibilityService() { |
1525 | 0 | if ( responsibilityService == null ) { |
1526 | 0 | responsibilityService = KimApiServiceLocator.getResponsibilityService(); |
1527 | |
} |
1528 | 0 | return responsibilityService; |
1529 | |
} |
1530 | |
|
1531 | |
public void setResponsibilityService(ResponsibilityService responsibilityService) { |
1532 | 0 | this.responsibilityService = responsibilityService; |
1533 | 0 | } |
1534 | |
|
1535 | |
|
1536 | |
|
1537 | |
@SuppressWarnings("unchecked") |
1538 | |
public void loadRoleDoc(IdentityManagementRoleDocument identityManagementRoleDocument, KimRoleInfo kimRole){ |
1539 | 0 | KimRoleInfo kimRoleInfo = (KimRoleInfo)kimRole; |
1540 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
1541 | 0 | criteria.put(KIMPropertyConstants.Role.ROLE_ID, kimRoleInfo.getRoleId()); |
1542 | 0 | RoleImpl kimRoleImpl = (RoleImpl) |
1543 | |
getBusinessObjectService().findByPrimaryKey(RoleImpl.class, criteria); |
1544 | 0 | identityManagementRoleDocument.setRoleId(kimRoleImpl.getRoleId()); |
1545 | 0 | identityManagementRoleDocument.setKimType(KimTypeBo.to(kimRoleImpl.getKimRoleType())); |
1546 | 0 | identityManagementRoleDocument.setRoleTypeName(kimRoleImpl.getKimRoleType().getName()); |
1547 | 0 | identityManagementRoleDocument.setRoleTypeId(kimRoleImpl.getKimTypeId()); |
1548 | 0 | identityManagementRoleDocument.setRoleName(kimRoleImpl.getRoleName()); |
1549 | 0 | identityManagementRoleDocument.setRoleDescription(kimRoleImpl.getRoleDescription()); |
1550 | 0 | identityManagementRoleDocument.setActive(kimRoleImpl.isActive()); |
1551 | 0 | identityManagementRoleDocument.setRoleNamespace(kimRoleImpl.getNamespaceCode()); |
1552 | 0 | identityManagementRoleDocument.setEditing(true); |
1553 | |
|
1554 | 0 | identityManagementRoleDocument.setPermissions(loadPermissions((List<RolePermissionImpl>)getBusinessObjectService().findMatching(RolePermissionImpl.class, criteria))); |
1555 | 0 | identityManagementRoleDocument.setResponsibilities(loadResponsibilities((List<RoleResponsibilityImpl>)getBusinessObjectService().findMatching(RoleResponsibilityImpl.class, criteria))); |
1556 | 0 | loadResponsibilityRoleRspActions(identityManagementRoleDocument); |
1557 | 0 | identityManagementRoleDocument.setMembers(loadRoleMembers(identityManagementRoleDocument, kimRoleImpl.getMembers())); |
1558 | 0 | loadMemberRoleRspActions(identityManagementRoleDocument); |
1559 | 0 | identityManagementRoleDocument.setDelegations(loadRoleDocumentDelegations(identityManagementRoleDocument, getRoleDelegations(kimRoleImpl.getRoleId()))); |
1560 | |
|
1561 | 0 | setDelegationMembersInDocument(identityManagementRoleDocument); |
1562 | 0 | identityManagementRoleDocument.setKimType(KimTypeBo.to(kimRoleImpl.getKimRoleType())); |
1563 | 0 | } |
1564 | |
|
1565 | |
public void setDelegationMembersInDocument(IdentityManagementRoleDocument identityManagementRoleDocument){ |
1566 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getDelegations())){ |
1567 | 0 | for(RoleDocumentDelegation delegation: identityManagementRoleDocument.getDelegations()){ |
1568 | 0 | if(CollectionUtils.isNotEmpty(delegation.getMembers())){ |
1569 | 0 | for(RoleDocumentDelegationMember member: delegation.getMembers()){ |
1570 | 0 | member.setDelegationTypeCode(delegation.getDelegationTypeCode()); |
1571 | 0 | identityManagementRoleDocument.getDelegationMembers().add(member); |
1572 | |
} |
1573 | |
} |
1574 | |
} |
1575 | |
} |
1576 | 0 | } |
1577 | |
|
1578 | |
protected List<KimDocumentRoleResponsibility> loadResponsibilities(List<RoleResponsibilityImpl> roleResponsibilities){ |
1579 | 0 | List<KimDocumentRoleResponsibility> documentRoleResponsibilities = new ArrayList<KimDocumentRoleResponsibility>(); |
1580 | 0 | if(ObjectUtils.isNotNull(roleResponsibilities)){ |
1581 | 0 | for(RoleResponsibilityImpl roleResponsibility: roleResponsibilities){ |
1582 | 0 | if(roleResponsibility.isActive()) { |
1583 | 0 | KimDocumentRoleResponsibility roleResponsibilityCopy = new KimDocumentRoleResponsibility(); |
1584 | 0 | KimCommonUtilsInternal.copyProperties(roleResponsibilityCopy, roleResponsibility); |
1585 | 0 | roleResponsibilityCopy.setEdit(true); |
1586 | 0 | documentRoleResponsibilities.add(roleResponsibilityCopy); |
1587 | 0 | } |
1588 | |
} |
1589 | |
} |
1590 | 0 | return documentRoleResponsibilities; |
1591 | |
} |
1592 | |
|
1593 | |
protected List<KimDocumentRolePermission> loadPermissions(List<RolePermissionImpl> rolePermissions){ |
1594 | 0 | List<KimDocumentRolePermission> documentRolePermissions = new ArrayList<KimDocumentRolePermission>(); |
1595 | |
KimDocumentRolePermission rolePermissionCopy; |
1596 | 0 | if(ObjectUtils.isNotNull(rolePermissions)){ |
1597 | 0 | for(RolePermissionImpl rolePermission: rolePermissions){ |
1598 | 0 | if ( rolePermission.isActive() ) { |
1599 | 0 | rolePermissionCopy = new KimDocumentRolePermission(); |
1600 | 0 | rolePermissionCopy.setRolePermissionId(rolePermission.getRolePermissionId()); |
1601 | 0 | rolePermissionCopy.setRoleId(rolePermission.getRoleId()); |
1602 | 0 | rolePermissionCopy.setPermissionId(rolePermission.getPermissionId()); |
1603 | 0 | rolePermissionCopy.setKimPermission(rolePermission.getKimPermission().toSimpleInfo()); |
1604 | 0 | rolePermissionCopy.setEdit(true); |
1605 | 0 | documentRolePermissions.add(rolePermissionCopy); |
1606 | |
} |
1607 | |
} |
1608 | |
} |
1609 | 0 | return documentRolePermissions; |
1610 | |
} |
1611 | |
|
1612 | |
protected List<KimDocumentRoleMember> loadRoleMembers( |
1613 | |
IdentityManagementRoleDocument identityManagementRoleDocument, List<RoleMemberImpl> members){ |
1614 | 0 | List<KimDocumentRoleMember> pndMembers = new ArrayList<KimDocumentRoleMember>(); |
1615 | 0 | KimDocumentRoleMember pndMember = new KimDocumentRoleMember(); |
1616 | 0 | if(ObjectUtils.isNotNull(members)){ |
1617 | 0 | for(RoleMemberImpl member: members){ |
1618 | 0 | pndMember = new KimDocumentRoleMember(); |
1619 | 0 | pndMember.setActiveFromDate(member.getActiveFromDate()); |
1620 | 0 | pndMember.setActiveToDate(member.getActiveToDate()); |
1621 | 0 | pndMember.setActive(member.isActive()); |
1622 | 0 | if(pndMember.isActive()){ |
1623 | 0 | pndMember.setRoleMemberId(member.getRoleMemberId()); |
1624 | 0 | pndMember.setRoleId(member.getRoleId()); |
1625 | 0 | pndMember.setMemberId(member.getMemberId()); |
1626 | 0 | pndMember.setMemberNamespaceCode(getMemberNamespaceCode(member.getMemberTypeCode(), member.getMemberId())); |
1627 | 0 | pndMember.setMemberName(getMemberName(member.getMemberTypeCode(), member.getMemberId())); |
1628 | 0 | pndMember.setMemberFullName(getMemberFullName(member.getMemberTypeCode(), member.getMemberId())); |
1629 | 0 | pndMember.setMemberTypeCode(member.getMemberTypeCode()); |
1630 | 0 | pndMember.setQualifiers(loadRoleMemberQualifiers(identityManagementRoleDocument, member.getAttributes())); |
1631 | 0 | pndMember.setEdit(true); |
1632 | 0 | pndMembers.add(pndMember); |
1633 | |
} |
1634 | |
} |
1635 | |
} |
1636 | 0 | Collections.sort(pndMembers, identityManagementRoleDocument.getMemberMetaDataType()); |
1637 | 0 | return pndMembers; |
1638 | |
} |
1639 | |
|
1640 | |
protected void loadResponsibilityRoleRspActions(IdentityManagementRoleDocument identityManagementRoleDocument){ |
1641 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getResponsibilities())){ |
1642 | 0 | for(KimDocumentRoleResponsibility responsibility: identityManagementRoleDocument.getResponsibilities()){ |
1643 | 0 | responsibility.getRoleRspActions().addAll(loadKimDocumentRoleRespActions( |
1644 | |
getRoleResponsibilityActionImpls(responsibility.getRoleResponsibilityId()))); |
1645 | |
} |
1646 | |
} |
1647 | 0 | } |
1648 | |
|
1649 | |
@SuppressWarnings("unchecked") |
1650 | |
protected List<RoleResponsibilityActionImpl> getRoleResponsibilityActionImpls(String roleResponsibilityId){ |
1651 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
1652 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, "*"); |
1653 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.ROLE_RESPONSIBILITY_ID, roleResponsibilityId); |
1654 | 0 | return (List<RoleResponsibilityActionImpl>) |
1655 | |
getBusinessObjectService().findMatching(RoleResponsibilityActionImpl.class, criteria); |
1656 | |
} |
1657 | |
|
1658 | |
@SuppressWarnings("unchecked") |
1659 | |
public List<RoleResponsibilityActionImpl> getRoleMemberResponsibilityActionImpls(String roleMemberId){ |
1660 | 0 | Map<String, String> criteria = new HashMap<String, String>(1); |
1661 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId); |
1662 | 0 | return (List<RoleResponsibilityActionImpl>) |
1663 | |
getBusinessObjectService().findMatching(RoleResponsibilityActionImpl.class, criteria); |
1664 | |
} |
1665 | |
|
1666 | |
protected void loadMemberRoleRspActions(IdentityManagementRoleDocument identityManagementRoleDocument){ |
1667 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getMembers())){ |
1668 | 0 | for(KimDocumentRoleMember member: identityManagementRoleDocument.getMembers()){ |
1669 | 0 | member.getRoleRspActions().addAll(loadKimDocumentRoleRespActions( |
1670 | |
getRoleMemberResponsibilityActionImpls(member.getRoleMemberId()) ) ); |
1671 | |
} |
1672 | |
} |
1673 | 0 | } |
1674 | |
|
1675 | |
protected List<KimDocumentRoleResponsibilityAction> loadKimDocumentRoleRespActions( |
1676 | |
List<RoleResponsibilityActionImpl> roleRespActionImpls){ |
1677 | 0 | List<KimDocumentRoleResponsibilityAction> documentRoleRespActions = new ArrayList<KimDocumentRoleResponsibilityAction>(); |
1678 | |
KimDocumentRoleResponsibilityAction documentRoleRespAction; |
1679 | 0 | if(ObjectUtils.isNotNull(roleRespActionImpls)){ |
1680 | 0 | for(RoleResponsibilityActionImpl roleRespActionImpl: roleRespActionImpls){ |
1681 | 0 | documentRoleRespAction = new KimDocumentRoleResponsibilityAction(); |
1682 | 0 | KimCommonUtilsInternal.copyProperties(documentRoleRespAction, roleRespActionImpl); |
1683 | |
|
1684 | 0 | if ( ObjectUtils.isNotNull(roleRespActionImpl.getRoleResponsibility()) ) { |
1685 | 0 | documentRoleRespAction.setKimResponsibility(roleRespActionImpl.getRoleResponsibility().getKimResponsibility()); |
1686 | |
} |
1687 | 0 | documentRoleRespActions.add(documentRoleRespAction); |
1688 | |
} |
1689 | |
} |
1690 | 0 | return documentRoleRespActions; |
1691 | |
} |
1692 | |
|
1693 | |
public BusinessObject getMember(String memberTypeCode, String memberId){ |
1694 | 0 | Class<? extends BusinessObject> roleMemberTypeClass = null; |
1695 | 0 | String roleMemberIdName = ""; |
1696 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1697 | 0 | roleMemberTypeClass = PrincipalBo.class; |
1698 | 0 | roleMemberIdName = KimConstants.PrimaryKeyConstants.PRINCIPAL_ID; |
1699 | 0 | Principal principalInfo = getIdentityManagementService().getPrincipal(memberId); |
1700 | 0 | if (principalInfo != null) { |
1701 | |
|
1702 | |
} |
1703 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1704 | 0 | roleMemberTypeClass = GroupBo.class; |
1705 | 0 | roleMemberIdName = KimConstants.PrimaryKeyConstants.GROUP_ID; |
1706 | 0 | Group groupInfo = null; |
1707 | 0 | groupInfo = getGroupService().getGroup(memberId); |
1708 | 0 | if (groupInfo != null) { |
1709 | |
|
1710 | |
} |
1711 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1712 | 0 | roleMemberTypeClass = RoleImpl.class; |
1713 | 0 | roleMemberIdName = KimConstants.PrimaryKeyConstants.ROLE_ID; |
1714 | 0 | KimRoleInfo roleInfo = null; |
1715 | 0 | roleInfo = getRoleService().getRole(memberId); |
1716 | 0 | if (roleInfo != null) { |
1717 | |
|
1718 | |
} |
1719 | |
} |
1720 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
1721 | 0 | criteria.put(roleMemberIdName, memberId); |
1722 | 0 | return getBusinessObjectService().findByPrimaryKey(roleMemberTypeClass, criteria); |
1723 | |
} |
1724 | |
|
1725 | |
public String getMemberName(String memberTypeCode, String memberId){ |
1726 | 0 | if(StringUtils.isEmpty(memberTypeCode) || StringUtils.isEmpty(memberId)) return ""; |
1727 | 0 | BusinessObject member = getMember(memberTypeCode, memberId); |
1728 | 0 | if (member == null) { |
1729 | 0 | String fakeName = ""; |
1730 | 0 | Principal kp = KimApiServiceLocator.getIdentityManagementService().getPrincipal(memberId); |
1731 | 0 | if(kp != null && kp.getPrincipalName() != null && !"".equals(kp.getPrincipalName())){ |
1732 | 0 | fakeName = kp.getPrincipalName(); |
1733 | |
} |
1734 | |
|
1735 | 0 | return fakeName; |
1736 | |
} |
1737 | 0 | return getMemberName(memberTypeCode, member); |
1738 | |
} |
1739 | |
|
1740 | |
public String getMemberFullName(String memberTypeCode, String memberId){ |
1741 | 0 | if(StringUtils.isEmpty(memberTypeCode) || StringUtils.isEmpty(memberId)) return ""; |
1742 | 0 | String memberFullName = ""; |
1743 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1744 | 0 | Principal principalInfo = null; |
1745 | 0 | principalInfo = getIdentityManagementService().getPrincipal(memberId); |
1746 | 0 | if (principalInfo != null) { |
1747 | 0 | String principalName = principalInfo.getPrincipalName(); |
1748 | 0 | Person psn = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalName); |
1749 | 0 | memberFullName = psn.getFirstName() + " " + psn.getLastName(); |
1750 | |
} |
1751 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1752 | 0 | Group group = null; |
1753 | 0 | group = getIdentityManagementService().getGroup(memberId); |
1754 | 0 | if (group != null) { |
1755 | 0 | memberFullName = group.getName(); |
1756 | |
} |
1757 | |
|
1758 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1759 | 0 | KimRoleInfo roleInfo = null; |
1760 | 0 | roleInfo = getRoleService().getRole(memberId); |
1761 | 0 | memberFullName = roleInfo.getRoleName(); |
1762 | |
} |
1763 | 0 | return memberFullName; |
1764 | |
} |
1765 | |
|
1766 | |
public String getMemberNamespaceCode(String memberTypeCode, String memberId){ |
1767 | 0 | if(StringUtils.isEmpty(memberTypeCode) || StringUtils.isEmpty(memberId)) return ""; |
1768 | 0 | String roleMemberNamespaceCode = ""; |
1769 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1770 | 0 | roleMemberNamespaceCode = ""; |
1771 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1772 | 0 | Group groupInfo = getIdentityManagementService().getGroup(memberId); |
1773 | 0 | if (groupInfo!= null) { |
1774 | 0 | roleMemberNamespaceCode = groupInfo.getNamespaceCode(); |
1775 | |
} |
1776 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1777 | 0 | KimRoleInfo roleInfo = getRoleService().getRole(memberId); |
1778 | 0 | if (roleInfo != null) { |
1779 | 0 | roleMemberNamespaceCode = roleInfo.getNamespaceCode(); |
1780 | |
} |
1781 | |
} |
1782 | 0 | return roleMemberNamespaceCode; |
1783 | |
} |
1784 | |
|
1785 | |
public String getMemberIdByName(String memberTypeCode, String memberNamespaceCode, String memberName){ |
1786 | 0 | String memberId = ""; |
1787 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1788 | 0 | Principal principal = getIdentityManagementService().getPrincipalByPrincipalName(memberName); |
1789 | 0 | if(principal!=null) |
1790 | 0 | memberId = principal.getPrincipalId(); |
1791 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1792 | 0 | Group groupInfo = getIdentityManagementService().getGroupByName(memberNamespaceCode, memberName); |
1793 | 0 | if(groupInfo!=null) |
1794 | 0 | memberId = groupInfo.getId(); |
1795 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1796 | 0 | memberId = getRoleManagementService().getRoleIdByName(memberNamespaceCode, memberName); |
1797 | |
} |
1798 | 0 | return memberId; |
1799 | |
} |
1800 | |
|
1801 | |
public String getMemberName(String memberTypeCode, BusinessObject member){ |
1802 | 0 | String roleMemberName = ""; |
1803 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1804 | 0 | roleMemberName = ((PrincipalBo)member).getPrincipalName(); |
1805 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1806 | 0 | roleMemberName = ((GroupBo)member).getName(); |
1807 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1808 | 0 | roleMemberName = ((RoleImpl)member).getRoleName(); |
1809 | |
} |
1810 | 0 | return roleMemberName; |
1811 | |
} |
1812 | |
|
1813 | |
public String getMemberNamespaceCode(String memberTypeCode, BusinessObject member){ |
1814 | 0 | String roleMemberNamespaceCode = ""; |
1815 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
1816 | 0 | roleMemberNamespaceCode = ""; |
1817 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
1818 | 0 | roleMemberNamespaceCode = ((GroupBo)member).getNamespaceCode(); |
1819 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
1820 | 0 | roleMemberNamespaceCode = ((RoleImpl)member).getNamespaceCode(); |
1821 | |
} |
1822 | 0 | return roleMemberNamespaceCode; |
1823 | |
} |
1824 | |
|
1825 | |
protected List<KimDocumentRoleQualifier> loadRoleMemberQualifiers(IdentityManagementRoleDocument identityManagementRoleDocument, |
1826 | |
List<RoleMemberAttributeDataImpl> attributeDataList){ |
1827 | 0 | List<KimDocumentRoleQualifier> pndMemberRoleQualifiers = new ArrayList<KimDocumentRoleQualifier>(); |
1828 | 0 | KimDocumentRoleQualifier pndMemberRoleQualifier = new KimDocumentRoleQualifier(); |
1829 | |
|
1830 | |
|
1831 | 0 | if(attributeDataList!=null){ |
1832 | 0 | for(RoleMemberAttributeDataImpl memberRoleQualifier: attributeDataList){ |
1833 | 0 | pndMemberRoleQualifier = new KimDocumentRoleQualifier(); |
1834 | 0 | pndMemberRoleQualifier.setAttrDataId(memberRoleQualifier.getId()); |
1835 | 0 | pndMemberRoleQualifier.setAttrVal(memberRoleQualifier.getAttributeValue()); |
1836 | 0 | pndMemberRoleQualifier.setRoleMemberId(memberRoleQualifier.getAssignedToId()); |
1837 | 0 | pndMemberRoleQualifier.setKimTypId(memberRoleQualifier.getKimTypeId()); |
1838 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(memberRoleQualifier.getKimAttributeId()); |
1839 | 0 | pndMemberRoleQualifier.setKimAttribute(memberRoleQualifier.getKimAttribute()); |
1840 | 0 | formatAttrValIfNecessary(pndMemberRoleQualifier); |
1841 | 0 | pndMemberRoleQualifiers.add(pndMemberRoleQualifier); |
1842 | |
} |
1843 | |
} |
1844 | |
|
1845 | 0 | int countOfOriginalAttributesNotPresent = 0; |
1846 | 0 | List<KimDocumentRoleQualifier> fillerRoleQualifiers = new ArrayList<KimDocumentRoleQualifier>(); |
1847 | |
|
1848 | 0 | AttributeDefinitionMap origAttributes = identityManagementRoleDocument.getDefinitions(); |
1849 | 0 | if ( origAttributes != null ) { |
1850 | 0 | for(String key: origAttributes.keySet()) { |
1851 | 0 | boolean attributePresent = false; |
1852 | 0 | String origAttributeId = identityManagementRoleDocument.getKimAttributeDefnId(origAttributes.get(key)); |
1853 | 0 | if(attributeDataList!=null){ |
1854 | 0 | for(RoleMemberAttributeDataImpl memberRoleQualifier: attributeDataList){ |
1855 | 0 | if(origAttributeId!=null && StringUtils.equals(origAttributeId, memberRoleQualifier.getKimAttribute().getId())){ |
1856 | 0 | attributePresent = true; |
1857 | 0 | break; |
1858 | |
} |
1859 | |
} |
1860 | |
} |
1861 | 0 | if(!attributePresent){ |
1862 | 0 | countOfOriginalAttributesNotPresent++; |
1863 | 0 | pndMemberRoleQualifier = new KimDocumentRoleQualifier(); |
1864 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(origAttributeId); |
1865 | 0 | pndMemberRoleQualifier.refreshReferenceObject("kimAttribute"); |
1866 | 0 | fillerRoleQualifiers.add(pndMemberRoleQualifier); |
1867 | |
} |
1868 | 0 | } |
1869 | |
|
1870 | 0 | if(countOfOriginalAttributesNotPresent != origAttributes.size()) { |
1871 | 0 | pndMemberRoleQualifiers.addAll(fillerRoleQualifiers); |
1872 | |
} |
1873 | |
} |
1874 | 0 | return pndMemberRoleQualifiers; |
1875 | |
} |
1876 | |
|
1877 | |
@SuppressWarnings("unchecked") |
1878 | |
public List<KimDelegationImpl> getRoleDelegations(String roleId){ |
1879 | 0 | if(roleId==null) |
1880 | 0 | return new ArrayList<KimDelegationImpl>(); |
1881 | 0 | Map<String,String> criteria = new HashMap<String,String>(1); |
1882 | 0 | criteria.put("roleId", roleId); |
1883 | 0 | return (List<KimDelegationImpl>)getBusinessObjectService().findMatching(KimDelegationImpl.class, criteria); |
1884 | |
} |
1885 | |
|
1886 | |
protected List<RoleDocumentDelegation> loadRoleDocumentDelegations(IdentityManagementRoleDocument identityManagementRoleDocument, List<KimDelegationImpl> delegations){ |
1887 | 0 | List<RoleDocumentDelegation> delList = new ArrayList<RoleDocumentDelegation>(); |
1888 | |
RoleDocumentDelegation documentDelegation; |
1889 | 0 | if(ObjectUtils.isNotNull(delegations)){ |
1890 | 0 | for(KimDelegationImpl del: delegations){ |
1891 | 0 | documentDelegation = new RoleDocumentDelegation(); |
1892 | 0 | documentDelegation.setActive(del.isActive()); |
1893 | 0 | if(documentDelegation.isActive()){ |
1894 | 0 | documentDelegation.setDelegationId(del.getDelegationId()); |
1895 | 0 | documentDelegation.setDelegationTypeCode(del.getDelegationTypeCode()); |
1896 | 0 | documentDelegation.setKimTypeId(del.getKimTypeId()); |
1897 | 0 | documentDelegation.setMembers(loadDelegationMembers(identityManagementRoleDocument, del.getMembers())); |
1898 | 0 | documentDelegation.setRoleId(del.getRoleId()); |
1899 | 0 | documentDelegation.setEdit(true); |
1900 | 0 | delList.add(documentDelegation); |
1901 | |
} |
1902 | |
} |
1903 | |
} |
1904 | 0 | return delList; |
1905 | |
} |
1906 | |
|
1907 | |
protected List<RoleDocumentDelegationMember> loadDelegationMembers(IdentityManagementRoleDocument identityManagementRoleDocument, List<KimDelegationMemberImpl> members){ |
1908 | 0 | List<RoleDocumentDelegationMember> pndMembers = new ArrayList<RoleDocumentDelegationMember>(); |
1909 | 0 | RoleDocumentDelegationMember pndMember = new RoleDocumentDelegationMember(); |
1910 | |
RoleMemberImpl roleMember; |
1911 | 0 | if(ObjectUtils.isNotNull(members)){ |
1912 | 0 | for(KimDelegationMemberImpl member: members){ |
1913 | 0 | pndMember = new RoleDocumentDelegationMember(); |
1914 | 0 | pndMember.setActiveFromDate(member.getActiveFromDate()); |
1915 | 0 | pndMember.setActiveToDate(member.getActiveToDate()); |
1916 | 0 | pndMember.setActive(member.isActive()); |
1917 | 0 | if(pndMember.isActive()){ |
1918 | 0 | KimCommonUtilsInternal.copyProperties(pndMember, member); |
1919 | 0 | pndMember.setRoleMemberId(member.getRoleMemberId()); |
1920 | 0 | roleMember = getRoleMemberForRoleMemberId(member.getRoleMemberId()); |
1921 | 0 | if(roleMember!=null){ |
1922 | 0 | pndMember.setRoleMemberName(getMemberName(roleMember.getMemberTypeCode(), roleMember.getMemberId())); |
1923 | 0 | pndMember.setRoleMemberNamespaceCode(getMemberNamespaceCode(roleMember.getMemberTypeCode(), roleMember.getMemberId())); |
1924 | |
} |
1925 | 0 | pndMember.setMemberNamespaceCode(getMemberNamespaceCode(member.getMemberTypeCode(), member.getMemberId())); |
1926 | 0 | pndMember.setMemberName(getMemberName(member.getMemberTypeCode(), member.getMemberId())); |
1927 | 0 | pndMember.setEdit(true); |
1928 | 0 | pndMember.setQualifiers(loadDelegationMemberQualifiers(identityManagementRoleDocument, member.getAttributes())); |
1929 | 0 | pndMembers.add(pndMember); |
1930 | |
} |
1931 | |
} |
1932 | |
} |
1933 | 0 | return pndMembers; |
1934 | |
} |
1935 | |
|
1936 | |
protected RoleMemberImpl getRoleMemberForRoleMemberId(String roleMemberId){ |
1937 | 0 | Map<String,String> criteria = new HashMap<String,String>( 2 ); |
1938 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId); |
1939 | 0 | return (RoleMemberImpl)getBusinessObjectService().findByPrimaryKey(RoleMemberImpl.class, criteria); |
1940 | |
} |
1941 | |
|
1942 | |
protected List<RoleDocumentDelegationMemberQualifier> loadDelegationMemberQualifiers(IdentityManagementRoleDocument identityManagementRoleDocument, |
1943 | |
List<KimDelegationMemberAttributeDataImpl> attributeDataList){ |
1944 | 0 | List<RoleDocumentDelegationMemberQualifier> pndMemberRoleQualifiers = new ArrayList<RoleDocumentDelegationMemberQualifier>(); |
1945 | 0 | RoleDocumentDelegationMemberQualifier pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
1946 | 0 | AttributeDefinitionMap origAttributes = identityManagementRoleDocument.getDefinitions(); |
1947 | 0 | boolean attributePresent = false; |
1948 | |
String origAttributeId; |
1949 | 0 | if(origAttributes!=null){ |
1950 | 0 | for(String key: origAttributes.keySet()) { |
1951 | 0 | origAttributeId = identityManagementRoleDocument.getKimAttributeDefnId(origAttributes.get(key)); |
1952 | 0 | if(attributeDataList!=null){ |
1953 | 0 | for(KimDelegationMemberAttributeDataImpl memberRoleQualifier: attributeDataList){ |
1954 | 0 | if(origAttributeId!=null && StringUtils.equals(origAttributeId, memberRoleQualifier.getKimAttribute().getId())){ |
1955 | 0 | pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
1956 | 0 | pndMemberRoleQualifier.setAttrDataId(memberRoleQualifier.getId()); |
1957 | 0 | pndMemberRoleQualifier.setAttrVal(memberRoleQualifier.getAttributeValue()); |
1958 | 0 | pndMemberRoleQualifier.setDelegationMemberId(memberRoleQualifier.getAssignedToId()); |
1959 | 0 | pndMemberRoleQualifier.setKimTypId(memberRoleQualifier.getKimTypeId()); |
1960 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(memberRoleQualifier.getKimAttributeId()); |
1961 | 0 | pndMemberRoleQualifier.setKimAttribute(memberRoleQualifier.getKimAttribute()); |
1962 | 0 | pndMemberRoleQualifiers.add(pndMemberRoleQualifier); |
1963 | 0 | attributePresent = true; |
1964 | |
} |
1965 | |
} |
1966 | |
} |
1967 | 0 | if(!attributePresent){ |
1968 | 0 | pndMemberRoleQualifier = new RoleDocumentDelegationMemberQualifier(); |
1969 | 0 | pndMemberRoleQualifier.setKimAttrDefnId(origAttributeId); |
1970 | 0 | pndMemberRoleQualifier.refreshReferenceObject("kimAttribute"); |
1971 | 0 | pndMemberRoleQualifiers.add(pndMemberRoleQualifier); |
1972 | |
} |
1973 | 0 | attributePresent = false; |
1974 | |
} |
1975 | |
} |
1976 | 0 | return pndMemberRoleQualifiers; |
1977 | |
} |
1978 | |
|
1979 | |
|
1980 | |
|
1981 | |
|
1982 | |
@SuppressWarnings("unchecked") |
1983 | |
public void saveRole(IdentityManagementRoleDocument identityManagementRoleDocument) { |
1984 | 0 | RoleImpl kimRole = new RoleImpl(); |
1985 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
1986 | 0 | String roleId = identityManagementRoleDocument.getRoleId(); |
1987 | 0 | criteria.put(KIMPropertyConstants.Role.ROLE_ID, roleId); |
1988 | 0 | RoleImpl origRole = (RoleImpl)getBusinessObjectService().findByPrimaryKey(RoleImpl.class, criteria); |
1989 | |
|
1990 | 0 | List<RolePermissionImpl> origRolePermissions = new ArrayList<RolePermissionImpl>(); |
1991 | 0 | List<RoleResponsibilityImpl> origRoleResponsibilities = new ArrayList<RoleResponsibilityImpl>(); |
1992 | 0 | List<RoleMemberImpl> origRoleMembers = new ArrayList<RoleMemberImpl>(); |
1993 | 0 | List<KimDelegationImpl> origRoleDelegations = new ArrayList<KimDelegationImpl>(); |
1994 | |
|
1995 | 0 | kimRole.setRoleId(identityManagementRoleDocument.getRoleId()); |
1996 | 0 | kimRole.setKimTypeId(identityManagementRoleDocument.getRoleTypeId()); |
1997 | 0 | kimRole.setNamespaceCode(identityManagementRoleDocument.getRoleNamespace()); |
1998 | 0 | kimRole.setRoleName(identityManagementRoleDocument.getRoleName()); |
1999 | 0 | kimRole.setRoleDescription(identityManagementRoleDocument.getRoleDescription()); |
2000 | |
|
2001 | 0 | if (origRole == null) { |
2002 | 0 | origRole = new RoleImpl(); |
2003 | 0 | kimRole.setActive(true); |
2004 | |
} else { |
2005 | 0 | kimRole.setActive(identityManagementRoleDocument.isActive()); |
2006 | 0 | kimRole.setVersionNumber(origRole.getVersionNumber()); |
2007 | 0 | origRolePermissions = (List<RolePermissionImpl>)getBusinessObjectService().findMatching(RolePermissionImpl.class, criteria); |
2008 | 0 | origRoleResponsibilities = (List<RoleResponsibilityImpl>)getBusinessObjectService().findMatching(RoleResponsibilityImpl.class, criteria); |
2009 | 0 | origRoleMembers = (List<RoleMemberImpl>)getBusinessObjectService().findMatching(RoleMemberImpl.class, criteria); |
2010 | 0 | origRoleDelegations = (List<KimDelegationImpl>)getBusinessObjectService().findMatching(KimDelegationImpl.class, criteria); |
2011 | |
} |
2012 | |
|
2013 | 0 | if( getKimTypeInfoService().getKimType(identityManagementRoleDocument.getRoleTypeId()) == null ) { |
2014 | 0 | LOG.error( "Kim type not found for:"+identityManagementRoleDocument.getRoleTypeId(), new Throwable() ); |
2015 | |
} |
2016 | |
|
2017 | 0 | List<PersistableBusinessObject> bos = new ArrayList<PersistableBusinessObject>(); |
2018 | |
|
2019 | 0 | bos.add(kimRole); |
2020 | 0 | bos.addAll(getRolePermissions(identityManagementRoleDocument, origRolePermissions)); |
2021 | 0 | bos.addAll(getRoleResponsibilities(identityManagementRoleDocument, origRoleResponsibilities)); |
2022 | 0 | bos.addAll(getRoleResponsibilitiesActions(identityManagementRoleDocument)); |
2023 | 0 | String initiatorPrincipalId = getInitiatorPrincipalId(identityManagementRoleDocument); |
2024 | 0 | if(canAssignToRole(identityManagementRoleDocument, initiatorPrincipalId)){ |
2025 | 0 | List<RoleMemberImpl> newRoleMembersList = getRoleMembers(identityManagementRoleDocument, origRoleMembers); |
2026 | 0 | bos.addAll(newRoleMembersList); |
2027 | 0 | bos.addAll(getRoleMemberResponsibilityActions(newRoleMembersList)); |
2028 | |
|
2029 | 0 | bos.addAll(getRoleDelegations(identityManagementRoleDocument, origRoleDelegations)); |
2030 | |
} |
2031 | 0 | getBusinessObjectService().save(bos); |
2032 | 0 | IdentityManagementNotificationService service = (IdentityManagementNotificationService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(new QName("KIM", "kimIdentityManagementNotificationService")); |
2033 | 0 | service.roleUpdated(); |
2034 | 0 | KIMServiceLocatorInternal.getResponsibilityInternalService().updateActionRequestsForResponsibilityChange(getChangedRoleResponsibilityIds(identityManagementRoleDocument, origRoleResponsibilities)); |
2035 | 0 | if(!kimRole.isActive()){ |
2036 | |
|
2037 | |
|
2038 | 0 | KimApiServiceLocator.getRoleManagementService().roleInactivated(identityManagementRoleDocument.getRoleId()); |
2039 | |
} |
2040 | 0 | } |
2041 | |
|
2042 | |
protected List<RolePermissionImpl> getRolePermissions( |
2043 | |
IdentityManagementRoleDocument identityManagementRoleDocument, List<RolePermissionImpl> origRolePermissions){ |
2044 | 0 | List<RolePermissionImpl> rolePermissions = new ArrayList<RolePermissionImpl>(); |
2045 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getPermissions())){ |
2046 | 0 | for(KimDocumentRolePermission documentRolePermission: identityManagementRoleDocument.getPermissions()){ |
2047 | 0 | RolePermissionImpl newRolePermission = new RolePermissionImpl(); |
2048 | 0 | newRolePermission.setRolePermissionId(documentRolePermission.getRolePermissionId()); |
2049 | 0 | newRolePermission.setRoleId(identityManagementRoleDocument.getRoleId()); |
2050 | 0 | newRolePermission.setPermissionId(documentRolePermission.getPermissionId()); |
2051 | 0 | newRolePermission.setActive( documentRolePermission.isActive() ); |
2052 | |
|
2053 | 0 | newRolePermission.setActive(documentRolePermission.isActive()); |
2054 | 0 | if(ObjectUtils.isNotNull(origRolePermissions)){ |
2055 | 0 | for(RolePermissionImpl origPermissionImpl: origRolePermissions){ |
2056 | 0 | if(!StringUtils.equals(origPermissionImpl.getRoleId(), newRolePermission.getRoleId()) && |
2057 | |
StringUtils.equals(origPermissionImpl.getPermissionId(), newRolePermission.getPermissionId()) && |
2058 | |
!origPermissionImpl.isActive() && newRolePermission.isActive()){ |
2059 | 0 | newRolePermission.setRolePermissionId(origPermissionImpl.getRolePermissionId()); |
2060 | |
} |
2061 | 0 | if(origPermissionImpl.getRolePermissionId()!=null && StringUtils.equals(origPermissionImpl.getRolePermissionId(), newRolePermission.getRolePermissionId())){ |
2062 | 0 | newRolePermission.setVersionNumber(origPermissionImpl.getVersionNumber()); |
2063 | |
} |
2064 | |
} |
2065 | |
} |
2066 | 0 | rolePermissions.add(newRolePermission); |
2067 | 0 | } |
2068 | |
} |
2069 | 0 | return rolePermissions; |
2070 | |
} |
2071 | |
|
2072 | |
protected List<RoleResponsibilityImpl> getRoleResponsibilities( |
2073 | |
IdentityManagementRoleDocument identityManagementRoleDocument, List<RoleResponsibilityImpl> origRoleResponsibilities){ |
2074 | 0 | List<RoleResponsibilityImpl> roleResponsibilities = new ArrayList<RoleResponsibilityImpl>(); |
2075 | |
RoleResponsibilityImpl newRoleResponsibility; |
2076 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getResponsibilities())){ |
2077 | 0 | for(KimDocumentRoleResponsibility documentRoleResponsibility: identityManagementRoleDocument.getResponsibilities()){ |
2078 | 0 | newRoleResponsibility = new RoleResponsibilityImpl(); |
2079 | 0 | KimCommonUtilsInternal.copyProperties(newRoleResponsibility, documentRoleResponsibility); |
2080 | 0 | newRoleResponsibility.setActive(documentRoleResponsibility.isActive()); |
2081 | 0 | newRoleResponsibility.setRoleId(identityManagementRoleDocument.getRoleId()); |
2082 | 0 | if(ObjectUtils.isNotNull(origRoleResponsibilities)){ |
2083 | 0 | for(RoleResponsibilityImpl origResponsibilityImpl: origRoleResponsibilities){ |
2084 | 0 | if(!StringUtils.equals(origResponsibilityImpl.getRoleId(), newRoleResponsibility.getRoleId()) && |
2085 | |
StringUtils.equals(origResponsibilityImpl.getResponsibilityId(), newRoleResponsibility.getResponsibilityId()) && |
2086 | |
!origResponsibilityImpl.isActive() && newRoleResponsibility.isActive()){ |
2087 | 0 | newRoleResponsibility.setRoleResponsibilityId(origResponsibilityImpl.getRoleResponsibilityId()); |
2088 | |
} |
2089 | 0 | if(origResponsibilityImpl.getRoleResponsibilityId()!=null && StringUtils.equals(origResponsibilityImpl.getRoleResponsibilityId(), newRoleResponsibility.getRoleResponsibilityId())) |
2090 | 0 | newRoleResponsibility.setVersionNumber(origResponsibilityImpl.getVersionNumber()); |
2091 | |
} |
2092 | |
} |
2093 | 0 | roleResponsibilities.add(newRoleResponsibility); |
2094 | |
} |
2095 | |
} |
2096 | 0 | return roleResponsibilities; |
2097 | |
} |
2098 | |
|
2099 | |
|
2100 | |
protected List <RoleResponsibilityActionImpl> getRoleResponsibilitiesActions( |
2101 | |
IdentityManagementRoleDocument identityManagementRoleDocument){ |
2102 | 0 | List <RoleResponsibilityActionImpl> roleRspActions = new ArrayList<RoleResponsibilityActionImpl>(); |
2103 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getResponsibilities())){ |
2104 | |
|
2105 | 0 | for(KimDocumentRoleResponsibility roleResponsibility : identityManagementRoleDocument.getResponsibilities()){ |
2106 | |
|
2107 | 0 | if(!getResponsibilityInternalService().areActionsAtAssignmentLevelById(roleResponsibility.getResponsibilityId())){ |
2108 | 0 | List<KimDocumentRoleResponsibilityAction> documentRoleResponsibilityActions = roleResponsibility.getRoleRspActions(); |
2109 | 0 | if( ObjectUtils.isNotNull(documentRoleResponsibilityActions) |
2110 | |
&& !documentRoleResponsibilityActions.isEmpty() |
2111 | |
&& StringUtils.isNotBlank(documentRoleResponsibilityActions.get(0).getRoleResponsibilityActionId() ) ) { |
2112 | 0 | RoleResponsibilityActionImpl roleRspAction = new RoleResponsibilityActionImpl(); |
2113 | 0 | roleRspAction.setRoleResponsibilityActionId(documentRoleResponsibilityActions.get(0).getRoleResponsibilityActionId()); |
2114 | 0 | roleRspAction.setActionPolicyCode(documentRoleResponsibilityActions.get(0).getActionPolicyCode()); |
2115 | 0 | roleRspAction.setActionTypeCode(documentRoleResponsibilityActions.get(0).getActionTypeCode()); |
2116 | 0 | roleRspAction.setPriorityNumber(documentRoleResponsibilityActions.get(0).getPriorityNumber()); |
2117 | 0 | roleRspAction.setForceAction(documentRoleResponsibilityActions.get(0).isForceAction()); |
2118 | 0 | roleRspAction.setRoleMemberId("*"); |
2119 | 0 | roleRspAction.setRoleResponsibilityId(documentRoleResponsibilityActions.get(0).getRoleResponsibilityId()); |
2120 | 0 | updateResponsibilityActionVersionNumber(roleRspAction, getRoleResponsibilityActionImpls(roleResponsibility.getRoleResponsibilityId())); |
2121 | 0 | roleRspActions.add(roleRspAction); |
2122 | |
} |
2123 | 0 | } |
2124 | |
} |
2125 | |
} |
2126 | 0 | return roleRspActions; |
2127 | |
} |
2128 | |
|
2129 | |
|
2130 | |
|
2131 | |
protected void updateResponsibilityActionVersionNumber(RoleResponsibilityActionImpl newRoleRspAction, |
2132 | |
List<RoleResponsibilityActionImpl> origRoleRespActionImpls){ |
2133 | 0 | if(ObjectUtils.isNotNull(origRoleRespActionImpls)){ |
2134 | 0 | for(RoleResponsibilityActionImpl origRoleResponsibilityActionImpl: origRoleRespActionImpls){ |
2135 | 0 | if(origRoleResponsibilityActionImpl.getRoleResponsibilityActionId()!=null && StringUtils.equals(origRoleResponsibilityActionImpl.getRoleResponsibilityActionId(), |
2136 | |
newRoleRspAction.getRoleResponsibilityActionId())) { |
2137 | 0 | newRoleRspAction.setVersionNumber(origRoleResponsibilityActionImpl.getVersionNumber()); |
2138 | 0 | break; |
2139 | |
} |
2140 | |
} |
2141 | |
} |
2142 | 0 | } |
2143 | |
|
2144 | |
protected List<RoleResponsibilityActionImpl> getRoleMemberResponsibilityActions(List<RoleMemberImpl> newRoleMembersList){ |
2145 | 0 | List<RoleResponsibilityActionImpl> roleRspActions = new ArrayList<RoleResponsibilityActionImpl>(); |
2146 | 0 | if(ObjectUtils.isNotNull(newRoleMembersList)){ |
2147 | 0 | for(RoleMemberImpl roleMember: newRoleMembersList){ |
2148 | 0 | roleRspActions.addAll(roleMember.getRoleRspActions()); |
2149 | |
} |
2150 | |
} |
2151 | 0 | return roleRspActions; |
2152 | |
} |
2153 | |
|
2154 | |
protected List<RoleResponsibilityActionImpl> getRoleMemberResponsibilityActions(IdentityManagementRoleDocument identityManagementRoleDocument){ |
2155 | 0 | List<RoleResponsibilityActionImpl> roleRspActions = new ArrayList<RoleResponsibilityActionImpl>(); |
2156 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getMembers())){ |
2157 | 0 | for(KimDocumentRoleMember roleMember: identityManagementRoleDocument.getMembers()){ |
2158 | 0 | for(KimDocumentRoleResponsibilityAction roleRspAction : roleMember.getRoleRspActions()){ |
2159 | 0 | RoleResponsibilityActionImpl entRoleRspAction = new RoleResponsibilityActionImpl(); |
2160 | 0 | entRoleRspAction.setRoleResponsibilityActionId(roleRspAction.getRoleResponsibilityActionId()); |
2161 | 0 | entRoleRspAction.setActionPolicyCode(roleRspAction.getActionPolicyCode()); |
2162 | 0 | entRoleRspAction.setActionTypeCode(roleRspAction.getActionTypeCode()); |
2163 | 0 | entRoleRspAction.setPriorityNumber(roleRspAction.getPriorityNumber()); |
2164 | 0 | entRoleRspAction.setRoleMemberId(roleRspAction.getRoleMemberId()); |
2165 | 0 | entRoleRspAction.setForceAction(roleRspAction.isForceAction()); |
2166 | 0 | entRoleRspAction.setRoleResponsibilityId(roleRspAction.getRoleResponsibilityId()); |
2167 | 0 | List<RoleResponsibilityActionImpl> actions = getRoleRspActions(roleMember.getRoleMemberId()); |
2168 | 0 | if(ObjectUtils.isNotNull(actions)){ |
2169 | 0 | for(RoleResponsibilityActionImpl orgRspAction : actions) { |
2170 | 0 | if (orgRspAction.getRoleResponsibilityActionId()!=null && StringUtils.equals(orgRspAction.getRoleResponsibilityActionId(), roleRspAction.getRoleResponsibilityActionId())) { |
2171 | 0 | entRoleRspAction.setVersionNumber(orgRspAction.getVersionNumber()); |
2172 | |
} |
2173 | |
} |
2174 | |
} |
2175 | 0 | roleRspActions.add(entRoleRspAction); |
2176 | 0 | } |
2177 | |
} |
2178 | |
} |
2179 | 0 | return roleRspActions; |
2180 | |
} |
2181 | |
|
2182 | |
protected List<RoleMemberImpl> getRoleMembers(IdentityManagementRoleDocument identityManagementRoleDocument, List<RoleMemberImpl> origRoleMembers){ |
2183 | 0 | List<RoleMemberImpl> roleMembers = new ArrayList<RoleMemberImpl>(); |
2184 | |
RoleMemberImpl newRoleMember; |
2185 | 0 | RoleMemberImpl origRoleMemberImplTemp = null; |
2186 | 0 | List<RoleMemberAttributeDataImpl> origAttributes = new ArrayList<RoleMemberAttributeDataImpl>(); |
2187 | 0 | boolean activatingInactive = false; |
2188 | 0 | String newRoleMemberIdAssigned = ""; |
2189 | |
|
2190 | 0 | identityManagementRoleDocument.setKimType(KimApiServiceLocator.getKimTypeInfoService().getKimType(identityManagementRoleDocument.getRoleTypeId())); |
2191 | 0 | KimTypeService kimTypeService = KIMServiceLocatorWeb.getKimTypeService(identityManagementRoleDocument.getKimType()); |
2192 | |
|
2193 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getMembers())){ |
2194 | 0 | for(KimDocumentRoleMember documentRoleMember: identityManagementRoleDocument.getMembers()){ |
2195 | 0 | origRoleMemberImplTemp = null; |
2196 | |
|
2197 | 0 | newRoleMember = new RoleMemberImpl(); |
2198 | 0 | KimCommonUtilsInternal.copyProperties(newRoleMember, documentRoleMember); |
2199 | 0 | newRoleMember.setRoleId(identityManagementRoleDocument.getRoleId()); |
2200 | 0 | if(ObjectUtils.isNotNull(origRoleMembers)){ |
2201 | 0 | for(RoleMemberImpl origRoleMemberImpl: origRoleMembers){ |
2202 | 0 | if((origRoleMemberImpl.getRoleId()!=null && StringUtils.equals(origRoleMemberImpl.getRoleId(), newRoleMember.getRoleId())) && |
2203 | |
(origRoleMemberImpl.getMemberId()!=null && StringUtils.equals(origRoleMemberImpl.getMemberId(), newRoleMember.getMemberId())) && |
2204 | |
(origRoleMemberImpl.getMemberTypeCode()!=null && StringUtils.equals(origRoleMemberImpl.getMemberTypeCode(), newRoleMember.getMemberTypeCode())) && |
2205 | |
!origRoleMemberImpl.isActive() && |
2206 | |
!kimTypeService.validateUniqueAttributes(identityManagementRoleDocument.getKimType().getId(), |
2207 | |
documentRoleMember.getQualifierAsAttributeSet(), origRoleMemberImpl.getQualifier())){ |
2208 | |
|
2209 | |
|
2210 | 0 | newRoleMemberIdAssigned = newRoleMember.getRoleMemberId(); |
2211 | 0 | newRoleMember.setRoleMemberId(origRoleMemberImpl.getRoleMemberId()); |
2212 | 0 | activatingInactive = true; |
2213 | |
} |
2214 | 0 | if(origRoleMemberImpl.getRoleMemberId()!=null && StringUtils.equals(origRoleMemberImpl.getRoleMemberId(), newRoleMember.getRoleMemberId())){ |
2215 | 0 | newRoleMember.setVersionNumber(origRoleMemberImpl.getVersionNumber()); |
2216 | 0 | origRoleMemberImplTemp = origRoleMemberImpl; |
2217 | |
} |
2218 | |
} |
2219 | |
} |
2220 | 0 | origAttributes = (origRoleMemberImplTemp==null || origRoleMemberImplTemp.getAttributes()==null)? |
2221 | |
new ArrayList<RoleMemberAttributeDataImpl>():origRoleMemberImplTemp.getAttributes(); |
2222 | 0 | newRoleMember.setAttributes(getRoleMemberAttributeData(documentRoleMember.getQualifiers(), origAttributes, activatingInactive, newRoleMemberIdAssigned)); |
2223 | 0 | newRoleMember.setRoleRspActions(getRoleMemberResponsibilityActions(documentRoleMember, origRoleMemberImplTemp, activatingInactive, newRoleMemberIdAssigned)); |
2224 | 0 | roleMembers.add(newRoleMember); |
2225 | 0 | activatingInactive = false; |
2226 | |
} |
2227 | |
} |
2228 | 0 | return roleMembers; |
2229 | |
} |
2230 | |
|
2231 | |
protected List<RoleResponsibilityActionImpl> getRoleMemberResponsibilityActions( |
2232 | |
KimDocumentRoleMember documentRoleMember, RoleMemberImpl origRoleMemberImplTemp, boolean activatingInactive, String newRoleMemberIdAssigned){ |
2233 | 0 | List<RoleResponsibilityActionImpl> roleRspActions = new ArrayList<RoleResponsibilityActionImpl>(); |
2234 | 0 | List<RoleResponsibilityActionImpl> origActions = new ArrayList<RoleResponsibilityActionImpl>(); |
2235 | 0 | if(origRoleMemberImplTemp!=null) { |
2236 | 0 | origActions = getRoleRspActions(origRoleMemberImplTemp.getRoleMemberId()); |
2237 | |
} |
2238 | 0 | if(CollectionUtils.isNotEmpty(documentRoleMember.getRoleRspActions())){ |
2239 | 0 | for(KimDocumentRoleResponsibilityAction roleRspAction : documentRoleMember.getRoleRspActions()){ |
2240 | 0 | RoleResponsibilityActionImpl newRoleRspAction = new RoleResponsibilityActionImpl(); |
2241 | 0 | newRoleRspAction.setRoleResponsibilityActionId(roleRspAction.getRoleResponsibilityActionId()); |
2242 | 0 | newRoleRspAction.setActionPolicyCode(roleRspAction.getActionPolicyCode()); |
2243 | 0 | newRoleRspAction.setActionTypeCode(roleRspAction.getActionTypeCode()); |
2244 | 0 | newRoleRspAction.setPriorityNumber(roleRspAction.getPriorityNumber()); |
2245 | 0 | newRoleRspAction.setRoleMemberId(roleRspAction.getRoleMemberId()); |
2246 | 0 | newRoleRspAction.setForceAction(roleRspAction.isForceAction()); |
2247 | 0 | newRoleRspAction.setRoleResponsibilityId("*"); |
2248 | 0 | if(ObjectUtils.isNotNull(origActions)){ |
2249 | 0 | for(RoleResponsibilityActionImpl origRspAction: origActions) { |
2250 | 0 | if(activatingInactive && StringUtils.equals(origRspAction.getRoleResponsibilityId(), newRoleRspAction.getRoleResponsibilityId()) && |
2251 | |
StringUtils.equals(newRoleRspAction.getRoleMemberId(), newRoleMemberIdAssigned)){ |
2252 | 0 | newRoleRspAction.setRoleMemberId(origRspAction.getRoleMemberId()); |
2253 | 0 | newRoleRspAction.setRoleResponsibilityActionId(origRspAction.getRoleResponsibilityActionId()); |
2254 | |
} |
2255 | 0 | if (origRspAction.getRoleResponsibilityActionId()!=null && StringUtils.equals(origRspAction.getRoleResponsibilityActionId(), newRoleRspAction.getRoleResponsibilityActionId())) { |
2256 | 0 | newRoleRspAction.setVersionNumber(origRspAction.getVersionNumber()); |
2257 | |
} |
2258 | |
} |
2259 | |
} |
2260 | 0 | roleRspActions.add(newRoleRspAction); |
2261 | 0 | } |
2262 | |
} |
2263 | 0 | return roleRspActions; |
2264 | |
} |
2265 | |
|
2266 | |
protected List<RoleMemberAttributeDataImpl> getRoleMemberAttributeData(List<KimDocumentRoleQualifier> qualifiers, |
2267 | |
List<RoleMemberAttributeDataImpl> origAttributes, boolean activatingInactive, String newRoleMemberIdAssigned){ |
2268 | 0 | List<RoleMemberAttributeDataImpl> roleMemberAttributeDataList = new ArrayList<RoleMemberAttributeDataImpl>(); |
2269 | |
RoleMemberAttributeDataImpl newRoleMemberAttributeData; |
2270 | 0 | if(CollectionUtils.isNotEmpty(qualifiers)){ |
2271 | 0 | for(KimDocumentRoleQualifier memberRoleQualifier: qualifiers){ |
2272 | 0 | if(StringUtils.isNotBlank(memberRoleQualifier.getAttrVal())){ |
2273 | 0 | newRoleMemberAttributeData = new RoleMemberAttributeDataImpl(); |
2274 | 0 | newRoleMemberAttributeData.setId(memberRoleQualifier.getAttrDataId()); |
2275 | 0 | newRoleMemberAttributeData.setAttributeValue(memberRoleQualifier.getAttrVal()); |
2276 | 0 | newRoleMemberAttributeData.setAssignedToId(memberRoleQualifier.getRoleMemberId()); |
2277 | 0 | newRoleMemberAttributeData.setKimTypeId(memberRoleQualifier.getKimTypId()); |
2278 | 0 | newRoleMemberAttributeData.setKimAttributeId(memberRoleQualifier.getKimAttrDefnId()); |
2279 | |
|
2280 | 0 | updateAttrValIfNecessary(newRoleMemberAttributeData); |
2281 | |
|
2282 | 0 | if(ObjectUtils.isNotNull(origAttributes)){ |
2283 | 0 | for(RoleMemberAttributeDataImpl origAttribute: origAttributes){ |
2284 | 0 | if(activatingInactive && StringUtils.equals(origAttribute.getKimAttributeId(), newRoleMemberAttributeData.getKimAttributeId()) && |
2285 | |
StringUtils.equals(newRoleMemberAttributeData.getAssignedToId(), newRoleMemberIdAssigned)){ |
2286 | 0 | newRoleMemberAttributeData.setAssignedToId(origAttribute.getAssignedToId()); |
2287 | 0 | newRoleMemberAttributeData.setId(origAttribute.getId()); |
2288 | |
} |
2289 | 0 | if(origAttribute.getId()!=null && StringUtils.equals(origAttribute.getId(), newRoleMemberAttributeData.getId())){ |
2290 | 0 | newRoleMemberAttributeData.setVersionNumber(origAttribute.getVersionNumber()); |
2291 | |
} |
2292 | |
} |
2293 | |
} |
2294 | 0 | roleMemberAttributeDataList.add(newRoleMemberAttributeData); |
2295 | |
} |
2296 | |
} |
2297 | |
} |
2298 | 0 | return roleMemberAttributeDataList; |
2299 | |
} |
2300 | |
|
2301 | |
|
2302 | |
|
2303 | |
|
2304 | |
|
2305 | |
|
2306 | |
|
2307 | |
protected void updateAttrValIfNecessary(RoleMemberAttributeDataImpl roleMemberAttributeData) { |
2308 | 0 | final AttributeDefinition attributeDefinition = getKNSAttributeDefinition(roleMemberAttributeData.getKimTypeId(), roleMemberAttributeData.getKimAttributeId()); |
2309 | 0 | if (attributeDefinition != null) { |
2310 | 0 | if (attributeDefinition.getControl() != null && attributeDefinition.getControl().isCheckbox()) { |
2311 | 0 | convertCheckboxAttributeData(roleMemberAttributeData); |
2312 | |
} |
2313 | |
} |
2314 | 0 | } |
2315 | |
|
2316 | |
protected void formatAttrValIfNecessary(KimDocumentRoleQualifier roleQualifier) { |
2317 | 0 | final AttributeDefinition attributeDefinition = getKNSAttributeDefinition(roleQualifier.getKimTypId(), roleQualifier.getKimAttrDefnId()); |
2318 | 0 | if (attributeDefinition != null) { |
2319 | 0 | if (attributeDefinition.getControl() != null && attributeDefinition.getControl().isCheckbox()) { |
2320 | 0 | formatCheckboxAttributeData(roleQualifier); |
2321 | |
} |
2322 | |
} |
2323 | 0 | } |
2324 | |
|
2325 | |
protected void formatCheckboxAttributeData(KimDocumentRoleQualifier roleQualifier) { |
2326 | 0 | if (roleQualifier.getAttrVal().equals(KimConstants.KIM_ATTRIBUTE_BOOLEAN_TRUE_STR_VALUE)) { |
2327 | 0 | roleQualifier.setAttrVal(KimConstants.KIM_ATTRIBUTE_BOOLEAN_TRUE_STR_VALUE_DISPLAY); |
2328 | 0 | } else if (roleQualifier.getAttrVal().equals(KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE)) { |
2329 | 0 | roleQualifier.setAttrVal(KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE_DISPLAY); |
2330 | |
} |
2331 | 0 | } |
2332 | |
|
2333 | |
|
2334 | |
|
2335 | |
|
2336 | |
|
2337 | |
|
2338 | |
protected AttributeDefinition getKNSAttributeDefinition(String kimTypId, String attrDefnId) { |
2339 | 0 | final KimType type = getKimTypeInfoService().getKimType(kimTypId); |
2340 | 0 | if (type != null) { |
2341 | 0 | final KimTypeService typeService = (KimTypeService) KIMServiceLocatorInternal.getBean(type.getServiceName()); |
2342 | 0 | if (typeService != null) { |
2343 | 0 | final KimTypeAttribute attributeInfo = type.getAttributeDefinitionById(attrDefnId); |
2344 | 0 | if (attributeInfo != null) { |
2345 | 0 | final AttributeDefinitionMap attributeMap = typeService.getAttributeDefinitions(type.getId()); |
2346 | 0 | if (attributeMap != null) { |
2347 | 0 | return attributeMap.getByAttributeName(attributeInfo.getKimAttribute().getAttributeName()); |
2348 | |
} |
2349 | |
} |
2350 | |
} |
2351 | |
} |
2352 | 0 | return null; |
2353 | |
} |
2354 | |
|
2355 | |
|
2356 | |
|
2357 | |
|
2358 | |
|
2359 | |
|
2360 | |
protected void convertCheckboxAttributeData(RoleMemberAttributeDataImpl roleMemberAttributeData) { |
2361 | 0 | if (roleMemberAttributeData.getAttributeValue().equalsIgnoreCase(KimConstants.KIM_ATTRIBUTE_BOOLEAN_TRUE_STR_VALUE_DISPLAY)) { |
2362 | 0 | roleMemberAttributeData.setAttributeValue(KimConstants.KIM_ATTRIBUTE_BOOLEAN_TRUE_STR_VALUE); |
2363 | 0 | } else if (roleMemberAttributeData.getAttributeValue().equalsIgnoreCase(KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE_DISPLAY)) { |
2364 | 0 | roleMemberAttributeData.setAttributeValue(KimConstants.KIM_ATTRIBUTE_BOOLEAN_FALSE_STR_VALUE); |
2365 | |
} |
2366 | 0 | } |
2367 | |
|
2368 | |
protected List<KimDelegationImpl> getRoleDelegations(IdentityManagementRoleDocument identityManagementRoleDocument, List<KimDelegationImpl> origDelegations){ |
2369 | 0 | List<KimDelegationImpl> kimDelegations = new ArrayList<KimDelegationImpl>(); |
2370 | |
KimDelegationImpl newKimDelegation; |
2371 | 0 | KimDelegationImpl origDelegationImplTemp = null; |
2372 | 0 | List<KimDelegationMemberImpl> origMembers = new ArrayList<KimDelegationMemberImpl>(); |
2373 | 0 | boolean activatingInactive = false; |
2374 | 0 | String newDelegationIdAssigned = ""; |
2375 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getDelegations())){ |
2376 | 0 | for(RoleDocumentDelegation roleDocumentDelegation: identityManagementRoleDocument.getDelegations()){ |
2377 | 0 | newKimDelegation = new KimDelegationImpl(); |
2378 | 0 | KimCommonUtilsInternal.copyProperties(newKimDelegation, roleDocumentDelegation); |
2379 | 0 | newKimDelegation.setRoleId(identityManagementRoleDocument.getRoleId()); |
2380 | 0 | if(ObjectUtils.isNotNull(origDelegations)){ |
2381 | 0 | for(KimDelegationImpl origDelegationImpl: origDelegations){ |
2382 | 0 | if(StringUtils.equals(origDelegationImpl.getRoleId(), newKimDelegation.getRoleId()) && |
2383 | |
StringUtils.equals(origDelegationImpl.getDelegationId(), newKimDelegation.getDelegationId())){ |
2384 | |
|
2385 | 0 | newDelegationIdAssigned = newKimDelegation.getDelegationId(); |
2386 | 0 | newKimDelegation.setDelegationId(origDelegationImpl.getDelegationId()); |
2387 | 0 | activatingInactive = true; |
2388 | |
} |
2389 | 0 | if(origDelegationImpl.getDelegationId()!=null && StringUtils.equals(origDelegationImpl.getDelegationId(), newKimDelegation.getDelegationId())){ |
2390 | 0 | newKimDelegation.setVersionNumber(origDelegationImpl.getVersionNumber()); |
2391 | 0 | origDelegationImplTemp = origDelegationImpl; |
2392 | |
} |
2393 | |
} |
2394 | |
} |
2395 | 0 | origMembers = (origDelegationImplTemp==null || origDelegationImplTemp.getMembers()==null)? |
2396 | |
new ArrayList<KimDelegationMemberImpl>():origDelegationImplTemp.getMembers(); |
2397 | 0 | newKimDelegation.setMembers(getDelegationMembers(roleDocumentDelegation.getMembers(), origMembers, activatingInactive, newDelegationIdAssigned)); |
2398 | 0 | kimDelegations.add(newKimDelegation); |
2399 | 0 | activatingInactive = false; |
2400 | |
} |
2401 | |
} |
2402 | 0 | return kimDelegations; |
2403 | |
} |
2404 | |
|
2405 | |
protected List<KimDelegationMemberImpl> getDelegationMembers(List<RoleDocumentDelegationMember> delegationMembers, |
2406 | |
List<KimDelegationMemberImpl> origDelegationMembers, boolean activatingInactive, String newDelegationIdAssigned){ |
2407 | 0 | List<KimDelegationMemberImpl> delegationsMembersList = new ArrayList<KimDelegationMemberImpl>(); |
2408 | |
KimDelegationMemberImpl newDelegationMemberImpl; |
2409 | 0 | KimDelegationMemberImpl origDelegationMemberImplTemp = null; |
2410 | |
List<KimDelegationMemberAttributeDataImpl> origAttributes; |
2411 | 0 | String delegationMemberId = ""; |
2412 | 0 | if(CollectionUtils.isNotEmpty(delegationMembers)){ |
2413 | 0 | for(RoleDocumentDelegationMember delegationMember: delegationMembers){ |
2414 | 0 | newDelegationMemberImpl = new KimDelegationMemberImpl(); |
2415 | 0 | KimCommonUtilsInternal.copyProperties(newDelegationMemberImpl, delegationMember); |
2416 | 0 | if(ObjectUtils.isNotNull(origDelegationMembers)){ |
2417 | 0 | for(KimDelegationMemberImpl origDelegationMember: origDelegationMembers){ |
2418 | 0 | if(activatingInactive && StringUtils.equals(origDelegationMember.getMemberId(), newDelegationMemberImpl.getMemberId()) && |
2419 | |
StringUtils.equals(newDelegationMemberImpl.getDelegationId(), newDelegationIdAssigned) && |
2420 | |
!origDelegationMember.isActive()){ |
2421 | 0 | newDelegationMemberImpl.setDelegationId(origDelegationMember.getDelegationId()); |
2422 | 0 | delegationMemberId = newDelegationMemberImpl.getDelegationMemberId(); |
2423 | 0 | newDelegationMemberImpl.setDelegationMemberId(origDelegationMember.getDelegationMemberId()); |
2424 | |
} |
2425 | 0 | if(origDelegationMember.getDelegationMemberId()!=null && StringUtils.equals(origDelegationMember.getDelegationMemberId(), newDelegationMemberImpl.getDelegationMemberId())){ |
2426 | 0 | newDelegationMemberImpl.setVersionNumber(origDelegationMember.getVersionNumber()); |
2427 | 0 | origDelegationMemberImplTemp = origDelegationMember; |
2428 | |
} |
2429 | |
} |
2430 | |
} |
2431 | 0 | origAttributes = (origDelegationMemberImplTemp==null || origDelegationMemberImplTemp.getAttributes()==null)? |
2432 | |
new ArrayList<KimDelegationMemberAttributeDataImpl>():origDelegationMemberImplTemp.getAttributes(); |
2433 | 0 | newDelegationMemberImpl.setAttributes(getDelegationMemberAttributeData(delegationMember.getQualifiers(), origAttributes, activatingInactive, delegationMemberId)); |
2434 | 0 | delegationsMembersList.add(newDelegationMemberImpl); |
2435 | |
} |
2436 | |
} |
2437 | 0 | return delegationsMembersList; |
2438 | |
} |
2439 | |
|
2440 | |
|
2441 | |
protected List<KimDelegationMemberAttributeDataImpl> getDelegationMemberAttributeData( |
2442 | |
List<RoleDocumentDelegationMemberQualifier> qualifiers, List<KimDelegationMemberAttributeDataImpl> origAttributes, |
2443 | |
boolean activatingInactive, String delegationMemberId){ |
2444 | 0 | List<KimDelegationMemberAttributeDataImpl> delegationMemberAttributeDataList = new ArrayList<KimDelegationMemberAttributeDataImpl>(); |
2445 | |
KimDelegationMemberAttributeDataImpl newDelegationMemberAttributeData; |
2446 | 0 | if(CollectionUtils.isNotEmpty(qualifiers)){ |
2447 | 0 | for(RoleDocumentDelegationMemberQualifier memberRoleQualifier: qualifiers){ |
2448 | 0 | if(StringUtils.isNotBlank(memberRoleQualifier.getAttrVal())){ |
2449 | 0 | newDelegationMemberAttributeData = new KimDelegationMemberAttributeDataImpl(); |
2450 | 0 | newDelegationMemberAttributeData.setId(memberRoleQualifier.getAttrDataId()); |
2451 | 0 | newDelegationMemberAttributeData.setAttributeValue(memberRoleQualifier.getAttrVal()); |
2452 | 0 | newDelegationMemberAttributeData.setAssignedToId(memberRoleQualifier.getDelegationMemberId()); |
2453 | 0 | newDelegationMemberAttributeData.setKimTypeId(memberRoleQualifier.getKimTypId()); |
2454 | 0 | newDelegationMemberAttributeData.setKimAttributeId(memberRoleQualifier.getKimAttrDefnId()); |
2455 | 0 | if(ObjectUtils.isNotNull(origAttributes)){ |
2456 | 0 | for(KimDelegationMemberAttributeDataImpl origAttribute: origAttributes){ |
2457 | 0 | if(activatingInactive && StringUtils.equals(origAttribute.getKimAttributeId(), newDelegationMemberAttributeData.getKimAttributeId()) && |
2458 | |
StringUtils.equals(newDelegationMemberAttributeData.getAssignedToId(), delegationMemberId)){ |
2459 | 0 | newDelegationMemberAttributeData.setAssignedToId(origAttribute.getAssignedToId()); |
2460 | 0 | newDelegationMemberAttributeData.setId(origAttribute.getId()); |
2461 | |
} |
2462 | 0 | if(StringUtils.equals(origAttribute.getId(), newDelegationMemberAttributeData.getId())){ |
2463 | 0 | newDelegationMemberAttributeData.setVersionNumber(origAttribute.getVersionNumber()); |
2464 | |
} |
2465 | |
} |
2466 | |
} |
2467 | 0 | delegationMemberAttributeDataList.add(newDelegationMemberAttributeData); |
2468 | |
} |
2469 | |
} |
2470 | |
} |
2471 | 0 | return delegationMemberAttributeDataList; |
2472 | |
} |
2473 | |
|
2474 | |
|
2475 | |
public void loadGroupDoc(IdentityManagementGroupDocument identityManagementGroupDocument, Group groupInfo){ |
2476 | |
|
2477 | |
|
2478 | |
|
2479 | |
|
2480 | |
|
2481 | 0 | identityManagementGroupDocument.setGroupId(groupInfo.getId()); |
2482 | 0 | KimType kimType = KimApiServiceLocator.getKimTypeInfoService().getKimType(groupInfo.getKimTypeId()); |
2483 | 0 | identityManagementGroupDocument.setKimType(kimType); |
2484 | 0 | identityManagementGroupDocument.setGroupTypeName(kimType.getName()); |
2485 | 0 | identityManagementGroupDocument.setGroupTypeId(kimType.getId()); |
2486 | 0 | identityManagementGroupDocument.setGroupName(groupInfo.getName()); |
2487 | 0 | identityManagementGroupDocument.setGroupDescription(groupInfo.getDescription()); |
2488 | 0 | identityManagementGroupDocument.setActive(groupInfo.isActive()); |
2489 | 0 | identityManagementGroupDocument.setGroupNamespace(groupInfo.getNamespaceCode()); |
2490 | |
|
2491 | 0 | List<GroupMember> members = new ArrayList(KimApiServiceLocator.getGroupService().getMembersOfGroup(groupInfo.getId())); |
2492 | 0 | identityManagementGroupDocument.setMembers(loadGroupMembers(identityManagementGroupDocument, members)); |
2493 | |
|
2494 | |
|
2495 | |
|
2496 | 0 | identityManagementGroupDocument.setQualifiers(loadGroupQualifiers(identityManagementGroupDocument, groupInfo.getAttributes())); |
2497 | 0 | identityManagementGroupDocument.setEditing(true); |
2498 | 0 | } |
2499 | |
|
2500 | 0 | protected static class GroupMemberNameComparator implements Comparator<GroupDocumentMember> { |
2501 | |
|
2502 | |
|
2503 | |
|
2504 | |
public int compare(GroupDocumentMember m1, GroupDocumentMember m2) { |
2505 | 0 | return m1.getMemberName().compareToIgnoreCase(m2.getMemberName()); |
2506 | |
} |
2507 | |
} |
2508 | |
|
2509 | 0 | protected GroupMemberNameComparator groupMemberNameComparator = new GroupMemberNameComparator(); |
2510 | |
|
2511 | |
protected List<GroupDocumentMember> loadGroupMembers( |
2512 | |
IdentityManagementGroupDocument identityManagementGroupDocument, List<GroupMember> members){ |
2513 | 0 | List<GroupDocumentMember> pndMembers = new ArrayList<GroupDocumentMember>(); |
2514 | 0 | GroupDocumentMember pndMember = new GroupDocumentMember(); |
2515 | 0 | if(ObjectUtils.isNotNull(members)){ |
2516 | 0 | for(GroupMember member: members){ |
2517 | 0 | pndMember = new GroupDocumentMember(); |
2518 | 0 | pndMember.setActiveFromDate(member.getActiveFromDate()); |
2519 | 0 | pndMember.setActiveToDate(member.getActiveToDate()); |
2520 | |
|
2521 | 0 | if(pndMember.isActive()){ |
2522 | 0 | pndMember.setGroupMemberId(member.getMemberId()); |
2523 | 0 | pndMember.setGroupId(member.getGroupId()); |
2524 | 0 | pndMember.setMemberId(member.getMemberId()); |
2525 | 0 | pndMember.setMemberName(getMemberName(member.getTypeCode(), member.getMemberId())); |
2526 | 0 | pndMember.setMemberFullName(getMemberFullName(member.getTypeCode(), member.getMemberId())); |
2527 | 0 | pndMember.setMemberTypeCode(member.getTypeCode()); |
2528 | 0 | pndMember.setEdit(true); |
2529 | 0 | pndMembers.add(pndMember); |
2530 | |
} |
2531 | |
} |
2532 | |
} |
2533 | 0 | Collections.sort(pndMembers, groupMemberNameComparator); |
2534 | 0 | return pndMembers; |
2535 | |
} |
2536 | |
|
2537 | |
protected List<GroupDocumentQualifier> loadGroupQualifiers(IdentityManagementGroupDocument IdentityManagementGroupDocument, |
2538 | |
Attributes attributes){ |
2539 | 0 | List<GroupDocumentQualifier> pndGroupQualifiers = new ArrayList<GroupDocumentQualifier>(); |
2540 | 0 | GroupDocumentQualifier pndGroupQualifier = new GroupDocumentQualifier(); |
2541 | 0 | AttributeDefinitionMap origAttributes = IdentityManagementGroupDocument.getDefinitions(); |
2542 | 0 | boolean attributePresent = false; |
2543 | |
String origAttributeId; |
2544 | 0 | if(origAttributes!=null){ |
2545 | |
|
2546 | 0 | for(String key: origAttributes.keySet()) { |
2547 | 0 | origAttributeId = IdentityManagementGroupDocument.getKimAttributeDefnId(origAttributes.get(key)); |
2548 | 0 | if(!attributes.isEmpty()){ |
2549 | |
|
2550 | 0 | for(GroupAttributeBo groupQualifier: KimAttributeDataBo.createFrom(GroupAttributeBo.class, attributes, IdentityManagementGroupDocument.getGroupTypeId())){ |
2551 | 0 | if(origAttributeId!=null && ObjectUtils.isNotNull(groupQualifier.getKimAttribute()) && |
2552 | |
StringUtils.equals(origAttributeId, groupQualifier.getKimAttribute().getId())){ |
2553 | 0 | pndGroupQualifier = new GroupDocumentQualifier(); |
2554 | 0 | KimCommonUtilsInternal.copyProperties(pndGroupQualifier, groupQualifier); |
2555 | 0 | pndGroupQualifier.setAttrDataId(groupQualifier.getId()); |
2556 | 0 | pndGroupQualifier.setAttrVal(groupQualifier.getAttributeValue()); |
2557 | 0 | pndGroupQualifier.setKimAttrDefnId(groupQualifier.getKimAttribute().getId()); |
2558 | 0 | pndGroupQualifier.setKimTypId(groupQualifier.getKimType().getId()); |
2559 | 0 | pndGroupQualifier.setGroupId(groupQualifier.getAssignedToId()); |
2560 | 0 | pndGroupQualifiers.add(pndGroupQualifier); |
2561 | 0 | attributePresent = true; |
2562 | |
} |
2563 | |
} |
2564 | |
} |
2565 | 0 | if(!attributePresent){ |
2566 | 0 | pndGroupQualifier = new GroupDocumentQualifier(); |
2567 | 0 | pndGroupQualifier.setKimAttrDefnId(origAttributeId); |
2568 | 0 | pndGroupQualifiers.add(pndGroupQualifier); |
2569 | |
} |
2570 | 0 | attributePresent = false; |
2571 | |
} |
2572 | |
} |
2573 | 0 | return pndGroupQualifiers; |
2574 | |
} |
2575 | |
|
2576 | |
|
2577 | |
|
2578 | |
|
2579 | |
@SuppressWarnings("unchecked") |
2580 | |
public void saveGroup(IdentityManagementGroupDocument identityManagementGroupDocument) { |
2581 | 0 | GroupBo kimGroup = new GroupBo(); |
2582 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
2583 | 0 | String groupId = identityManagementGroupDocument.getGroupId(); |
2584 | 0 | criteria.put("groupId", groupId); |
2585 | 0 | GroupBo origGroup = (GroupBo)getBusinessObjectService().findBySinglePrimaryKey(GroupBo.class, groupId); |
2586 | 0 | List<GroupMemberBo> origGroupMembers = new ArrayList<GroupMemberBo>(); |
2587 | 0 | if (ObjectUtils.isNull(origGroup)) { |
2588 | 0 | origGroup = new GroupBo(); |
2589 | 0 | kimGroup.setActive(true); |
2590 | |
} else { |
2591 | 0 | kimGroup.setVersionNumber(origGroup.getVersionNumber()); |
2592 | |
|
2593 | |
|
2594 | 0 | kimGroup.setActive(identityManagementGroupDocument.isActive()); |
2595 | 0 | origGroupMembers = (List<GroupMemberBo>)getBusinessObjectService().findMatching(GroupMemberBo.class, criteria); |
2596 | |
} |
2597 | |
|
2598 | 0 | kimGroup.setId(identityManagementGroupDocument.getGroupId()); |
2599 | 0 | KimType kimType = getKimTypeInfoService().getKimType(identityManagementGroupDocument.getGroupTypeId()); |
2600 | 0 | if( kimType == null ) { |
2601 | 0 | throw new RuntimeException("Kim type not found for:"+identityManagementGroupDocument.getGroupTypeId()); |
2602 | |
} |
2603 | |
|
2604 | 0 | kimGroup.setKimTypeId(kimType.getId()); |
2605 | 0 | kimGroup.setNamespaceCode(identityManagementGroupDocument.getGroupNamespace()); |
2606 | 0 | kimGroup.setName(identityManagementGroupDocument.getGroupName()); |
2607 | 0 | kimGroup.setDescription(identityManagementGroupDocument.getGroupDescription()); |
2608 | 0 | kimGroup.setAttributeDetails(getGroupAttributeData(identityManagementGroupDocument, origGroup.getAttributeDetails())); |
2609 | |
|
2610 | 0 | List<String> oldIds = null; |
2611 | 0 | List<String> newIds = null; |
2612 | |
|
2613 | 0 | oldIds = getGroupService().getMemberPrincipalIds(kimGroup.getId()); |
2614 | |
|
2615 | |
|
2616 | 0 | List<GroupMemberBo> newGroupMembersList = getGroupMembers(identityManagementGroupDocument, origGroupMembers); |
2617 | 0 | kimGroup.setMembers(newGroupMembersList); |
2618 | |
|
2619 | 0 | kimGroup = (GroupBo)getBusinessObjectService().save(kimGroup); |
2620 | |
|
2621 | 0 | newIds = kimGroup.getMemberPrincipalIds(); |
2622 | |
|
2623 | |
|
2624 | |
|
2625 | 0 | KIMServiceLocatorInternal.getGroupInternalService().updateForWorkgroupChange(kimGroup.getId(), oldIds, newIds); |
2626 | 0 | IdentityManagementNotificationService service = (IdentityManagementNotificationService) KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(new QName("KIM", "kimIdentityManagementNotificationService")); |
2627 | 0 | service.groupUpdated(); |
2628 | 0 | if(!kimGroup.isActive()){ |
2629 | |
|
2630 | |
|
2631 | 0 | KimApiServiceLocator.getRoleService().groupInactivated(identityManagementGroupDocument.getGroupId()); |
2632 | |
} |
2633 | |
|
2634 | 0 | } |
2635 | |
|
2636 | |
|
2637 | |
|
2638 | |
|
2639 | |
|
2640 | |
|
2641 | |
protected List<? extends Group> getGroupsByIds(List<String> groupIds) { |
2642 | 0 | List<Group> groups = new ArrayList<Group>(); |
2643 | 0 | Map<String, Group> groupInfoMap = getGroupService().getGroups(groupIds); |
2644 | 0 | for (String groupId : groupInfoMap.keySet()) { |
2645 | 0 | groups.add(groupInfoMap.get(groupId)); |
2646 | |
} |
2647 | 0 | return groups; |
2648 | |
} |
2649 | |
|
2650 | |
protected List<GroupMemberBo> getGroupMembers(IdentityManagementGroupDocument identityManagementGroupDocument, List<GroupMemberBo> origGroupMembers){ |
2651 | 0 | List<GroupMemberBo> groupMembers = new ArrayList<GroupMemberBo>(); |
2652 | |
GroupMemberBo newGroupMember; |
2653 | 0 | if(CollectionUtils.isNotEmpty(identityManagementGroupDocument.getMembers())){ |
2654 | 0 | for(GroupDocumentMember documentGroupMember: identityManagementGroupDocument.getMembers()){ |
2655 | 0 | newGroupMember = new GroupMemberBo(); |
2656 | |
|
2657 | |
|
2658 | |
|
2659 | 0 | newGroupMember.setGroupId(identityManagementGroupDocument.getGroupId()); |
2660 | 0 | newGroupMember.setActiveFromDate(documentGroupMember.getActiveFromDate()); |
2661 | 0 | newGroupMember.setActiveToDate(documentGroupMember.getActiveToDate()); |
2662 | 0 | newGroupMember.setMemberId(documentGroupMember.getMemberId()); |
2663 | 0 | newGroupMember.setTypeCode(documentGroupMember.getMemberTypeCode()); |
2664 | 0 | if(ObjectUtils.isNotNull(origGroupMembers)){ |
2665 | 0 | for(GroupMemberBo origGroupMemberImpl: origGroupMembers){ |
2666 | 0 | if(StringUtils.equals(origGroupMemberImpl.getGroupId(), newGroupMember.getGroupId()) && |
2667 | |
StringUtils.equals(origGroupMemberImpl.getMemberId(), newGroupMember.getMemberId()) && |
2668 | |
!origGroupMemberImpl.isActive()){ |
2669 | |
|
2670 | 0 | newGroupMember.setMemberId(origGroupMemberImpl.getMemberId()); |
2671 | |
} |
2672 | 0 | if(StringUtils.equals(origGroupMemberImpl.getGroupId(), newGroupMember.getGroupId()) && |
2673 | |
StringUtils.equals(origGroupMemberImpl.getMemberId(), newGroupMember.getMemberId()) && |
2674 | |
origGroupMemberImpl.isActive()){ |
2675 | 0 | newGroupMember.setId(origGroupMemberImpl.getId()); |
2676 | 0 | newGroupMember.setVersionNumber(origGroupMemberImpl.getVersionNumber()); |
2677 | |
} |
2678 | |
} |
2679 | |
} |
2680 | 0 | groupMembers.add(newGroupMember); |
2681 | |
} |
2682 | |
} |
2683 | 0 | return groupMembers; |
2684 | |
} |
2685 | |
|
2686 | |
protected List<GroupAttributeBo> getGroupAttributeData(IdentityManagementGroupDocument identityManagementGroupDocument, |
2687 | |
List<GroupAttributeBo> origAttributes){ |
2688 | 0 | List<GroupAttributeBo> groupAttributeDataList = new ArrayList<GroupAttributeBo>(); |
2689 | |
GroupAttributeBo newGroupAttributeData; |
2690 | 0 | if(CollectionUtils.isNotEmpty(identityManagementGroupDocument.getQualifiers())){ |
2691 | 0 | for(GroupDocumentQualifier groupQualifier: identityManagementGroupDocument.getQualifiers()){ |
2692 | 0 | if(StringUtils.isNotBlank(groupQualifier.getAttrVal())){ |
2693 | 0 | newGroupAttributeData = new GroupAttributeBo(); |
2694 | 0 | newGroupAttributeData.setId(groupQualifier.getAttrDataId()); |
2695 | 0 | newGroupAttributeData.setAttributeValue(groupQualifier.getAttrVal()); |
2696 | 0 | newGroupAttributeData.setAssignedToId(groupQualifier.getGroupId()); |
2697 | 0 | newGroupAttributeData.setKimTypeId(groupQualifier.getKimTypId()); |
2698 | 0 | newGroupAttributeData.setKimAttributeId(groupQualifier.getKimAttrDefnId()); |
2699 | 0 | if(ObjectUtils.isNotNull(origAttributes)){ |
2700 | 0 | for(GroupAttributeBo origAttribute: origAttributes){ |
2701 | 0 | if(StringUtils.equals(origAttribute.getKimAttributeId(), newGroupAttributeData.getKimAttributeId()) && |
2702 | |
StringUtils.equals(newGroupAttributeData.getAssignedToId(), origAttribute.getAssignedToId())){ |
2703 | 0 | newGroupAttributeData.setId(origAttribute.getId()); |
2704 | |
} |
2705 | 0 | if(origAttribute.getId()!=null && StringUtils.equals(origAttribute.getId(), newGroupAttributeData.getId())){ |
2706 | 0 | newGroupAttributeData.setVersionNumber(origAttribute.getVersionNumber()); |
2707 | |
} |
2708 | |
} |
2709 | |
} |
2710 | 0 | groupAttributeDataList.add(newGroupAttributeData); |
2711 | |
} |
2712 | |
} |
2713 | |
} |
2714 | 0 | return groupAttributeDataList; |
2715 | |
} |
2716 | |
|
2717 | |
@SuppressWarnings("unchecked") |
2718 | |
public KimDocumentRoleMember getKimDocumentRoleMember(String memberTypeCode, String memberId, String roleId){ |
2719 | 0 | if(StringUtils.isEmpty(memberTypeCode) || StringUtils.isEmpty(memberId) || StringUtils.isEmpty(roleId)) |
2720 | 0 | return null; |
2721 | 0 | KimDocumentRoleMember documentRoleMember = new KimDocumentRoleMember(); |
2722 | 0 | documentRoleMember.setRoleId(roleId); |
2723 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
2724 | 0 | criteria.put(KimConstants.PrimaryKeyConstants.ROLE_ID, roleId); |
2725 | 0 | criteria.put("mbr_id", memberId); |
2726 | |
|
2727 | 0 | List<RoleMemberImpl> matchingRoleMembers = (List<RoleMemberImpl>)getBusinessObjectService().findMatching(RoleMemberImpl.class, criteria); |
2728 | 0 | if(matchingRoleMembers==null || matchingRoleMembers.size()<1) return null; |
2729 | |
|
2730 | 0 | RoleMemberImpl roleMemberImpl = matchingRoleMembers.get(0); |
2731 | 0 | documentRoleMember.setRoleMemberId(roleMemberImpl.getRoleMemberId()); |
2732 | 0 | if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode)){ |
2733 | 0 | Principal principal = getIdentityManagementService().getPrincipal(memberId); |
2734 | 0 | if (principal != null) { |
2735 | 0 | documentRoleMember.setMemberId(principal.getPrincipalId()); |
2736 | 0 | documentRoleMember.setMemberName(principal.getPrincipalName()); |
2737 | 0 | documentRoleMember.setMemberTypeCode(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE); |
2738 | |
} |
2739 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode)){ |
2740 | 0 | Group group = null; |
2741 | 0 | group = getGroupService().getGroup(memberId); |
2742 | 0 | if (group != null) { |
2743 | 0 | documentRoleMember.setMemberNamespaceCode(group.getNamespaceCode()); |
2744 | 0 | documentRoleMember.setMemberId(group.getId()); |
2745 | 0 | documentRoleMember.setMemberName(group.getName()); |
2746 | 0 | documentRoleMember.setMemberTypeCode(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE); |
2747 | |
} |
2748 | |
|
2749 | 0 | } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode)){ |
2750 | 0 | KimRoleInfo role = null; |
2751 | 0 | role = getRoleService().getRole(memberId); |
2752 | 0 | if (role != null) { |
2753 | 0 | documentRoleMember.setMemberNamespaceCode(role.getNamespaceCode()); |
2754 | 0 | documentRoleMember.setMemberId(role.getRoleId()); |
2755 | 0 | documentRoleMember.setMemberName(role.getRoleName()); |
2756 | 0 | documentRoleMember.setMemberTypeCode(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE); |
2757 | |
} |
2758 | |
} |
2759 | 0 | return documentRoleMember; |
2760 | |
} |
2761 | |
|
2762 | |
protected Set<String> getChangedRoleResponsibilityIds( |
2763 | |
IdentityManagementRoleDocument identityManagementRoleDocument, List<RoleResponsibilityImpl> origRoleResponsibilities){ |
2764 | 0 | Set<String> lRet = new HashSet<String>(); |
2765 | 0 | List<String> newResp = new ArrayList<String>(); |
2766 | 0 | List<String> oldResp = new ArrayList<String>(); |
2767 | 0 | if(CollectionUtils.isNotEmpty(identityManagementRoleDocument.getResponsibilities())){ |
2768 | 0 | for(KimDocumentRoleResponsibility documentRoleResponsibility: identityManagementRoleDocument.getResponsibilities()){ |
2769 | 0 | newResp.add(documentRoleResponsibility.getResponsibilityId()); |
2770 | |
} |
2771 | |
} |
2772 | 0 | if(ObjectUtils.isNotNull(origRoleResponsibilities)){ |
2773 | 0 | for(RoleResponsibilityImpl roleResp: origRoleResponsibilities){ |
2774 | 0 | oldResp.add(roleResp.getResponsibilityId()); |
2775 | |
} |
2776 | |
} |
2777 | 0 | lRet.addAll(newResp); |
2778 | 0 | lRet.addAll(oldResp); |
2779 | |
|
2780 | 0 | return lRet; |
2781 | |
} |
2782 | |
|
2783 | |
public KimTypeInfoService getKimTypeInfoService() { |
2784 | 0 | if ( kimTypeInfoService == null ) { |
2785 | 0 | kimTypeInfoService = KimApiServiceLocator.getKimTypeInfoService(); |
2786 | |
} |
2787 | 0 | return kimTypeInfoService; |
2788 | |
} |
2789 | |
|
2790 | |
public List<KimDocumentRoleMember> getRoleMembers(Map<String,String> fieldValues) { |
2791 | 0 | List<KimDocumentRoleMember> matchingRoleMembers = new ArrayList<KimDocumentRoleMember>(); |
2792 | 0 | List<RoleMembershipInfo> matchingRoleMembersTemp = getRoleService().findRoleMembers(fieldValues); |
2793 | |
KimDocumentRoleMember matchingRoleMember; |
2794 | |
BusinessObject roleMemberObject; |
2795 | |
RoleMemberImpl roleMember; |
2796 | 0 | if(CollectionUtils.isNotEmpty(matchingRoleMembersTemp)){ |
2797 | 0 | for(RoleMembershipInfo roleMembership: matchingRoleMembersTemp){ |
2798 | 0 | roleMember = getRoleMember(roleMembership.getRoleMemberId()); |
2799 | 0 | roleMemberObject = getMember(roleMember.getMemberTypeCode(), roleMember.getMemberId()); |
2800 | 0 | matchingRoleMember = new KimDocumentRoleMember(); |
2801 | 0 | KimCommonUtilsInternal.copyProperties(matchingRoleMember, roleMember); |
2802 | 0 | matchingRoleMember.setMemberName(getMemberName(roleMember.getMemberTypeCode(), roleMemberObject)); |
2803 | 0 | matchingRoleMember.setMemberNamespaceCode(getMemberNamespaceCode(roleMember.getMemberTypeCode(), roleMemberObject)); |
2804 | 0 | matchingRoleMember.setQualifiers(getQualifiers(roleMember.getAttributes())); |
2805 | 0 | matchingRoleMembers.add(matchingRoleMember); |
2806 | |
} |
2807 | |
} |
2808 | 0 | return matchingRoleMembers; |
2809 | |
} |
2810 | |
|
2811 | |
private List<KimDocumentRoleQualifier> getQualifiers(List<RoleMemberAttributeDataImpl> attributes){ |
2812 | 0 | if(attributes==null) return null; |
2813 | 0 | List<KimDocumentRoleQualifier> qualifiers = new ArrayList<KimDocumentRoleQualifier>(); |
2814 | |
KimDocumentRoleQualifier qualifier; |
2815 | 0 | if(ObjectUtils.isNotNull(attributes)){ |
2816 | 0 | for(RoleMemberAttributeDataImpl attribute: attributes){ |
2817 | 0 | qualifier = new KimDocumentRoleQualifier(); |
2818 | 0 | qualifier.setAttrDataId(attribute.getId()); |
2819 | 0 | qualifier.setAttrVal(attribute.getAttributeValue()); |
2820 | 0 | qualifier.setRoleMemberId(attribute.getAssignedToId()); |
2821 | 0 | qualifier.setKimTypId(attribute.getKimTypeId()); |
2822 | 0 | qualifier.setKimAttrDefnId(attribute.getKimAttributeId()); |
2823 | 0 | qualifier.setKimAttribute(attribute.getKimAttribute()); |
2824 | 0 | qualifiers.add(qualifier); |
2825 | |
} |
2826 | |
} |
2827 | 0 | return qualifiers; |
2828 | |
} |
2829 | |
|
2830 | |
public ResponsibilityInternalService getResponsibilityInternalService() { |
2831 | 0 | if ( responsibilityInternalService == null ) { |
2832 | 0 | responsibilityInternalService = KIMServiceLocatorInternal.getResponsibilityInternalService(); |
2833 | |
} |
2834 | 0 | return responsibilityInternalService; |
2835 | |
} |
2836 | |
} |