use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestValidator method testServiceFailure_1.
public void testServiceFailure_1() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
// Page does not exist
((MockHttpServletRequest) reqCtx.getRequest()).setServletPath("/it/notexists.wp");
int status = _requestValidator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(ControllerManager.REDIRECT, status);
String redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertEquals("/Entando/it/notfound.page?redirectflag=1", redirectUrl);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestValidator method testService.
public void testService() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
((MockHttpServletRequest) reqCtx.getRequest()).setServletPath("/it/homepage.wp");
int status = this._requestValidator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(ControllerManager.CONTINUE, status);
Lang lang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
assertNotNull(page);
assertNotNull(lang);
assertEquals("it", lang.getCode());
assertEquals("homepage", page.getCode());
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class BaseTestCase method createRequestContext.
protected RequestContext createRequestContext(ApplicationContext applicationContext, ServletContext srvCtx) {
RequestContext reqCtx = new RequestContext();
srvCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(RequestContext.REQCTX, reqCtx);
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpSession session = new MockHttpSession(srvCtx);
request.setSession(session);
reqCtx.setRequest(request);
reqCtx.setResponse(response);
ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
Lang defaultLang = langManager.getDefaultLang();
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, defaultLang);
return reqCtx;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class GuiFragmentTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
Object extractedValue = this.extractFragmentOutput(reqCtx);
if (null == extractedValue) {
_logger.info("The fragment '{}' is not available", this.getCode());
extractedValue = "The fragment '" + this.getCode() + "' is not available";
}
if (this.getVar() != null) {
this.pageContext.setAttribute(this.getVar(), extractedValue);
} else {
if (this.getEscapeXml()) {
out(this.pageContext, this.getEscapeXml(), extractedValue);
} else {
this.pageContext.getOut().print(extractedValue);
}
}
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
throw new JspException("Error during tag initialization", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class RowContentListTag method doEndTag.
@Override
public int doEndTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
try {
this.extractExtraWidgetParameters(reqCtx);
List<Properties> contents = this.getContents(reqCtx);
this.pageContext.setAttribute(this.getListName(), contents);
} catch (Throwable t) {
_logger.error("error in end tag", t);
throw new JspException("Error detected while finalising the tag", t);
}
this.release();
return EVAL_PAGE;
}
Aggregations