use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class PreviewControllerServlet method service.
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
RequestContext reqCtx = this.initRequestContext(request, response);
int status = this.controlRequest(request, reqCtx);
if (status == ControllerManager.OUTPUT) {
_logger.debug("Output");
try {
this.initFreemarker(request, response, reqCtx);
this.executePage(request, reqCtx);
} catch (Throwable t) {
_logger.error("Error building response", t);
throw new ServletException("Error building response", t);
}
} else {
// if (status == ControllerManager.REDIRECT) {
// _logger.debug("Redirection");
// this.redirect(reqCtx, response);
// } else if (status == ControllerManager.ERROR) {
// _logger.debug("Error");
// this.outputError(reqCtx, response);
// } else {
_logger.error("Error: final status = {} - request: {} - path: {}", ControllerManager.getStatusDescription(status), request.getServletPath(), request.getPathInfo());
throw new ServletException("Service not available");
// }
}
return;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class ContentPreviewTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
IContentViewerHelper helper = (IContentViewerHelper) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_PREVIEW_VIEWER_HELPER, this.pageContext);
String renderedContent = helper.getRenderedContent(null, null, reqCtx);
this.pageContext.getOut().print(renderedContent);
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
throw new JspException("Error detected during tag initialisation", t);
}
return EVAL_PAGE;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestControllerManager method testService_3.
public void testService_3() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
ControllerManager controller = (ControllerManager) this.getService(SystemConstants.CONTROLLER_MANAGER);
MockHttpServletRequest request = (MockHttpServletRequest) reqCtx.getRequest();
request.setServletPath("/it/administrators_page.page");
request.setRequestURI("/Entando/it/customers_page.page");
int status = controller.service(reqCtx);
assertEquals(ControllerManager.REDIRECT, status);
String redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertTrue(redirectUrl.contains("/Entando/it/login.page?"));
assertTrue(redirectUrl.contains("redirectflag=1"));
assertTrue(redirectUrl.contains("returnUrl="));
assertTrue(redirectUrl.contains("customers_page.page"));
request.setParameter(RequestContext.PAR_REDIRECT_FLAG, "1");
status = controller.service(reqCtx);
assertEquals(ControllerManager.REDIRECT, status);
redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertEquals("/Entando/it/errorpage.page", redirectUrl);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestControllerManager method testService_2.
public void testService_2() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
ControllerManager controller = (ControllerManager) this.getService(SystemConstants.CONTROLLER_MANAGER);
MockHttpServletRequest request = (MockHttpServletRequest) reqCtx.getRequest();
request.setServletPath("/it/customers_page.page");
int status = controller.service(reqCtx);
assertEquals(ControllerManager.REDIRECT, status);
request.setParameter("username", "admin");
request.setParameter("password", "admin");
request.setServletPath("/it/customers_page.page");
status = controller.service(reqCtx);
assertEquals(ControllerManager.OUTPUT, status);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestControllerManager method testService_1.
public void testService_1() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
ControllerManager controller = (ControllerManager) this.getService(SystemConstants.CONTROLLER_MANAGER);
MockHttpServletRequest request = (MockHttpServletRequest) reqCtx.getRequest();
request.setServletPath("/it/homepage.page");
int status = controller.service(reqCtx);
assertEquals(ControllerManager.OUTPUT, status);
request.setParameter("username", "admin");
request.setParameter("password", "admin");
status = controller.service(reqCtx);
assertEquals(ControllerManager.OUTPUT, status);
}
Aggregations