Search in sources :

Example 51 with ApsProperties

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

the class PageDAO method createPageMetadata.

protected PageMetadata createPageMetadata(String code, ResultSet res, int startIndex) throws Throwable {
    PageMetadata pageMetadata = new PageMetadata();
    int index = startIndex;
    String titleText = res.getString(index++);
    ApsProperties titles = new ApsProperties();
    try {
        titles.loadFromXml(titleText);
    } catch (Throwable t) {
        _logger.error("IO error detected while parsing the titles of the page {}", code, t);
        String msg = "IO error detected while parsing the titles of the page '" + code + "'";
        throw new ApsSystemException(msg, t);
    }
    pageMetadata.setTitles(titles);
    pageMetadata.setModel(this.getPageModelManager().getPageModel(res.getString(index++)));
    Integer showable = res.getInt(index++);
    pageMetadata.setShowable(showable == 1);
    String extraConfig = res.getString(index++);
    if (null != extraConfig && extraConfig.trim().length() > 0) {
        try {
            PageExtraConfigDOM configDom = new PageExtraConfigDOM();
            configDom.addExtraConfig(pageMetadata, extraConfig);
        } catch (Throwable t) {
            _logger.error("IO error detected while parsing the extra config of the page {}", code, t);
            String msg = "IO error detected while parsing the extra config of the page '" + code + "'";
            throw new ApsSystemException(msg, t);
        }
    }
    Timestamp date = res.getTimestamp(index++);
    pageMetadata.setUpdatedAt(date != null ? new Date(date.getTime()) : null);
    return pageMetadata;
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Timestamp(java.sql.Timestamp) Date(java.util.Date) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 52 with ApsProperties

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

the class PageMetadata method clone.

@Override
public PageMetadata clone() throws CloneNotSupportedException {
    PageMetadata copy = null;
    try {
        copy = this.getClass().newInstance();
        ApsProperties titles = new ApsProperties();
        titles.putAll(this.getTitles());
        copy.setTitles(titles);
        Set<String> extraGroups = this.getExtraGroups();
        if (extraGroups != null) {
            copy.setExtraGroups(new TreeSet<String>(extraGroups));
        }
        copy.setModel(this.getModel());
        copy.setShowable(this.isShowable());
        copy.setUseExtraTitles(this.isUseExtraTitles());
        copy.setMimeType(this.getMimeType());
        copy.setCharset(this.getCharset());
        copy.setUpdatedAt(this.getUpdatedAt());
    } catch (Throwable t) {
        logger.error("Error cloning {}" + this.getClass(), t);
        throw new RuntimeException("Error cloning " + this.getClass(), t);
    }
    return copy;
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 53 with ApsProperties

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

the class PageModelDOM method buildDefaultWidget.

private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
    Widget widget = new Widget();
    String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
    WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
    if (null == type) {
        _logger.error("Unknown code of the default widget - '{}'", widgetCode);
        return;
    }
    widget.setType(type);
    Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
    if (null != propertiesElement) {
        ApsProperties prop = this.buildProperties(propertiesElement);
        widget.setConfig(prop);
    }
    // else {
    // widget.setConfig(new ApsProperties());
    // }
    frame.setDefaultWidget(widget);
}
Also used : Element(org.jdom.Element) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 54 with ApsProperties

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

the class PageWithWidgetTag method filterByConfigParamValue.

protected List<IPage> filterByConfigParamValue(List<IPage> pages) {
    List<IPage> filteredPages = new ArrayList<IPage>();
    Iterator<IPage> it = pages.iterator();
    while (it.hasNext()) {
        IPage currentPage = it.next();
        Widget[] widgets = currentPage.getWidgets();
        if (widgets != null) {
            for (Widget currentWidget : widgets) {
                if (null != currentWidget && currentWidget.getType().getCode().equals(this.getWidgetTypeCode())) {
                    ApsProperties config = currentWidget.getConfig();
                    if (null != config) {
                        String value = config.getProperty(this.getFilterParamName());
                        if (StringUtils.isNotBlank(value) && value.equals(this.getFilterParamValue())) {
                            filteredPages.add(currentPage);
                        }
                    }
                }
            }
        }
    }
    return filteredPages;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) ArrayList(java.util.ArrayList) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 55 with ApsProperties

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

the class ApiServiceAction method checkParameters.

private void checkParameters() {
    try {
        this.setApiParameterValues(new ApsProperties());
        ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
        List<ApiMethodParameter> apiParameters = masterMethod.getParameters();
        if (null == apiParameters) {
            return;
        }
        this.extractFreeParameters(apiParameters);
        this.setApiParameters(apiParameters);
        for (int i = 0; i < apiParameters.size(); i++) {
            ApiMethodParameter apiParameter = apiParameters.get(i);
            String fieldName = apiParameter.getKey() + "_apiParam";
            String value = this.getRequest().getParameter(fieldName);
            if (null != value && value.trim().length() > 0) {
                this.getApiParameterValues().put(apiParameter.getKey(), value);
            }
            boolean isFreeParameter = (null != this.getFreeParameters()) ? this.getFreeParameters().contains(apiParameter.getKey()) : false;
            if (apiParameter.isRequired() && (null == value || value.trim().length() == 0) && !isFreeParameter) {
                this.addFieldError(fieldName, this.getText("error.service.parameter.invalidSetting", new String[] { apiParameter.getKey(), apiParameter.getDescription() }));
            }
        }
    } catch (Throwable t) {
        _logger.error("Error checking parameters", t);
        throw new RuntimeException("Error checking parameters", t);
    }
}
Also used : ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) ApiMethodParameter(org.entando.entando.aps.system.services.api.model.ApiMethodParameter) 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