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