use of com.openmeap.AuthorizerImpl in project OpenMEAP by OpenMEAP.
the class AdminServlet method service.
@SuppressWarnings("unchecked")
@Override
public void service(HttpServletRequest request, HttpServletResponse response) {
logger.trace("Entering service()");
try {
DocumentProcessor documentProcessor = null;
logger.debug("Request uri: {}", request.getRequestURI());
logger.debug("Request url: {}", request.getRequestURL());
logger.debug("Query string: {}", request.getQueryString());
if (logger.isDebugEnabled()) {
logger.debug("Parameter map: {}", ParameterMapUtils.toString(request.getParameterMap()));
}
if (request.getParameter("logout") != null) {
logger.trace("Executing logout");
request.getSession().invalidate();
response.sendRedirect(request.getContextPath() + "/interface/");
}
if (request.getParameter("refreshContext") != null && context instanceof AbstractApplicationContext) {
logger.trace("Refreshing context");
((AbstractApplicationContext) context).refresh();
}
// support for clearing the persistence context
if (request.getParameter("clearPersistenceContext") != null && context instanceof AbstractApplicationContext) {
logger.trace("Clearing the persistence context");
ModelServiceImpl ms = (ModelServiceImpl) ((AbstractApplicationContext) context).getBean("modelService");
ms.clearPersistenceContext();
}
// default to the mainOptionPage, unless otherwise specified
String pageBean = null;
if (request.getParameter(FormConstants.PAGE_BEAN) != null)
pageBean = request.getParameter(FormConstants.PAGE_BEAN);
else
pageBean = FormConstants.PAGE_BEAN_MAIN;
logger.debug("Using page bean: {}", pageBean);
documentProcessor = (DocumentProcessor) context.getBean(pageBean);
ModelManager mgr = getModelManager();
Map<Object, Object> map = new HashMap<Object, Object>();
// TODO: I'm not really happy with this hacky work-around for the login form not being in actual request scope
if (documentProcessor.getProcessesFormData()) {
GlobalSettings settings = mgr.getGlobalSettings();
map = ServletUtils.cloneParameterMap(settings.getMaxFileUploadSize(), settings.getTemporaryStoragePath(), request);
map.put("userPrincipalName", new String[] { request.getUserPrincipal().getName() });
AuthorizerImpl authorizer = (AuthorizerImpl) context.getBean("authorizer");
authorizer.setRequest(request);
}
response.setContentType(FormConstants.CONT_TYPE_HTML);
Map<Object, Object> defaultTemplateVars = new HashMap<Object, Object>();
defaultTemplateVars.put("request", new BeanModel(request, new DefaultObjectWrapper()));
documentProcessor.setTemplateVariables(defaultTemplateVars);
documentProcessor.handleProcessAndRender(map, response.getWriter());
response.getWriter().flush();
response.getWriter().close();
} catch (IOException te) {
throw new RuntimeException(te);
}
logger.trace("Leaving service()");
}
Aggregations