Commit 6fe0f02f authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Added RESTful request to create questions

This method uses the same entity as used for websockets. It needs a valid
session key in request path. This session key MUST match the session key
used in entity to provide semantic URIs
parent 58c3e5af
......@@ -42,6 +42,7 @@ import de.thm.arsnova.entities.User;
import de.thm.arsnova.services.ISessionService;
import de.thm.arsnova.services.IUserService;
import de.thm.arsnova.socket.ARSnovaSocketIOServer;
import de.thm.arsnova.socket.message.Question;
@Controller
public class SessionController {
......@@ -125,6 +126,24 @@ public class SessionController {
response.setStatus(HttpStatus.SERVICE_UNAVAILABLE.value());
return null;
}
@RequestMapping(value="/session/{sessionkey}/question", method=RequestMethod.POST)
@ResponseBody
public void postQuestion(@PathVariable String sessionkey, @RequestBody Question question, HttpServletResponse response) {
if (! sessionkey.equals(question.getSession())) {
response.setStatus(HttpStatus.PRECONDITION_FAILED.value());
return;
}
if (sessionService.saveQuestion(question)) {
response.setStatus(HttpStatus.CREATED.value());
return;
}
response.setStatus(HttpStatus.BAD_REQUEST.value());
return;
}
@RequestMapping(value="/socketurl", method=RequestMethod.GET)
@ResponseBody
......
Markdown is supported
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