Search in sources :

Example 56 with ApsProperties

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

the class ApiServiceAction method newService.

/**
 * Create of new api service.
 *
 * @return The result code.
 */
public String newService() {
    try {
        if (null != this.getResourceCode()) {
            String[] sections = this.getResourceCode().split(":");
            if (sections.length == 2) {
                this.setNamespace(sections[0]);
                this.setResourceName(sections[1]);
            } else {
                this.setResourceName(sections[0]);
            }
        }
        String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
        if (null != check) {
            return check;
        }
        ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
        if (null != this.getWidgetTypeCode() && null != masterMethod.getRelatedWidget()) {
            WidgetType type = this.getWidgetTypeManager().getWidgetType(this.getWidgetTypeCode());
            if (null != type && type.isLogic()) {
                ApsProperties parameters = this.extractParametersFromWidgetProperties(masterMethod.getRelatedWidget(), type.getConfig());
                this.setApiParameterValues(parameters);
            }
        }
        this.setApiParameters(masterMethod.getParameters());
        this.setStrutsAction(ApsAdminSystemConstants.ADD);
        this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
    } catch (Throwable t) {
        _logger.error("error in newService", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 57 with ApsProperties

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

the class CurrentUserProfileAction method addLabelGroups.

protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
    try {
        ApsProperties properties = new ApsProperties();
        Lang defaultLang = super.getLangManager().getDefaultLang();
        properties.put(defaultLang.getCode(), defaultValue);
        this.getI18nManager().addLabelGroup(key, properties);
    } catch (Throwable t) {
        _logger.error("Error adding label groups - key '{}'", key, t);
        // ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
        throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 58 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 59 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 60 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)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)146 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)34 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)29 HashMap (java.util.HashMap)17 IPage (com.agiletec.aps.system.services.page.IPage)16 Lang (com.agiletec.aps.system.services.lang.Lang)14 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 List (java.util.List)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 Page (com.agiletec.aps.system.services.page.Page)6 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6