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.api.config.property.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 @Deprecated
35 @SuppressWarnings("serial")
36 public class ServerPropertiesRpcGwtServlet extends RemoteServiceServlet implements ServerPropertiesRpcService {
37
38 final Logger logger = Logger.getLogger(ServerPropertiesRpcGwtServlet.class);
39
40 Map<String, String> properties = new HashMap<String, String>();
41
42 public Map<String, String> getProperties() {
43 return properties;
44 }
45
46 public void setProperties(Map<String, String> properties) {
47 this.properties = properties;
48 }
49
50 @Override
51 public String get(String property) {
52 String value = properties.get(property);
53 logger.info("Getting property: " + property + " with value: " + value);
54 if (null == value) {
55 value = ConfigContext.getCurrentContextConfig().getProperty(property);
56 logger.info("Property not found, looking in Context: " + property + " with value: " + value);
57 }
58 return value;
59 }
60
61 @Override
62 public Map<String, String> get(List<String> properties) {
63 Map<String, String> map = new LinkedHashMap<String, String>();
64 for (String property : properties) {
65 map.put(property, get(property));
66 }
67 return map;
68 }
69
70 @Override
71 public String getContextPath(){
72 String contextPath = this.getThreadLocalRequest().getContextPath();
73 logger.info("Returning servlet path of [" + contextPath + "]");
74 return contextPath;
75 }
76
77 @Override
78 public void init(ServletConfig config) throws ServletException {
79 super.init(config);
80 try {
81 logger.info("Obtaining build information from " + ManifestInspector.MANIFEST_LOCATION);
82 ManifestInspector inspector = new ManifestInspector();
83 String buildInfo = inspector.getBuildInformationString(getServletConfig().getServletContext());
84 logger.info("Build information: " + buildInfo);
85 properties.put("ks.application.version", buildInfo);
86 } catch (IOException e) {
87 throw new ServletException(e);
88 }
89 }
90 }