Search in sources :

Example 11 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class PageAction method addPublishedContents.

protected void addPublishedContents(Widget[] widgets, Collection<Content> contents) {
    try {
        if (widgets != null) {
            for (Widget widget : widgets) {
                ApsProperties config = (null != widget) ? widget.getConfig() : null;
                if (null == config || config.isEmpty()) {
                    continue;
                }
                String extracted = config.getProperty("contentId");
                this.addContent(contents, extracted);
                String contentsParam = config.getProperty("contents");
                List<Properties> properties = (null != contentsParam) ? RowContentListHelper.fromParameterToContents(contentsParam) : 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");
                    this.addContent(contents, extracted2);
                }
            }
        }
    } catch (Throwable t) {
        String msg = "Error extracting published contents on page";
        _logger.error("Error extracting published contents on page", t);
        throw new RuntimeException(msg, t);
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 12 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ContentListViewerWidgetAction method validateFilters.

protected void validateFilters() {
    WidgetType type = this.getWidget().getType();
    ApsProperties config = this.getWidget().getConfig();
    if (null != config && null != type && type.hasParameter("categories") && type.hasParameter("maxElemForItem") && type.hasParameter("maxElements") && StringUtils.isNotEmpty(config.getProperty("contentType")) && StringUtils.isEmpty(config.getProperty("categories")) && StringUtils.isEmpty(config.getProperty("maxElemForItem")) && StringUtils.isEmpty(config.getProperty("maxElements"))) {
        this.addFieldError("categories", this.getText("error.widget.listViewer.parameters.invalid"));
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 13 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ContentListViewerWidgetAction method createValuedShowlet.

@Override
protected void createValuedShowlet() throws Exception {
    try {
        super.createValuedShowlet();
        ApsProperties config = this.getWidget().getConfig();
        this.extractFiltersProperties(config);
        this.extractUserFiltersProperties(config);
        this.extractCategories(config);
    } catch (Throwable t) {
        _logger.error("Error creating user filter", t);
        throw new ApsSystemException("Error creating user filter", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 14 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ContentListViewerWidgetAction method init.

@Override
public String init() {
    try {
        super.init();
        ApsProperties config = this.getWidget().getConfig();
        if (null == config) {
            return SUCCESS;
        }
        this.extractFiltersProperties(config);
        this.extractUserFiltersProperties(config);
        this.extractCategories(config);
    } catch (Throwable t) {
        _logger.error("error in init", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 15 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class PageConfigurationControllerWidgetsIntegrationTest method createPage.

protected Page createPage(String pageCode) {
    IPage parentPage = pageManager.getDraftPage("service");
    PageModel pageModel = parentPage.getMetadata().getModel();
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
    return pageToAdd;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)157 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)35 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)28 HashMap (java.util.HashMap)22 IPage (com.agiletec.aps.system.services.page.IPage)18 Lang (com.agiletec.aps.system.services.lang.Lang)14 Test (org.junit.Test)12 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 Page (com.agiletec.aps.system.services.page.Page)8 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)8 List (java.util.List)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)5