Search in sources :

Example 21 with ApsProperties

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

the class ApiI18nLabelInterface method updateInlineLabel.

public void updateInlineLabel(JAXBI18nLabel jaxbI18nLabel) throws ApiException {
    try {
        this.checkLabels(jaxbI18nLabel);
        String key = jaxbI18nLabel.getKey();
        ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
        _logger.info("KEY ->  {} ", key);
        boolean isEdit = (null != labelGroups);
        if (!isEdit) {
            labelGroups = new ApsProperties();
        } else {
        // 
        }
        ApsProperties labels = jaxbI18nLabel.extractLabels();
        Iterator<Object> iterator = labels.keySet().iterator();
        while (iterator.hasNext()) {
            Object langKey = iterator.next();
            labelGroups.put(langKey, labels.get(langKey));
        }
        if (isEdit) {
            this.getI18nManager().updateLabelGroup(key, labelGroups);
            _logger.info("*** EDIT DONE *** -> {}", labelGroups);
        } else {
            this.getI18nManager().addLabelGroup(key, labelGroups);
            _logger.info("*** ADD DONE *** -> {}", labelGroups);
        }
    } catch (ApiException | ApsSystemException t) {
        _logger.error("Error updating label {} ", t);
        throw new ApiException("Error updating labels", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 22 with ApsProperties

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

the class ApiI18nLabelInterface method checkLabels.

protected void checkLabels(JAXBI18nLabel jaxbI18nLabel) throws ApiException {
    try {
        String key = jaxbI18nLabel.getKey();
        if (null == key || key.trim().length() == 0) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label key required", Response.Status.CONFLICT);
        }
        ApsProperties labels = jaxbI18nLabel.extractLabels();
        if (null == labels || labels.isEmpty()) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label list can't be empty", Response.Status.CONFLICT);
        }
        Iterator<Object> labelCodeIter = labels.keySet().iterator();
        while (labelCodeIter.hasNext()) {
            Object langCode = labelCodeIter.next();
            Object value = labels.get(langCode);
            if (null == value || value.toString().trim().length() == 0) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label for the language '" + langCode + "' is empty", Response.Status.CONFLICT);
            }
        }
    } catch (ApiException ae) {
        _logger.error("Error method checkLabels ", ae);
        throw new ApiException("Error method checkLabels", ae);
    }
}
Also used : ApiException(org.entando.entando.aps.system.services.api.model.ApiException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 23 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.warn("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);
    }
    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 24 with ApsProperties

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

the class DataObjectViewerHelper method getRenderizationInfo.

@Override
public DataObjectRenderizationInfo getRenderizationInfo(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    DataObjectRenderizationInfo renderizationInfo = null;
    try {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties widgetConfig = widget.getConfig();
        dataobjectId = this.extractDataId(dataobjectId, widgetConfig, reqCtx);
        modelId = this.extractModelId(dataobjectId, modelId, widgetConfig, reqCtx);
        if (dataobjectId != null && modelId != null) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(dataobjectId, longModelId, langCode, reqCtx, true);
            if (null == renderizationInfo) {
                _logger.info("Null Renderization informations: dataobject={}", dataobjectId);
                return null;
            }
            this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
        } else {
            _logger.warn("Parametri visualizzazione dataobject incompleti: dataobject={} modello={}", dataobjectId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting renderization info", t);
        throw new ApsSystemException("Error extracting renderization info", t);
    }
    return renderizationInfo;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 25 with ApsProperties

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

the class DataObjectListHelper method getConfiguredUserFilters.

@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
    List<UserFilterOptionBean> userEntityFilters = null;
    try {
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties config = (null != widget) ? widget.getConfig() : null;
        if (null == config || null == config.getProperty(WIDGET_PARAM_CONTENT_TYPE)) {
            return null;
        }
        String dataObjectTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
        IApsEntity prototype = this.getDataObjectManager().getEntityPrototype(dataObjectTypeCode);
        if (null == prototype) {
            _logger.error("Null dataObject type by code '{}'", dataObjectTypeCode);
            return null;
        }
        Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String userFilters = config.getProperty(WIDGET_PARAM_USER_FILTERS);
        if (null != userFilters && userFilters.length() > 0) {
            userEntityFilters = FilterUtils.getUserFilters(userFilters, currentFrame, currentLang, prototype, this.getUserFilterDateFormat(), reqCtx.getRequest());
        }
    } catch (Throwable t) {
        _logger.error("Error extracting user filters", t);
        throw new ApsSystemException("Error extracting user filters", t);
    }
    return userEntityFilters;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) 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