1 package org.kuali.rice.kew.impl.extension;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
5 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
6 import org.kuali.rice.kew.api.extension.ExtensionRepositoryService;
7 import org.kuali.rice.kew.rule.bo.RuleAttribute;
8 import org.kuali.rice.kew.rule.service.RuleAttributeService;
9
10
11
12
13
14
15
16 public class ExtensionRepositoryServiceImpl implements ExtensionRepositoryService {
17
18 private RuleAttributeService ruleAttributeService;
19
20 @Override
21 public ExtensionDefinition getExtensionById(String id) throws RiceIllegalArgumentException {
22 if (StringUtils.isBlank(id)) {
23 throw new RiceIllegalArgumentException("id was null or blank");
24 }
25 RuleAttribute ruleAttribute = ruleAttributeService.findByRuleAttributeId(id);
26 return translateFromRuleAttribute(ruleAttribute);
27 }
28
29 @Override
30 public ExtensionDefinition getExtensionByName(String name) throws RiceIllegalArgumentException {
31 if (StringUtils.isBlank(name)) {
32 throw new RiceIllegalArgumentException("name was null or blank");
33 }
34 RuleAttribute ruleAttribute = ruleAttributeService.findByName(name);
35 return translateFromRuleAttribute(ruleAttribute);
36 }
37
38 private ExtensionDefinition translateFromRuleAttribute(RuleAttribute ruleAttribute) {
39 return RuleAttribute.to(ruleAttribute);
40 }
41
42 public void setRuleAttributeService(RuleAttributeService ruleAttributeService) {
43 this.ruleAttributeService = ruleAttributeService;
44 }
45
46 }