Created method for VitroHttpServlet setup, callable by FreeMarker controllers that have their own doGet() method.

This commit is contained in:
rjy7 2010-07-02 14:45:11 +00:00
parent e7675e494d
commit 767ca049e0
3 changed files with 23 additions and 28 deletions

View file

@ -44,26 +44,31 @@ public class VitroHttpServlet extends HttpServlet
protected void doGet( HttpServletRequest request, HttpServletResponse response ) protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException throws ServletException, IOException
{ {
if (request.getSession() != null) { setup(request);
Object webappDaoFactoryAttr = request.getSession().getAttribute("webappDaoFactory"); }
if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) {
myWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr; protected final void setup(HttpServletRequest request) {
}
webappDaoFactoryAttr = request.getSession().getAttribute("assertionsWebappDaoFactory"); if (request.getSession() != null) {
if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) { Object webappDaoFactoryAttr = request.getSession().getAttribute("webappDaoFactory");
myAssertionsWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr; if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) {
} myWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr;
webappDaoFactoryAttr = request.getSession().getAttribute("deductionsWebappDaoFactory"); }
if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) { webappDaoFactoryAttr = request.getSession().getAttribute("assertionsWebappDaoFactory");
myDeductionsWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr; if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) {
} myAssertionsWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr;
} }
webappDaoFactoryAttr = request.getSession().getAttribute("deductionsWebappDaoFactory");
if (webappDaoFactoryAttr != null && webappDaoFactoryAttr instanceof WebappDaoFactory) {
myDeductionsWebappDaoFactory = (WebappDaoFactory) webappDaoFactoryAttr;
}
}
//check to see if VitroRequestPrep filter was run //check to see if VitroRequestPrep filter was run
if( request.getAttribute("appBean") == null || if( request.getAttribute("appBean") == null ||
request.getAttribute("webappDaoFactory") == null ){ request.getAttribute("webappDaoFactory") == null ){
log.warn("request scope was not prepared by VitroRequestPrep"); log.warn("request scope was not prepared by VitroRequestPrep");
} }
} }

View file

@ -50,16 +50,6 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(FreeMarkerHttpServlet.class.getName()); private static final Log log = LogFactory.getLog(FreeMarkerHttpServlet.class.getName());
private static final int FILTER_SECURITY_LEVEL = LoginFormBean.EDITOR; private static final int FILTER_SECURITY_LEVEL = LoginFormBean.EDITOR;
/**
* If a subclass doesn't want to call <code>super.doGet(req, resp)</code>,
* it can call this method instead, to run
* <code>VitroHttpServlet.doGet(req, resp)</code>.
*/
protected final void vitroHttpServletDoGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
super.doGet(request, response);
}
public void doGet( HttpServletRequest request, HttpServletResponse response ) public void doGet( HttpServletRequest request, HttpServletResponse response )
throws IOException, ServletException { throws IOException, ServletException {

View file

@ -142,8 +142,8 @@ public class ImageUploadController extends FreeMarkerHttpServlet {
} }
try { try {
// execute super.super.doGet() // do setup defined in VitroHttpServlet
vitroHttpServletDoGet(request, response); setup(request);
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
ResponseValues values = buildTheResponse(vreq); ResponseValues values = buildTheResponse(vreq);