use of com.agiletec.aps.system.services.lang.Lang 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.lang.Lang in project entando-core by entando.
the class CurrentUserProfileAction method addLabelGroups.
protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
try {
ApsProperties properties = new ApsProperties();
Lang defaultLang = super.getLangManager().getDefaultLang();
properties.put(defaultLang.getCode(), defaultValue);
this.getI18nManager().addLabelGroup(key, properties);
} catch (Throwable t) {
_logger.error("Error adding label groups - key '{}'", key, t);
// ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class DataObjectActionHelper method createActivityStreamInfo.
@Override
public ActivityStreamInfo createActivityStreamInfo(DataObject dataobject, int strutsAction, boolean addLink) {
ActivityStreamInfo asi = new ActivityStreamInfo();
asi.setActionType(strutsAction);
Lang defaultLang = this.getLangManager().getDefaultLang();
Properties titles = new Properties();
titles.setProperty(defaultLang.getCode(), (null != dataobject.getDescription()) ? dataobject.getDescription() : "-");
asi.setObjectTitles(titles);
if (addLink) {
asi.setLinkNamespace("/do/dataobject");
asi.setLinkActionName("edit");
asi.addLinkParameter("dataId", dataobject.getId());
asi.setLinkAuthGroup(dataobject.getMainGroup());
asi.setLinkAuthPermission(Permission.CONTENT_EDITOR);
}
List<String> groupCodes = new ArrayList<String>();
if (null != dataobject.getMainGroup()) {
groupCodes.addAll(dataobject.getGroups());
}
groupCodes.add(dataobject.getMainGroup());
asi.setGroups(groupCodes);
return asi;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentListViewerWidgetAction method validateTitle.
protected void validateTitle() {
String titleParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_TITLE + "_";
if (this.isMultilanguageParamValued(titleParamPrefix)) {
Lang defaultLang = this.getLangManager().getDefaultLang();
String defaultTitleParam = titleParamPrefix + defaultLang.getCode();
String defaultTitle = this.getWidget().getConfig().getProperty(defaultTitleParam);
if (defaultTitle == null || defaultTitle.length() == 0) {
String[] args = { defaultLang.getDescr() };
this.addFieldError(defaultTitleParam, this.getText("error.widget.listViewer.defaultLangTitle.required", args));
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class AbstractMultiLangAttributeManager method updateAttribute.
@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
List<Lang> langs = this.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang currentLang = langs.get(i);
tracer.setLang(currentLang);
String value = this.getValueFromForm(attribute, tracer, request);
// TODO PAY ATTENTION TO THIS CHECK
if (value != null) {
if (value.trim().length() == 0) {
value = null;
}
this.setValue(attribute, currentLang, value);
}
}
}
Aggregations