1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.property.processor;
17
18 import java.io.File;
19 import java.util.Properties;
20
21 import org.kuali.common.util.Mode;
22 import org.kuali.common.util.OrgUtils;
23 import org.kuali.common.util.PropertyUtils;
24 import org.kuali.common.util.Str;
25 import org.kuali.common.util.property.Constants;
26 import org.springframework.util.Assert;
27
28 public class HomeProcessor implements PropertyProcessor {
29
30 Mode propertyOverwriteMode = Constants.DEFAULT_PROPERTY_OVERWRITE_MODE;
31 String userHomeProperty = Constants.DEFAULT_USER_HOME_PROPERTY;
32 String fileSeparator = File.separator;
33 String hiddenDirectoryIndicator = Str.DOT;
34 String organizationGroupId;
35 String groupId;
36
37 public HomeProcessor() {
38 this(null, null);
39 }
40
41 public HomeProcessor(String organizationGroupId, String groupId) {
42 super();
43 this.organizationGroupId = organizationGroupId;
44 this.groupId = groupId;
45 }
46
47 @Override
48 public void process(Properties properties) {
49 Assert.notNull(organizationGroupId);
50 Assert.notNull(groupId);
51
52 String organizationCode = OrgUtils.getOrgCode(organizationGroupId);
53 String groupCode = OrgUtils.getGroupCode(organizationGroupId, groupId);
54
55 String organizationHomeProperty = organizationCode + Str.DOT + Constants.DEFAULT_HOME_SUFFIX;
56 String groupHomeProperty = organizationCode + Str.DOT + Constants.GROUP + Str.DOT + Constants.DEFAULT_HOME_SUFFIX;
57
58 String organizationHome = System.getProperty(userHomeProperty) + fileSeparator + hiddenDirectoryIndicator + organizationCode;
59 String groupHome = organizationHome + fileSeparator + groupCode;
60
61 PropertyUtils.addOrOverrideProperty(properties, organizationHomeProperty, organizationHome, propertyOverwriteMode);
62 PropertyUtils.addOrOverrideProperty(properties, groupHomeProperty, groupHome, propertyOverwriteMode);
63 }
64
65 public Mode getPropertyOverwriteMode() {
66 return propertyOverwriteMode;
67 }
68
69 public void setPropertyOverwriteMode(Mode propertyOverwriteMode) {
70 this.propertyOverwriteMode = propertyOverwriteMode;
71 }
72
73 public String getUserHomeProperty() {
74 return userHomeProperty;
75 }
76
77 public void setUserHomeProperty(String userHomeProperty) {
78 this.userHomeProperty = userHomeProperty;
79 }
80
81 public String getFileSeparator() {
82 return fileSeparator;
83 }
84
85 public void setFileSeparator(String fileSeparator) {
86 this.fileSeparator = fileSeparator;
87 }
88
89 public String getHiddenDirectoryIndicator() {
90 return hiddenDirectoryIndicator;
91 }
92
93 public void setHiddenDirectoryIndicator(String hiddenDirectoryIndicator) {
94 this.hiddenDirectoryIndicator = hiddenDirectoryIndicator;
95 }
96
97 public String getOrganizationGroupId() {
98 return organizationGroupId;
99 }
100
101 public void setOrganizationGroupId(String organizationGroupId) {
102 this.organizationGroupId = organizationGroupId;
103 }
104
105 public String getGroupId() {
106 return groupId;
107 }
108
109 public void setGroupId(String groupId) {
110 this.groupId = groupId;
111 }
112 }