Search in sources :

Example 11 with ILangManager

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

the class TestWidgetTypeDAO method testLoadWidgetTypes.

public void testLoadWidgetTypes() throws Throwable {
    DataSource dataSource = (DataSource) this.getApplicationContext().getBean("portDataSource");
    WidgetTypeDAO widgetTypeDao = new WidgetTypeDAO();
    widgetTypeDao.setDataSource(dataSource);
    ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
    widgetTypeDao.setLangManager(langManager);
    Map<String, WidgetType> types = null;
    try {
        types = widgetTypeDao.loadWidgetTypes();
    } catch (Throwable t) {
        throw t;
    }
    WidgetType showletType = (WidgetType) types.get("content_viewer");
    assertNotNull(showletType);
    showletType = (WidgetType) types.get("content_viewer_list");
    assertNotNull(showletType);
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) WidgetTypeDAO(org.entando.entando.aps.system.services.widgettype.WidgetTypeDAO) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) DataSource(javax.sql.DataSource)

Example 12 with ILangManager

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

the class TestContentDAO method init.

private void init() throws Exception {
    this._contentDao = new ContentDAO();
    try {
        this._contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
        Content mockContent = this.getMockContent();
        DataSource dataSource = (DataSource) this.getApplicationContext().getBean("portDataSource");
        this._contentDao.setDataSource(dataSource);
        ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
        this._contentDao.setLangManager(langManager);
        this._contentDao.addEntity(mockContent);
    } catch (Throwable e) {
        throw new Exception(e);
    }
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataSource(javax.sql.DataSource)

Example 13 with ILangManager

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

the class ContentListTag method addMultilanguageWidgetParameter.

protected void addMultilanguageWidgetParameter(ApsProperties config, String widgetParamPrefix, Lang currentLang, String var) {
    if (null == var || null == config)
        return;
    String paramValue = config.getProperty(widgetParamPrefix + "_" + currentLang.getCode());
    if (null == paramValue) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
        Lang defaultLang = langManager.getDefaultLang();
        paramValue = config.getProperty(widgetParamPrefix + "_" + defaultLang.getCode());
    }
    if (null != paramValue) {
        this.pageContext.setAttribute(var, paramValue);
    }
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 14 with ILangManager

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

the class CurrentPageTag method extractPageTitleFromExtraTitles.

private void extractPageTitleFromExtraTitles(IPage page, Lang currentLang, Map extraTitlesMap) {
    Object value = null;
    if ((this.getLangCode() == null) || (this.getLangCode().equals("")) || (currentLang.getCode().equalsIgnoreCase(this.getLangCode()))) {
        value = extraTitlesMap.get(currentLang.getCode());
    } else {
        value = extraTitlesMap.get(this.getLangCode());
    }
    if (value == null || value.toString().trim().equals("")) {
        ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
        value = extraTitlesMap.get(langManager.getDefaultLang().getCode());
    }
    if (null != value && value.toString().trim().length() > 0) {
        this.setValue(value.toString());
    }
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager)

Example 15 with ILangManager

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

the class I18nTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    RequestContext reqCtx = (RequestContext) this.pageContext.getRequest().getAttribute(RequestContext.REQCTX);
    try {
        Lang currentLang = null;
        if (reqCtx != null) {
            currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        } else {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            currentLang = langManager.getDefaultLang();
        }
        String label = this.extractLabel(currentLang);
        if (this._varName != null) {
            this.pageContext.setAttribute(this._varName, label);
        } else {
            if (this.getEscapeXml()) {
                out(this.pageContext, this.getEscapeXml(), label);
            } else {
                this.pageContext.getOut().print(label);
            }
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return super.doStartTag();
}
Also used : JspException(javax.servlet.jsp.JspException) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

ILangManager (com.agiletec.aps.system.services.lang.ILangManager)17 Lang (com.agiletec.aps.system.services.lang.Lang)8 RequestContext (com.agiletec.aps.system.RequestContext)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 ConfigInterface (com.agiletec.aps.system.services.baseconfig.ConfigInterface)3 ServletRequest (javax.servlet.ServletRequest)3 DataSource (javax.sql.DataSource)3 IURLManager (com.agiletec.aps.system.services.url.IURLManager)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)2 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)1 CompositeAttribute (com.agiletec.aps.system.common.entity.model.attribute.CompositeAttribute)1 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)1 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)1 II18nManager (com.agiletec.aps.system.services.i18n.II18nManager)1 IKeyGeneratorManager (com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)1 IRoleManager (com.agiletec.aps.system.services.role.IRoleManager)1