diff --git a/src/main/java/de/thm/arsnova/controller/SessionController.java b/src/main/java/de/thm/arsnova/controller/SessionController.java index 5e8f03fa8d5ce011e6ea3f6807bec97bcac12c75..b54df6d521021fbedeae70ec5365538e732246bf 100644 --- a/src/main/java/de/thm/arsnova/controller/SessionController.java +++ b/src/main/java/de/thm/arsnova/controller/SessionController.java @@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import de.thm.arsnova.connector.model.Course; -import de.thm.arsnova.entities.LoggedIn; import de.thm.arsnova.entities.Session; import de.thm.arsnova.exceptions.UnauthorizedException; import de.thm.arsnova.services.ISessionService; @@ -65,7 +64,7 @@ public class SessionController extends AbstractController { @RequestMapping(value = "/{sessionkey}", method = RequestMethod.GET) public final Session joinSession(@PathVariable final String sessionkey) { - final Session session = sessionService.joinSession(sessionkey); + final Session session = sessionService.getSession(sessionkey); if (! session.getCreator().equals(userService.getCurrentUser().getUsername())) { session.setCreator("NOT VISIBLE TO YOU"); } else { @@ -79,13 +78,6 @@ public class SessionController extends AbstractController { sessionService.deleteSession(sessionkey); } - @DeprecatedApi - @RequestMapping(value = "/{sessionkey}/online", method = RequestMethod.POST) - @ResponseStatus(HttpStatus.CREATED) - public final LoggedIn registerAsOnlineUser(@PathVariable final String sessionkey) { - return sessionService.registerAsOnlineUser(sessionkey); - } - @DeprecatedApi @RequestMapping(value = "/{sessionkey}/activeusercount", method = RequestMethod.GET) public final int countActiveUsers(@PathVariable final String sessionkey) { diff --git a/src/main/java/de/thm/arsnova/services/ISessionService.java b/src/main/java/de/thm/arsnova/services/ISessionService.java index 20e40d828d1b5958df5b0ed50935b496f5853fd3..16faadd4a2c037de8a3a74952fc4f80d38aa20c9 100644 --- a/src/main/java/de/thm/arsnova/services/ISessionService.java +++ b/src/main/java/de/thm/arsnova/services/ISessionService.java @@ -28,7 +28,7 @@ import de.thm.arsnova.entities.LoggedIn; import de.thm.arsnova.entities.Session; public interface ISessionService { - Session joinSession(String keyword); + Session getSession(String keyword); Session saveSession(Session session); @@ -40,8 +40,6 @@ public interface ISessionService { List<Session> getMyVisitedSessions(); - LoggedIn registerAsOnlineUser(String sessionkey); - int countSessions(List<Course> courses); int activeUsers(String sessionkey); diff --git a/src/main/java/de/thm/arsnova/services/SessionService.java b/src/main/java/de/thm/arsnova/services/SessionService.java index d2742c182e907e67e451b35661d7baa360b378c7..a00c4e448ca1776c9e297cb312630e50ee1aab5c 100644 --- a/src/main/java/de/thm/arsnova/services/SessionService.java +++ b/src/main/java/de/thm/arsnova/services/SessionService.java @@ -35,7 +35,6 @@ import org.springframework.stereotype.Service; import de.thm.arsnova.connector.client.ConnectorClient; import de.thm.arsnova.connector.model.Course; import de.thm.arsnova.dao.IDatabaseDao; -import de.thm.arsnova.entities.LoggedIn; import de.thm.arsnova.entities.Question; import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.User; @@ -116,9 +115,7 @@ public class SessionService implements ISessionService { @Override @PreAuthorize("isAuthenticated()") - public final Session joinSession(final String keyword) { - /* HTTP polling solution (legacy) */ - + public final Session getSession(final String keyword) { final User user = userService.getCurrentUser(); final Session session = databaseDao.getSessionFromKeyword(keyword); if (session == null) { @@ -132,10 +129,6 @@ public class SessionService implements ISessionService { } } - userService.addCurrentUserToSessionMap(keyword); - socketIoServer.reportActiveUserCountForSession(keyword); - socketIoServer.reportFeedbackForUserInSession(session, userService.getCurrentUser()); - if (connectorClient != null && session.isCourseSession()) { final String courseid = session.getCourseId(); if (!connectorClient.getMembership(userService.getCurrentUser().getUsername(), courseid).isMember()) { @@ -206,21 +199,6 @@ public class SessionService implements ISessionService { return generateKeyword(); } - @Override - public final LoggedIn registerAsOnlineUser(final String sessionkey) { - /* HTTP polling solution (legacy) */ - - final Session session = this.joinSession(sessionkey); - if (session == null) { - throw new NotFoundException(); - } - if (session.getCreator().equals(userService.getCurrentUser().getUsername())) { - databaseDao.updateSessionOwnerActivity(session); - } - - return databaseDao.registerAsOnlineUser(userService.getCurrentUser(), session); - } - @Override public int countSessions(final List<Course> courses) { final List<Session> sessions = databaseDao.getCourseSessions(courses); diff --git a/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java b/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java index 4860c0746b8a68a0dea2f49d99e1a53371b4c1dc..76ca780e0d21123f0f045dbf599765d6a2c4c4d0 100644 --- a/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java +++ b/src/test/java/de/thm/arsnova/controller/SessionControllerTest.java @@ -147,14 +147,6 @@ public class SessionControllerTest { .andExpect(header().string(AbstractController.X_DEPRECATED_API, "1")); } - @Test - public void testShouldEndInUnauthorizedResult() throws Exception { - setAuthenticated(false, "ptsr00"); - - mockMvc.perform(post("/session/12345678/online").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isUnauthorized()); - } - @Test public void testShouldEndInForbidden() throws Exception { setAuthenticated(true, "ptsr00"); diff --git a/src/test/java/de/thm/arsnova/services/SessionServiceTest.java b/src/test/java/de/thm/arsnova/services/SessionServiceTest.java index 09c07f18580afea478ee913eed35b2b2efb68cd4..d3a7211408197d4f070393ba5464ea86538d369b 100644 --- a/src/test/java/de/thm/arsnova/services/SessionServiceTest.java +++ b/src/test/java/de/thm/arsnova/services/SessionServiceTest.java @@ -103,13 +103,13 @@ public class SessionServiceTest { @Test(expected = NotFoundException.class) public void testShouldNotFindNonExistantSession() { setAuthenticated(true, "ptsr00"); - sessionService.joinSession("00000000"); + sessionService.getSession("00000000"); } @Test(expected = AuthenticationCredentialsNotFoundException.class) public void testShouldNotReturnSessionIfUnauthorized() { setAuthenticated(false, null); - sessionService.joinSession("12345678"); + sessionService.getSession("12345678"); } @Test(expected = AuthenticationCredentialsNotFoundException.class) @@ -126,7 +126,7 @@ public class SessionServiceTest { setAuthenticated(true, "ptsr00"); - assertNull(sessionService.joinSession("11111111")); + assertNull(sessionService.getSession("11111111")); } @Test @@ -140,7 +140,7 @@ public class SessionServiceTest { session.setName("TestSessionX"); session.setShortName("TSX"); sessionService.saveSession(session); - assertNotNull(sessionService.joinSession("11111111")); + assertNotNull(sessionService.getSession("11111111")); } @Test(expected = AccessDeniedException.class)