1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util;
17
18 import org.apache.commons.lang3.StringUtils;
19
20 public class OrgUtils {
21
22
23
24
25 public static final String getOrgCode(String organizationGroupId) {
26 int pos = StringUtils.lastIndexOf(organizationGroupId, ".");
27 if (pos == -1) {
28 return organizationGroupId;
29 } else {
30 return StringUtils.substring(organizationGroupId, pos + 1);
31 }
32 }
33
34
35
36
37
38 public static final String getGroupCode(String organizationGroupId, String groupId) {
39 if (!StringUtils.startsWith(groupId, organizationGroupId)) {
40 throw new IllegalArgumentException(groupId + " does not start with " + organizationGroupId);
41 }
42 String code = StringUtils.remove(groupId, organizationGroupId);
43 if (StringUtils.startsWith(code, ".")) {
44 code = StringUtils.substring(code, 1);
45 }
46 int pos = StringUtils.indexOf(code, ".");
47 if (pos != -1) {
48 code = StringUtils.substring(code, 0, pos);
49 }
50 return code;
51 }
52
53
54
55
56 public static final String getGroupBase(String organizationGroupId, String groupId) {
57 return organizationGroupId + "." + getGroupCode(organizationGroupId, groupId);
58 }
59
60 }