Backend API

This commit is contained in:
Maximilian Leopold 2019-06-23 01:09:42 +02:00
parent 3e1607f5b0
commit 781d8346a8
13 changed files with 255 additions and 131 deletions

View File

@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
@ -14,6 +15,7 @@ import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class }) @SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
@ServletComponentScan
@EnableSwagger2 @EnableSwagger2
public class Application extends SpringBootServletInitializer{ public class Application extends SpringBootServletInitializer{

View File

@ -7,13 +7,10 @@ import hhn.labsw.bugageocaching.helper.POI;
import hhn.labsw.bugageocaching.helper.RankingListHelper; import hhn.labsw.bugageocaching.helper.RankingListHelper;
import hhn.labsw.bugageocaching.helper.TeamRankingListHelper; import hhn.labsw.bugageocaching.helper.TeamRankingListHelper;
import hhn.labsw.bugageocaching.repositories.*; import hhn.labsw.bugageocaching.repositories.*;
import hhn.labsw.bugageocaching.util.CacheConstructionUtil;
import hhn.labsw.bugageocaching.util.FinderUtil; import hhn.labsw.bugageocaching.util.FinderUtil;
import hhn.labsw.bugageocaching.util.VerificationUtil; import hhn.labsw.bugageocaching.util.VerificationUtil;
import io.jsonwebtoken.Claims; import io.jsonwebtoken.Claims;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.*;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -25,12 +22,11 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil; import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.*;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.editCacheUtil;
import static hhn.labsw.bugageocaching.util.VerificationUtil.fetchPublicKey; import static hhn.labsw.bugageocaching.util.VerificationUtil.fetchPublicKey;
@RestController @RestController
@Api(value = "/api", description = "All Backend API Operations for the geocaching Application")
public class Controller { public class Controller {
@Autowired @Autowired
@ -67,7 +63,13 @@ public class Controller {
fetchPublicKey(); fetchPublicKey();
} }
@ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database") @ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database", response = Cache.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/allCaches", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/allCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
@ -78,7 +80,7 @@ public class Controller {
} }
@ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache") @ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache", responseContainer = "ResponseEntity", response = Bearbeitet.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"), @ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ -88,10 +90,10 @@ public class Controller {
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/checkStation", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/checkStation", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity checkStation(@RequestParam String token, public ResponseEntity checkStation(@ApiParam(value = "JWT Token indentifiying the cser", required = true) @RequestParam String token,
@RequestParam String cacheID, @ApiParam(value = "The CacheID from the scanned QR Code", required = true) @RequestParam String cacheID,
@RequestParam String stationID, @ApiParam(value = "The StationID from the scanned QR Code", required = true) @RequestParam String stationID,
@RequestParam String durchgefuehrterCacheID) { @ApiParam(value = "The CacheID from the cache the user does at the time scanning the code", required = true)@RequestParam String durchgefuehrterCacheID) {
//---------------------- //----------------------
//Verify token //Verify token
ResponseEntity tokenVerification = VerificationUtil.verifyToken(token); ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
@ -233,45 +235,49 @@ public class Controller {
} }
@ApiOperation(value = "Creates a new Cache") @ApiOperation(value = "Creates a new Cache", response = String.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 400, message = "Something wrong with the given Parameters") @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json") @RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity createCache(@RequestBody Cache cache) { public ResponseEntity createCache(@ApiParam(value = "The cache to be created and saved in the database", required = true) @RequestBody Cache cache) {
logger.warn("API CALL: api/createCache"); logger.warn("API CALL: api/createCache");
logger.debug("/api/allCaches PARAMETERS:\ncache: " + cache.getName()); logger.debug("/api/allCaches PARAMETERS:\ncache: " + cache.getName());
return createCacheUtil(cache); return createCacheUtil(cache);
} }
@ApiOperation(value = "Edits a Cache") @ApiOperation(value = "Edits a Cache", responseContainer = "Body of ResponseEntity", response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something wrong with the given Parameters") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/editCache", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity editCache(@RequestBody Cache newCache) { public ResponseEntity editCache(@ApiParam(value = "The edited cache", required = true) @RequestBody Cache newCache) {
logger.warn("API CALL: /api/editCache"); logger.warn("API CALL: /api/editCache");
logger.debug("/api/editCache PARAMETERS:\nnewCache: " + newCache.getName()); logger.debug("/api/editCache PARAMETERS:\nnewCache: " + newCache.getName());
return editCacheUtil(newCache); return editCacheUtil(newCache);
} }
@ApiOperation(value = "Checks if the given User has an admin role") @ApiOperation(value = "Checks if the given User has an admin role", response = Boolean.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/checkAdmin", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/checkAdmin", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity checkAdmin(@RequestParam String token) { public ResponseEntity checkAdmin(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -299,9 +305,12 @@ public class Controller {
return ResponseEntity.status(401).body(false); return ResponseEntity.status(401).body(false);
} }
@ApiOperation(value = "Returns all Stations") @ApiOperation(value = "Returns all Stations", response = Station.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error") @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getAllStations", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getAllStations", method = RequestMethod.GET, produces = "application/json")
@ -312,29 +321,33 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll())); return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
} }
@ApiOperation(value = "Deletes a Cache") @ApiOperation(value = "Deletes a Cache", responseContainer = "Body of ResponseEntity", response = Boolean.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error") @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/deleteCache", method = {RequestMethod.DELETE}, produces = "application/json") @RequestMapping(value = "/api/deleteCache", method = {RequestMethod.DELETE}, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity deleteCache(@RequestParam String cacheID) { public ResponseEntity deleteCache(@ApiParam(value = "The cache ID to be deleted", required = true) @RequestParam String cacheID) {
logger.warn("API CALL: /api/deleteCache"); logger.warn("API CALL: /api/deleteCache");
logger.debug("/api/deleteCache: PARAMETERS:\ncacheID: " + cacheID); logger.debug("/api/deleteCache: PARAMETERS:\ncacheID: " + cacheID);
return deleteCacheUtil(cacheID); return deleteCacheUtil(cacheID);
} }
@ApiOperation(value = "Returns all Caches finished/started by a given User") @ApiOperation(value = "Returns all Caches finished/started by a given User", response = Bearbeitet.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getMyCaches", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getMyCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity getMyCaches(@RequestParam String token) { public ResponseEntity getMyCaches(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
logger.warn("API CALL: /api/getMyCaches"); logger.warn("API CALL: /api/getMyCaches");
logger.debug("/api/getMyCaches: PARAMETERS:\ntoken: " + token); logger.debug("/api/getMyCaches: PARAMETERS:\ntoken: " + token);
@ -375,14 +388,17 @@ public class Controller {
} }
} }
@ApiOperation(value = "Returns the rankinglist") @ApiOperation(value = "Returns the rankinglist", response = RankingListHelper.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error") @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getRankingList", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getRankingList", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity getRankingList(@RequestParam(value = "token", defaultValue = "null") String token) { public ResponseEntity getRankingList(@ApiParam(value = "JWT Token indentifiying the User", required = false) @RequestParam(value = "token", defaultValue = "null") String token) {
logger.warn("API CALL: /api/getRankingList"); logger.warn("API CALL: /api/getRankingList");
logger.debug("/api/getRankingList: PARAMETERS: -"); logger.debug("/api/getRankingList: PARAMETERS: -");
@ -401,7 +417,7 @@ public class Controller {
logger.debug("/api/getRankingList Converted Objects to RankingListHelper"); logger.debug("/api/getRankingList Converted Objects to RankingListHelper");
logger.debug("/api/getRankingList RankingList: " + new GsonBuilder().setPrettyPrinting().create().toJson(sendBackUsers)); logger.debug("/api/getRankingList RankingList: " + new GsonBuilder().setPrettyPrinting().create().toJson(sendBackUsers));
if(!token.equals("null")) { if (!token.equals("null")) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -422,16 +438,16 @@ public class Controller {
User user = (User) getUser.getBody(); User user = (User) getUser.getBody();
boolean userAlreadyInRankingList = false; boolean userAlreadyInRankingList = false;
for (RankingListHelper rankingListHelper: sendBackUsers) { for (RankingListHelper rankingListHelper : sendBackUsers) {
logger.debug("RankingList Helper " + rankingListHelper.getUsername()); logger.debug("RankingList Helper " + rankingListHelper.getUsername());
logger.debug("User: " + user.getUsername()); logger.debug("User: " + user.getUsername());
if(rankingListHelper.getUsername().equals(user.getEmail())){ if (rankingListHelper.getUsername().equals(user.getEmail())) {
userAlreadyInRankingList = true; userAlreadyInRankingList = true;
break; break;
} }
} }
if(!userAlreadyInRankingList) { if (!userAlreadyInRankingList) {
ResponseEntity singlePlace = getRankingPlace(user.getEmail()); ResponseEntity singlePlace = getRankingPlace(user.getEmail());
if (singlePlace.getStatusCodeValue() == 200) { if (singlePlace.getStatusCodeValue() == 200) {
@ -444,9 +460,12 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers)); return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
} }
@ApiOperation(value = "Returns the Team Rankinglist") @ApiOperation(value = "Returns the Team Rankinglist", response = TeamRankingListHelper.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error") @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getTeamRankingList", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getTeamRankingList", method = RequestMethod.GET, produces = "application/json")
@ -472,16 +491,17 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams)); return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
} }
@ApiOperation(value = "Returns a user from a given token") @ApiOperation(value = "Returns a user from a given token", response = User.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getUser", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getUser", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity getUser(@RequestParam String token) { public ResponseEntity getUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
logger.warn("API CALL: /api/getUser"); logger.warn("API CALL: /api/getUser");
logger.debug("/api/getUser: PARAMETERS:\ntoken: " + token); logger.debug("/api/getUser: PARAMETERS:\ntoken: " + token);
@ -518,17 +538,18 @@ public class Controller {
} }
} }
@ApiOperation(value = "Creates a new Team") @ApiOperation(value = "Creates a new Team", response = Team.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/createTeam", method = RequestMethod.POST, produces = "application/json") @RequestMapping(value = "/api/createTeam", method = RequestMethod.POST, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity createTeam(@RequestParam String token, public ResponseEntity createTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String name) { @ApiParam(value = "Name of the team to be created", required = true) @RequestParam String name) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -573,17 +594,18 @@ public class Controller {
} }
//--------- //---------
@ApiOperation(value = "Lets the user join a Team") @ApiOperation(value = "Lets the user join a Team", response = Team.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/joinTeam", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/joinTeam", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity joinTeam(@RequestParam String token, public ResponseEntity joinTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String teamID) { @ApiParam(value = "Team id of the team the user wants to join", required = true) @RequestParam String teamID) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -644,16 +666,17 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(team)); return ResponseEntity.status(200).body(new Gson().toJson(team));
} }
@ApiOperation(value = "Removes the user from the Team") @ApiOperation(value = "Removes the user from the Team", responseContainer = "Body of ResponseEntity", response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/leaveTeam", method = {RequestMethod.PUT, RequestMethod.GET}, produces = "application/json") @RequestMapping(value = "/api/leaveTeam", method = {RequestMethod.PUT, RequestMethod.GET}, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity leaveTeam(@RequestParam String token) { public ResponseEntity leaveTeam(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -715,17 +738,18 @@ public class Controller {
return ResponseEntity.status(200).body("Ok"); return ResponseEntity.status(200).body("Ok");
} }
@ApiOperation(value = "Sends a Team Invite to the invitedUserEmail from the User (token)") @ApiOperation(value = "Sends a Team Invite to the invitedUserEmail from the User (token)", responseContainer = "Body of ResponseEntity", response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/sendTeamInvite", method = RequestMethod.POST, produces = "application/json") @RequestMapping(value = "/api/sendTeamInvite", method = RequestMethod.POST, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity sendTeamInvite(@RequestParam String token, public ResponseEntity sendTeamInvite(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String invitedUserEmail) { @ApiParam(value = "The email of the invited User", required = true)@RequestParam String invitedUserEmail) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -787,16 +811,17 @@ public class Controller {
return ResponseEntity.status(200).body("OK"); return ResponseEntity.status(200).body("OK");
} }
@ApiOperation(value = "Returns all User invites for a specific User") @ApiOperation(value = "Returns all User invites for a specific User", response = TeamInvite.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/getMyTeamInvites", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getMyTeamInvites", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity getMyTeamInvites(@RequestParam String token) { public ResponseEntity getMyTeamInvites(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -833,17 +858,18 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList)); return ResponseEntity.status(200).body(new Gson().toJson(teamInvitesList));
} }
@ApiOperation(value = "Removes a team invite from a user (called if a user declined a team invite)") @ApiOperation(value = "Removes a team invite from a user (called if a user declined a team invite)", response = String.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/deleteTeamInvite", method = RequestMethod.DELETE, produces = "application/json") @RequestMapping(value = "/api/deleteTeamInvite", method = RequestMethod.DELETE, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity deleteTeamInvite(@RequestParam String token, public ResponseEntity deleteTeamInvite(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String teamInviteID) { @ApiParam(value = "The id of the TeamInvite to be deletd", required = true) @RequestParam String teamInviteID) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -865,17 +891,18 @@ public class Controller {
return ResponseEntity.status(200).body("OK"); return ResponseEntity.status(200).body("OK");
} }
@ApiOperation(value = "Sets the team status") @ApiOperation(value = "Sets the team status", responseContainer = "Body of ResponseEntity", response = String.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/setTeamStatus", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/setTeamStatus", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity setTeamStatus(@RequestParam String token, public ResponseEntity setTeamStatus(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String teamStatus) { @ApiParam(value = "The new team status", required = true) @RequestParam String teamStatus) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -916,39 +943,46 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(teamStatus)); return ResponseEntity.status(200).body(new Gson().toJson(teamStatus));
} }
@ApiOperation(value = "Returns a team by a name") @ApiOperation(value = "Returns a team by a name", response = Team.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/getTeam", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getTeam", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeam(@RequestParam String name) { public ResponseEntity getTeam(@ApiParam(value = "The name of the team", required = true) @RequestParam String name) {
ResponseEntity responseEntity = FinderUtil.findTeamByName(name); ResponseEntity responseEntity = FinderUtil.findTeamByName(name);
return responseEntity; return responseEntity;
} }
@ApiOperation(value = "Returns all teammembers by the team name") @ApiOperation(value = "Returns all teammembers by the team name", response = User.class, responseContainer = "List in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@RequestMapping(value = "/api/getTeamMembers", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getTeamMembers", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamMembers(@RequestParam String name) { public ResponseEntity getTeamMembers(@ApiParam(value = "The name of the team") @RequestParam String name) {
return FinderUtil.findTeammemberByTeamName(name); return FinderUtil.findTeammemberByTeamName(name);
} }
@ApiOperation(value = "Returns the station the user is currently at (for a specific cache)") @ApiOperation(value = "Returns the station the user is currently at (for a specific cache)", response = Station.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getCurrentStation", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getCurrentStation", method = RequestMethod.GET, produces = "application/json")
@ResponseBody @ResponseBody
public ResponseEntity getStationFromUserAndCache(@RequestParam String token, public ResponseEntity getStationFromUserAndCache(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@RequestParam String cacheID) { @ApiParam(value = "The Cache id for the searched station", required = true) @RequestParam String cacheID) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -982,27 +1016,29 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetRepository.findByUserAndCache(user, cache))); return ResponseEntity.status(200).body(new Gson().toJson(bearbeitetRepository.findByUserAndCache(user, cache)));
} }
@ApiOperation(value = "Returns the ranking place on the leaderboard for a specific user") @ApiOperation(value = "Returns the ranking place on the leaderboard for a specific user", response = Integer.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getRankingPlace", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getRankingPlace(@RequestParam String email) { public ResponseEntity getRankingPlace(@ApiParam(value = "The email of the user as unique identifier", required = true)@RequestParam String email) {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email)); return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(email));
} }
@ApiOperation(value = "Returns startstations and all other stations the user already visited as POIS") @ApiOperation(value = "Returns startstations and all other stations the user already visited as POIS", response = POI.class, responseContainer = "Array in Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getMyStationPOIS", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getMyStationPOIS", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getMyStationPOIS(@RequestParam String token) { public ResponseEntity getMyStationPOIS(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -1060,15 +1096,16 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(pois)); return ResponseEntity.status(200).body(new Gson().toJson(pois));
} }
@ApiOperation(value = "Returns the Team of a user") @ApiOperation(value = "Returns the Team of a user", response = Team.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token) { public ResponseEntity getTeamOfUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -1093,15 +1130,17 @@ public class Controller {
return ResponseEntity.status(200).body(user_info.getTeam()); return ResponseEntity.status(200).body(user_info.getTeam());
} }
@ApiOperation(value = "Returns the Team of a user") @ApiOperation(value = "Returns the Team of a user", response = POI.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/getCurrentStationMap", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/getCurrentStationMap", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getCurrentStationMap(@RequestParam String token, @RequestParam String cacheID) { public ResponseEntity getCurrentStationMap(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@ApiParam(value = "Cache id of the searched station", required = true) @RequestParam String cacheID) {
logger.warn("API CALL: /api/getCurrentStationMap"); logger.warn("API CALL: /api/getCurrentStationMap");
@ -1162,15 +1201,16 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(poi)); return ResponseEntity.status(200).body(new Gson().toJson(poi));
} }
@ApiOperation(value = "Resets the rankinglist") @ApiOperation(value = "Resets the rankinglist", response = HttpStatus.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/resetRankingList", method = RequestMethod.GET, produces = "application/json") @RequestMapping(value = "/api/resetRankingList", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity resetRankingList(@RequestParam String token) { public ResponseEntity resetRankingList(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token) {
logger.warn("API CALL: /api/resetRankingList"); logger.warn("API CALL: /api/resetRankingList");
// verify user // verify user
@ -1216,15 +1256,17 @@ public class Controller {
} }
} }
@ApiOperation(value = "Deletes the bearbeitet entry from a User from a Cache") @ApiOperation(value = "Deletes the bearbeitet entry from a User from a Cache", response = String.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/deleteCacheForUser", method = RequestMethod.DELETE, produces = "application/json") @RequestMapping(value = "/api/deleteCacheForUser", method = RequestMethod.DELETE, produces = "application/json")
public ResponseEntity deleteCacheForUser(@RequestParam String token, @RequestParam String cacheID) { public ResponseEntity deleteCacheForUser(@ApiParam(value = "JWT Token indentifiying the User", required = true) @RequestParam String token,
@ApiParam(value = "The cache id for the cache to be deleted", required = true) @RequestParam String cacheID) {
logger.warn("API CALL: /api/deleteCacheForUser"); logger.warn("API CALL: /api/deleteCacheForUser");
// verify user // verify user
@ -1284,15 +1326,17 @@ public class Controller {
} }
@ApiOperation(value = "Resets the points of a single User ") @ApiOperation(value = "Resets the points of a single User", response = HttpStatus.class, responseContainer = "Body of ResponseEntity")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })
@CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping(value = "/api/resetSingleUser", method = RequestMethod.PUT, produces = "application/json") @RequestMapping(value = "/api/resetSingleUser", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity resetSingleUser(@RequestParam String token, @RequestParam String username) { public ResponseEntity resetSingleUser(@ApiParam(value = "JWT Token indentifiying the User (Admin in this case)", required = true) @RequestParam String token,
@ApiParam(value = "The username of the user to be reseted", required = true) @RequestParam String username) {
logger.debug("API CALL: /api/resetSingleUser"); logger.debug("API CALL: /api/resetSingleUser");
// verify user // verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token); ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
@ -1326,7 +1370,7 @@ public class Controller {
User deleteUser = userRepository.findByEmail(username); User deleteUser = userRepository.findByEmail(username);
if(deleteUser == null) { if (deleteUser == null) {
return ResponseEntity.status(400).body("Es wurde kein User mit dieser Email gefunden."); return ResponseEntity.status(400).body("Es wurde kein User mit dieser Email gefunden.");
} }
@ -1348,6 +1392,7 @@ public class Controller {
@ApiOperation(value = "Test method (Changes its purpose often)") @ApiOperation(value = "Test method (Changes its purpose often)")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"), @ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 400, message = "Given Station is NOT the correct following station"),
@ApiResponse(code = 401, message = "JWT Token expired"), @ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification") @ApiResponse(code = 400, message = "Something went wrong at verification")
}) })

View File

@ -1,6 +1,8 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -10,18 +12,23 @@ public class Bearbeitet {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The User (Foreign Key)")
private User user; private User user;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The Cache (Foreign Key)")
private Cache cache; private Cache cache;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The cacheAccessDefinition (Foreign Key)")
private CacheAccesDefinition cacheAccesDefinition; private CacheAccesDefinition cacheAccesDefinition;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The current Station (Foreign Key)")
private Station aktuelleStation; private Station aktuelleStation;
public int getId() { public int getId() {

View File

@ -1,6 +1,8 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
@Entity @Entity
@ -9,8 +11,10 @@ public class CacheAccesDefinition {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The description for the CacheAcessDefinition")
private String description; private String description;
public int getId() { public int getId() {

View File

@ -1,6 +1,8 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -12,8 +14,10 @@ public class Reward {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The description for the reward")
private String rewardDescription; private String rewardDescription;
public Reward() { public Reward() {

View File

@ -1,5 +1,8 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -9,8 +12,11 @@ public class Role {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The name of the role")
private String name; private String name;
@ApiModelProperty(notes = "The domain of the role (e.g. geocaching, flowertours...)")
private String domain; private String domain;
public Role() { public Role() {

View File

@ -1,6 +1,8 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -10,22 +12,28 @@ public class Station {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@NotNull @NotNull
@ApiModelProperty(notes = "The riddle for the Station")
private String description; private String description;
@NotNull @NotNull
@ApiModelProperty(notes = "The longitude of the position for the station")
private double longitude; private double longitude;
@NotNull @NotNull
@ApiModelProperty(notes = "The latitude of the position for the station")
private double lattitude; private double lattitude;
@Column(unique = true) @Column(unique = true)
@NotNull @NotNull
@ApiModelProperty(notes = "The unique code for a Station (needed for the QR Code)")
private int code; private int code;
@NotNull @NotNull
@ApiModelProperty(notes = "The solution for the riddle of the station")
private String solution; private String solution;
public Station() { public Station() {

View File

@ -1,5 +1,7 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -10,10 +12,13 @@ public class Team {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The name of the team")
private String name; private String name;
@ApiModelProperty(notes = "The teamstatus")
private String teamStatus; private String teamStatus;
public int getId() { public int getId() {

View File

@ -1,5 +1,7 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
@Entity @Entity
@ -8,12 +10,15 @@ public class TeamInvite {
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The user to be invited")
private User user; private User user;
@OneToOne @OneToOne
@ApiModelProperty(notes = "The team the user is invited to join")
private Team team; private Team team;
public int getId() { public int getId() {

View File

@ -1,5 +1,7 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*; import javax.persistence.*;
import java.util.Set; import java.util.Set;
@ -12,18 +14,24 @@ import java.util.List;
public class User { public class User {
@Id @Id
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The username of the user")
private String username; private String username;
@ApiModelProperty(notes = "The email of the user")
private String email; private String email;
@ApiModelProperty(notes = "The password for the user")
private String password; private String password;
@ManyToMany @ManyToMany
@ApiModelProperty(notes = "A List of roles for the User (e.g. Cacher, Admin...)")
private List<Role> roles; private List<Role> roles;
@Transient @Transient
@ApiModelProperty(notes = "A copy of the password for confirmation (transient)")
private String passwordConfirm; private String passwordConfirm;
public int getId() { public int getId() {

View File

@ -1,5 +1,6 @@
package hhn.labsw.bugageocaching.entities; package hhn.labsw.bugageocaching.entities;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.UniqueElements; import org.hibernate.validator.constraints.UniqueElements;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
@ -14,15 +15,19 @@ public class User_Info implements Serializable {
@Id @Id
@OneToOne @OneToOne
@ApiModelProperty(notes = "The User (Foreign Key)")
private User user; private User user;
@Id @Id
@GeneratedValue @GeneratedValue
@ApiModelProperty(notes = "The autogenerated ID (Primary Key)")
private int id; private int id;
@ApiModelProperty(notes = "The rankingPointsSum for the user")
private int rankingPointsSum; private int rankingPointsSum;
@ManyToOne @ManyToOne
@ApiModelProperty(notes = "The team of the user (Foreign Key)")
private Team team; private Team team;

View File

@ -0,0 +1,46 @@
package hhn.labsw.bugageocaching.util;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Set;
/**
* @author Paul Keller
* @version 1.0
*/
@WebListener
public class ThreadListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent arg0) {
//Get all registered drivers
Enumeration<Driver> drivers = DriverManager.getDrivers();
Driver d = null;
//as long as there are any registered drivers left - unregister them
while(drivers.hasMoreElements()) {
try {
d = drivers.nextElement();
DriverManager.deregisterDriver(d);
} catch(SQLException ex) {
//Log any exception while unregistering drivers - shouldn't occure.
}
}
//Get all Threads that are running
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
//convert them to an array
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
//for all threads, only stop threads that have the name "Abandoned connection cleanup thread" - a mysql connection thread
for(Thread t: threadArray) {
if(t.getName().contains("Abandoned connection cleanup thread")) {
synchronized (t) {
t.stop();
}
}
}
}
}

View File

@ -1235,19 +1235,16 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingGET", "operationId": "errorHtmlUsingGET",
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1257,22 +1254,19 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingHEAD", "operationId": "errorHtmlUsingHEAD",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1282,22 +1276,19 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingPOST", "operationId": "errorHtmlUsingPOST",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1307,22 +1298,19 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingPUT", "operationId": "errorHtmlUsingPUT",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1332,19 +1320,16 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingDELETE", "operationId": "errorHtmlUsingDELETE",
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1354,22 +1339,19 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingOPTIONS", "operationId": "errorHtmlUsingOPTIONS",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1379,22 +1361,19 @@
"tags": [ "tags": [
"basic-error-controller" "basic-error-controller"
], ],
"summary": "error", "summary": "errorHtml",
"operationId": "errorUsingPATCH", "operationId": "errorHtmlUsingPATCH",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"produces": [ "produces": [
"*/*" "text/html"
], ],
"responses": { "responses": {
"200": { "200": {
"description": "OK", "description": "OK",
"schema": { "schema": {
"type": "object", "$ref": "#/definitions/ModelAndView"
"additionalProperties": {
"type": "object"
}
} }
} }
}, },
@ -1673,4 +1652,4 @@
"title": "View" "title": "View"
} }
} }
} }