View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.impl.responsibility;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.commons.lang.exception.ExceptionUtils;
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  import org.kuali.rice.core.api.criteria.CriteriaLookupService;
23  import org.kuali.rice.core.api.criteria.GenericQueryResults;
24  import org.kuali.rice.core.api.criteria.LookupCustomizer;
25  import org.kuali.rice.core.api.criteria.Predicate;
26  import org.kuali.rice.core.api.criteria.QueryByCriteria;
27  import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
28  import org.kuali.rice.core.api.exception.RiceIllegalStateException;
29  import org.kuali.rice.core.api.membership.MemberType;
30  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
31  import org.kuali.rice.kim.api.common.delegate.DelegateType;
32  import org.kuali.rice.kim.api.common.template.Template;
33  import org.kuali.rice.kim.api.common.template.TemplateQueryResults;
34  import org.kuali.rice.kim.api.responsibility.Responsibility;
35  import org.kuali.rice.kim.api.responsibility.ResponsibilityAction;
36  import org.kuali.rice.kim.api.responsibility.ResponsibilityQueryResults;
37  import org.kuali.rice.kim.api.responsibility.ResponsibilityService;
38  import org.kuali.rice.kim.api.role.RoleMembership;
39  import org.kuali.rice.kim.api.role.RoleResponsibilityAction;
40  import org.kuali.rice.kim.api.role.RoleService;
41  import org.kuali.rice.kim.api.type.KimType;
42  import org.kuali.rice.kim.api.type.KimTypeInfoService;
43  import org.kuali.rice.kim.framework.responsibility.ResponsibilityTypeService;
44  import org.kuali.rice.kim.impl.KIMPropertyConstants;
45  import org.kuali.rice.kim.impl.common.attribute.AttributeTransform;
46  import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo;
47  import org.kuali.rice.kim.impl.role.RoleResponsibilityActionBo;
48  import org.kuali.rice.kim.impl.role.RoleResponsibilityBo;
49  import org.kuali.rice.krad.service.BusinessObjectService;
50  
51  import java.util.ArrayList;
52  import java.util.Collection;
53  import java.util.Collections;
54  import java.util.HashMap;
55  import java.util.Iterator;
56  import java.util.List;
57  import java.util.Map;
58  
59  import static org.kuali.rice.core.api.criteria.PredicateFactory.*;
60  
61  public class ResponsibilityServiceImpl implements ResponsibilityService {
62  
63      private static final Integer DEFAULT_PRIORITY_NUMBER = Integer.valueOf(1);
64      private static final Log LOG = LogFactory.getLog(ResponsibilityServiceImpl.class);
65  
66      private BusinessObjectService businessObjectService;
67      private CriteriaLookupService criteriaLookupService;
68      private ResponsibilityTypeService defaultResponsibilityTypeService;
69      private KimTypeInfoService kimTypeInfoService;
70      private RoleService roleService;
71  
72      @Override
73      public Responsibility createResponsibility(final Responsibility responsibility)
74              throws RiceIllegalArgumentException, RiceIllegalStateException {
75          incomingParamCheck(responsibility, "responsibility");
76  
77          if (StringUtils.isNotBlank(responsibility.getId()) && getResponsibility(responsibility.getId()) != null) {
78              throw new RiceIllegalStateException("the responsibility to create already exists: " + responsibility);
79          }
80          List<ResponsibilityAttributeBo> attrBos = Collections.emptyList();
81          if (responsibility.getTemplate() != null) {
82              attrBos = KimAttributeDataBo.createFrom(ResponsibilityAttributeBo.class, responsibility.getAttributes(), responsibility.getTemplate().getKimTypeId());
83          }
84          ResponsibilityBo bo = ResponsibilityBo.from(responsibility);
85          bo.setAttributeDetails(attrBos);
86          return ResponsibilityBo.to(businessObjectService.save(bo));
87      }
88  
89      @Override
90      public Responsibility updateResponsibility(final Responsibility responsibility)
91              throws RiceIllegalArgumentException, RiceIllegalStateException {
92          incomingParamCheck(responsibility, "responsibility");
93  
94          if (StringUtils.isBlank(responsibility.getId()) || getResponsibility(responsibility.getId()) == null) {
95              throw new RiceIllegalStateException("the responsibility does not exist: " + responsibility);
96          }
97  
98         List<ResponsibilityAttributeBo> attrBos = Collections.emptyList();
99          if (responsibility.getTemplate() != null) {
100             attrBos = KimAttributeDataBo.createFrom(ResponsibilityAttributeBo.class, responsibility.getAttributes(), responsibility.getTemplate().getKimTypeId());
101         }
102         ResponsibilityBo bo = ResponsibilityBo.from(responsibility);
103 
104         if (bo.getAttributeDetails() != null) {
105             bo.getAttributeDetails().clear();
106             bo.setAttributeDetails(attrBos);
107         }
108 
109         return ResponsibilityBo.to(businessObjectService.save(bo));
110     }
111 
112     @Override
113     public Responsibility getResponsibility(final String id) throws RiceIllegalArgumentException {
114         incomingParamCheck(id, "id");
115 
116         return ResponsibilityBo.to(businessObjectService.findBySinglePrimaryKey(ResponsibilityBo.class, id));
117     }
118 
119     @Override
120     public Responsibility findRespByNamespaceCodeAndName(final String namespaceCode, final String name)
121             throws RiceIllegalArgumentException {
122         incomingParamCheck(namespaceCode, "namespaceCode");
123         incomingParamCheck(name, "name");
124 
125         final Map<String, String> crit = new HashMap<String, String>();
126         crit.put("namespaceCode", namespaceCode);
127         crit.put("name", name);
128         crit.put("active", "Y");
129 
130         final Collection<ResponsibilityBo> bos = businessObjectService.findMatching(ResponsibilityBo.class, Collections.unmodifiableMap(crit));
131 
132         if (bos != null) {
133             if (bos.size() > 1) {
134                 throw new RiceIllegalStateException("more than one Responsibility found with namespace code: " + namespaceCode + " and name: " + name);
135             }
136 
137             final Iterator<ResponsibilityBo> i = bos.iterator();
138             return i.hasNext() ? ResponsibilityBo.to(i.next()) : null;
139         }
140         return null;
141     }
142 
143     @Override
144     public Template getResponsibilityTemplate(final String id) throws RiceIllegalArgumentException {
145         incomingParamCheck(id, "id");
146 
147         return ResponsibilityTemplateBo.to(businessObjectService.findBySinglePrimaryKey(ResponsibilityTemplateBo.class, id));
148     }
149 
150     @Override
151     public Template findRespTemplateByNamespaceCodeAndName(final String namespaceCode, final String name) throws RiceIllegalArgumentException {
152         incomingParamCheck(namespaceCode, "namespaceCode");
153         incomingParamCheck(name, "name");
154 
155         final Map<String, String> crit = new HashMap<String, String>();
156         crit.put("namespaceCode", namespaceCode);
157         crit.put("name", name);
158         crit.put("active", "Y");
159 
160         final Collection<ResponsibilityTemplateBo> bos = businessObjectService.findMatching(ResponsibilityTemplateBo.class, Collections.unmodifiableMap(crit));
161         if (bos != null) {
162             if (bos.size() > 1) {
163                 throw new RiceIllegalStateException("more than one Responsibility Template found with namespace code: " + namespaceCode + " and name: " + name);
164             }
165 
166             final Iterator<ResponsibilityTemplateBo> i = bos.iterator();
167             return i.hasNext() ? ResponsibilityTemplateBo.to(i.next()) : null;
168         }
169         return null;
170     }
171 
172     @Override
173     public boolean hasResponsibility(final String principalId, final String namespaceCode,
174             final String respName, final Map<String, String> qualification) throws RiceIllegalArgumentException {
175         incomingParamCheck(principalId, "principalId");
176         incomingParamCheck(namespaceCode, "namespaceCode");
177         incomingParamCheck(respName, "respName");
178         incomingParamCheck(qualification, "qualification");
179 
180         // get all the responsibility objects whose name match that requested
181         final List<Responsibility> responsibilities = Collections.singletonList(findRespByNamespaceCodeAndName(namespaceCode, respName));
182         return hasResp(principalId, namespaceCode, responsibilities, qualification, null);
183     }
184 
185     @Override
186     public boolean hasResponsibilityByTemplate(final String principalId, final String namespaceCode,
187             final String respTemplateName, final Map<String, String> qualification,
188             final Map<String, String> responsibilityDetails) throws RiceIllegalArgumentException {
189         incomingParamCheck(principalId, "principalId");
190         incomingParamCheck(namespaceCode, "namespaceCode");
191         incomingParamCheck(respTemplateName, "respTemplateName");
192         incomingParamCheck(qualification, "qualification");
193         incomingParamCheck(responsibilityDetails, "responsibilityDetails");
194 
195 
196         // get all the responsibility objects whose name match that requested
197         final List<Responsibility> responsibilities = findRespsByTemplate(namespaceCode, respTemplateName);
198         return hasResp(principalId, namespaceCode, responsibilities, qualification, responsibilityDetails);
199     }
200 
201     private boolean hasResp(final String principalId, final String namespaceCode,
202             final List<Responsibility> responsibilities,
203             final Map<String, String> qualification,
204             final Map<String, String> responsibilityDetails) throws RiceIllegalArgumentException {
205         // now, filter the full list by the detail passed
206         final List<String> ids = new ArrayList<String>();
207         for (Responsibility r : getMatchingResponsibilities(responsibilities, responsibilityDetails)) {
208             ids.add(r.getId());
209         }
210         final List<String> roleIds = getRoleIdsForResponsibilities(ids);
211         return roleService.principalHasRole(principalId, roleIds, qualification);
212     }
213 
214     @Override
215     public List<ResponsibilityAction> getResponsibilityActions(final String namespaceCode,
216             final String responsibilityName, final Map<String, String> qualification) throws RiceIllegalArgumentException {
217         incomingParamCheck(namespaceCode, "namespaceCode");
218         incomingParamCheck(responsibilityName, "responsibilityName");
219         incomingParamCheck(qualification, "qualification");
220         
221         if ( LOG.isDebugEnabled() ) {
222             logResponsibilityCheck( namespaceCode, responsibilityName, qualification, Collections.<String, String>emptyMap() );
223         }
224 
225         // get all the responsibility objects whose name match that requested
226         List<Responsibility> responsibilities = Collections.singletonList(findRespByNamespaceCodeAndName(namespaceCode, responsibilityName));
227         return getRespActions(namespaceCode, responsibilities, qualification, null);
228     }
229 
230     @Override
231     public List<ResponsibilityAction> getResponsibilityActionsByTemplate(final String namespaceCode,
232             final String respTemplateName, final Map<String, String> qualification,
233             final Map<String, String> responsibilityDetails) throws RiceIllegalArgumentException {
234         incomingParamCheck(namespaceCode, "namespaceCode");
235         incomingParamCheck(respTemplateName, "respTemplateName");
236         incomingParamCheck(qualification, "qualification");
237         
238         if ( LOG.isDebugEnabled() ) {
239             logResponsibilityCheck( namespaceCode, respTemplateName, qualification, responsibilityDetails );
240         }
241 
242         // get all the responsibility objects whose name match that requested
243         List<Responsibility> responsibilities = findRespsByTemplate(namespaceCode, respTemplateName);
244         return getRespActions(namespaceCode, responsibilities, qualification, responsibilityDetails);
245     }
246 
247     private List<ResponsibilityAction> getRespActions(final String namespaceCode,
248             final List<Responsibility> responsibilities,
249             final Map<String, String> qualification,
250             final Map<String, String> responsibilityDetails) {
251         // now, filter the full list by the detail passed
252         List<Responsibility> applicableResponsibilities = getMatchingResponsibilities(responsibilities, responsibilityDetails);
253         List<ResponsibilityAction> results = new ArrayList<ResponsibilityAction>();
254         for (Responsibility r : applicableResponsibilities) {
255             List<String> roleIds = getRoleIdsForResponsibility(r.getId());
256             results.addAll(getActionsForResponsibilityRoles(r, roleIds, qualification));
257         }
258         if ( LOG.isDebugEnabled() ) {
259             LOG.debug("Found " + results.size() + " matching ResponsibilityAction objects");
260             if ( LOG.isTraceEnabled() ) {
261                 LOG.trace( results );
262             }
263         }
264         return results;
265     }
266 
267     private List<ResponsibilityAction> getActionsForResponsibilityRoles(Responsibility responsibility, List<String> roleIds, Map<String, String> qualification) {
268         List<ResponsibilityAction> results = new ArrayList<ResponsibilityAction>();
269         Collection<RoleMembership> roleMembers = roleService.getRoleMembers(roleIds,qualification);
270         for (RoleMembership rm : roleMembers) {
271             // only add them to the list if the member ID has been populated
272             if (StringUtils.isNotBlank(rm.getMemberId())) {
273                 final ResponsibilityAction.Builder rai = ResponsibilityAction.Builder.create();
274                 rai.setMemberRoleId((rm.getEmbeddedRoleId() == null) ? rm.getRoleId() : rm.getEmbeddedRoleId());
275                 rai.setRoleId(rm.getRoleId());
276                 rai.setQualifier(rm.getQualifier());
277                 final List<DelegateType.Builder> bs = new ArrayList<DelegateType.Builder>();
278                 for (DelegateType d : rm.getDelegates()) {
279                     bs.add(DelegateType.Builder.create(d));
280                 }
281                 rai.setDelegates(bs);
282                 rai.setResponsibilityId(responsibility.getId());
283                 rai.setResponsibilityName(responsibility.getName());
284                 rai.setResponsibilityNamespaceCode(responsibility.getNamespaceCode());
285 
286                 if (MemberType.PRINCIPAL.equals(rm.getType())) {
287                     rai.setPrincipalId(rm.getMemberId());
288                 } else {
289                     rai.setGroupId(rm.getMemberId());
290                 }
291                 // get associated resp resolution objects
292                 RoleResponsibilityAction action = getResponsibilityAction(rm.getRoleId(), responsibility.getId(), rm.getId());
293                 if (action == null) {
294                     LOG.error("Unable to get responsibility action record for role/responsibility/roleMember: "
295                             + rm.getRoleId() + "/" + responsibility.getId() + "/" + rm.getId());
296                     LOG.error("Skipping this role member in getActionsForResponsibilityRoles()");
297                     continue;
298                 }
299                 // add the data to the ResponsibilityActionInfo objects
300                 rai.setActionTypeCode(action.getActionTypeCode());
301                 rai.setActionPolicyCode(action.getActionPolicyCode());
302                 rai.setPriorityNumber(action.getPriorityNumber() == null ? DEFAULT_PRIORITY_NUMBER : action.getPriorityNumber());
303                 rai.setForceAction(action.isForceAction());
304                 rai.setParallelRoutingGroupingCode((rm.getRoleSortingCode() == null) ? "" : rm.getRoleSortingCode());
305                 rai.setRoleResponsibilityActionId(action.getId());
306                 results.add(rai.build());
307             }
308         }
309         return Collections.unmodifiableList(results);
310     }
311 
312     private RoleResponsibilityAction getResponsibilityAction(String roleId, String responsibilityId, String roleMemberId) {
313         final Predicate p =
314                 or(
315                         and(
316                                 equal("roleResponsibility.responsibilityId", responsibilityId),
317                                 equal("roleResponsibility.roleId", roleId),
318                                 equal("roleResponsibility.active", "Y"),
319                                 or(
320                                         equal(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId),
321                                         equal(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, "*")
322                                 )
323                         ),
324                         and(
325                                 equal("roleResponsibilityId", "*"),
326                                 equal(KIMPropertyConstants.RoleMember.ROLE_MEMBER_ID, roleMemberId)
327                         )
328                 );
329 
330         final QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
331         builder.setPredicates(p);
332         final GenericQueryResults<RoleResponsibilityActionBo> results = criteriaLookupService.lookup(RoleResponsibilityActionBo.class, builder.build());
333         final List<RoleResponsibilityActionBo> bos = results.getResults();
334         //seems a little dubious that we are just returning the first result...
335         return !bos.isEmpty() ? RoleResponsibilityActionBo.to(bos.get(0)) : null;
336     }
337 
338     @Override
339     public List<String> getRoleIdsForResponsibility(String id) throws RiceIllegalArgumentException {
340         incomingParamCheck(id, "id");
341 
342         final List<String> roleIds = getRoleIdsForPredicate(and(equal("responsibilityId", id), equal("active", "Y")));
343 
344         return Collections.unmodifiableList(roleIds);
345     }
346 
347     @Override
348     public ResponsibilityQueryResults findResponsibilities(final QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException {
349         incomingParamCheck(queryByCriteria, "queryByCriteria");
350 
351         LookupCustomizer.Builder<ResponsibilityBo> lc = LookupCustomizer.Builder.create();
352         lc.setPredicateTransform(AttributeTransform.getInstance());
353 
354         GenericQueryResults<ResponsibilityBo> results = criteriaLookupService.lookup(ResponsibilityBo.class, queryByCriteria, lc.build());
355 
356         ResponsibilityQueryResults.Builder builder = ResponsibilityQueryResults.Builder.create();
357         builder.setMoreResultsAvailable(results.isMoreResultsAvailable());
358         builder.setTotalRowCount(results.getTotalRowCount());
359 
360         final List<Responsibility.Builder> ims = new ArrayList<Responsibility.Builder>();
361         for (ResponsibilityBo bo : results.getResults()) {
362             ims.add(Responsibility.Builder.create(bo));
363         }
364 
365         builder.setResults(ims);
366         return builder.build();
367     }
368 
369     @Override
370     public TemplateQueryResults findResponsibilityTemplates(final QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException {
371         incomingParamCheck(queryByCriteria, "queryByCriteria");
372 
373         GenericQueryResults<ResponsibilityTemplateBo> results = criteriaLookupService.lookup(ResponsibilityTemplateBo.class, queryByCriteria);
374 
375         TemplateQueryResults.Builder builder = TemplateQueryResults.Builder.create();
376         builder.setMoreResultsAvailable(results.isMoreResultsAvailable());
377         builder.setTotalRowCount(results.getTotalRowCount());
378 
379         final List<Template.Builder> ims = new ArrayList<Template.Builder>();
380         for (ResponsibilityTemplateBo bo : results.getResults()) {
381             ims.add(Template.Builder.create(bo));
382         }
383 
384         builder.setResults(ims);
385         return builder.build();
386     }
387 
388     /**
389      * Compare each of the passed in responsibilities with the given responsibilityDetails.  Those that
390      * match are added to the result list.
391      */
392     private List<Responsibility> getMatchingResponsibilities(List<Responsibility> responsibilities, Map<String, String> responsibilityDetails) {
393         // if no details passed, assume that all match
394         if (responsibilityDetails == null || responsibilityDetails.isEmpty()) {
395             return responsibilities;
396         }
397 
398         final List<Responsibility> applicableResponsibilities = new ArrayList<Responsibility>();
399         // otherwise, attempt to match the permission details
400         // build a map of the template IDs to the type services
401         Map<String, ResponsibilityTypeService> responsibilityTypeServices = getResponsibilityTypeServicesByTemplateId(responsibilities);
402         // build a map of permissions by template ID
403         Map<String, List<Responsibility>> responsibilityMap = groupResponsibilitiesByTemplate(responsibilities);
404         // loop over the different templates, matching all of the same template against the type
405         // service at once
406         for (Map.Entry<String, List<Responsibility>> respEntry : responsibilityMap.entrySet()) {
407             ResponsibilityTypeService responsibilityTypeService = responsibilityTypeServices.get(respEntry.getKey());
408             List<Responsibility> responsibilityInfos = respEntry.getValue();
409             if (responsibilityTypeService == null) {
410                 responsibilityTypeService = defaultResponsibilityTypeService;
411             }
412             applicableResponsibilities.addAll(responsibilityTypeService.getMatchingResponsibilities(responsibilityDetails, responsibilityInfos));
413         }
414         return Collections.unmodifiableList(applicableResponsibilities);
415     }
416 
417     private Map<String, ResponsibilityTypeService> getResponsibilityTypeServicesByTemplateId(Collection<Responsibility> responsibilities) {
418         Map<String, ResponsibilityTypeService> responsibilityTypeServices = new HashMap<String, ResponsibilityTypeService>(responsibilities.size());
419         for (Responsibility responsibility : responsibilities) {
420             final Template t = responsibility.getTemplate();
421             final KimType type = kimTypeInfoService.getKimType(t.getKimTypeId());
422 
423             final String serviceName = type.getServiceName();
424             if (serviceName != null) {
425                 ResponsibilityTypeService responsibiltyTypeService = GlobalResourceLoader.getService(serviceName);
426                 if (responsibiltyTypeService != null) {
427                     responsibilityTypeServices.put(responsibility.getTemplate().getId(), responsibiltyTypeService);
428                 } else {
429                     responsibilityTypeServices.put(responsibility.getTemplate().getId(), defaultResponsibilityTypeService);
430                 }
431             }
432         }
433         return Collections.unmodifiableMap(responsibilityTypeServices);
434     }
435 
436     private Map<String, List<Responsibility>> groupResponsibilitiesByTemplate(Collection<Responsibility> responsibilities) {
437         final Map<String, List<Responsibility>> results = new HashMap<String, List<Responsibility>>();
438         for (Responsibility responsibility : responsibilities) {
439             List<Responsibility> responsibilityInfos = results.get(responsibility.getTemplate().getId());
440             if (responsibilityInfos == null) {
441                 responsibilityInfos = new ArrayList<Responsibility>();
442                 results.put(responsibility.getTemplate().getId(), responsibilityInfos);
443             }
444             responsibilityInfos.add(responsibility);
445         }
446         return Collections.unmodifiableMap(results);
447     }
448 
449     private List<String> getRoleIdsForResponsibilities(Collection<String> ids) {
450         final List<String> roleIds = getRoleIdsForPredicate(and(in("responsibilityId", ids.toArray()), equal("active", "Y")));
451 
452         return Collections.unmodifiableList(roleIds);
453     }
454 
455     private List<String> getRoleIdsForPredicate(Predicate p) {
456         final QueryByCriteria.Builder builder = QueryByCriteria.Builder.create();
457         builder.setPredicates(p);
458         final GenericQueryResults<RoleResponsibilityBo> qr = criteriaLookupService.lookup(RoleResponsibilityBo.class, builder.build());
459 
460         final List<String> roleIds = new ArrayList<String>();
461         for (RoleResponsibilityBo bo : qr.getResults()) {
462             roleIds.add(bo.getRoleId());
463         }
464         return Collections.unmodifiableList(roleIds);
465     }
466 
467     private List<Responsibility> findRespsByTemplate(final String namespaceCode, final String templateName) {
468         if (namespaceCode == null) {
469             throw new RiceIllegalArgumentException("namespaceCode is null");
470         }
471 
472         if (templateName == null) {
473             throw new RiceIllegalArgumentException("name is null");
474         }
475 
476         final Map<String, String> crit = new HashMap<String, String>();
477         crit.put("template.namespaceCode", namespaceCode); 
478         crit.put("template.name", templateName); 
479         crit.put("active", "Y"); 
480 
481         final Collection<ResponsibilityBo> bos = businessObjectService.findMatching(ResponsibilityBo.class, Collections.unmodifiableMap(crit));
482         final List<Responsibility> ims = new ArrayList<Responsibility>();
483         if (bos != null) {
484             for (ResponsibilityBo bo : bos) {
485                 if (bo != null) {
486                     ims.add(ResponsibilityBo.to(bo));
487                 }
488             }
489         }
490 
491         return Collections.unmodifiableList(ims);
492     }
493 
494     public void setBusinessObjectService(BusinessObjectService businessObjectService) {
495         this.businessObjectService = businessObjectService;
496     }
497 
498     public void setCriteriaLookupService(final CriteriaLookupService criteriaLookupService) {
499         this.criteriaLookupService = criteriaLookupService;
500     }
501 
502     public void setDefaultResponsibilityTypeService(final ResponsibilityTypeService defaultResponsibilityTypeService) {
503         this.defaultResponsibilityTypeService = defaultResponsibilityTypeService;
504     }
505 
506     public void setKimTypeInfoService(final KimTypeInfoService kimTypeInfoService) {
507         this.kimTypeInfoService = kimTypeInfoService;
508     }
509 
510     public void setRoleService(final RoleService roleService) {
511         this.roleService = roleService;
512     }
513 
514     protected void logResponsibilityCheck(String namespaceCode, String responsibilityName, 
515                     Map<String, String> responsibilityDetails, Map<String, String> qualification ) {
516         StringBuilder sb = new StringBuilder();
517         sb.append(  '\n' );
518         sb.append( "Get Resp Actions: " ).append( namespaceCode ).append( "/" ).append( responsibilityName ).append( '\n' );
519         sb.append( "             Details:\n" );
520         if ( responsibilityDetails != null ) {
521             sb.append( responsibilityDetails );
522         } else {
523             sb.append( "                         [null]\n" );
524         }
525         sb.append( "             Qualifiers:\n" );
526         if ( qualification != null ) {
527             sb.append( qualification );
528         } else {
529             sb.append( "                         [null]\n" );
530         }
531         if (LOG.isTraceEnabled()) { 
532             LOG.trace( sb.append(ExceptionUtils.getStackTrace(new Throwable())));
533         } else {
534             LOG.debug(sb.toString());
535         }
536     }
537 
538     private void incomingParamCheck(Object object, String name) {
539         if (object == null) {
540             throw new RiceIllegalArgumentException(name + " was null");
541         } else if (object instanceof String
542                 && StringUtils.isBlank((String) object)) {
543             throw new RiceIllegalArgumentException(name + " was blank");
544         }
545     }
546 }