use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class WidgetTag method doEndTag.
public int doEndTag() throws JspException {
ServletRequest req = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
try {
String[] showletOutput = (String[]) reqCtx.getExtraParam("ShowletOutput");
if (_frame < 0 || _frame >= showletOutput.length) {
_logger.error("Frame attribute {} exceeds the limit in the page {}", _frame, page.getCode());
String msg = "Frame attribute =" + _frame + " exceeds the limit in the page " + page.getCode();
throw new JspException(msg);
// ApsSystemUtils.getLogger().error(msg);
}
String showlet = showletOutput[_frame];
if (null == showlet)
showlet = "";
this.pageContext.getOut().print(showlet);
} catch (Throwable t) {
String msg = "Error detected in the inclusion of the output widget";
_logger.error("Error detected in the inclusion of the output widget", t);
// ApsSystemUtils.logThrowable(t, this, "doEndTag", msg);
throw new JspException(msg, t);
}
return EVAL_PAGE;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class PagerTagHelper method getPagerId.
private String getPagerId(String pagerId, boolean pagerIdFromFrame, ServletRequest request) {
String truePagerId = pagerId;
if (null == truePagerId && pagerIdFromFrame) {
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
if (reqCtx != null) {
int currentFrame = this.getCurrentFrame(reqCtx);
truePagerId = "frame" + currentFrame;
}
}
return truePagerId;
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class Struts2ServletDispatcher method service.
@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
try {
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
String currentFrameActionPath = request.getParameter(InternalServletTag.REQUEST_PARAM_FRAMEDEST);
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Boolean staticAction = (Boolean) reqCtx.getExtraParam(InternalServletTag.EXTRAPAR_STATIC_ACTION);
boolean executeCustomAction = (null == staticAction || !staticAction) && (null == currentFrameActionPath || Integer.parseInt(currentFrameActionPath) == currentFrame.intValue());
prepare.createActionContext(request, response);
prepare.assignDispatcherToThread();
prepare.setEncodingAndLocale(request, response);
request = prepare.wrapRequest(request);
ActionMapper actionMapper = new ExtendedDefaultActionMapper();
Dispatcher dispatcher = prepare.getDispatcher();
String entandoActionName = EntandoActionUtils.extractEntandoActionName(request);
ActionMapping mapping = actionMapper.getMapping(request, dispatcher.getConfigurationManager());
if (mapping != null && null != entandoActionName && executeCustomAction) {
mapping.setName(entandoActionName);
}
if (mapping == null) {
boolean handled = execute.executeStaticResourceRequest(request, response);
if (!handled) {
throw new ServletException("Resource loading not supported, use the StrutsPrepareAndExecuteFilter instead.");
}
} else {
execute.executeAction(request, response, mapping);
}
} finally {
prepare.cleanupRequest(request);
}
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContent_1.
public void testGetRenderedContent_1() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String contentId = null;
String langCode = "en";
long modelId = -1;
try {
modelId = this.createMockContentModel();
contentId = this.createMockContent();
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
ContentRenderizationInfo cachedOutputInfo = (ContentRenderizationInfo) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey);
assertNotNull(cachedOutputInfo);
assertEquals(outputInfo.hashCode(), cachedOutputInfo.hashCode());
assertEquals(outputInfo.getContentId(), cachedOutputInfo.getContentId());
assertEquals(outputInfo.getModelId(), cachedOutputInfo.getModelId());
assertEquals(outputInfo.getCachedRenderedContent(), cachedOutputInfo.getCachedRenderedContent());
} catch (Throwable t) {
throw t;
} finally {
this.deleteMockContentObject(contentId, modelId);
}
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContentsGroup.
protected void testGetRenderedContentsGroup(String contentId, long modelId, String cacheGroupId) throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String langCode = "en";
try {
String groupsCsv = BaseContentDispenser.getRenderizationInfoCacheGroupsCsv(contentId, modelId);
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
assertTrue(groupsCsv.indexOf(cacheGroupId) > -1);
this._cacheInfoManager.flushGroup(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheGroupId);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
} catch (Throwable t) {
throw t;
}
}
Aggregations