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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations