Search in sources :

Example 76 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class CmsHypertextAttribute method getReferences.

@Override
public List<CmsAttributeReference> getReferences(List<Lang> systemLangs) {
    List<CmsAttributeReference> refs = new ArrayList<>();
    for (Lang lang : systemLangs) {
        String text = this.getTextMap().get(lang.getCode());
        List<SymbolicLink> links = HypertextAttributeUtil.getSymbolicLinksOnText(text);
        if (null != links && !links.isEmpty()) {
            for (SymbolicLink symbLink : links) {
                if (symbLink.getDestType() != SymbolicLink.URL_TYPE) {
                    CmsAttributeReference ref = new CmsAttributeReference(symbLink.getPageDest(), symbLink.getContentDest(), symbLink.getResourceDest());
                    refs.add(ref);
                }
            }
        }
    }
    return refs;
}
Also used : ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 77 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class ContentListHelper method getConfiguredUserFilters.

@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IContentListTagBean 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 contentTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
        IApsEntity prototype = this.getContentManager().getEntityPrototype(contentTypeCode);
        if (null == prototype) {
            _logger.error("Null content type by code '{}'", contentTypeCode);
            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)

Example 78 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class ContentListHelper method buildCacheKey.

protected static String buildCacheKey(String listName, Collection<String> userGroupCodes, RequestContext reqCtx) {
    IPage page = (null != reqCtx) ? (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE) : null;
    StringBuilder cacheKey = (null != page) ? new StringBuilder(page.getCode()) : new StringBuilder("NOTFOUND");
    Widget currentWidget = (null != reqCtx) ? (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET) : null;
    if (null != currentWidget && null != currentWidget.getType()) {
        cacheKey.append("_").append(currentWidget.getType().getCode());
    }
    if (null != reqCtx) {
        Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        if (null != frame) {
            cacheKey.append("_").append(frame.intValue());
        }
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        if (null != currentLang) {
            cacheKey.append("_LANG").append(currentLang.getCode()).append("_");
        }
    }
    List<String> groupCodes = new ArrayList<String>(userGroupCodes);
    if (!groupCodes.contains(Group.FREE_GROUP_NAME)) {
        groupCodes.add(Group.FREE_GROUP_NAME);
    }
    Collections.sort(groupCodes);
    for (String code : groupCodes) {
        cacheKey.append("_").append(code);
    }
    if (null != currentWidget && null != currentWidget.getConfig()) {
        List<String> paramKeys = new ArrayList(currentWidget.getConfig().keySet());
        Collections.sort(paramKeys);
        for (int i = 0; i < paramKeys.size(); i++) {
            if (i == 0) {
                cacheKey.append("_WIDGETPARAM");
            } else {
                cacheKey.append(",");
            }
            String paramkey = (String) paramKeys.get(i);
            cacheKey.append(paramkey).append("=").append(currentWidget.getConfig().getProperty(paramkey));
        }
    }
    if (null != listName) {
        cacheKey.append("_LISTNAME").append(listName);
    }
    return cacheKey.toString();
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 79 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class ContentViewerHelper method getRenderizationInfo.

@Override
public ContentRenderizationInfo getRenderizationInfo(String contentId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    ContentRenderizationInfo 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();
        contentId = this.extractContentId(contentId, widgetConfig, reqCtx);
        modelId = this.extractModelId(contentId, modelId, widgetConfig, reqCtx);
        if (contentId != null && modelId != null) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx, true);
            if (null == renderizationInfo) {
                _logger.info("Null Renderization informations: content={}", contentId);
                return null;
            }
            this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
            this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
        } else {
            _logger.warn("Parametri visualizzazione contenuto incompleti: " + "contenuto={} modello={}", contentId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting renderization info", t);
        throw new ApsSystemException("Error extracting renderization info", t);
    }
    return renderizationInfo;
}
Also used : ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) 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 80 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class FilterUtils method getUserFilter.

public UserFilterOptionBean getUserFilter(String contentType, IEntityFilterBean bean, IContentManager contentManager, String dateFormat, RequestContext reqCtx) {
    UserFilterOptionBean filter = null;
    try {
        IApsEntity prototype = contentManager.createContentType(contentType);
        Properties props = new Properties();
        props.setProperty(UserFilterOptionBean.PARAM_KEY, bean.getKey());
        props.setProperty(UserFilterOptionBean.PARAM_IS_ATTRIBUTE_FILTER, String.valueOf(bean.isAttributeFilter()));
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        filter = new UserFilterOptionBean(props, prototype, currentFrame, currentLang, dateFormat, reqCtx.getRequest());
    } catch (Throwable t) {
        _logger.error("Error creating user filter", t);
    // ApsSystemUtils.logThrowable(t, FilterUtils.class, "getUserFilter", "Error creating user filter");
    }
    return filter;
}
Also used : UserFilterOptionBean(com.agiletec.plugins.jacms.aps.system.services.content.widget.UserFilterOptionBean) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4