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.OrgUtils;
22 import org.kuali.common.util.Project;
23 import org.kuali.common.util.Str;
24 import org.springframework.util.Assert;
25
26 public class ProjectProcessor implements PropertyProcessor {
27
28 private static final String FS = File.separator;
29 private static final String DOT = ".";
30
31 @Override
32 public void process(Properties properties) {
33 Project p = getProject(properties);
34 validate(p);
35 String groupCode = OrgUtils.getGroupCode(p.getOrgId(), p.getGroupId());
36 String groupBase = OrgUtils.getGroupBase(p.getOrgId(), p.getGroupId());
37 String userHome = System.getProperty("user.home");
38 String orgHome = userHome + FS + DOT + p.getOrgCode();
39 String groupHome = orgHome + FS + groupCode;
40 properties.setProperty("project.groupId.code", groupCode);
41 properties.setProperty("project.groupId.path", Str.getPath(p.getGroupId()));
42 properties.setProperty("project.groupId.base", groupBase);
43 properties.setProperty("project.groupId.base.path", Str.getPath(groupBase));
44 properties.setProperty("project.orgId.home", orgHome);
45 properties.setProperty("project.groupId.home", groupHome);
46 }
47
48 protected void validate(Project project) {
49 Assert.notNull(project.getOrgId(), "orgId is null");
50 Assert.notNull(project.getOrgCode(), "orgCode is null");
51 Assert.notNull(project.getOrgPath(), "orgPath is null");
52 Assert.notNull(project.getGroupId(), "groupId is null");
53 Assert.notNull(project.getArtifactId(), "artifactId is null");
54 Assert.notNull(project.getVersion(), "version is null");
55 }
56
57 protected Project getProject(Properties properties) {
58 Project project = new Project();
59 project.setOrgId(properties.getProperty("project.orgId"));
60 project.setOrgCode(properties.getProperty("project.orgId.code"));
61 project.setOrgPath(properties.getProperty("project.orgId.path"));
62 project.setGroupId(properties.getProperty("project.groupId"));
63 project.setArtifactId(properties.getProperty("project.artifactId"));
64 project.setVersion(properties.getProperty("project.version"));
65 return project;
66 }
67
68 }