Skip to content
Snippets Groups Projects
Commit bdd543d0 authored by Tom Käsler's avatar Tom Käsler
Browse files

outsource ApiResponse Status Codes Text in Abstract controller

parent 2df937dc
No related merge requests found
......@@ -23,4 +23,12 @@ package de.thm.arsnova.controller;
public class AbstractController {
protected static final String X_DEPRECATED_API = "X-Deprecated-API";
protected static final String X_FORWARDED = "X-Forwarded";
protected static final String HTML_STATUS_200 = "OK";
protected static final String HTML_STATUS_201 = "Created";
protected static final String HTML_STATUS_204 = "No Content";
protected static final String HTML_STATUS_400 = "Bad request";
protected static final String HTML_STATUS_403 = "Forbidden";
protected static final String HTML_STATUS_404 = "Not Found";
protected static final String HTML_STATUS_501 = "Not Implemented";
protected static final String HTML_STATUS_503 = "Service Unavailable";
}
......@@ -93,7 +93,7 @@ public class AudienceQuestionController extends PaginationController {
@ApiOperation(value = "Creates a new Interposed Question for a Session and returns the InterposedQuestion's data",
nickname = "postInterposedQuestion")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error")
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
......
......@@ -62,7 +62,7 @@ public class CourseController extends AbstractController {
@ApiOperation(value = "retrieves a User Courses",
nickname = "myCourses")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful API requests")
@ApiResponse(code = 200, message = HTML_STATUS_200)
})
@RequestMapping(value = "/mycourses", method = RequestMethod.GET)
public List<Course> myCourses(
......
......@@ -70,7 +70,7 @@ public class FeedbackController extends AbstractController {
@ApiOperation(value = "Get own feedback from a session",
nickname = "getMyFeedback")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Not Found - The requested resource could not be found but may be available again in the future.")
@ApiResponse(code = 404, message = HTML_STATUS_404)
})
@DeprecatedApi
@Deprecated
......@@ -111,7 +111,7 @@ public class FeedbackController extends AbstractController {
@ApiOperation(value = "Post feedback for a session",
nickname = "postFeedback")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Not Found - The requested resource could not be found but may be available again in the future.")
@ApiResponse(code = 404, message = HTML_STATUS_404)
})
@DeprecatedApi
@Deprecated
......
......@@ -67,7 +67,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Get question with provided question Id",
nickname = "getQuestion")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Not Found - The requested resource could not be found but may be available again in the future.")
@ApiResponse(code = 404, message = HTML_STATUS_404)
})
@RequestMapping(value = "/{questionId}", method = RequestMethod.GET)
public Question getQuestion(@PathVariable final String questionId) {
......@@ -82,7 +82,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Post provided question",
nickname = "postQuestion")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error")
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
......@@ -96,7 +96,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Update the question, identified by provided id, with the provided question in the Request Body",
nickname = "updateQuestion")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error")
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/{questionId}", method = RequestMethod.PUT)
public Question updateQuestion(
......@@ -619,7 +619,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Set the sort order of the subjects from a session, identified by the sessionkey",
nickname = "setSubjectSortOrder")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error")
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/subjectsort", method = RequestMethod.POST)
public void setSubjectSortOrder(
......@@ -648,7 +648,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Set the sort order of the questions from a subject in a session, identified by the sessionkey",
nickname = "setQuestionSortOrder")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error")
@ApiResponse(code = 400, message = HTML_STATUS_400)
})
@RequestMapping(value = "/questionsort", method = RequestMethod.POST)
public void setQuestionSortOrder(
......@@ -668,7 +668,7 @@ public class LecturerQuestionController extends PaginationController {
@ApiOperation(value = "Get the sort order of the questions from a subject in a session, identified by the sessionkey",
nickname = "getQuestionSortType")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request")
@ApiResponse(code = 204, message = HTML_STATUS_204)
})
@RequestMapping(value = "/questionsort", method = RequestMethod.GET)
public String getQuestionSortType(
......
......@@ -100,8 +100,8 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Creates a new Session and returns the Session's data",
nickname = "postNewSession")
@ApiResponses(value = {
@ApiResponse(code = 201, message = "The request has been fulfilled and resulted in a new resource being created"),
@ApiResponse(code = 503, message = "Service Unavailable - The Api is currently unavailable (because it is overloaded or down for maintenance)")
@ApiResponse(code = 201, message = HTML_STATUS_201),
@ApiResponse(code = 503, message = HTML_STATUS_503)
})
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
......@@ -142,8 +142,8 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Retrieves a list of Sessions",
nickname = "getSessions")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request"),
@ApiResponse(code = 501, message = "Not implemented - The Api either does not recognize the request method, or it lacks the ability to fulfil the request")
@ApiResponse(code = 204, message = HTML_STATUS_204),
@ApiResponse(code = 501, message = HTML_STATUS_501)
})
@RequestMapping(value = "/", method = RequestMethod.GET)
@Pagination
......@@ -192,7 +192,7 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Retrieves a Session",
nickname = "getMySessions")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request")
@ApiResponse(code = 204, message = HTML_STATUS_204)
})
@RequestMapping(value = "/", method = RequestMethod.GET, params = "statusonly=true")
@Pagination
......@@ -224,7 +224,7 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Retrieves all public pool sessions for the current user",
nickname = "getMyPublicPoolSessions")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request")
@ApiResponse(code = 204, message = HTML_STATUS_204)
})
@RequestMapping(value = "/publicpool", method = RequestMethod.GET, params = "statusonly=true")
public List<SessionInfo> getMyPublicPoolSessions(
......@@ -243,7 +243,7 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Retrieves all public pool sessions",
nickname = "getMyPublicPoolSessions")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request")
@ApiResponse(code = 204, message = HTML_STATUS_204)
})
@RequestMapping(value = "/publicpool", method = RequestMethod.GET)
public List<SessionInfo> getPublicPoolSessions(
......@@ -272,7 +272,7 @@ public class SessionController extends PaginationController {
@ApiOperation(value = "Locks or unlocks a Session",
nickname = "lockSession")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Not Found - The requested resource could not be found but may be available again in the future")
@ApiResponse(code = 404, message = HTML_STATUS_404)
})
@RequestMapping(value = "/{sessionkey}/lock", method = RequestMethod.POST)
public Session lockSession(
......
......@@ -65,9 +65,9 @@ public class SocketController extends AbstractController {
@ApiOperation(value = "requested to assign Websocket session",
nickname = "authorize")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "No Content - successfully processed the request"),
@ApiResponse(code = 400, message = "Bad Request - The Api cannot or will not process the request due to something that is perceived to be a client error"),
@ApiResponse(code = 403, message = "Forbidden - The request was a valid request, but the Api is refusing to respond to it")
@ApiResponse(code = 204, message = HTML_STATUS_204),
@ApiResponse(code = 400, message = HTML_STATUS_400),
@ApiResponse(code = 403, message = HTML_STATUS_403)
})
@RequestMapping(method = RequestMethod.POST, value = "/assign")
public void authorize(@ApiParam(value="sessionMap", required=true) @RequestBody final Map<String, String> sessionMap, @ApiParam(value="response", required=true) final HttpServletResponse response) {
......
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