2121
2222import java .io .IOException ;
2323import java .util .Date ;
24- import java .util .HashSet ;
25- import java .util .Set ;
2624
2725import javax .servlet .http .HttpServletRequest ;
2826import javax .servlet .http .HttpServletResponse ;
@@ -67,7 +65,16 @@ public void launchSurveyRun(@PathVariable String code, HttpServletResponse respo
6765 Projectcode projectCode = new Projectcode (code .replaceAll ("\\ +\\ +" , " " ));
6866 Run run = runService .retrieveRunByRuncode (projectCode .getRuncode ());
6967 if (run .getIsSurvey ()) {
70- if (!SecurityContextHolder .getContext ().getAuthentication ().getPrincipal ().equals ("anonymousUser" )) { // Already signed in
68+ handleSurveyLaunched (response , request , run , projectCode );
69+ } else {
70+ response .sendRedirect ("/" );
71+ }
72+ }
73+
74+ private void handleSurveyLaunched (HttpServletResponse response , HttpServletRequest request , Run run , Projectcode projectCode )
75+ throws AuthorityNotFoundException , IOException , DuplicateUsernameException , ObjectNotFoundException ,
76+ PeriodNotFoundException , StudentUserAlreadyAssociatedWithRunException , RunHasEndedException {
77+ if (userAlreadySignedIn ()) {
7178 response .sendRedirect ("/survey/logout" );
7279 } else if (underWorkgroupLimit (run )) {
7380 User user = this .createNewStudentAccount ();
@@ -77,9 +84,10 @@ public void launchSurveyRun(@PathVariable String code, HttpServletResponse respo
7784 } else {
7885 response .sendRedirect ("/survey/workgroupLimitReached" );
7986 }
80- } else {
81- response .sendRedirect ("/" );
82- }
87+ }
88+
89+ private Boolean userAlreadySignedIn () {
90+ return !SecurityContextHolder .getContext ().getAuthentication ().getPrincipal ().equals ("anonymousUser" );
8391 }
8492
8593 private Boolean underWorkgroupLimit (Run run ) {
0 commit comments