1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.dao.impl; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collection; |
20 | |
import java.util.HashMap; |
21 | |
import java.util.List; |
22 | |
import java.util.Map; |
23 | |
import java.util.Map.Entry; |
24 | |
|
25 | |
import org.apache.commons.collections.CollectionUtils; |
26 | |
import org.apache.commons.lang.StringUtils; |
27 | |
import org.apache.ojb.broker.query.Criteria; |
28 | |
import org.apache.ojb.broker.query.Query; |
29 | |
import org.apache.ojb.broker.query.QueryFactory; |
30 | |
import org.apache.ojb.broker.query.ReportQueryByCriteria; |
31 | |
import org.kuali.rice.kim.bo.Role; |
32 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
33 | |
import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo; |
34 | |
import org.kuali.rice.kim.bo.group.dto.GroupMembershipInfo; |
35 | |
import org.kuali.rice.kim.bo.impl.KimAttributes; |
36 | |
import org.kuali.rice.kim.bo.impl.RoleImpl; |
37 | |
import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo; |
38 | |
import org.kuali.rice.kim.bo.role.dto.KimResponsibilityInfo; |
39 | |
import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo; |
40 | |
import org.kuali.rice.kim.bo.role.dto.RoleMembershipInfo; |
41 | |
import org.kuali.rice.kim.bo.role.impl.KimDelegationImpl; |
42 | |
import org.kuali.rice.kim.bo.role.impl.KimDelegationMemberImpl; |
43 | |
import org.kuali.rice.kim.bo.role.impl.RoleMemberAttributeDataImpl; |
44 | |
import org.kuali.rice.kim.bo.role.impl.RoleMemberImpl; |
45 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
46 | |
import org.kuali.rice.kim.dao.KimRoleDao; |
47 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
48 | |
import org.kuali.rice.kim.util.KIMPropertyConstants; |
49 | |
import org.kuali.rice.kim.util.KimConstants; |
50 | |
import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 0 | public class KimRoleDaoOjb extends PlatformAwareDaoBaseOjb implements KimRoleDao { |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
private void addSubCriteriaBasedOnRoleQualification(Criteria c, AttributeSet qualification) { |
68 | 0 | if(qualification != null && CollectionUtils.isNotEmpty(qualification.keySet())) { |
69 | 0 | for(Map.Entry<String, String> qualifier : qualification.entrySet()) { |
70 | 0 | Criteria subCrit = new Criteria(); |
71 | 0 | if(StringUtils.isNotEmpty(qualifier.getValue())) { |
72 | 0 | String value = (qualifier.getValue()).replace('*', '%'); |
73 | 0 | subCrit.addLike("attributeValue", value); |
74 | 0 | subCrit.addEqualTo("kimAttributeId", qualifier.getKey()); |
75 | 0 | ReportQueryByCriteria subQuery = QueryFactory.newReportQuery(RoleMemberAttributeDataImpl.class, subCrit); |
76 | 0 | c.addExists(subQuery); |
77 | |
} |
78 | 0 | } |
79 | |
} |
80 | 0 | } |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
@SuppressWarnings("unchecked") |
87 | |
public List<RoleMemberImpl> getRolePrincipalsForPrincipalIdAndRoleIds( Collection<String> roleIds, String principalId, AttributeSet qualification) { |
88 | |
|
89 | 0 | Criteria c = new Criteria(); |
90 | |
|
91 | 0 | if ( roleIds != null ) { |
92 | 0 | c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds); |
93 | |
} |
94 | 0 | if(principalId!=null) |
95 | 0 | c.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, principalId); |
96 | 0 | c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE ); |
97 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
98 | |
|
99 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
100 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
101 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
102 | 0 | for ( RoleMemberImpl rm : coll ) { |
103 | 0 | if ( rm.isActive() ) { |
104 | 0 | results.add(rm); |
105 | |
} |
106 | |
} |
107 | 0 | return results; |
108 | |
} |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public List<GroupMembershipInfo> getGroupPrincipalsForPrincipalIdAndGroupIds( Collection<String> groupIds, String principalId) { |
115 | 0 | List<String> groupIdValues = new ArrayList<String>(); |
116 | 0 | List<GroupMembershipInfo> groupPrincipals = new ArrayList<GroupMembershipInfo>(); |
117 | 0 | if (groupIds != null |
118 | |
&& principalId == null) { |
119 | 0 | groupIdValues = new ArrayList<String>(groupIds); |
120 | 0 | } else if (principalId != null) { |
121 | 0 | groupIdValues = KIMServiceLocator.getGroupService().getGroupIdsForPrincipal(principalId); |
122 | |
} |
123 | 0 | if (groupIdValues != null |
124 | |
&& groupIdValues.size() > 0) { |
125 | 0 | Collection<GroupMembershipInfo> groupMembershipInfos = KIMServiceLocator.getGroupService().getGroupMembers(groupIdValues); |
126 | 0 | for (GroupMembershipInfo groupMembershipInfo : groupMembershipInfos) { |
127 | 0 | if (principalId != null) { |
128 | 0 | if (StringUtils.equals(groupMembershipInfo.getMemberTypeCode(), Role.PRINCIPAL_MEMBER_TYPE) |
129 | |
&& StringUtils.equals(principalId, groupMembershipInfo.getMemberId()) |
130 | |
&& groupMembershipInfo.isActive()) { |
131 | 0 | groupPrincipals.add(groupMembershipInfo); |
132 | |
} |
133 | |
} else { |
134 | 0 | groupPrincipals.add(groupMembershipInfo); |
135 | |
} |
136 | |
} |
137 | |
} |
138 | 0 | return groupPrincipals; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public List<GroupMembershipInfo> getGroupMembers(Collection<String> groupIds) { |
146 | 0 | List<String> groupIdValues = new ArrayList<String>(); |
147 | 0 | List<GroupMembershipInfo> groupMembers = new ArrayList<GroupMembershipInfo>(); |
148 | 0 | if (groupIds != null) { |
149 | 0 | groupIdValues = new ArrayList<String>(groupIds); |
150 | |
|
151 | 0 | if (groupIdValues != null |
152 | |
&& groupIdValues.size() > 0) { |
153 | 0 | Collection<GroupMembershipInfo> groupMembershipInfos = KIMServiceLocator.getGroupService().getGroupMembers(groupIdValues); |
154 | 0 | if (groupMembershipInfos != null) { |
155 | 0 | groupMembers = new ArrayList<GroupMembershipInfo>(groupMembershipInfos); |
156 | |
} |
157 | |
|
158 | |
|
159 | |
|
160 | |
} |
161 | |
} |
162 | 0 | return groupMembers; |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
@SuppressWarnings("unchecked") |
170 | |
public List<RoleMemberImpl> getRoleGroupsForGroupIdsAndRoleIds( Collection<String> roleIds, Collection<String> groupIds, AttributeSet qualification ) { |
171 | 0 | Criteria c = new Criteria(); |
172 | 0 | if(roleIds!=null && !roleIds.isEmpty()) |
173 | 0 | c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds); |
174 | 0 | if(groupIds!=null && !groupIds.isEmpty()) |
175 | 0 | c.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds); |
176 | 0 | c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE ); |
177 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
178 | |
|
179 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
180 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
181 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
182 | 0 | for ( RoleMemberImpl rm : coll ) { |
183 | 0 | if ( rm.isActive() ) { |
184 | 0 | results.add(rm); |
185 | |
} |
186 | |
} |
187 | 0 | return results; |
188 | |
} |
189 | |
|
190 | |
@SuppressWarnings("unchecked") |
191 | |
public Map<String,KimDelegationImpl> getDelegationImplMapFromRoleIds(Collection<String> roleIds) { |
192 | 0 | HashMap<String,KimDelegationImpl> results = new HashMap<String, KimDelegationImpl>(); |
193 | 0 | if ( roleIds != null && !roleIds.isEmpty() ) { |
194 | 0 | Criteria c = new Criteria(); |
195 | 0 | c.addIn(KIMPropertyConstants.Delegation.ROLE_ID, roleIds); |
196 | 0 | c.addEqualTo(KIMPropertyConstants.Delegation.ACTIVE, Boolean.TRUE); |
197 | 0 | Query query = QueryFactory.newQuery(KimDelegationImpl.class, c); |
198 | 0 | Collection<KimDelegationImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
199 | 0 | for ( KimDelegationImpl dele : coll ) { |
200 | 0 | results.put( dele.getDelegationId(), dele); |
201 | |
} |
202 | |
} |
203 | 0 | return results; |
204 | |
} |
205 | |
|
206 | |
@SuppressWarnings("unchecked") |
207 | |
public List<KimDelegationImpl> getDelegationImplsForRoleIds(Collection<String> roleIds) { |
208 | 0 | List<KimDelegationImpl> results = new ArrayList<KimDelegationImpl>(); |
209 | 0 | if ( roleIds != null && !roleIds.isEmpty() ) { |
210 | 0 | Criteria c = new Criteria(); |
211 | 0 | c.addIn(KIMPropertyConstants.Delegation.ROLE_ID, roleIds); |
212 | 0 | c.addEqualTo(KIMPropertyConstants.Delegation.ACTIVE, Boolean.TRUE); |
213 | 0 | Query query = QueryFactory.newQuery(KimDelegationImpl.class, c); |
214 | 0 | Collection<KimDelegationImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
215 | 0 | for ( KimDelegationImpl dele : coll ) { |
216 | 0 | results.add(dele); |
217 | |
} |
218 | |
} |
219 | 0 | return results; |
220 | |
} |
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
@SuppressWarnings("unchecked") |
229 | |
public List<KimDelegationMemberImpl> getDelegationPrincipalsForPrincipalIdAndDelegationIds( |
230 | |
Collection<String> delegationIds, String principalId) { |
231 | 0 | Criteria c = new Criteria(); |
232 | |
|
233 | 0 | if(principalId!=null) |
234 | 0 | c.addEqualTo(KIMPropertyConstants.DelegationMember.MEMBER_ID, principalId); |
235 | 0 | c.addEqualTo( KIMPropertyConstants.DelegationMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE ); |
236 | 0 | if(delegationIds!=null && !delegationIds.isEmpty()) |
237 | 0 | c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds); |
238 | 0 | Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c); |
239 | 0 | Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
240 | 0 | ArrayList<KimDelegationMemberImpl> results = new ArrayList<KimDelegationMemberImpl>( coll.size() ); |
241 | 0 | for ( KimDelegationMemberImpl rm : coll ) { |
242 | 0 | if ( rm.isActive() ) { |
243 | 0 | results.add(rm); |
244 | |
} |
245 | |
} |
246 | 0 | return results; |
247 | |
} |
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
@SuppressWarnings("unchecked") |
256 | |
public List<KimDelegationMemberImpl> getDelegationGroupsForGroupIdsAndDelegationIds( |
257 | |
Collection<String> delegationIds, List<String> groupIds) { |
258 | 0 | Criteria c = new Criteria(); |
259 | 0 | if(delegationIds!=null && !delegationIds.isEmpty()) |
260 | 0 | c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds); |
261 | 0 | if(groupIds!=null && !groupIds.isEmpty()) |
262 | 0 | c.addIn(KIMPropertyConstants.DelegationMember.MEMBER_ID, groupIds); |
263 | 0 | c.addEqualTo( KIMPropertyConstants.DelegationMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE ); |
264 | 0 | Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c); |
265 | 0 | Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
266 | 0 | ArrayList<KimDelegationMemberImpl> results = new ArrayList<KimDelegationMemberImpl>( coll.size() ); |
267 | 0 | for ( KimDelegationMemberImpl rm : coll ) { |
268 | 0 | if ( rm.isActive() ) { |
269 | 0 | results.add(rm); |
270 | |
} |
271 | |
} |
272 | 0 | return results; |
273 | |
} |
274 | |
|
275 | |
|
276 | |
|
277 | |
|
278 | |
@SuppressWarnings("unchecked") |
279 | |
public List<RoleMemberImpl> getRoleMembersForRoleIds( Collection<String> roleIds, String memberTypeCode, AttributeSet qualification ) { |
280 | 0 | Criteria c = new Criteria(); |
281 | |
|
282 | 0 | if(roleIds!=null && !roleIds.isEmpty()) |
283 | 0 | c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds); |
284 | 0 | if ( memberTypeCode != null ) { |
285 | 0 | c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, memberTypeCode ); |
286 | |
} |
287 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
288 | |
|
289 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
290 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
291 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
292 | 0 | for ( RoleMemberImpl rm : coll ) { |
293 | 0 | if ( rm.isActive() ) { |
294 | 0 | results.add(rm); |
295 | |
} |
296 | |
} |
297 | 0 | return results; |
298 | |
} |
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
@SuppressWarnings("unchecked") |
304 | |
public List<RoleMemberImpl> getRoleMembershipsForRoleIdsAsMembers( Collection<String> roleIds, AttributeSet qualification) { |
305 | 0 | Criteria c = new Criteria(); |
306 | |
|
307 | 0 | if(roleIds!=null && !roleIds.isEmpty()) |
308 | 0 | c.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, roleIds); |
309 | 0 | c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE); |
310 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
311 | |
|
312 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
313 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
314 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
315 | 0 | for ( RoleMemberImpl rm : coll ) { |
316 | 0 | if ( rm.isActive() ) { |
317 | 0 | results.add(rm); |
318 | |
} |
319 | |
} |
320 | 0 | return results; |
321 | |
} |
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
@SuppressWarnings("unchecked") |
327 | |
public List<RoleMemberImpl> getRoleMembershipsForMemberId(String memberType, String memberId, AttributeSet qualification) { |
328 | 0 | Criteria c = new Criteria(); |
329 | 0 | List<RoleMemberImpl> parentRoleMembers = new ArrayList<RoleMemberImpl>(); |
330 | |
|
331 | 0 | if(StringUtils.isEmpty(memberId) |
332 | |
|| StringUtils.isEmpty(memberType)) { |
333 | 0 | return parentRoleMembers; |
334 | |
} |
335 | |
|
336 | 0 | c.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, memberId); |
337 | 0 | c.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, memberType); |
338 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
339 | |
|
340 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
341 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
342 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
343 | 0 | for ( RoleMemberImpl rm : coll ) { |
344 | 0 | if ( rm.isActive() ) { |
345 | 0 | results.add(rm); |
346 | |
} |
347 | |
} |
348 | 0 | return results; |
349 | |
} |
350 | |
|
351 | |
@SuppressWarnings("unchecked") |
352 | |
public List<RoleMemberImpl> getRoleMembersForRoleIdsWithFilters( Collection<String> roleIds, String principalId, List<String> groupIds, AttributeSet qualification) { |
353 | 0 | Criteria c = new Criteria(); |
354 | |
|
355 | 0 | if(roleIds!=null && !roleIds.isEmpty()) |
356 | 0 | c.addIn(KIMPropertyConstants.RoleMember.ROLE_ID, roleIds); |
357 | 0 | Criteria orSet = new Criteria(); |
358 | 0 | orSet.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.ROLE_MEMBER_TYPE ); |
359 | 0 | Criteria principalCheck = new Criteria(); |
360 | 0 | if(principalId!=null) |
361 | 0 | principalCheck.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_ID, principalId); |
362 | 0 | principalCheck.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE ); |
363 | 0 | orSet.addOrCriteria( principalCheck ); |
364 | 0 | Criteria groupCheck = new Criteria(); |
365 | 0 | if(groupIds!=null && !groupIds.isEmpty()) |
366 | 0 | groupCheck.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds); |
367 | 0 | groupCheck.addEqualTo( KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE ); |
368 | 0 | orSet.addOrCriteria( groupCheck ); |
369 | 0 | c.addAndCriteria( orSet ); |
370 | 0 | addSubCriteriaBasedOnRoleQualification(c, qualification); |
371 | |
|
372 | 0 | Query query = QueryFactory.newQuery(RoleMemberImpl.class, c); |
373 | 0 | Collection<RoleMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
374 | 0 | ArrayList<RoleMemberImpl> results = new ArrayList<RoleMemberImpl>( coll.size() ); |
375 | 0 | for ( RoleMemberImpl rm : coll ) { |
376 | 0 | if ( rm.isActive() ) { |
377 | 0 | results.add(rm); |
378 | |
} |
379 | |
} |
380 | 0 | return results; |
381 | |
} |
382 | |
|
383 | |
|
384 | |
|
385 | |
|
386 | |
@SuppressWarnings("unchecked") |
387 | |
public Map<String,List<KimDelegationMemberImpl>> getDelegationMembersForDelegationIds( |
388 | |
List<String> delegationIds) { |
389 | 0 | Criteria c = new Criteria(); |
390 | 0 | if(delegationIds!=null && !delegationIds.isEmpty()) |
391 | 0 | c.addIn(KIMPropertyConstants.DelegationMember.DELEGATION_ID, delegationIds); |
392 | 0 | Query query = QueryFactory.newQuery(KimDelegationMemberImpl.class, c); |
393 | 0 | Collection<KimDelegationMemberImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
394 | 0 | HashMap<String,List<KimDelegationMemberImpl>> result = new HashMap<String,List<KimDelegationMemberImpl>>(); |
395 | 0 | for ( KimDelegationMemberImpl dp : coll ) { |
396 | 0 | if ( dp.isActive() ) { |
397 | 0 | if ( !result.containsKey( dp.getDelegationId() ) ) { |
398 | 0 | result.put( dp.getDelegationId(), new ArrayList<KimDelegationMemberImpl>() ); |
399 | |
} |
400 | 0 | result.get( dp.getDelegationId() ).add( dp ); |
401 | |
} |
402 | |
} |
403 | 0 | return result; |
404 | |
} |
405 | |
|
406 | |
public List<RoleImpl> getRoles(Map<String,String> fieldValues) { |
407 | 0 | Criteria crit = new Criteria(); |
408 | 0 | Map<String,Map<String,String>> critMap = setupCritMaps(fieldValues); |
409 | |
|
410 | |
|
411 | |
|
412 | 0 | Map<String,String> lookupNames = critMap.get("lookupNames"); |
413 | 0 | for (Entry<String, String> entry : lookupNames.entrySet()) { |
414 | 0 | if (StringUtils.isNotBlank(entry.getValue())) { |
415 | 0 | if (!entry.getKey().equals(KIMPropertyConstants.Principal.PRINCIPAL_NAME)) { |
416 | 0 | addLikeToCriteria(crit, entry.getKey(), entry.getValue()); |
417 | |
} else { |
418 | 0 | List roleIds = getRoleIdsForPrincipalName(entry.getValue()); |
419 | 0 | if (roleIds!=null && !roleIds.isEmpty()) { |
420 | 0 | crit.addIn(KIMPropertyConstants.Role.ROLE_ID, roleIds); |
421 | |
} else { |
422 | |
|
423 | 0 | roleIds.add("NOTFOUND"); |
424 | 0 | crit.addIn(KIMPropertyConstants.Role.ROLE_ID, roleIds); |
425 | |
} |
426 | 0 | } |
427 | |
} |
428 | |
} |
429 | 0 | if (!critMap.get("attr").isEmpty()) { |
430 | 0 | String kimTypeId=null; |
431 | 0 | for (Map.Entry<String,String> entry : fieldValues.entrySet()) { |
432 | 0 | if (entry.getKey().equals("kimTypeId")) { |
433 | 0 | kimTypeId=entry.getValue(); |
434 | 0 | break; |
435 | |
} |
436 | |
} |
437 | 0 | setupAttrCriteria(crit, critMap.get("attr"),kimTypeId); |
438 | |
} |
439 | 0 | if (!critMap.get("perm").isEmpty()) { |
440 | 0 | crit.addExists(setupPermCriteria(critMap.get("perm"))); |
441 | |
} |
442 | 0 | if (!critMap.get("resp").isEmpty()) { |
443 | 0 | crit.addExists(setupRespCriteria(critMap.get("resp"))); |
444 | |
} |
445 | 0 | if (!critMap.get("group").isEmpty()) { |
446 | 0 | crit.addExists(setupGroupCriteria(critMap.get("group"))); |
447 | |
} |
448 | |
|
449 | 0 | Query q = QueryFactory.newQuery(RoleImpl.class, crit); |
450 | |
|
451 | 0 | return (List)getPersistenceBrokerTemplate().getCollectionByQuery(q); |
452 | |
} |
453 | |
|
454 | |
|
455 | |
private List<String> getPrincipalIdsForPrincipalName(String principalName){ |
456 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
457 | 0 | criteria.put("principals.principalName", principalName); |
458 | 0 | List<? extends KimEntityDefaultInfo> entities = KIMServiceLocator.getIdentityService().lookupEntityDefaultInfo(criteria, false); |
459 | |
|
460 | 0 | List<String> principalIds = new ArrayList<String>(); |
461 | 0 | for (KimEntityDefaultInfo entity : entities) { |
462 | 0 | for (KimPrincipal principal : entity.getPrincipals()) { |
463 | 0 | principalIds.add(principal.getPrincipalId()); |
464 | |
} |
465 | |
} |
466 | |
|
467 | 0 | return principalIds; |
468 | |
|
469 | |
} |
470 | |
|
471 | |
private List<String> getRoleIdsForPrincipalName(String value) { |
472 | 0 | String principalName = value.replace('*', '%'); |
473 | 0 | List<String> roleIds = new ArrayList<String>(); |
474 | 0 | Criteria memberSubCrit = new Criteria(); |
475 | 0 | Map<String, String> criteria = new HashMap<String, String>(); |
476 | 0 | criteria.put("principals.principalName", principalName); |
477 | 0 | List<? extends KimEntityDefaultInfo> entities = KIMServiceLocator.getIdentityService().lookupEntityDefaultInfo(criteria, false); |
478 | 0 | if (entities == null |
479 | |
|| entities.size() == 0) { |
480 | 0 | return roleIds; |
481 | |
} |
482 | |
|
483 | 0 | List<String> principalIds = new ArrayList<String>(); |
484 | 0 | for (KimEntityDefaultInfo entity : entities) { |
485 | 0 | for (KimPrincipal principal : entity.getPrincipals()) { |
486 | 0 | principalIds.add(principal.getPrincipalId()); |
487 | |
} |
488 | |
} |
489 | 0 | if(principalIds!=null && !principalIds.isEmpty()){ |
490 | 0 | memberSubCrit.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.PRINCIPAL_MEMBER_TYPE); |
491 | 0 | memberSubCrit.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, principalIds); |
492 | |
|
493 | 0 | ReportQueryByCriteria memberSubQuery = QueryFactory.newReportQuery(RoleMemberImpl.class, memberSubCrit); |
494 | 0 | for (RoleMemberImpl roleMbr : (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(memberSubQuery)) { |
495 | 0 | if (roleMbr.isActive() && !roleIds.contains(roleMbr.getRoleId())) { |
496 | 0 | roleIds.add(roleMbr.getRoleId()); |
497 | |
} |
498 | |
} |
499 | |
} |
500 | |
|
501 | 0 | List<String> groupIds = new ArrayList<String>(); |
502 | 0 | for (String principalId : principalIds) { |
503 | 0 | List<String> principalGroupIds = KIMServiceLocator.getGroupService().getGroupIdsForPrincipal(principalId); |
504 | 0 | for (String groupId : principalGroupIds) { |
505 | 0 | if (!groupIds.contains(groupId)) { |
506 | 0 | groupIds.add(groupId); |
507 | |
} |
508 | |
} |
509 | 0 | } |
510 | |
|
511 | 0 | if(groupIds!=null && !groupIds.isEmpty()){ |
512 | 0 | Criteria grpRoleCrit = new Criteria(); |
513 | 0 | grpRoleCrit.addEqualTo(KIMPropertyConstants.RoleMember.MEMBER_TYPE_CODE, Role.GROUP_MEMBER_TYPE); |
514 | 0 | grpRoleCrit.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, groupIds); |
515 | |
|
516 | 0 | ReportQueryByCriteria memberSubQuery = QueryFactory.newReportQuery(RoleMemberImpl.class, grpRoleCrit); |
517 | |
|
518 | 0 | for (RoleMemberImpl roleMbr : (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(memberSubQuery)) { |
519 | 0 | if (roleMbr.isActive() && !roleIds.contains(roleMbr.getRoleId()) ) { |
520 | 0 | roleIds.add(roleMbr.getRoleId()); |
521 | |
} |
522 | |
} |
523 | |
} |
524 | |
|
525 | 0 | return roleIds; |
526 | |
} |
527 | |
|
528 | |
private Map setupCritMaps(Map<String,String> fieldValues) { |
529 | 0 | Map <String, Map> critMap = new HashMap(); |
530 | 0 | List permFieldName = new ArrayList(); |
531 | 0 | permFieldName.add("permName"); |
532 | 0 | permFieldName.add("permNamespaceCode"); |
533 | 0 | permFieldName.add("permTmplName"); |
534 | 0 | permFieldName.add("permTmplNamespaceCode"); |
535 | 0 | List respFieldName = new ArrayList(); |
536 | 0 | respFieldName.add("respName"); |
537 | 0 | respFieldName.add("respNamespaceCode"); |
538 | 0 | respFieldName.add("respTmplName"); |
539 | 0 | respFieldName.add("respTmplNamespaceCode"); |
540 | 0 | Map<String,String> permFieldMap = new HashMap<String,String>(); |
541 | 0 | Map<String,String> respFieldMap = new HashMap<String,String>(); |
542 | 0 | Map<String,String> attrFieldMap = new HashMap<String,String>(); |
543 | 0 | Map<String,String> groupFieldMap = new HashMap<String,String>(); |
544 | 0 | Map<String,String> lookupNamesMap = new HashMap<String,String>(); |
545 | |
|
546 | 0 | for (Entry<String, String> entry : fieldValues.entrySet()) { |
547 | 0 | if (StringUtils.isNotBlank(entry.getValue())) { |
548 | 0 | String nameValue = entry.getValue().replace('*', '%'); |
549 | 0 | if (permFieldName.contains(entry.getKey())) { |
550 | 0 | permFieldMap.put(entry.getKey(), nameValue); |
551 | 0 | } else if (respFieldName.contains(entry.getKey())) { |
552 | 0 | respFieldMap.put(entry.getKey(), nameValue); |
553 | 0 | } else if (entry.getKey().startsWith(KimAttributes.GROUP_NAME)) { |
554 | 0 | groupFieldMap.put(entry.getKey(), nameValue); |
555 | 0 | } else if (entry.getKey().contains(".")) { |
556 | 0 | attrFieldMap.put(entry.getKey(), nameValue); |
557 | |
} else { |
558 | 0 | lookupNamesMap.put(entry.getKey(), nameValue); |
559 | |
} |
560 | 0 | } |
561 | |
} |
562 | |
|
563 | 0 | critMap.put("perm", permFieldMap); |
564 | 0 | critMap.put("resp", respFieldMap); |
565 | 0 | critMap.put("group", groupFieldMap); |
566 | 0 | critMap.put("attr", attrFieldMap); |
567 | 0 | critMap.put("lookupNames", lookupNamesMap); |
568 | 0 | return critMap; |
569 | |
} |
570 | |
|
571 | |
|
572 | |
private void setupAttrCriteria(Criteria crit, Map<String,String> attrCrit, String kimTypeId) { |
573 | 0 | for (Entry<String, String> entry : attrCrit.entrySet()) { |
574 | 0 | Criteria subCrit = new Criteria(); |
575 | 0 | addLikeToCriteria(subCrit, "attributes.attributeValue",entry.getValue()); |
576 | 0 | addEqualToCriteria(subCrit, "attributes.kimAttributeId",entry.getKey().substring(entry.getKey().indexOf(".")+1, entry.getKey().length())); |
577 | 0 | addEqualToCriteria(subCrit, "attributes.kimTypeId", kimTypeId); |
578 | 0 | subCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId"); |
579 | 0 | crit.addExists(QueryFactory.newReportQuery(RoleMemberImpl.class, subCrit)); |
580 | 0 | } |
581 | 0 | } |
582 | |
|
583 | |
private ReportQueryByCriteria setupPermCriteria(Map<String,String> permCrit) { |
584 | |
|
585 | 0 | Map<String,String> searchCrit = new HashMap<String, String>(); |
586 | |
|
587 | 0 | for (Entry<String, String> entry : permCrit.entrySet()) { |
588 | 0 | if (entry.getKey().equals("permTmplName") || entry.getKey().equals("permTmplNamespaceCode")) { |
589 | 0 | if (entry.getKey().equals("permTmplName")) { |
590 | 0 | searchCrit.put("template." + KimConstants.UniqueKeyConstants.PERMISSION_TEMPLATE_NAME,entry.getValue()); |
591 | |
|
592 | |
} else { |
593 | 0 | searchCrit.put("template." + KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue()); |
594 | |
} |
595 | |
} |
596 | |
|
597 | 0 | if (entry.getKey().equals("permName") || entry.getKey().equals("permNamespaceCode")) { |
598 | 0 | if (entry.getKey().equals("permName")) { |
599 | 0 | searchCrit.put(KimConstants.UniqueKeyConstants.PERMISSION_NAME, entry.getValue()); |
600 | |
} else { |
601 | 0 | searchCrit.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue()); |
602 | |
|
603 | |
} |
604 | |
} |
605 | |
} |
606 | |
|
607 | 0 | List<KimPermissionInfo> permList = KIMServiceLocator.getPermissionService().lookupPermissions(searchCrit, true); |
608 | 0 | List<String> roleIds = null; |
609 | |
|
610 | 0 | if(permList != null && !permList.isEmpty()){ |
611 | 0 | roleIds = KIMServiceLocator.getPermissionService().getRoleIdsForPermissions(permList); |
612 | |
} |
613 | |
|
614 | 0 | if(roleIds == null || roleIds.isEmpty()){ |
615 | 0 | roleIds = new ArrayList<String>(); |
616 | 0 | roleIds.add("-1"); |
617 | |
} |
618 | |
|
619 | 0 | Criteria memberSubCrit = new Criteria(); |
620 | 0 | memberSubCrit.addIn("roleId", roleIds); |
621 | 0 | memberSubCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId"); |
622 | 0 | return QueryFactory.newReportQuery(RoleImpl.class, memberSubCrit); |
623 | |
|
624 | |
} |
625 | |
|
626 | |
private ReportQueryByCriteria setupRespCriteria(Map<String,String> respCrit) { |
627 | |
|
628 | |
try{ |
629 | |
|
630 | |
}catch(Exception ex){ |
631 | |
ex.printStackTrace(); |
632 | 0 | } |
633 | 0 | Map<String,String> searchCrit = new HashMap<String, String>(); |
634 | |
|
635 | 0 | for (Entry<String, String> entry : respCrit.entrySet()) { |
636 | 0 | if (entry.getKey().equals("respTmplName") || entry.getKey().equals("respTmplNamespaceCode")) { |
637 | 0 | if (entry.getKey().equals("respTmplName")) { |
638 | 0 | searchCrit.put("template." + KimConstants.UniqueKeyConstants.RESPONSIBILITY_TEMPLATE_NAME,entry.getValue()); |
639 | |
|
640 | |
} else { |
641 | 0 | searchCrit.put("template." + KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue()); |
642 | |
} |
643 | |
} |
644 | |
|
645 | 0 | if (entry.getKey().equals("respName") || entry.getKey().equals("respNamespaceCode")) { |
646 | 0 | if (entry.getKey().equals("respName")) { |
647 | 0 | searchCrit.put(KimConstants.UniqueKeyConstants.RESPONSIBILITY_NAME, entry.getValue()); |
648 | |
} else { |
649 | 0 | searchCrit.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE,entry.getValue()); |
650 | |
|
651 | |
} |
652 | |
} |
653 | |
} |
654 | |
|
655 | 0 | List<? extends KimResponsibilityInfo> kriList = KIMServiceLocator.getResponsibilityService().lookupResponsibilityInfo(searchCrit, true); |
656 | 0 | List<String> roleIds = new ArrayList<String>(); |
657 | |
|
658 | 0 | for(KimResponsibilityInfo kri : kriList){ |
659 | 0 | roleIds.addAll(KIMServiceLocator.getResponsibilityService().getRoleIdsForResponsibility(kri, null)); |
660 | |
} |
661 | |
|
662 | 0 | if(roleIds == null || roleIds.isEmpty()){ |
663 | 0 | roleIds = new ArrayList<String>(); |
664 | 0 | roleIds.add("-1"); |
665 | |
} |
666 | |
|
667 | 0 | Criteria memberSubCrit = new Criteria(); |
668 | 0 | memberSubCrit.addIn("roleId", roleIds); |
669 | 0 | memberSubCrit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId"); |
670 | 0 | return QueryFactory.newReportQuery(RoleImpl.class, memberSubCrit); |
671 | |
|
672 | |
} |
673 | |
|
674 | |
private ReportQueryByCriteria setupGroupCriteria(Map<String,String> groupCrit) { |
675 | |
|
676 | 0 | Map<String,String> searchCrit = new HashMap<String, String>(); |
677 | 0 | for (Entry<String, String> entry : groupCrit.entrySet()) { |
678 | 0 | if (entry.getKey().equals(KimAttributes.GROUP_NAME)) { |
679 | 0 | searchCrit.put(entry.getKey(), entry.getValue()); |
680 | |
} else { |
681 | 0 | searchCrit.put(KimAttributes.NAMESPACE_CODE, entry.getValue()); |
682 | |
} |
683 | |
} |
684 | |
|
685 | 0 | Criteria crit = new Criteria(); |
686 | |
|
687 | 0 | List<String> groupIds = KIMServiceLocator.getGroupService().lookupGroupIds(searchCrit); |
688 | |
|
689 | 0 | if(groupIds == null || groupIds.isEmpty()){ |
690 | 0 | groupIds = new ArrayList<String>(); |
691 | 0 | groupIds.add("-1"); |
692 | |
} |
693 | 0 | crit.addIn("memberId", groupIds); |
694 | 0 | crit.addEqualToField("roleId", Criteria.PARENT_QUERY_PREFIX + "roleId"); |
695 | |
|
696 | 0 | return QueryFactory.newReportQuery(RoleMemberImpl.class, crit); |
697 | |
|
698 | |
} |
699 | |
|
700 | |
private void addLikeToCriteria(Criteria criteria, String propertyName, String propertyValue){ |
701 | 0 | String[] keyValues = getCaseInsensitiveValues(propertyName, propertyValue); |
702 | 0 | criteria.addLike(keyValues[0], keyValues[1]); |
703 | 0 | } |
704 | |
|
705 | |
private void addEqualToCriteria(Criteria criteria, String propertyName, String propertyValue){ |
706 | 0 | String[] keyValues = getCaseInsensitiveValues(propertyName, propertyValue); |
707 | 0 | criteria.addEqualTo(keyValues[0], keyValues[1]); |
708 | 0 | } |
709 | |
|
710 | |
private String[] getCaseInsensitiveValues(String propertyName, String propertyValue){ |
711 | 0 | String[] keyValues = new String[2]; |
712 | 0 | keyValues[0] = propertyName==null?"":getDbPlatform().getUpperCaseFunction() + "(" + propertyName + ")"; |
713 | 0 | keyValues[1] = propertyValue==null?"":propertyValue.toUpperCase(); |
714 | 0 | return keyValues; |
715 | |
} |
716 | |
|
717 | |
@SuppressWarnings("unchecked") |
718 | |
protected List<RoleMemberImpl> getRoleMemberImpls(Map<String, String> fieldValues){ |
719 | 0 | Criteria queryCriteria = new Criteria(); |
720 | 0 | List<String> memberIds = new ArrayList<String>(); |
721 | 0 | if(hasExtraRoleMemberCriteria(fieldValues)){ |
722 | 0 | String memberName = fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAME); |
723 | 0 | String memberNamespaceCode = fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAMESPACE_CODE); |
724 | |
|
725 | |
|
726 | 0 | List<RoleImpl> roles = getRoleMembersRoles(memberNamespaceCode, memberName); |
727 | 0 | if(roles!=null){ |
728 | 0 | for(RoleImpl role: roles) |
729 | 0 | memberIds.add(role.getRoleId()); |
730 | |
} |
731 | |
|
732 | 0 | memberIds.addAll(this.getPrincipalIdsForPrincipalName(memberName)); |
733 | |
|
734 | 0 | memberIds.addAll(getRoleMembersGroupIds(memberNamespaceCode, memberName)); |
735 | |
|
736 | 0 | if(memberIds!=null && !memberIds.isEmpty()) |
737 | 0 | queryCriteria.addIn(KIMPropertyConstants.RoleMember.MEMBER_ID, memberIds); |
738 | |
} |
739 | 0 | if(hasCoreRoleMemberCriteria(fieldValues)){ |
740 | 0 | String roleMemberId = fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID); |
741 | 0 | String roleId = fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_ID); |
742 | 0 | String memberId = fieldValues.get(KimConstants.PrimaryKeyConstants.MEMBER_ID); |
743 | 0 | String memberTypeCode = fieldValues.get(KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE); |
744 | 0 | String activeFromDate = fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE); |
745 | 0 | String activeToDate = fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE); |
746 | |
|
747 | 0 | if(StringUtils.isNotEmpty(roleMemberId)) |
748 | 0 | addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID, roleMemberId); |
749 | 0 | if(StringUtils.isNotEmpty(roleId)) |
750 | 0 | addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.ROLE_ID, roleId); |
751 | 0 | if(StringUtils.isNotEmpty(memberId)) |
752 | 0 | addEqualToCriteria(queryCriteria, KimConstants.PrimaryKeyConstants.MEMBER_ID, memberId); |
753 | 0 | if(StringUtils.isNotEmpty(memberTypeCode)) |
754 | 0 | addEqualToCriteria(queryCriteria, KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE, memberTypeCode); |
755 | 0 | if(StringUtils.isNotEmpty(activeFromDate)) |
756 | 0 | queryCriteria.addGreaterOrEqualThan(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE, activeFromDate); |
757 | 0 | if(StringUtils.isNotEmpty(activeToDate)) |
758 | 0 | queryCriteria.addLessOrEqualThan(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE, activeToDate); |
759 | |
} |
760 | 0 | Query q = QueryFactory.newQuery(RoleMemberImpl.class, queryCriteria); |
761 | 0 | return (List<RoleMemberImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(q); |
762 | |
} |
763 | |
|
764 | |
public List<RoleMembershipInfo> getRoleMembers(Map<String,String> fieldValues) { |
765 | 0 | List<RoleMemberImpl> roleMembers = getRoleMemberImpls(fieldValues); |
766 | 0 | List<RoleMembershipInfo> roleMemberships = new ArrayList<RoleMembershipInfo>(); |
767 | |
RoleMembershipInfo roleMembership; |
768 | 0 | for(RoleMemberImpl roleMember: roleMembers){ |
769 | 0 | roleMembership = new RoleMembershipInfo(roleMember.getRoleId(), roleMember.getRoleMemberId(), roleMember.getMemberId(), roleMember.getMemberTypeCode(), roleMember.getQualifier() ); |
770 | 0 | roleMemberships.add(roleMembership); |
771 | |
} |
772 | 0 | return roleMemberships; |
773 | |
} |
774 | |
|
775 | |
public List<RoleMemberCompleteInfo> getRoleMembersCompleteInfo(Map<String,String> fieldValues) { |
776 | 0 | List<RoleMemberImpl> roleMembers = getRoleMemberImpls(fieldValues); |
777 | 0 | List<RoleMemberCompleteInfo> roleMembersCompleteInfo = new ArrayList<RoleMemberCompleteInfo>(); |
778 | |
RoleMemberCompleteInfo roleMemberCompleteInfo; |
779 | 0 | for(RoleMemberImpl roleMember: roleMembers){ |
780 | 0 | roleMemberCompleteInfo = new RoleMemberCompleteInfo( |
781 | |
roleMember.getRoleId(), roleMember.getRoleMemberId(), roleMember.getMemberId(), |
782 | |
roleMember.getMemberTypeCode(), roleMember.getActiveFromDate(), roleMember.getActiveToDate(), |
783 | |
roleMember.getQualifier() ); |
784 | 0 | roleMembersCompleteInfo.add(roleMemberCompleteInfo); |
785 | |
} |
786 | 0 | return roleMembersCompleteInfo; |
787 | |
} |
788 | |
|
789 | |
private boolean hasCoreRoleMemberCriteria(Map<String, String> fieldValues){ |
790 | 0 | return StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_MEMBER_ID)) || |
791 | |
StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.ROLE_ID)) || |
792 | |
StringUtils.isNotEmpty(fieldValues.get(KimConstants.PrimaryKeyConstants.MEMBER_ID)) || |
793 | |
StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.MEMBER_TYPE_CODE)) || |
794 | |
StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_FROM_DATE)) || |
795 | |
StringUtils.isNotEmpty(fieldValues.get(KIMPropertyConstants.KimMember.ACTIVE_TO_DATE)); |
796 | |
} |
797 | |
|
798 | |
private boolean hasExtraRoleMemberCriteria(Map<String, String> fieldValues){ |
799 | 0 | return StringUtils.isNotEmpty(fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAME)) || |
800 | |
StringUtils.isNotEmpty(fieldValues.get(KimConstants.KimUIConstants.MEMBER_NAMESPACE_CODE)); |
801 | |
} |
802 | |
|
803 | |
@SuppressWarnings("unchecked") |
804 | |
private List<RoleImpl> getRoleMembersRoles(String memberNamespaceCode, String memberName){ |
805 | 0 | Criteria queryCriteria = new Criteria(); |
806 | 0 | addEqualToCriteria(queryCriteria, KimConstants.UniqueKeyConstants.NAMESPACE_CODE, memberNamespaceCode); |
807 | 0 | addEqualToCriteria(queryCriteria, KimConstants.UniqueKeyConstants.ROLE_NAME, memberName); |
808 | 0 | Query q = QueryFactory.newQuery(RoleImpl.class, queryCriteria); |
809 | 0 | return (List<RoleImpl>)getPersistenceBrokerTemplate().getCollectionByQuery(q); |
810 | |
} |
811 | |
|
812 | |
private List<String> getRoleMembersGroupIds(String memberNamespaceCode, String memberName){ |
813 | |
|
814 | 0 | Map<String,String> searchCrit = new HashMap<String, String>(); |
815 | 0 | searchCrit.put(KimAttributes.GROUP_NAME, memberName); |
816 | 0 | searchCrit.put(KimAttributes.NAMESPACE_CODE, memberNamespaceCode); |
817 | |
|
818 | 0 | return KIMServiceLocator.getGroupService().lookupGroupIds(searchCrit); |
819 | |
} |
820 | |
} |