1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.server.gwt;
17
18 import java.io.IOException;
19 import java.util.HashMap;
20 import java.util.LinkedHashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import javax.servlet.ServletConfig;
25 import javax.servlet.ServletException;
26
27 import org.apache.log4j.Logger;
28 import org.kuali.rice.core.config.ConfigContext;
29 import org.kuali.student.common.ui.client.service.ServerPropertiesRpcService;
30 import org.kuali.student.common.util.ManifestInspector;
31
32 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
33
34 @SuppressWarnings("serial")
35 public class ServerPropertiesRpcGwtServlet extends RemoteServiceServlet implements ServerPropertiesRpcService {
36
37 final Logger logger = Logger.getLogger(ServerPropertiesRpcGwtServlet.class);
38
39 Map<String, String> properties = new HashMap<String, String>();
40
41 public Map<String, String> getProperties() {
42 return properties;
43 }
44
45 public void setProperties(Map<String, String> properties) {
46 this.properties = properties;
47 }
48
49 @Override
50 public String get(String property) {
51 String value = properties.get(property);
52 logger.info("Getting property: " + property + " with value: " + value);
53 if (null == value) {
54 value = ConfigContext.getCurrentContextConfig().getProperty(property);
55 logger.info("Property not found, looking in Context: " + property + " with value: " + value);
56 }
57 return value;
58 }
59
60 @Override
61 public Map<String, String> get(List<String> properties) {
62 Map<String, String> map = new LinkedHashMap<String, String>();
63 for (String property : properties) {
64 map.put(property, get(property));
65 }
66 return map;
67 }
68
69 @Override
70 public String getContextPath(){
71 String contextPath = this.getThreadLocalRequest().getContextPath();
72 logger.info("Returning servlet path of [" + contextPath + "]");
73 return contextPath;
74 }
75
76 @Override
77 public void init(ServletConfig config) throws ServletException {
78 super.init(config);
79 try {
80 logger.info("Obtaining build information from " + ManifestInspector.MANIFEST_LOCATION);
81 ManifestInspector inspector = new ManifestInspector();
82 String buildInfo = inspector.getBuildInformationString(getServletConfig().getServletContext());
83 logger.info("Build information: " + buildInfo);
84 properties.put("ks.application.version", buildInfo);
85 } catch (IOException e) {
86 throw new ServletException(e);
87 }
88 }
89 }