use of de.tudarmstadt.ukp.clarin.webanno.support.interceptors.GlobalInterceptor in project webanno by webanno.
the class ApplicationPageBase method commonInit.
private void commonInit() {
for (GlobalInterceptor interceptor : interceptorsRegistry.getInterceptors()) {
interceptor.intercept(this);
}
footerItems = new ListModel<>(new ArrayList<>());
footerItemRegistry.getFooterItems().stream().map(c -> c.create("item")).forEach(c -> footerItems.getObject().add(c));
footer = new WebMarkupContainer("footer");
footer.setOutputMarkupId(true);
add(footer);
footer.add(new ListView<Component>("footerItems", footerItems) {
private static final long serialVersionUID = 5912513189482015963L;
{
setReuseItems(true);
}
@Override
protected void populateItem(ListItem<Component> aItem) {
aItem.setOutputMarkupPlaceholderTag(true);
aItem.add(aItem.getModelObject());
}
});
Properties settings = SettingsUtil.getSettings();
// Override locale to be used by application
String locale = settings.getProperty(SettingsUtil.CFG_LOCALE, "en");
switch(locale) {
case "auto":
// Do nothing - locale is picked up from browser
break;
default:
// Override the locale in the session
getSession().setLocale(Locale.forLanguageTag(locale));
break;
}
// Add menubar
try {
Class<? extends Component> menubarClass = getApplication().getMetaData(MENUBAR_CLASS);
if (menubarClass == null) {
menubarClass = MenuBar.class;
}
add(ConstructorUtils.invokeConstructor(menubarClass, "menubar"));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e1) {
throw new RuntimeException(e1);
}
feedbackPanel = new BootstrapFeedbackPanel("feedbackPanel");
feedbackPanel.setOutputMarkupId(true);
feedbackPanel.setFilter((IFeedbackMessageFilter) aMessage -> {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String username = auth != null ? auth.getName() : "SYSTEM";
if (aMessage.isFatal()) {
LOG.error("{}: {}", username, aMessage.getMessage());
} else if (aMessage.isError()) {
LOG.error("{}: {}", username, aMessage.getMessage());
} else if (aMessage.isWarning()) {
LOG.warn("{}: {}", username, aMessage.getMessage());
} else if (aMessage.isInfo()) {
LOG.info("{}: {}", username, aMessage.getMessage());
} else if (aMessage.isDebug()) {
LOG.debug("{}: {}", username, aMessage.getMessage());
}
return true;
});
add(feedbackPanel);
}
Aggregations