SessionController completed
authorMichael <Michael@Michael-LT.bfh.ch>
Wed, 9 Dec 2015 13:19:11 +0000 (14:19 +0100)
committerMichael <Michael@Michael-LT.bfh.ch>
Wed, 9 Dec 2015 13:19:11 +0000 (14:19 +0100)
src/main/java/ch/bfh/ti/srs/controller/SessionController.java

index 5c3099b..04484d0 100644 (file)
@@ -7,13 +7,12 @@
  */\r
 package ch.bfh.ti.srs.controller;\r
 \r
-import java.rmi.AlreadyBoundException;\r
 import java.util.HashSet;\r
-import java.util.Map;\r
 import java.util.Set;\r
 \r
 import ch.bfh.ti.srs.datahandler.DataHandler;\r
 import ch.bfh.ti.srs.datahandler.DataHandlerForTests;\r
+import ch.bfh.ti.srs.dataschema.Role;\r
 import ch.bfh.ti.srs.dataschema.User;\r
 \r
 public class SessionController {\r
@@ -37,8 +36,6 @@ public class SessionController {
         *         correct.\r
         * @throws Exception\r
         *             no <code>DataHandler</code> set\r
-        * @throws AlreadyBoundException\r
-        *             a <code>User</code> is already logged in\r
         */\r
        public Set<Controller> logIn(String userName, String password) throws Exception {\r
                if (dh == null)\r
@@ -48,7 +45,18 @@ public class SessionController {
                User tempUser = dh.findUser(userName);\r
                if (tempUser != null || tempUser.checkPassword(password)){\r
                        currentUser = tempUser;\r
-                       //TODO: Check for userRoles, add new controller object for each\r
+                       \r
+                       Set<Controller> retSet = new HashSet<Controller>();\r
+                       for (Role role : currentUser.getRoles()) {\r
+                               switch(role){\r
+                                       case User:\r
+                                               retSet.add(new UserController(dh, this));\r
+                                       case ResourceManager:\r
+                                               retSet.add(new ResourceManagerController(dh, this));\r
+                                       case Admin:\r
+                                               \r
+                               }\r
+                       }\r
                }\r
                return controllers;\r
        }\r
@@ -66,7 +74,7 @@ public class SessionController {
                        throw new Exception("No user is logged in");\r
                currentUser = null;\r
                for (Controller controller : controllers) {\r
-                       \r
+                       controller = null;\r
                }\r
                controllers.clear();\r
        }\r