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

Fix handling of RoomRepository.findByShortId(null)

When null was set as database key, the whole view would be requested
before this change.
parent 12410a3b
Branches
Tags
1 merge request!89Foundation for development of version 3.0
......@@ -58,6 +58,9 @@ public class CouchDbRoomRepository extends CouchDbCrudRepository<Room> implement
@Override
public Room findByShortId(final String shortId) {
if (shortId == null) {
return null;
}
final List<Room> roomList = queryView("by_shortid", shortId);
return !roomList.isEmpty() ? roomList.get(0) : null;
......
......@@ -201,6 +201,9 @@ public class RoomServiceImpl extends DefaultEntityServiceImpl<Room> implements R
@Override
@Cacheable("room.id-by-shortid")
public String getIdByShortId(final String shortId) {
if (shortId == null) {
throw new NullPointerException("shortId cannot be null");
}
Room room = roomRepository.findByShortId(shortId);
if (room == null) {
throw new NotFoundException("No Room exists for short ID");
......
......@@ -172,16 +172,18 @@ public class ArsnovaSocketioServerImpl implements ArsnovaSocketioServer, Arsnova
return;
}
final String oldRoomId = userService.getRoomIdByUserId(u.getId());
if (null != room.getKeyword() && room.getKeyword().equals(oldRoomId)) {
return;
}
final String roomId = roomService.getIdByShortId(room.getKeyword());
if (null != room.getKeyword()) {
if (room.getKeyword().equals(oldRoomId)) {
return;
}
final String roomId = roomService.getIdByShortId(room.getKeyword());
if (null != roomId && null != roomService.join(roomId, client.getSessionId())) {
/* active user count has to be sent to the client since the broadcast is
* not always sent as long as the polling solution is active simultaneously */
reportActiveUserCountForRoom(roomId);
reportRoomDataToClient(roomId, u, client);
if (null != roomId && null != roomService.join(roomId, client.getSessionId())) {
/* active user count has to be sent to the client since the broadcast is
* not always sent as long as the polling solution is active simultaneously */
reportActiveUserCountForRoom(roomId);
reportRoomDataToClient(roomId, u, client);
}
}
if (null != oldRoomId) {
reportActiveUserCountForRoom(oldRoomId);
......
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