Changed visibility of FreeMarkerHttpServlet root hashmap to private, so other controllers can't add to it.
This commit is contained in:
parent
bbc5765663
commit
6bfab4e431
2 changed files with 13 additions and 45 deletions
|
@ -2,6 +2,9 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -19,9 +22,9 @@ public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(FreeMarkerHttpServlet.class.getName());
|
||||
|
||||
|
||||
FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
|
||||
doSetup(request, response);
|
||||
doSetup(request, response);
|
||||
}
|
||||
|
||||
public String getIdentity() {
|
||||
|
@ -42,7 +45,7 @@ public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
|
|||
|
||||
private String get(String templateName) {
|
||||
String template = "page/partials/" + templateName + ".ftl";
|
||||
return mergeToTemplate(template, root).toString();
|
||||
return mergeTemplateToRoot(template);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,9 +57,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
|||
protected String appName;
|
||||
protected UrlBuilder urlBuilder;
|
||||
|
||||
// RY Change to private. Only used now by FreeMarkerComponentGenerator, which
|
||||
// can be moved here as a nested class. Subclasses should not use root.
|
||||
protected Map<String, Object> root = new HashMap<String, Object>();
|
||||
private Map<String, Object> root = new HashMap<String, Object>();
|
||||
|
||||
public void doGet( HttpServletRequest request, HttpServletResponse response )
|
||||
throws IOException, ServletException {
|
||||
|
@ -344,7 +342,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
|||
return config != null;
|
||||
}
|
||||
|
||||
// TEMPORARY for transition from JSP to FreeMarker. Once transition
|
||||
// TEMPORARY methods for transition from JSP to FreeMarker. Once transition
|
||||
// is complete and no more pages are generated in JSP, this can be removed.
|
||||
// Do this if FreeMarker is configured (i.e., not Datastar) and if we are not in
|
||||
// a FreeMarkerHttpServlet, which will generate identity, menu, and footer from the page template.
|
||||
|
@ -356,43 +354,10 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
|
|||
request.setAttribute("ftl_search", fcg.getSearch());
|
||||
request.setAttribute("ftl_footer", fcg.getFooter());
|
||||
}
|
||||
|
||||
/**
|
||||
* TEMPORARY for transition from JSP to FreeMarker. Once transition
|
||||
* is complete and no more pages are generated in JSP, this can be removed.
|
||||
*
|
||||
* @author rjy7
|
||||
*
|
||||
*/
|
||||
// public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
|
||||
//
|
||||
// private static final long serialVersionUID = 1L;
|
||||
//
|
||||
// FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
|
||||
// doSetup(request, response);
|
||||
// }
|
||||
//
|
||||
// public String getIdentity() {
|
||||
// return get("identity");
|
||||
// }
|
||||
//
|
||||
// public String getMenu() {
|
||||
// return get("menu");
|
||||
// }
|
||||
//
|
||||
// public String getSearch() {
|
||||
// return get("search");
|
||||
// }
|
||||
//
|
||||
// public String getFooter() {
|
||||
// return get("footer");
|
||||
// }
|
||||
//
|
||||
// private String get(String templateName) {
|
||||
// String template = "partials/" + templateName + ".ftl";
|
||||
// return mergeToTemplate(template, root).toString();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// This method is called by FreeMarkerComponentGenerator, since root is private.
|
||||
// Don't want to make root protected because other controllers shouldn't add to it.
|
||||
protected String mergeTemplateToRoot(String template) {
|
||||
return mergeToTemplate(template, root).toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue