Search in sources :

Example 1 with Widget

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

the class CmsPageManagerWrapper method findContentUtilizers.

public boolean findContentUtilizers(Widget[] widgets, String contentId) throws ApsSystemException {
    boolean found = false;
    if (null != widgets) {
        for (Widget widget : widgets) {
            ApsProperties config = (null != widget) ? widget.getConfig() : null;
            if (null == config || config.isEmpty()) {
                continue;
            }
            String extracted = config.getProperty("contentId");
            if (null != extracted && contentId.equals(extracted)) {
                found = true;
            } else {
                String contents = config.getProperty("contents");
                List<Properties> properties = (null != contents) ? RowContentListHelper.fromParameterToContents(contents) : null;
                if (null == properties || properties.isEmpty()) {
                    continue;
                }
                for (int j = 0; j < properties.size(); j++) {
                    Properties widgProp = properties.get(j);
                    String extracted2 = widgProp.getProperty("contentId");
                    if (null != extracted2 && contentId.equals(extracted2)) {
                        found = true;
                        break;
                    }
                }
            }
        }
    }
    return found;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 2 with Widget

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

the class RowContentListTag method getContents.

protected List<Properties> getContents(RequestContext reqCtx) throws ApsSystemException {
    List<Properties> contents = null;
    try {
        Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        if (null == currentWidget || null == currentWidget.getConfig()) {
            return new ArrayList<Properties>();
        }
        String widgetConfig = currentWidget.getConfig().getProperty("contents");
        contents = RowContentListHelper.fromParameterToContents(widgetConfig);
        if (StringUtils.isBlank(widgetConfig)) {
            return contents;
        }
    } catch (Throwable t) {
        _logger.error("Error extracting contents", t);
        throw new ApsSystemException("Error extracting contents", t);
    }
    return contents;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ArrayList(java.util.ArrayList) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Properties(java.util.Properties)

Example 3 with Widget

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

the class CmsPageUtil method isDraftFreeViewerPage.

/**
 * Check whether the page can publish free content, related to the draft
 * configuration of the page.
 *
 * @param page
 * 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 isDraftFreeViewerPage(IPage page, String viewerWidgetCode) {
    if (page.isOnlineInstance()) {
        _logger.warn("this check expects a draft instance of the page");
        return false;
    }
    boolean found = false;
    PageMetadata metadata = page.getMetadata();
    Widget[] widgets = page.getWidgets();
    if (metadata != null) {
        found = isFreeViewerPage(metadata.getModel(), widgets, viewerWidgetCode);
    }
    return found;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Widget(com.agiletec.aps.system.services.page.Widget)

Example 4 with Widget

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

the class ContentInfoTag method extractModelId.

private Object extractModelId(PublicContentAuthorizationInfo authInfo, RequestContext reqCtx) {
    Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
    ApsProperties showletConfig = widget.getConfig();
    String modelId = (String) showletConfig.get("modelId");
    if (null == modelId) {
        modelId = reqCtx.getRequest().getParameter("modelId");
    }
    if (null == modelId) {
        IContentManager contentManager = (IContentManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_MANAGER, this.pageContext);
        modelId = contentManager.getDefaultModel(authInfo.getContentId());
    }
    return modelId;
}
Also used : IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 5 with Widget

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

the class PageService method getWidgetConfiguration.

@Override
public WidgetConfigurationDto getWidgetConfiguration(String pageCode, int frameId, String status) {
    IPage page = this.loadPage(pageCode, status);
    if (null == page) {
        throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
    }
    if (frameId > page.getWidgets().length) {
        throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
    }
    Widget widget = page.getWidgets()[frameId];
    if (null == widget) {
        return null;
    }
    return new WidgetConfigurationDto(widget);
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) IPage(com.agiletec.aps.system.services.page.IPage) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) Widget(com.agiletec.aps.system.services.page.Widget)

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