diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java index bcf83a979..99dec7616 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/ApplicationBean.java @@ -49,15 +49,6 @@ public class ApplicationBean { private String copyrightAnchor; private String themeDir; - public static ApplicationBean getAppBean(ServletContext sc){ - if( sc != null ){ - Object obj = sc.getAttribute("applicationBean"); - if( obj != null ) - return (ApplicationBean)obj; - } - return new ApplicationBean(); - } - public String toString() { String output = "Application Bean Contents:\n"; output += " initialized from DB: [" + initialized + "]\n"; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java index da86839ca..6d85141e2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/OntologyController.java @@ -33,9 +33,6 @@ import edu.cornell.mannlib.vitro.webapp.web.ContentType; public class OntologyController extends VitroHttpServlet{ private static final Log log = LogFactory.getLog(OntologyController.class.getName()); - private String default_jsp = Controllers.BASIC_JSP; - private ApplicationBean appBean; - public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ doGet(request, response); @@ -242,7 +239,7 @@ public class OntologyController extends VitroHttpServlet{ throws IOException, ServletException { VitroRequest vreq = new VitroRequest(req); - ApplicationBean appBean = ApplicationBean.getAppBean(getServletContext()); + ApplicationBean appBean = vreq.getAppBean(); //set title before we do the highlighting so we don't get markup in it. req.setAttribute("title","not found"); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java index 7e67e0886..88416f911 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java @@ -283,12 +283,8 @@ public class VitroRequest extends HttpServletRequestWrapper { } public ApplicationBean getAppBean(){ - //return (ApplicationBean) getAttribute("appBean"); return getWebappDaoFactory().getApplicationDao().getApplicationBean(); } - public void setAppBean(ApplicationBean ab){ - setAttribute("appBean",ab); - } @SuppressWarnings("unchecked") @Override diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java index 2b5866b5a..fb587eb20 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/admin/StartupStatusController.java @@ -7,7 +7,6 @@ import java.util.Map; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; @@ -31,7 +30,7 @@ public class StartupStatusController extends FreemarkerHttpServlet { body.put("title", "Startup Status"); body.put("status", StartupStatus.getBean(getServletContext())); body.put("contextPath", getContextPath()); - body.put("applicationName", getApplicationName()); + body.put("applicationName", getApplicationName(vreq)); return new TemplateResponseValues("startupStatus-display.ftl", body); } @@ -45,11 +44,10 @@ public class StartupStatusController extends FreemarkerHttpServlet { } } - private Object getApplicationName() { + private Object getApplicationName(VitroRequest vreq) { String name = ""; try { - ApplicationBean app = ApplicationBean.getAppBean(getServletContext()); - name = app.getApplicationName(); + name = vreq.getAppBean().getApplicationName(); } catch (Exception e) { // deal with problems below } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java index 4a145dc8d..789be6947 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/StartupStatusDisplayFilter.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; import freemarker.cache.WebappTemplateLoader; import freemarker.template.Configuration; @@ -69,34 +70,34 @@ public class StartupStatusDisplayFilter implements Filter { private void displayStartupStatus(ServletRequest req, ServletResponse resp) throws IOException, ServletException { - HttpServletResponse hResp = (HttpServletResponse) resp; + HttpServletResponse hresp = (HttpServletResponse) resp; + HttpServletRequest hreq = (HttpServletRequest) req; try { Map bodyMap = new HashMap(); bodyMap.put("status", ss); bodyMap.put("showLink", !isFatal()); bodyMap.put("contextPath", getContextPath()); - bodyMap.put("applicationName", getApplicationName()); + bodyMap.put("applicationName", getApplicationName(hreq)); - HttpServletRequest httpreq = (HttpServletRequest) req; String url = ""; - String path = httpreq.getRequestURI(); + String path = hreq.getRequestURI(); if( path != null ){ url = path; } - String query = httpreq.getQueryString(); + String query = hreq.getQueryString(); if( !StringUtils.isEmpty( query )){ url = url + "?" + query; } bodyMap.put("url", url ); - hResp.setContentType("text/html;charset=UTF-8"); - hResp.setStatus(SC_INTERNAL_SERVER_ERROR); + hresp.setContentType("text/html;charset=UTF-8"); + hresp.setStatus(SC_INTERNAL_SERVER_ERROR); Template tpl = loadFreemarkerTemplate(); - tpl.process(bodyMap, hResp.getWriter()); + tpl.process(bodyMap, hresp.getWriter()); } catch (TemplateException e) { throw new ServletException("Problem with Freemarker Template", e); } @@ -111,10 +112,10 @@ public class StartupStatusDisplayFilter implements Filter { } } - private Object getApplicationName() { + private Object getApplicationName(HttpServletRequest hreq) { String name = ""; try { - ApplicationBean app = ApplicationBean.getAppBean(ctx); + ApplicationBean app = new VitroRequest(hreq).getAppBean(); name = app.getApplicationName(); } catch (Exception e) { // deal with problems below diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java index 02924963f..f1d7a6e71 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java @@ -38,7 +38,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers; import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper; import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList; -import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; @@ -82,19 +81,10 @@ public class VitroRequestPrep implements Filter { }; private ServletContext _context; - private ApplicationBean _appbean; @Override public void init(FilterConfig filterConfig) throws ServletException { _context = filterConfig.getServletContext(); - - Object o = _context.getAttribute("applicationBean"); - if (o instanceof ApplicationBean) { - _appbean = (ApplicationBean) o; - } else { - _appbean = new ApplicationBean(); - } - log.debug("VitroRequestPrep: AppBean theme " + _appbean.getThemeDir()); } @Override @@ -132,9 +122,6 @@ public class VitroRequestPrep implements Filter { VitroRequest vreq = new VitroRequest(req); - //-- setup appBean --// - vreq.setAppBean(_appbean); - //-- setup DAO factory --// WebappDaoFactory wdf = getWebappDaoFactory(vreq); //TODO: get accept-language from request and set as preferred languages diff --git a/webapp/web/error.jsp b/webapp/web/error.jsp index 00622fc76..a429ebed2 100755 --- a/webapp/web/error.jsp +++ b/webapp/web/error.jsp @@ -13,7 +13,6 @@ request.setAttribute("bodyJsp", "/errorbody.jsp"); request.setAttribute("title", "Error"); request.setAttribute("css", ""); - request.setAttribute("appBean", appBean); request.setAttribute("themeDir", themeDir); %> diff --git a/webapp/web/templates/page/basicPage.jsp b/webapp/web/templates/page/basicPage.jsp index 4685288bc..07b328d72 100644 --- a/webapp/web/templates/page/basicPage.jsp +++ b/webapp/web/templates/page/basicPage.jsp @@ -38,9 +38,6 @@ if (request.getAttribute("css") == null){ e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n"; } - if( request.getAttribute("appBean") == null){ - e+="basicPage.jsp expects that request attribute 'appBean' be set.\n"; - } if( e.length() > 0 ){ throw new JspException(e); } diff --git a/webapp/web/templates/page/blankPage.jsp b/webapp/web/templates/page/blankPage.jsp index 62e65e0a7..9fec63cb2 100644 --- a/webapp/web/templates/page/blankPage.jsp +++ b/webapp/web/templates/page/blankPage.jsp @@ -31,9 +31,6 @@ if (request.getAttribute("css") == null){ e+="basicPage.jsp expects that request parameter 'css' be set to css to include in page.\n"; } - if( request.getAttribute("appBean") == null){ - e+="basicPage.jsp expects that request attribute 'appBean' be set.\n"; - } if( e.length() > 0 ){ throw new JspException(e); }