Skip to content
Snippets Groups Projects
Commit 890f49af authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Remove session joining via HTTP and online ping

parent b4dece4c
Branches
Tags
No related merge requests found
...@@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; ...@@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import de.thm.arsnova.connector.model.Course; import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.entities.LoggedIn;
import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.Session;
import de.thm.arsnova.exceptions.UnauthorizedException; import de.thm.arsnova.exceptions.UnauthorizedException;
import de.thm.arsnova.services.ISessionService; import de.thm.arsnova.services.ISessionService;
...@@ -65,7 +64,7 @@ public class SessionController extends AbstractController { ...@@ -65,7 +64,7 @@ public class SessionController extends AbstractController {
@RequestMapping(value = "/{sessionkey}", method = RequestMethod.GET) @RequestMapping(value = "/{sessionkey}", method = RequestMethod.GET)
public final Session joinSession(@PathVariable final String sessionkey) { 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())) { if (! session.getCreator().equals(userService.getCurrentUser().getUsername())) {
session.setCreator("NOT VISIBLE TO YOU"); session.setCreator("NOT VISIBLE TO YOU");
} else { } else {
...@@ -79,13 +78,6 @@ public class SessionController extends AbstractController { ...@@ -79,13 +78,6 @@ public class SessionController extends AbstractController {
sessionService.deleteSession(sessionkey); 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 @DeprecatedApi
@RequestMapping(value = "/{sessionkey}/activeusercount", method = RequestMethod.GET) @RequestMapping(value = "/{sessionkey}/activeusercount", method = RequestMethod.GET)
public final int countActiveUsers(@PathVariable final String sessionkey) { public final int countActiveUsers(@PathVariable final String sessionkey) {
......
...@@ -28,7 +28,7 @@ import de.thm.arsnova.entities.LoggedIn; ...@@ -28,7 +28,7 @@ import de.thm.arsnova.entities.LoggedIn;
import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.Session;
public interface ISessionService { public interface ISessionService {
Session joinSession(String keyword); Session getSession(String keyword);
Session saveSession(Session session); Session saveSession(Session session);
...@@ -40,8 +40,6 @@ public interface ISessionService { ...@@ -40,8 +40,6 @@ public interface ISessionService {
List<Session> getMyVisitedSessions(); List<Session> getMyVisitedSessions();
LoggedIn registerAsOnlineUser(String sessionkey);
int countSessions(List<Course> courses); int countSessions(List<Course> courses);
int activeUsers(String sessionkey); int activeUsers(String sessionkey);
......
...@@ -35,7 +35,6 @@ import org.springframework.stereotype.Service; ...@@ -35,7 +35,6 @@ import org.springframework.stereotype.Service;
import de.thm.arsnova.connector.client.ConnectorClient; import de.thm.arsnova.connector.client.ConnectorClient;
import de.thm.arsnova.connector.model.Course; import de.thm.arsnova.connector.model.Course;
import de.thm.arsnova.dao.IDatabaseDao; import de.thm.arsnova.dao.IDatabaseDao;
import de.thm.arsnova.entities.LoggedIn;
import de.thm.arsnova.entities.Question; import de.thm.arsnova.entities.Question;
import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.Session;
import de.thm.arsnova.entities.User; import de.thm.arsnova.entities.User;
...@@ -116,9 +115,7 @@ public class SessionService implements ISessionService { ...@@ -116,9 +115,7 @@ public class SessionService implements ISessionService {
@Override @Override
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
public final Session joinSession(final String keyword) { public final Session getSession(final String keyword) {
/* HTTP polling solution (legacy) */
final User user = userService.getCurrentUser(); final User user = userService.getCurrentUser();
final Session session = databaseDao.getSessionFromKeyword(keyword); final Session session = databaseDao.getSessionFromKeyword(keyword);
if (session == null) { if (session == null) {
...@@ -132,10 +129,6 @@ public class SessionService implements ISessionService { ...@@ -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()) { if (connectorClient != null && session.isCourseSession()) {
final String courseid = session.getCourseId(); final String courseid = session.getCourseId();
if (!connectorClient.getMembership(userService.getCurrentUser().getUsername(), courseid).isMember()) { if (!connectorClient.getMembership(userService.getCurrentUser().getUsername(), courseid).isMember()) {
...@@ -206,21 +199,6 @@ public class SessionService implements ISessionService { ...@@ -206,21 +199,6 @@ public class SessionService implements ISessionService {
return generateKeyword(); 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 @Override
public int countSessions(final List<Course> courses) { public int countSessions(final List<Course> courses) {
final List<Session> sessions = databaseDao.getCourseSessions(courses); final List<Session> sessions = databaseDao.getCourseSessions(courses);
......
...@@ -147,14 +147,6 @@ public class SessionControllerTest { ...@@ -147,14 +147,6 @@ public class SessionControllerTest {
.andExpect(header().string(AbstractController.X_DEPRECATED_API, "1")); .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 @Test
public void testShouldEndInForbidden() throws Exception { public void testShouldEndInForbidden() throws Exception {
setAuthenticated(true, "ptsr00"); setAuthenticated(true, "ptsr00");
......
...@@ -103,13 +103,13 @@ public class SessionServiceTest { ...@@ -103,13 +103,13 @@ public class SessionServiceTest {
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void testShouldNotFindNonExistantSession() { public void testShouldNotFindNonExistantSession() {
setAuthenticated(true, "ptsr00"); setAuthenticated(true, "ptsr00");
sessionService.joinSession("00000000"); sessionService.getSession("00000000");
} }
@Test(expected = AuthenticationCredentialsNotFoundException.class) @Test(expected = AuthenticationCredentialsNotFoundException.class)
public void testShouldNotReturnSessionIfUnauthorized() { public void testShouldNotReturnSessionIfUnauthorized() {
setAuthenticated(false, null); setAuthenticated(false, null);
sessionService.joinSession("12345678"); sessionService.getSession("12345678");
} }
@Test(expected = AuthenticationCredentialsNotFoundException.class) @Test(expected = AuthenticationCredentialsNotFoundException.class)
...@@ -126,7 +126,7 @@ public class SessionServiceTest { ...@@ -126,7 +126,7 @@ public class SessionServiceTest {
setAuthenticated(true, "ptsr00"); setAuthenticated(true, "ptsr00");
assertNull(sessionService.joinSession("11111111")); assertNull(sessionService.getSession("11111111"));
} }
@Test @Test
...@@ -140,7 +140,7 @@ public class SessionServiceTest { ...@@ -140,7 +140,7 @@ public class SessionServiceTest {
session.setName("TestSessionX"); session.setName("TestSessionX");
session.setShortName("TSX"); session.setShortName("TSX");
sessionService.saveSession(session); sessionService.saveSession(session);
assertNotNull(sessionService.joinSession("11111111")); assertNotNull(sessionService.getSession("11111111"));
} }
@Test(expected = AccessDeniedException.class) @Test(expected = AccessDeniedException.class)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment