1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.impl.namespace;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
20 import org.kuali.rice.coreservice.api.namespace.Namespace;
21 import org.kuali.rice.coreservice.api.namespace.NamespaceService;
22 import org.kuali.rice.krad.service.BusinessObjectService;
23
24 import java.util.ArrayList;
25 import java.util.Collections;
26 import java.util.List;
27
28 import static java.util.Collections.singletonMap;
29
30 public class NamespaceServiceImpl implements NamespaceService {
31
32 private BusinessObjectService boService;
33
34 @Override
35 public Namespace getNamespace(String code) {
36 if (StringUtils.isBlank(code)) {
37 throw new RiceIllegalArgumentException("the code is blank");
38 }
39
40 return NamespaceBo.to(boService.findByPrimaryKey(NamespaceBo.class, singletonMap("code", code)));
41 }
42
43 @Override
44 public List<Namespace> findAllNamespaces() {
45 List<NamespaceBo> namespaceBos = (List<NamespaceBo>) boService.findAll(NamespaceBo.class);
46 List<Namespace> namespaces = new ArrayList<Namespace>();
47
48 for (NamespaceBo bo : namespaceBos) {
49 namespaces.add(NamespaceBo.to(bo));
50 }
51 return Collections.unmodifiableList(namespaces);
52 }
53
54 public void setBusinessObjectService(BusinessObjectService boService) {
55 this.boService = boService;
56 }
57 }