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

Merge branch 'master' into issue-6674

parents 8417dc40 b9b7be40
Branches
Tags
No related merge requests found
......@@ -127,6 +127,15 @@ public class SessionController extends AbstractController {
return newSession;
}
@RequestMapping(value = "/{sessionkey}", method = RequestMethod.PUT)
@ResponseBody
public final Session updateSession(
@PathVariable final String sessionkey,
@RequestBody final Session session
) {
return sessionService.updateSession(sessionkey, session);
}
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody
public final List<Session> getSessions(
......
......@@ -1091,6 +1091,24 @@ public class CouchDBDao implements IDatabaseDao {
return null;
}
@Override
public Session updateSession(Session session) {
try {
Document s = this.database.getDocument(session.get_id());
s.put("name", session.getName());
s.put("shortName", session.getShortName());
s.put("active", session.isActive());
this.database.saveDocument(s);
session.set_rev(s.getRev());
return session;
} catch (IOException e) {
LOGGER.error("Could not lock session {}", session);
}
return null;
}
@Override
public void deleteSession(Session session) {
try {
......
......@@ -128,6 +128,8 @@ public interface IDatabaseDao {
List<String> getActiveUsers(int timeDifference);
Session updateSession(Session session);
void deleteSession(Session session);
List<Question> getLectureQuestions(User user, Session session);
......
......@@ -50,5 +50,7 @@ public interface ISessionService {
Session joinSession(String keyword, UUID socketId);
Session updateSession(String sessionkey, Session session);
void deleteSession(String sessionkey, User user);
}
......@@ -236,6 +236,19 @@ public class SessionService implements ISessionService {
return databaseDao.lockSession(session, lock);
}
@Override
@Authenticated
public Session updateSession(String sessionkey, Session session) {
Session s = databaseDao.getSession(sessionkey);
User user = userService.getCurrentUser();
if (!s.isCreator(user)) {
throw new ForbiddenException();
}
return databaseDao.updateSession(session);
}
@Override
@Authenticated
public void deleteSession(String sessionkey, User user) {
......
......@@ -393,6 +393,12 @@ public class StubDatabaseDao implements IDatabaseDao {
return null;
}
@Override
public Session updateSession(Session session) {
// TODO Auto-generated method stub
return null;
}
@Override
public void deleteSession(Session session) {
// TODO Auto-generated method stub
......
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