Search in sources :

Example 41 with GuiFragment

use of org.entando.entando.aps.system.services.guifragment.GuiFragment 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);
    }
}
Also used : IGuiFragmentManager(org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager) GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)10 ArrayList (java.util.ArrayList)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)6 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)5 ApsProperties (com.agiletec.aps.util.ApsProperties)4 IGuiFragmentManager (org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager)4 List (java.util.List)3 Test (org.junit.Test)3 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)2 Template (freemarker.template.Template)2 StringReader (java.io.StringReader)2 Writer (java.io.Writer)2 ExecutorBeanContainer (org.entando.entando.aps.system.services.controller.executor.ExecutorBeanContainer)2 GuiFragmentUtilizer (org.entando.entando.aps.system.services.guifragment.GuiFragmentUtilizer)2 GuiFragmentRequestBody (org.entando.entando.web.guifragment.model.GuiFragmentRequestBody)2 ListableBeanFactory (org.springframework.beans.factory.ListableBeanFactory)2 MapBindingResult (org.springframework.validation.MapBindingResult)2 RequestContext (com.agiletec.aps.system.RequestContext)1