Search in sources :

Example 56 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class CmsPageUtil method isFreeViewerPage.

/**
 * Check whether the page can publish free content, related to the model and
 * the widgets of the page.
 *
 * @param model
 * The model of the page to check.
 * @param widgets
 * The widgets of the page to check.
 * @param viewerWidgetCode
 * The code of the viewer widget (optional)
 * @return True if the page can publish free content, false else.
 */
public static boolean isFreeViewerPage(PageModel model, Widget[] widgets, String viewerWidgetCode) {
    try {
        if (model != null && widgets != null) {
            int mainFrame = model.getMainFrame();
            if (mainFrame < 0)
                return false;
            Widget viewer = widgets[mainFrame];
            if (null == viewer)
                return false;
            boolean isRightCode = null == viewerWidgetCode || viewer.getType().getCode().equals(viewerWidgetCode);
            String actionName = viewer.getType().getAction();
            boolean isRightAction = null != actionName && actionName.toLowerCase().indexOf("viewer") >= 0;
            List<WidgetTypeParameter> typeParameters = viewer.getType().getTypeParameters();
            if ((isRightCode || isRightAction) && (null != typeParameters && !typeParameters.isEmpty()) && (null == viewer.getConfig() || viewer.getConfig().isEmpty())) {
                return true;
            }
        }
    } catch (Throwable t) {
        _logger.error("Error while checking page for widget '{}'", viewerWidgetCode, t);
    // ApsSystemUtils.logThrowable(t, CmsPageActionUtil.class,
    // "isViewerPage", "Error while checking page '" + page.getCode() +
    // "'");
    }
    return false;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)

Example 57 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class DataObjectMapperCacheWrapper method searchPublishedDataObjects.

private void searchPublishedDataObjects(DataObjectPageMapper dataObjectPageMapper, IPage page, IPageManager pageManager) {
    PageModel pageModel = page.getModel();
    if (pageModel != null) {
        int mainFrame = pageModel.getMainFrame();
        Widget[] widgets = page.getWidgets();
        Widget widget = null;
        if (null != widgets && mainFrame != -1) {
            widget = widgets[mainFrame];
        }
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        String dataId = (null != config) ? config.getProperty("dataId") : null;
        if (null != dataId) {
            dataObjectPageMapper.add(dataId, page.getCode());
        }
        String[] childCodes = page.getChildrenCodes();
        for (String childCode : childCodes) {
            IPage child = pageManager.getOnlinePage(childCode);
            if (null != child) {
                this.searchPublishedDataObjects(dataObjectPageMapper, child, pageManager);
            }
        }
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 58 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class DataObjectModelManager method addReferencingPage.

private void addReferencingPage(long modelId, IPage page, Map<String, List<IPage>> utilizers) {
    if (null != page && null != page.getWidgets()) {
        Widget[] widgets = page.getWidgets();
        for (Widget widget : widgets) {
            if (null == widget) {
                continue;
            }
            if (null != widget.getConfig()) {
                String id = widget.getConfig().getProperty("modelId");
                String dataId = widget.getConfig().getProperty("dataId");
                if (null != id && null != dataId) {
                    long longId = Long.parseLong(id);
                    if (modelId == longId) {
                        List<IPage> pages = (List<IPage>) utilizers.get(dataId);
                        if (null == pages) {
                            pages = new ArrayList<>();
                        }
                        pages.add(page);
                        utilizers.put(dataId, pages);
                    }
                }
            }
        }
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) ArrayList(java.util.ArrayList) List(java.util.List)

Example 59 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestDataObjectListHelper method valueRequestContext.

private RequestContext valueRequestContext(String pageCode, int frame) throws Throwable {
    RequestContext reqCtx = this.getRequestContext();
    try {
        Widget widgetToAdd = this.getShowletForTest("content_viewer_list", null);
        this.setPageWidgets(pageCode, frame, widgetToAdd);
        IPage page = this._pageManager.getOnlinePage(pageCode);
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
        Widget widget = page.getWidgets()[frame];
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
        reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
    } catch (Throwable t) {
        this.setPageWidgets(pageCode, frame, null);
        throw t;
    }
    return reqCtx;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) RequestContext(com.agiletec.aps.system.RequestContext)

Example 60 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestDataObjectViewerHelper method init.

private void init() throws Exception {
    try {
        _requestContext = this.getRequestContext();
        Lang lang = new Lang();
        lang.setCode("it");
        lang.setDescr("italiano");
        _requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
        Widget widget = new Widget();
        IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
        WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
        widget.setType(showletType);
        widget.setConfig(new ApsProperties());
        _requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
        this._helper = (IDataObjectViewerHelper) this.getApplicationContext().getBean("DataObjectViewerHelper");
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Widget (com.agiletec.aps.system.services.page.Widget)117 ApsProperties (com.agiletec.aps.util.ApsProperties)60 IPage (com.agiletec.aps.system.services.page.IPage)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)20 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 HashMap (java.util.HashMap)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 Page (com.agiletec.aps.system.services.page.Page)7 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)7 ArrayList (java.util.ArrayList)7 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 Properties (java.util.Properties)6 RequestContext (com.agiletec.aps.system.RequestContext)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 JspException (javax.servlet.jsp.JspException)4 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)4 List (java.util.List)3 ServletRequest (javax.servlet.ServletRequest)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3