Search in sources :

Example 1 with ConfigInterface

use of com.agiletec.aps.system.services.baseconfig.ConfigInterface in project entando-core by entando.

the class InfoTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    try {
        if ("startLang".equals(this._key)) {
            Lang startLang = this.extractStartLang();
            this._info = startLang.getCode();
        } else if ("defaultLang".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getDefaultLang().getCode();
        } else if ("currentLang".equals(this._key)) {
            RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
            Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
            this._info = currentLang.getCode();
        } else if ("langs".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getLangs();
        } else if ("systemParam".equals(this._key)) {
            if (SystemConstants.PAR_APPL_BASE_URL.equals(this.getParamName())) {
                IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
                this._info = urlManager.getApplicationBaseURL((HttpServletRequest) request);
            } else {
                ConfigInterface confManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, this.pageContext);
                this._info = confManager.getParam(this.getParamName());
            }
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) IURLManager(com.agiletec.aps.system.services.url.IURLManager) Lang(com.agiletec.aps.system.services.lang.Lang) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) RequestContext(com.agiletec.aps.system.RequestContext)

Example 2 with ConfigInterface

use of com.agiletec.aps.system.services.baseconfig.ConfigInterface in project entando-core by entando.

the class InfoTag method extractStartLang.

private Lang extractStartLang() {
    Lang startLang = null;
    ConfigInterface baseConfigManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, this.pageContext);
    ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
    try {
        String startLangFromBrowser = baseConfigManager.getParam(SystemConstants.CONFIG_PARAM_START_LANG_FROM_BROWSER);
        if (null != startLangFromBrowser && startLangFromBrowser.equalsIgnoreCase("true")) {
            ServletRequest request = this.pageContext.getRequest();
            if (request instanceof HttpServletRequest) {
                String headerLang = ((HttpServletRequest) request).getHeader("Accept-Language");
                if (null != headerLang && headerLang.length() >= 2) {
                    String langCode = headerLang.substring(0, 2);
                    startLang = langManager.getLang(langCode);
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error extracting start lang", t);
    } finally {
        if (null == startLang) {
            startLang = langManager.getDefaultLang();
        }
    }
    return startLang;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface)

Example 3 with ConfigInterface

use of com.agiletec.aps.system.services.baseconfig.ConfigInterface in project entando-core by entando.

the class ApsFileUploadInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    if (null == super.maximumSize || super.maximumSize == 0) {
        ConfigInterface configManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, ServletActionContext.getRequest());
        String maxSizeParam = configManager.getParam(SystemConstants.PAR_FILEUPLOAD_MAXSIZE);
        if (null != maxSizeParam) {
            try {
                this.setMaximumSize(Long.parseLong(maxSizeParam));
            } catch (Throwable t) {
                _logger.error("Error parsing param 'maxSize' - value '{}' - message ", maxSizeParam, t);
            }
        }
    }
    if (null == super.maximumSize || super.maximumSize == 0) {
        this.setMaximumSize(DEFAULT_MAX_SIZE);
    }
    return super.intercept(invocation);
}
Also used : ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface)

Example 4 with ConfigInterface

use of com.agiletec.aps.system.services.baseconfig.ConfigInterface in project entando-core by entando.

the class TestApplicationContext method testGetServices.

public void testGetServices() {
    ConfigInterface configManager = (ConfigInterface) this.getService(SystemConstants.BASE_CONFIG_MANAGER);
    assertNotNull(configManager);
    ICacheInfoManager cacheInfoManager = (ICacheInfoManager) this.getService(SystemConstants.CACHE_INFO_MANAGER);
    assertNotNull(cacheInfoManager);
    ILangManager langManager = (ILangManager) this.getService(SystemConstants.LANGUAGE_MANAGER);
    assertNotNull(langManager);
    IWidgetTypeManager showletTypeManager = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
    assertNotNull(showletTypeManager);
    IPageModelManager pageModelManager = (IPageModelManager) this.getService(SystemConstants.PAGE_MODEL_MANAGER);
    assertNotNull(pageModelManager);
    IPageManager pageManager = (IPageManager) this.getService(SystemConstants.PAGE_MANAGER);
    assertNotNull(pageManager);
    IRoleManager roleManager = (IRoleManager) this.getService(SystemConstants.ROLE_MANAGER);
    assertNotNull(roleManager);
    IUserManager userManager = (IUserManager) this.getService(SystemConstants.USER_MANAGER);
    assertNotNull(userManager);
    IURLManager urlManager = (IURLManager) this.getService(SystemConstants.URL_MANAGER);
    assertNotNull(urlManager);
    II18nManager i18nManager = (II18nManager) this.getService(SystemConstants.I18N_MANAGER);
    assertNotNull(i18nManager);
    // ControllerManager controller = (ControllerManager) this.getService(SystemConstants.CONTROLLER_MANAGER);
    // assertNotNull(controller);
    IKeyGeneratorManager keyGeneratorManager = (IKeyGeneratorManager) this.getService(SystemConstants.KEY_GENERATOR_MANAGER);
    assertNotNull(keyGeneratorManager);
    ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
    assertNotNull(categoryManager);
}
Also used : IPageManager(com.agiletec.aps.system.services.page.IPageManager) ICacheInfoManager(org.entando.entando.aps.system.services.cache.ICacheInfoManager) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) IUserManager(com.agiletec.aps.system.services.user.IUserManager) IRoleManager(com.agiletec.aps.system.services.role.IRoleManager) IURLManager(com.agiletec.aps.system.services.url.IURLManager) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) IKeyGeneratorManager(com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager) II18nManager(com.agiletec.aps.system.services.i18n.II18nManager) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 5 with ConfigInterface

use of com.agiletec.aps.system.services.baseconfig.ConfigInterface in project entando-core by entando.

the class ResourceURLTag method doEndTag.

public int doEndTag() throws JspException {
    try {
        if (null == _root) {
            ConfigInterface configService = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, this.pageContext);
            _root = configService.getParam(SystemConstants.PAR_RESOURCES_ROOT_URL);
        }
        if (null == _folder) {
            _folder = "";
        }
        pageContext.getOut().print(_root + _folder);
    } catch (Throwable t) {
        _logger.error("Error closing the tag", t);
        // ApsSystemUtils.logThrowable(t, this, "doEndTag");
        throw new JspException("Error closing the tag", t);
    }
    return EVAL_PAGE;
}
Also used : JspException(javax.servlet.jsp.JspException) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface)

Aggregations

ConfigInterface (com.agiletec.aps.system.services.baseconfig.ConfigInterface)5 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)3 Lang (com.agiletec.aps.system.services.lang.Lang)2 IURLManager (com.agiletec.aps.system.services.url.IURLManager)2 ServletRequest (javax.servlet.ServletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 RequestContext (com.agiletec.aps.system.RequestContext)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 IUserManager (com.agiletec.aps.system.services.user.IUserManager)1 ICacheInfoManager (org.entando.entando.aps.system.services.cache.ICacheInfoManager)1 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)1