use of org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager in project entando-core by entando.
the class AbstractWidgetExecutorService method extractFragmentOutput.
protected String extractFragmentOutput(String fragmentCode, RequestContext reqCtx) throws Throwable {
if (StringUtils.isBlank(fragmentCode)) {
return null;
}
IGuiFragmentManager guiFragmentManager = (IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, reqCtx.getRequest());
GuiFragment fragment = guiFragmentManager.getGuiFragment(fragmentCode);
return extractFragmentOutput(fragment, reqCtx);
}
use of org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager in project entando-core by entando.
the class GuiFragmentTag method extractFragmentOutput.
protected String extractFragmentOutput(RequestContext reqCtx) throws ApsSystemException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
IGuiFragmentManager guiFragmentManager = (IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, this.pageContext);
GuiFragment guiFragment = guiFragmentManager.getGuiFragment(this.getCode());
if (null == guiFragment || StringUtils.isBlank(guiFragment.getCurrentGui())) {
return null;
}
ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
Writer out = new OutputStreamWriter(baos);
Template template = new Template(this.getCode(), new StringReader(guiFragment.getCurrentGui()), ebc.getConfiguration());
template.process(ebc.getTemplateModel(), out);
out.flush();
} catch (Throwable t) {
String msg = "Error creating fragment output - code '" + this.getCode() + "'";
_logger.error(msg, t);
throw new ApsSystemException(msg, t);
}
return baos.toString();
}
use of org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager in project entando-core by entando.
the class GuiFragmentResult method doExecute.
/**
* Execute this result, using the specified fragment.
* @param code The code of the fragment
* @param invocation The invocation
*/
@Override
public void doExecute(String code, ActionInvocation invocation) throws Exception {
if (null == code) {
code = conditionalParse(this._code, invocation);
}
if (null == code) {
this.executeDispatcherResult(invocation);
return;
}
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest req = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
IGuiFragmentManager guiFragmentManager = (IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, req);
try {
GuiFragment guiFragment = guiFragmentManager.getGuiFragment(code);
String output = (null != guiFragment) ? guiFragment.getCurrentGui() : null;
if (StringUtils.isBlank(output)) {
_logger.info("The fragment '{}' is not available - Action '{}' - Namespace '{}'", code, invocation.getProxy().getActionName(), invocation.getProxy().getNamespace());
boolean execution = this.executeDispatcherResult(invocation);
if (!execution) {
output = "The fragment '" + code + "' is not available";
} else {
return;
}
}
RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
Writer writer = this.getWriter();
Template template = new Template(code, new StringReader(output), ebc.getConfiguration());
template.process(ebc.getTemplateModel(), writer);
} catch (Throwable t) {
_logger.error("Error processing GuiFragment result!", t);
throw new RuntimeException("Error processing GuiFragment result!", t);
}
}
use of org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager in project entando-core by entando.
the class AbstractWidgetExecutorService method extractWidgetOutput.
public static String extractWidgetOutput(RequestContext reqCtx, WidgetType type) throws ApsSystemException {
if (null == type) {
return "";
}
String widgetTypeCode = (type.isLogic()) ? type.getParentType().getCode() : type.getCode();
try {
IGuiFragmentManager guiFragmentManager = (IGuiFragmentManager) ApsWebApplicationUtils.getBean(SystemConstants.GUI_FRAGMENT_MANAGER, reqCtx.getRequest());
GuiFragment guiFragment = guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode);
if (null != guiFragment) {
String fragmentOutput = extractFragmentOutput(guiFragment, reqCtx);
if (StringUtils.isBlank(fragmentOutput)) {
_logger.info("The fragment '{}' of widget '{}' is not available", guiFragment.getCode(), widgetTypeCode);
return "The fragment '" + guiFragment.getCode() + "' of widget '" + widgetTypeCode + "' is not available";
}
return fragmentOutput;
} else {
String widgetJspPath = type.getJspPath();
return extractJspWidgetOutput(widgetTypeCode, reqCtx, widgetJspPath);
}
} catch (Throwable t) {
String msg = "Error creating widget output - Type '" + widgetTypeCode + "'";
_logger.error(msg, t);
throw new ApsSystemException(msg, t);
}
}
Aggregations