Search in sources :

Example 1 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 ApsProperties

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

the class RowContentListViewerConfigProcessor method buildConfiguration.

@SuppressWarnings("unchecked")
@Override
public Object buildConfiguration(WidgetConfigurationRequest widget) {
    ApsProperties properties = new ApsProperties();
    List<RowContentListConfigurationEntry> entryList = (List<RowContentListConfigurationEntry>) widget.getProcessInfo().get(WidgetConfigurationValidator.PROCESS_INFO_CONFIG);
    if (null != entryList && !entryList.isEmpty()) {
        StringBuffer sbuffer = new StringBuffer("[");
        List<String> configTokens = entryList.stream().map(i -> i.toCfg()).collect(Collectors.toList());
        sbuffer.append(StringUtils.join(configTokens, ","));
        sbuffer.append("]");
        properties.put("contents", sbuffer.toString());
    }
    return properties;
}
Also used : Properties(java.util.Properties) IOException(java.io.IOException) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties) WidgetConfigurationProcessor(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationProcessor) RowContentListHelper(org.entando.entando.plugins.jacms.aps.system.services.content.widget.RowContentListHelper) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) List(java.util.List) Map(java.util.Map) WidgetConfigurationValidator(org.entando.entando.aps.system.services.widgettype.validators.WidgetConfigurationValidator) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) JsonParseException(com.fasterxml.jackson.core.JsonParseException) List(java.util.List) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 3 with ApsProperties

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

the class RowContentListViewerConfigProcessor method extractConfiguration.

/**
 * try to build the configuration from a complex structure or from a string
 *
 * @param widget
 * @return
 * @throws IOException
 * @throws JsonMappingException
 * @throws JsonParseException
 */
@Override
public ApsProperties extractConfiguration(ApsProperties widgetProperties) {
    List<Properties> props = RowContentListHelper.fromParameterToContents(widgetProperties.getProperty(WIDGET_CONFIG_KEY_CONTENTS));
    Map<String, List<Properties>> map = new HashMap<>();
    map.put(WIDGET_CONFIG_KEY_CONTENTS, props);
    ApsProperties smartProperties = new ApsProperties();
    smartProperties.putAll(map);
    return smartProperties;
}
Also used : HashMap(java.util.HashMap) List(java.util.List) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 4 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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 ApsProperties

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

the class TestContentViewerHelper method init.

private void init() throws Exception {
    try {
        _requestContext = this.getRequestContext();
        Lang lang = new Lang();
        lang.setCode("it");
        lang.setDescr("italiano");
        _requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
        Widget widget = new Widget();
        IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
        WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
        widget.setType(showletType);
        widget.setConfig(new ApsProperties());
        _requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
        this._helper = (IContentViewerHelper) this.getApplicationContext().getBean("jacmsContentViewerHelper");
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) 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