import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
/**
* A session bean for handling localization/internationalization changes. This
private Locale locale;
@Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("LandingLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
+ public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
// event should not be null
if (null == event) {
// Throw NPE
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
}
- // Set locale here
- this.setLocale(event.getLoggedInUser().getUserLocale());
+ // Is the locale set?
+ if (event.getLoggedInUser().getUserLocale() instanceof Locale) {
+ // Set locale here
+ this.setLocale(event.getLoggedInUser().getUserLocale());
+ }
+ }
+
+ @Override
+ public void afterUserLogoutEvent (@Observes final ObserveableUserLogoutEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLoggedOutUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.loggedOutUser is null"); //NOI18N
+ } else if (event.getLoggedOutUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.loggedOutUser.userId is null"); //NOI18N
+ } else if (event.getLoggedOutUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedOutUser(), event.getLoggedOutUser().getUserId())); //NOI18N
+ }
// Trace message
//* NOISY-DEBUG: */ System.out.println("LandingLocalizationSessionBean:afterUserLogin - EXIT!"); //NOI18N