NIHVIVO-4017 Get the Application Bean from the context WebappDaoFactory

Since this was caught by a filter, the request is not likely to have
a WebappDaoFactory in it.
This commit is contained in:
j2blake 2012-11-15 12:01:47 -05:00
parent 24a5784110
commit 4422fd07b9

View file

@ -22,6 +22,7 @@ import org.apache.commons.lang.StringUtils;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
import freemarker.cache.WebappTemplateLoader; import freemarker.cache.WebappTemplateLoader;
import freemarker.template.Configuration; import freemarker.template.Configuration;
@ -68,8 +69,8 @@ public class StartupStatusDisplayFilter implements Filter {
statusAlreadyDisplayed = true; statusAlreadyDisplayed = true;
} }
private void displayStartupStatus(ServletRequest req, ServletResponse resp) throws IOException, private void displayStartupStatus(ServletRequest req, ServletResponse resp)
ServletException { throws IOException, ServletException {
HttpServletResponse hresp = (HttpServletResponse) resp; HttpServletResponse hresp = (HttpServletResponse) resp;
HttpServletRequest hreq = (HttpServletRequest) req; HttpServletRequest hreq = (HttpServletRequest) req;
@ -78,7 +79,7 @@ public class StartupStatusDisplayFilter implements Filter {
bodyMap.put("status", ss); bodyMap.put("status", ss);
bodyMap.put("showLink", !isFatal()); bodyMap.put("showLink", !isFatal());
bodyMap.put("contextPath", getContextPath()); bodyMap.put("contextPath", getContextPath());
bodyMap.put("applicationName", getApplicationName(hreq)); bodyMap.put("applicationName", getApplicationName());
String url = ""; String url = "";
@ -112,10 +113,12 @@ public class StartupStatusDisplayFilter implements Filter {
} }
} }
private Object getApplicationName(HttpServletRequest hreq) { private Object getApplicationName() {
String name = ""; String name = "";
try { try {
ApplicationBean app = new VitroRequest(hreq).getAppBean(); WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
ApplicationBean app = wadf.getApplicationDao().getApplicationBean();
name = app.getApplicationName(); name = app.getApplicationName();
} catch (Exception e) { } catch (Exception e) {
// deal with problems below // deal with problems below