From 8b9a25a09ca66e4c43b1690414a05fd04908585c Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 3 Dec 2012 12:42:01 +0000 Subject: [PATCH] Fixed bug: after trying to search and found nothing do login/logout and then crash. --- .../src/org/splat/simer/ConnectionAction.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Workspace/Siman/src/org/splat/simer/ConnectionAction.java b/Workspace/Siman/src/org/splat/simer/ConnectionAction.java index ad7b060..ea56286 100644 --- a/Workspace/Siman/src/org/splat/simer/ConnectionAction.java +++ b/Workspace/Siman/src/org/splat/simer/ConnectionAction.java @@ -11,11 +11,13 @@ import javax.security.auth.callback.NameCallback; import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.TextOutputCallback; import javax.security.auth.callback.UnsupportedCallbackException; +import javax.security.auth.login.AccountNotFoundException; import javax.security.auth.login.FailedLoginException; import javax.security.auth.login.LoginContext; import org.splat.dal.bo.kernel.User; import org.splat.som.ApplicationRights; +import org.splat.wapp.Constants; /** * User login action. @@ -100,7 +102,7 @@ public class ConnectionAction extends Action { Subject identity = context.getSubject(); Set table = identity.getPrincipals(User.class); if (table.isEmpty()) { - throw new Exception(); + throw new AccountNotFoundException(); } User user = table.iterator().next(); // The user is (apparently...) the 1st principal @@ -112,18 +114,24 @@ public class ConnectionAction extends Action { Map sfilter = (Map) session .get("study.filter"); - sfilter.put("state", "ANY"); - sfilter.put("visibility", "PRIVATE"); - if (logged.canCreateStudy()) { - sfilter.put("author", String.valueOf(user.getIndex())); + if (sfilter != null) { + sfilter.put("state", "ANY"); + sfilter.put("visibility", "PRIVATE"); + if (logged.canCreateStudy()) { + sfilter.put("author", String.valueOf(user + .getIndex())); + } } } this.connect(context, user); // Updates the session context - setMenuProperty("none"); + setMenuProperty(Constants.NONE); initializationScreenContext(_menuProperty); res = _backmenu; + if (res == null || "null".equals(res)) { + res = Constants.NONE; + } } catch (FailedLoginException error) { setErrorCode("message.error.login." + error.getMessage()); res = INPUT; @@ -169,10 +177,13 @@ public class ConnectionAction extends Action { this.disconnect(); // Updates the session context - setMenuProperty("none"); + setMenuProperty(Constants.NONE); initializationScreenContext(_menuProperty); res = _backmenu; + if (res == null || "null".equals(res)) { + res = Constants.NONE; + } } catch (Exception error) { LOG.error("Reason:", error); res = ERROR; -- 2.39.2