//--- create request
ConfigurableApplicationContext applicationContext = JeevesDelegatingFilterProxy.getApplicationContextFromServletContext
(getServletContext());
JeevesEngine jeeves = applicationContext.getBean(JeevesEngine.class);
try {
srvReq = ServiceRequestFactory.create(req, res, jeeves.getUploadDir(), jeeves.getMaxUploadSize());
} catch (FileUploadTooBigEx e) {
StringBuilder sb = new StringBuilder();
sb.append("File upload too big - exceeds ").append(jeeves.getMaxUploadSize()).append(" Mb\n")
.append("Error : ").append(e.getClass().getName()).append("\n");
res.sendError(SC_BAD_REQUEST, sb.toString());
// now stick the stack trace on the end and log the whole lot
sb.append("Stack :\n").append(Util.getStackTrace(e));
Log.error(Log.REQUEST,sb.toString());
return;
} catch (Exception e) {
StringBuilder sb = new StringBuilder();
sb.append("Cannot build ServiceRequest\n").append("Cause : ").append(e.getMessage()).append("\n")
.append("Error : ").append(e.getClass().getName()).append("\n");
res.sendError(SC_BAD_REQUEST, sb.toString());
// now stick the stack trace on the end and log the whole lot
sb.append("Stack :\n").append(Util.getStackTrace(e));
Log.error(Log.REQUEST, sb.toString());
return;
}
// Set the language of the request as the preferred language in a cookie
final Cookie langCookie = new Cookie(Jeeves.LANG_COOKIE, srvReq.getLanguage());
langCookie.setMaxAge((int) TimeUnit.DAYS.toSeconds(7));
langCookie.setComment("Keeps the last language chosen to be the preferred language");
langCookie.setVersion(1);
langCookie.setPath("/");
res.addCookie(langCookie);
//--- execute request
jeeves.dispatch(srvReq, session);
}