+ @Override
+ public String lockUserAccount (final User user) {
+ // Is the user instance valid and CONFIRMED?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
+ // User account is locked
+ throw new FacesException(new UserStatusLockedException(user));
+ } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
+ // User account is locked
+ throw new FaceletException(new UserStatusUnconfirmedException(user));
+ } else if (this.getUserLockReason() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.userLockReason is null"); //NOI18N
+ } else if (this.getUserLockReason().isEmpty()) {
+ // Empty lock reason
+ throw new IllegalArgumentException("this.userLockReason is empty"); //NOI18N
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB to lock account
+ this.adminUserBean.lockUserAccount(user, this.getUserLockReason(), baseUrl);
+ } catch (final UserStatusLockedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Should go fine at this point, redirect to user profile
+ return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N
+ }
+
+ @Override
+ public String unlockUserAccount (final User user) {
+ // Is the user instance valid and CONFIRMED?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
+ // User account is locked
+ throw new FacesException(new UserStatusConfirmedException(user));
+ } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
+ // User account is locked
+ throw new FaceletException(new UserStatusUnconfirmedException(user));
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB to unlock account
+ this.adminUserBean.unlockUserAccount(user, baseUrl);
+ } catch (final UserStatusConfirmedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Should go fine at this point, redirect to user profile
+ return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N