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:
parent
24a5784110
commit
4422fd07b9
1 changed files with 23 additions and 20 deletions
|
@ -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,21 +79,21 @@ 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 = "";
|
||||||
|
|
||||||
String path = hreq.getRequestURI();
|
String path = hreq.getRequestURI();
|
||||||
if( path != null ){
|
if (path != null) {
|
||||||
url = path;
|
url = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
String query = hreq.getQueryString();
|
String query = hreq.getQueryString();
|
||||||
if( !StringUtils.isEmpty( query )){
|
if (!StringUtils.isEmpty(query)) {
|
||||||
url = url + "?" + query;
|
url = url + "?" + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyMap.put("url", url );
|
bodyMap.put("url", url);
|
||||||
|
|
||||||
hresp.setContentType("text/html;charset=UTF-8");
|
hresp.setContentType("text/html;charset=UTF-8");
|
||||||
hresp.setStatus(SC_INTERNAL_SERVER_ERROR);
|
hresp.setStatus(SC_INTERNAL_SERVER_ERROR);
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue