@@ -88,14 +87,17 @@
return false;
}
},
+ created() {
+ this.login();
+ },
methods: {
validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
},
register: function () {
+
if(this.user.email===this.user.checkemail&&this.user.password===this.user.checkpassword){
- this.login();
const data = {
name: this.user.name,
password: this.user.password,
@@ -110,7 +112,7 @@
console.log("POST /api/register/ - json: " + JSON.stringify(data));
const token = JSON.parse(localStorage.getItem('registerToken')).token;
- this.$axios.post('http://www.se.hs-heilbronn.de:8090/buga19usermanagement/account/register', data,{
+ this.$axios.post(process.env.USER_API+'/account/register', data,{
headers: {
'Authorization': 'Bearer ' + token,
}
@@ -158,7 +160,7 @@
}
}
},
- login: function () {
+ login() {
const logindata = {
email: "register@bugageocaching.de",
@@ -167,7 +169,7 @@
console.log("GET /api/login/ - json: " + JSON.stringify(logindata));
- this.$axios.post('http://www.se.hs-heilbronn.de:8090/buga19usermanagement/account/login', logindata)
+ this.$axios.post(process.env.USER_API+'/account/login', logindata)
.then((response) => {
localStorage.setItem('registerToken', JSON.stringify(response.data));
})
diff --git a/frontend/src/pages/StationEdit.vue b/frontend/src/pages/StationEdit.vue
index 3e1a6e8..a1736d9 100644
--- a/frontend/src/pages/StationEdit.vue
+++ b/frontend/src/pages/StationEdit.vue
@@ -49,7 +49,7 @@
description: "Rätsel, Aufgabe und Informationen zur Station.",
latlang: "",
station: {
- description: "Beschreibung",
+ description: "Rätsel, Aufgabe und Informationen zur Station.",
lattitude: "0.000",
longitude: "0.000",
solution: "",
diff --git a/frontend/src/pages/StationView.vue b/frontend/src/pages/StationView.vue
index 453ffb8..1a0ee7a 100644
--- a/frontend/src/pages/StationView.vue
+++ b/frontend/src/pages/StationView.vue
@@ -6,10 +6,10 @@
src="https://www.buga2019.de/we-bilder/3.Gartenausstellung/Gelaendeplan/190320_Gelaendeplan-quadratisch.jpg"
>
-
{{ data.cacheName }}
+
{{ cache.name }}
Station {{ showCacheProgress }}
-
{{ data.station.description }}
+
{{ station.description }}
@@ -52,19 +52,14 @@
data() {
return {
//code: "",
- cache: null,
- data: {
- cacheId: 22,
- cacheName: "Wasserfall Cache",
- station: {
- id: 22,
- description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
- longitude: 9.206628,
- lattitude: 49.147734,
- code: 213812,
- solution: "Schneeglöckchen"
- }
+ cacheID: "",
+ cacheName: "",
+ //cache: null,
+ cache: {
+ name: "",
+ stationen: [],
},
+ station: {},
// Following Params belong to QR-Code Scanner
askForPermission: true,
@@ -79,21 +74,49 @@
}
},
+ beforeRouteUpdate (to, from, next) {
+ console.log("beforeRouteUpdate: reset data and fetch");
+ this.cacheID = "";
+ this.cacheName = "";
+ this.cache = {
+ name: "",
+ stationen: [],
+ };
+ this.station = {};
+ this.askForPermission = true;
+ this.activateCamera = false;
+ this.isValid = false;
+ this.validating = false;
+ this.loading = false;
+ this.paused = false;
+ this.result = null;
+ this.params = null;
+ this.noStreamApiSupport = false;
+
+ this.fetchData();
+ next()
+ },
created: function () {
- console.log("StationView: ")
- // console.log("'id' from url: " + this.$route.params.id)
- // console.log("'cache' from url: " + this.$route.params.cache)
+ console.log("StationView: created!");
+ console.log("'id' from url: " + this.$route.params.id);
+ console.log("'cache' from url: " + this.$route.params.cache);
this.fetchData();
},
beforeMount: function () {
},
mounted: function () {
},
+ updated: function () {
+ },
computed: {
showCacheProgress() {
- let stationCount = this.cache.stationen.length;
- let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id));
- return `${stationPos} von ${stationCount}`;
+ if (this.cache !== null) {
+ let stationCount = this.cache.stationen.length;
+ let stationPos = 1 + this.cache.stationen.findIndex(station => station.id === Number(this.$route.params.id));
+ return `${stationPos} von ${stationCount}`;
+ } else {
+ return "";
+ }
}
},
methods: {
@@ -101,65 +124,16 @@
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
- console.log(JSON.stringify(this.data));
- console.log(this.data);
console.log(response.data);
const cache = response.data.find(cache => cache.id === Number(this.$route.params.cache));
- this.data.cacheId = cache.id;
- this.data.cacheName = cache.name;
this.cache = cache;
- console.log(JSON.stringify(this.data));
- this.$axios.get('/api/getAllStations')
- .then((response) => {
- console.log("/api/getAllStations");
- console.log(response.data);
- const stationView = response.data.find(station => station.id === Number(this.$route.params.id));
- console.log(JSON.stringify(stationView));
- this.data.station = stationView;
- }).catch((error) => {
- // Error
- let msg;
- let title;
- if (error.response) {
- // The request was made and the server responded with a status code
- title = "Problem with response!";
- msg = error.response;
- } else if (error.request) {
- // The request was made but no response was received
- title = "Problem with request!";
- msg = "Error occured due to wrong server request!"
- console.log(error.request);
- } else {
- // Something happened in setting up the request that triggered an Error
- title = "Error";
- msg = error.message;
- console.log('Error', error.message);
- }
- console.log(error.config);
- this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
- })
- }).catch((error) => {
- // Error
- let msg;
- let title;
- if (error.response) {
- // The request was made and the server responded with a status code
- title = "Problem with response!";
- msg = error.response;
- } else if (error.request) {
- // The request was made but no response was received
- title = "Problem with request!";
- msg = "Error occured due to wrong server request!"
- console.log(error.request);
- } else {
- // Something happened in setting up the request that triggered an Error
- title = "Error";
- msg = error.message;
- console.log('Error', error.message);
- }
- console.log(error.config);
- this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, });
- })
+ this.station = cache.stationen.find(station => station.id === Number(this.$route.params.id));
+ this.cacheName = cache.name;
+ this.cacheID = this.$route.params.cache;
+ console.log(JSON.stringify(this.cache));
+ console.log(JSON.stringify(this.station));
+ console.log(this.cache);
+ })
},
setParams() {
@@ -167,7 +141,8 @@
let params = {};
params.cacheID = this.result.split('/')[0];
params.stationID = this.result.split('/')[1];
- params.durchgefuehrterCacheID = this.cacheID;
+ params.durchgefuehrterCacheID = params.cacheID;
+ console.log(params.durchgefuehrterCacheID);
console.log(params.cacheID + " und " + params.stationID);
if (localStorage.getItem('userToken')) {
params.token = JSON.parse(localStorage.getItem('userToken')).token;
@@ -197,10 +172,12 @@
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log("resolve(true)");
+ console.log("cache access definition");
+ console.log(response.data.cacheAccesDefinition);
resolve(true);
- if (response.data.cache_acces_definition === 0) {
+ if (Number(response.data.cacheAccesDefinition.id) === 0) {
this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
- } else if (response.data.cache_acces_definition === 1) {
+ } else if (Number(response.data.cacheAccesDefinition.id) === 1) {
this.$router.push({path: `/CacheEnd/${params.cacheID}`});
}
}).catch((error) => {
diff --git a/frontend/src/pages/qr-scanner.vue b/frontend/src/pages/qr-scanner.vue
index 087cb71..e111c73 100644
--- a/frontend/src/pages/qr-scanner.vue
+++ b/frontend/src/pages/qr-scanner.vue
@@ -1,6 +1,6 @@
-
-
+
+
Um den QR-Code scannen zu können, müssen Sie den Zugriff auf Ihre Kamera erlauben.
{
- this.setParams(0);
- let params = this.params;
+ let params = this.setParams();
this.$axios.get('/api/checkStation', {params})
.then((response) => {
console.log("resolve(true)");
- resolve(true)
+ console.log("cache access definition");
+ console.log(response.data.cacheAccesDefinition);
+ resolve(true);
+ if (Number(response.data.cacheAccesDefinition.id) === 0) {
+ this.$router.push({path: `/station/${params.cacheID}/${params.stationID}`});
+ } else if (Number(response.data.cacheAccesDefinition.id) === 1) {
+ this.$router.push({path: `/CacheEnd/${params.cacheID}`});
+ }
}).catch((error) => {
console.log("resolve(false)");
// Error
@@ -96,20 +102,17 @@
})
},
- setParams(cacheID) {
+ setParams() {
console.log("setParams: ");
- let resCacheID = this.result.split('/')[0];
- let resStationID = this.result.split('/')[1];
- console.log(resCacheID + " und " + resStationID);
- this.params = {
- token: null,
- cacheID: resCacheID,
- stationID: resStationID,
- durchgefuehrterCacheID: cacheID
- };
+ let params = {};
+ params.cacheID = this.result.split('/')[0];
+ params.stationID = this.result.split('/')[1];
+ params.durchgefuehrterCacheID = params.cacheID;
+ console.log(params.cacheID + " und " + params.stationID);
if (localStorage.getItem('userToken')) {
- this.params.token = JSON.parse(localStorage.getItem('userToken')).token;
+ params.token = JSON.parse(localStorage.getItem('userToken')).token;
}
+ return params;
},
pauseCamera() {
diff --git a/frontend/src/router/routes.js b/frontend/src/router/routes.js
index 79fa81c..6a39f45 100644
--- a/frontend/src/router/routes.js
+++ b/frontend/src/router/routes.js
@@ -75,6 +75,11 @@ const routes = [
component: () => import("layouts/MyLayout.vue"),
children: [{ path: "", component: () => import("pages/Profile.vue") }]
},
+ {
+ path: "/mycaches/",
+ component: () => import("layouts/MyLayout.vue"),
+ children: [{ path: "", component: () => import("pages/MyCaches.vue") }]
+ },
{
path: "/register/",
component: () => import("layouts/MyLayout.vue"),
diff --git a/frontend/src/store/cacheCollector/getters.js b/frontend/src/store/cacheCollector/getters.js
index d2bea70..a09722a 100644
--- a/frontend/src/store/cacheCollector/getters.js
+++ b/frontend/src/store/cacheCollector/getters.js
@@ -10,3 +10,7 @@ export const GET_ENDSTATION = (state) => {
console.log("GET_ENDSTATION: retrieve cache from store. ");
return state.endStation;
};
+export const GET_STATIONS = (state) => {
+ console.log("GET_STATIONEN: retrieve cache from store. ");
+ return state.newCache.stationen;
+};
diff --git a/frontend/src/store/cacheCollector/mutations.js b/frontend/src/store/cacheCollector/mutations.js
index 72f58e1..fb9ae86 100644
--- a/frontend/src/store/cacheCollector/mutations.js
+++ b/frontend/src/store/cacheCollector/mutations.js
@@ -10,6 +10,10 @@ export const SET_ENDSTATION = (state, station) => {
console.log("SET_ENDSTATION: "+station);
state.endStation = station;
};
+export const SET_STATIONS = (state, station) => {
+ console.log("SET_STATIONEN: "+station);
+ state.newCache.stationen = station;
+};
export const ADD_STATION = (state, station) => {
console.log("ADD_STATION: add new station to cache: "+station);
state.newCache.stationen.push(station);
@@ -31,13 +35,18 @@ export const RESET_NEW_CACHE = (state) => {
name: "",
description: "",
rankingPoints: 0,
+ reward: {
+ rewardDescription: "",
+ },
stationen: []
};
state.endStation = {
description: "Endstation",
- longitude: 0.0001,
- lattitude: 0.0001,
+ longitude: 9.206628,
+ lattitude: 49.147734,
+ solution: "",
};
+
console.log("resetted new Cache");
};
export const LOAD_REMOTE_CACHE = (state, id) => {
diff --git a/frontend/src/store/cacheCollector/state.js b/frontend/src/store/cacheCollector/state.js
index 0f32de1..aef4926 100644
--- a/frontend/src/store/cacheCollector/state.js
+++ b/frontend/src/store/cacheCollector/state.js
@@ -3,48 +3,16 @@ export default {
name: "",
description: "",
rankingPoints: 0,
- reward: "",
+ reward: {
+ rewardDescription: "",
+ },
stationen: []
},
- // newCache: {
- // name: "Blumencache",
- // description: "Dieser Cache umfasst 4 Stationen mit Rätseln rund um das Thema Blumen",
- // rankingPoints: 100,
- // stationen: [
- // {
- // description: "Ein kleines winterliches Schlaginstrument. Welche Blume ist damit gemeint?",
- // longitude: 9.206628,
- // lattitude: 49.147734,
- // code: 213812,
- // solution: "Schneeglöckchen"
- // },
- // {
- // description: "Ein blühendes Federvieh. Welche Blume ist damit gemeint?",
- // longitude: 9.206806,
- // lattitude: 49.147318,
- // code: 237823,
- // solution: "Gänseblümchen"
- // },
- // {
- // description: "Eine wertvolle Farbe. Welche Blume ist damit gemeint?",
- // longitude: 9.207844,
- // lattitude: 49.148032,
- // code: 899423,
- // solution: "Edelweiß"
- // },
- // {
- // description: "Ein Zerkleinerungsgerät in der Brüllöffnung eines Raubtieres. Welche Blume ist damit gemeint?",
- // longitude: 9.207649,
- // lattitude: 49.150142,
- // code: 347923,
- // solution: "Löwenzahn"
- // }
- // ]
- // },
tempStation: {},
endStation: {
description: "Endstation",
longitude: 9.206628,
lattitude: 49.147734,
+ solution: "",
},
}
diff --git a/frontend/src/store/currentCache/actions.js b/frontend/src/store/currentCache/actions.js
new file mode 100644
index 0000000..4787a5f
--- /dev/null
+++ b/frontend/src/store/currentCache/actions.js
@@ -0,0 +1,4 @@
+/*
+export function someAction (context) {
+}
+*/
diff --git a/frontend/src/store/currentCache/getters.js b/frontend/src/store/currentCache/getters.js
new file mode 100644
index 0000000..cc054a3
--- /dev/null
+++ b/frontend/src/store/currentCache/getters.js
@@ -0,0 +1,4 @@
+/*
+export function someGetter (state) {
+}
+*/
diff --git a/frontend/src/store/currentCache/index.js b/frontend/src/store/currentCache/index.js
new file mode 100644
index 0000000..b41a219
--- /dev/null
+++ b/frontend/src/store/currentCache/index.js
@@ -0,0 +1,12 @@
+import state from './state'
+import * as getters from './getters'
+import * as mutations from './mutations'
+import * as actions from './actions'
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ mutations,
+ actions
+}
diff --git a/frontend/src/store/currentCache/mutations.js b/frontend/src/store/currentCache/mutations.js
new file mode 100644
index 0000000..63131e2
--- /dev/null
+++ b/frontend/src/store/currentCache/mutations.js
@@ -0,0 +1,4 @@
+/*
+export function someMutation (state) {
+}
+*/
diff --git a/frontend/src/store/currentCache/state.js b/frontend/src/store/currentCache/state.js
new file mode 100644
index 0000000..dbc1d63
--- /dev/null
+++ b/frontend/src/store/currentCache/state.js
@@ -0,0 +1,5 @@
+export default {
+ cache: {},
+ currentCacheID: null,
+ currentStationID: null,
+}
diff --git a/frontend/src/store/dialog/mutations.js b/frontend/src/store/dialog/mutations.js
index 8994399..4a14ffa 100644
--- a/frontend/src/store/dialog/mutations.js
+++ b/frontend/src/store/dialog/mutations.js
@@ -1,12 +1,12 @@
export function NEW_MESSAGE_DIALOG (state, messageObject) {
- console.log("NEW_MESSAGE_DIALOG");
- console.log(messageObject);
+ // console.log("NEW_MESSAGE_DIALOG");
+ // console.log(messageObject);
if (messageObject == null) {
state.dialog.show = true;
return;
}
- console.log(messageObject);
+ // console.log(messageObject);
if (messageObject.hasOwnProperty('color')) {
switch (messageObject.color) {
@@ -39,7 +39,7 @@ export function NEW_MESSAGE_DIALOG (state, messageObject) {
state.dialog.show = true;
}
export function RESET_MESSAGE_DIALOG (state) {
- console.log("RESET_MESSAGE_DIALOG");
+ // console.log("RESET_MESSAGE_DIALOG");
state.dialog.colorBackground = "bg-red-9 text-white";
state.dialog.colorButton = "red-9";
state.dialog.message = "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es noch einmal.";
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index 58a40f8..9a7a3b2 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -4,6 +4,7 @@ import Axios from "axios";
import auth from "./auth"
import cacheCollector from "./cacheCollector"
import dialog from "./dialog"
+import currentCache from "./currentCache"
// import example from './module-example'
@@ -19,7 +20,8 @@ export default function (/* { ssrContext } */) {
modules: {
auth,
cacheCollector,
- dialog
+ dialog,
+ currentCache
},
// enable strict mode (adds overhead!)
@@ -42,11 +44,15 @@ export default function (/* { ssrContext } */) {
module.hot.accept(['./cacheCollector'], () => {
const cacheCollector = require('./cacheCollector').default;
store.hotUpdate({ modules: { cacheCollector: newCacheCollector } })
- })
+ });
module.hot.accept(['./dialog'], () => {
const dialog = require('./dialog').default;
store.hotUpdate({ modules: { dialog: newDialog } })
- })
+ });
+ module.hot.accept(['./currentCache'], () => {
+ const currentCache = require('./currentCache').default;
+ store.hotUpdate({ modules: { currentCache: newCurrentCache } })
+ });
}
return Store
diff --git a/src/main/java/hhn/labsw/bugageocaching/Application.java b/src/main/java/hhn/labsw/bugageocaching/Application.java
index 75f1fb0..f835849 100644
--- a/src/main/java/hhn/labsw/bugageocaching/Application.java
+++ b/src/main/java/hhn/labsw/bugageocaching/Application.java
@@ -6,8 +6,15 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.Bean;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
+@EnableSwagger2
public class Application extends SpringBootServletInitializer{
@Override
@@ -18,4 +25,13 @@ public class Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
+
+ @Bean
+ public Docket swagger(){
+ return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false)
+ .select()
+ .apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any())
+ .build();
+ }
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
index cadd2c6..5cbb663 100644
--- a/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
+++ b/src/main/java/hhn/labsw/bugageocaching/controller/Controller.java
@@ -8,6 +8,10 @@ import hhn.labsw.bugageocaching.repositories.*;
import hhn.labsw.bugageocaching.util.FinderUtil;
import hhn.labsw.bugageocaching.util.VerificationUtil;
import io.jsonwebtoken.Claims;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -16,7 +20,6 @@ import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import java.util.Optional;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.createCacheUtil;
import static hhn.labsw.bugageocaching.util.CacheConstructionUtil.deleteCacheUtil;
@@ -57,98 +60,112 @@ public class Controller {
fetchPublicKey();
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/allCaches")
+ @ApiOperation(value = "Retrieves all Caches, including their Stations, from the Database")
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/allCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getAllCaches() {
return ResponseEntity.status(200).body(new Gson().toJson(cacheRepository.findAll()));
}
- // alte startCache-methode
-// @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
-// @RequestMapping("/api/startCache")
-// @ResponseBody
-// public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token,
-// @RequestParam String cacheID) {
-//
-// if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben)
-//
-// Bearbeitet bearbeitet = new Bearbeitet();
-//
-//
-// //----------------------
-// //Verify token
-// ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
-//
-// //Error in token verification
-// if (tokenVerification.getStatusCodeValue() != 200) {
-// return tokenVerification;
-// }
-//
-// Claims claims = (Claims) tokenVerification.getBody();
-//
-// ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
-//
-// if (getUser.getStatusCodeValue() != 200) {
-// return getUser;
-// }
-//
-// User user = (User) getUser.getBody();
-//
-// bearbeitet.setUser(user);
-//
-// //----------------------
-// //Get Cache
-// ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
-//
-// if (getCache.getStatusCodeValue() != 200) {
-// return getCache;
-// }
-//
-// Cache cache = (Cache) getCache.getBody();
-// //----------------------
-//
-// if (bearbeitetRepository.findByUserAndCache(user, cache) != null) {
-// Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache);
-// return ResponseEntity.status(200).body(bearbeitet1);
-// }
-//
-// bearbeitet.setCache(cache);
-//
-// Station startStation = cache.getStationen().get(0);
-// bearbeitet.setAktuelleStation(startStation);
-//
-// //Get CacheAccesDefinition
-// ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
-//
-// if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
-// return getCacheAccesDefinition;
-// }
-//
-// CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
-// //----------------------
-// bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
-//
-// bearbeitetRepository.save(bearbeitet);
-//
-// return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
-//
-// } else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben)
-//
-// ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
-//
-// if (getCache.getStatusCodeValue() != 200) {
-// return getCache;
-// }
-//
-// Cache cache = (Cache) getCache.getBody();
-//
-// return ResponseEntity.status(200).body(new Gson().toJson(cache));
-// }
-// }
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/checkStation")
+ @ApiOperation(value = "Starts the given Cache for the given User")
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error"),
+ @ApiResponse(code = 401, message = "JWT Token expired"),
+ @ApiResponse(code = 400, message = "Something went wrong at verification")
+ })
+ @RequestMapping(value = "/api/startCache", method = RequestMethod.POST, produces = "application/json")
+ @ResponseBody
+ public ResponseEntity startCache(@RequestParam(value = "token", defaultValue = "-1") String token,
+ @RequestParam String cacheID) {
+
+ if (!token.equals("-1")) { // ein angemeldeter user startet den cache(es werden zwei parameter übergeben)
+
+ Bearbeitet bearbeitet = new Bearbeitet();
+
+
+ //----------------------
+ //Verify token
+ ResponseEntity tokenVerification = VerificationUtil.verifyToken(token);
+
+ //Error in token verification
+ if (tokenVerification.getStatusCodeValue() != 200) {
+ return tokenVerification;
+ }
+
+ Claims claims = (Claims) tokenVerification.getBody();
+
+ ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
+
+ if (getUser.getStatusCodeValue() != 200) {
+ return getUser;
+ }
+
+ User user = (User) getUser.getBody();
+
+ bearbeitet.setUser(user);
+
+ //----------------------
+ //Get Cache
+ ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
+
+ if (getCache.getStatusCodeValue() != 200) {
+ return getCache;
+ }
+
+ Cache cache = (Cache) getCache.getBody();
+ //----------------------
+
+ if (bearbeitetRepository.findByUserAndCache(user, cache) != null) {
+ Bearbeitet bearbeitet1 = bearbeitetRepository.findByUserAndCache(user, cache);
+ return ResponseEntity.status(200).body(bearbeitet1);
+ }
+
+ bearbeitet.setCache(cache);
+
+ Station startStation = cache.getStationen().get(0);
+ bearbeitet.setAktuelleStation(startStation);
+
+ //Get CacheAccesDefinition
+ ResponseEntity getCacheAccesDefinition = FinderUtil.findCacheAccesDefinitionById("0");
+
+ if (getCacheAccesDefinition.getStatusCodeValue() != 200) {
+ return getCacheAccesDefinition;
+ }
+
+ CacheAccesDefinition cacheAccesDefinition = (CacheAccesDefinition) getCacheAccesDefinition.getBody();
+ //----------------------
+ bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
+
+ //bearbeitetRepository.save(bearbeitet);
+
+ return ResponseEntity.status(201).body(new Gson().toJson(bearbeitet));
+
+ } else { // kein angemeldeter User startet den cache(es wird nur der cache als parameter übergeben)
+
+ ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
+
+ if (getCache.getStatusCodeValue() != 200) {
+ return getCache;
+ }
+
+ Cache cache = (Cache) getCache.getBody();
+
+ return ResponseEntity.status(200).body(new Gson().toJson(cache));
+ }
+ }
+
+ @ApiOperation(value = "Checks if the given Station is the correct next Station in the Cache")
+ @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
+ @RequestMapping(value = "/api/checkStation", method = RequestMethod.PUT, produces = "application/json")
@ResponseBody
public ResponseEntity checkStation(@RequestParam String token,
@RequestParam String cacheID,
@@ -208,8 +225,11 @@ public class Controller {
Station station = (Station) getStation.getBody();
//----------------------
- if (cache != durchgefuehrterCache) {
- return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
+ System.out.println(cache.getName());
+ System.out.println(durchgefuehrterCache.getName());
+
+ if (!cacheID.equals(durchgefuehrterCacheID)) {
+ return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (Name)");
}
if (!cache.getStationen().contains(station)) {
@@ -223,6 +243,7 @@ public class Controller {
if (getBearbeitet.getStatusCodeValue() != 200) {
if (cache.getStationen().get(0).equals(station)) {
// start Cache
+ System.out.println("Startstation");
Bearbeitet bearbeitet = new Bearbeitet();
bearbeitet.setUser(user);
bearbeitet.setCache(cache);
@@ -259,7 +280,7 @@ public class Controller {
int i = cache.getStationen().indexOf(station);
if (i == 0) {
- return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
+ return ResponseEntity.status(400).body("The scanned station isn´t the correct following station (i==0)");
}
if (cache.getStationen().get(i - 1).equals(aktuelleStation)) {
@@ -277,13 +298,8 @@ public class Controller {
//----------------------
bearbeitet.setCacheAccesDefinition(cacheAccesDefinition);
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ System.out.println(String.valueOf(user.getId()));
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
user_info.setRankingPointsSum(user_info.getRankingPointsSum() + cache.getRankingPoints());
user_infoRepository.save(user_info);
@@ -291,20 +307,31 @@ public class Controller {
bearbeitetRepository.save(bearbeitet);
return ResponseEntity.status(200).body(new Gson().toJson(bearbeitet));
} else {
- return ResponseEntity.status(400).body("The scanned station isn´t the correct following station");
+ return ResponseEntity.status(400).body("The scanned station isn´t the correct following station(nicht letzte)");
}
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/createCache")
+ @ApiOperation(value = "Creates a new Cache")
+ @ApiResponses(value = {
+ @ApiResponse(code = 400, message = "Something wrong with the given Parameters")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/createCache", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResponseEntity createCache(@RequestBody Cache cache) {
return createCacheUtil(cache);
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/checkAdmin")
+ @ApiOperation(value = "Checks if the given User has an admin role")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error"),
+ @ApiResponse(code = 401, message = "JWT Token expired"),
+ @ApiResponse(code = 400, message = "Something went wrong at verification")
+
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/checkAdmin", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity checkAdmin(@RequestParam String token) {
@@ -334,23 +361,36 @@ public class Controller {
return ResponseEntity.status(401).body(false);
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/getAllStations")
+ @ApiOperation(value = "Returns all Stations")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/getAllStations", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getAllStations() {
return ResponseEntity.status(200).body(new Gson().toJson(stationRepository.findAll()));
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/deleteCache")
+ @ApiOperation(value = "Deletes a Cache")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/deleteCache", method = RequestMethod.DELETE, produces = "application/json")
@ResponseBody
public ResponseEntity deleteCache(@RequestParam String cacheID) {
return deleteCacheUtil(cacheID);
}
-
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/getMyCaches")
+ @ApiOperation(value = "Returns all Caches finished/started by a given User")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error"),
+ @ApiResponse(code = 401, message = "JWT Token expired"),
+ @ApiResponse(code = 400, message = "Something went wrong at verification")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/getMyCaches", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getMyCaches(@RequestParam String token) {
@@ -385,8 +425,12 @@ public class Controller {
}
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/getRankingList")
+ @ApiOperation(value = "Returns the rankinglist")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/getRankingList", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getRankingList() {
@@ -400,8 +444,12 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackUsers));
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/getTeamRankingList")
+ @ApiOperation(value = "Returns the Team Rankinglist")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/getTeamRankingList", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getTeamRankingList() {
@@ -415,8 +463,14 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(sendBackTeams));
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/getUser")
+ @ApiOperation(value = "Returns a user from a given token")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error"),
+ @ApiResponse(code = 401, message = "JWT Token expired"),
+ @ApiResponse(code = 400, message = "Something went wrong at verification")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/getUser", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseEntity getUser(@RequestParam String token) {
@@ -443,8 +497,14 @@ public class Controller {
}
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/createTeam")
+ @ApiOperation(value = "Creates a new Team")
+ @ApiResponses(value = {
+ @ApiResponse(code = 404, message = "Database error"),
+ @ApiResponse(code = 401, message = "JWT Token expired"),
+ @ApiResponse(code = 400, message = "Something went wrong at verification")
+ })
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping(value = "/api/createTeam", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public ResponseEntity createTeam(@RequestParam String token,
@RequestParam String name) {
@@ -467,13 +527,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() != null) {
return ResponseEntity.status(400).body("You already have a team");
@@ -496,7 +550,9 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(team));
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
+ //---------
+
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/joinTeam")
@ResponseBody
public ResponseEntity joinTeam(@RequestParam String token,
@@ -520,13 +576,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() != null) {
return ResponseEntity.status(400).body("You already have a team");
@@ -563,7 +613,7 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(team));
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
@RequestMapping("/api/leaveTeam")
@ResponseBody
public ResponseEntity leaveTeam(@RequestParam String token) {
@@ -587,13 +637,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@@ -663,13 +707,7 @@ public class Controller {
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@@ -780,13 +818,7 @@ public class Controller {
User user = (User) getUser.getBody();
//Get User_Info
- ResponseEntity getUser_Info = FinderUtil.findUser_InfoByID(String.valueOf(user.getId()));
-
- if (getUser_Info.getStatusCodeValue() != 200) {
- return getUser_Info;
- }
-
- User_Info user_info = (User_Info) getUser_Info.getBody();
+ User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
//----------------------
if (user_info.getTeam() == null) {
return ResponseEntity.status(400).body("You aren´t in any team");
@@ -821,10 +853,42 @@ public class Controller {
return FinderUtil.findTeammemberByTeamName(name);
}
- @CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
- @RequestMapping("/api/hello")
- public ResponseEntity hello(@RequestParam String name) {
- return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping("/api/getCurrentStation")
+ @ResponseBody
+ public ResponseEntity getStationFromUserAndCache(@RequestParam String token,
+ @RequestParam String cacheID){
+
+ // verify user
+ ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
+
+ if (verifyToken.getStatusCodeValue() != 200) {
+ return verifyToken;
+ }
+
+ // get user
+ Claims claims = (Claims) verifyToken.getBody();
+
+ ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
+
+ if (getUser.getStatusCodeValue() != 200) {
+ return getUser;
+ }
+
+ User user = (User) getUser.getBody();
+
+ //----------------------
+ //Get Cache
+ ResponseEntity getCache = FinderUtil.findCacheById(cacheID);
+
+ if (getCache.getStatusCodeValue() != 200) {
+ return getCache;
+ }
+
+ Cache cache = (Cache) getCache.getBody();
+ //----------------------
+
+ return ResponseEntity.status(200).body(bearbeitetRepository.findByUserAndCache(user, cache));
}
@CrossOrigin(origins = "http://localhost:8081") // only for dev purpose
@@ -852,6 +916,11 @@ public class Controller {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(user.getUsername()));
}
+ @CrossOrigin(origins = "*", allowedHeaders = "*") // only for dev purpose
+ @RequestMapping("/api/hello")
+ public ResponseEntity hello(@RequestParam String name) {
+ return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
+ }
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/Cache.java b/src/main/java/hhn/labsw/bugageocaching/entities/Cache.java
index 465b2cc..013e1b8 100644
--- a/src/main/java/hhn/labsw/bugageocaching/entities/Cache.java
+++ b/src/main/java/hhn/labsw/bugageocaching/entities/Cache.java
@@ -1,6 +1,9 @@
package hhn.labsw.bugageocaching.entities;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@@ -11,16 +14,24 @@ public class Cache {
@Id
@GeneratedValue
+ @ApiModelProperty(notes = "The autogenerated CacheID (Primary Key)")
private int id;
+ @ApiModelProperty(notes = "The name of the Cache")
private String name;
+
+ @ApiModelProperty(notes = "The Description of the Cache")
private String description;
+
+ @ApiModelProperty(notes = "The number of ranking points the user gets fro completing the cache")
private int rankingPoints;
@OneToMany
+ @ApiModelProperty(notes = "All stations included in the Cache")
private List stationen = new ArrayList<>();
- @ManyToOne
+ @ApiModelProperty(notes = "The Reward for the Cache")
+ @ManyToOne (cascade = {CascadeType.ALL})
private Reward reward;
public Cache() {
diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/User_Info.java b/src/main/java/hhn/labsw/bugageocaching/entities/User_Info.java
index 74ff0a3..c74c428 100644
--- a/src/main/java/hhn/labsw/bugageocaching/entities/User_Info.java
+++ b/src/main/java/hhn/labsw/bugageocaching/entities/User_Info.java
@@ -1,7 +1,9 @@
package hhn.labsw.bugageocaching.entities;
+import org.hibernate.validator.constraints.UniqueElements;
import org.springframework.context.annotation.Primary;
+import javax.annotation.Generated;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,6 +17,9 @@ public class User_Info implements Serializable {
private User user;
@Id
+ @GeneratedValue
+ private int id;
+
private int rankingPointsSum;
@ManyToOne
@@ -24,6 +29,14 @@ public class User_Info implements Serializable {
public User_Info() {
}
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
public User getUser() {
return user;
}
@@ -47,4 +60,5 @@ public class User_Info implements Serializable {
public void setTeam(Team team) {
this.team = team;
}
+
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/entities/User_InfoID.java b/src/main/java/hhn/labsw/bugageocaching/entities/User_InfoID.java
index 4d63e41..2c04860 100644
--- a/src/main/java/hhn/labsw/bugageocaching/entities/User_InfoID.java
+++ b/src/main/java/hhn/labsw/bugageocaching/entities/User_InfoID.java
@@ -4,5 +4,5 @@ import java.io.Serializable;
public class User_InfoID implements Serializable {
private int user;
- private int rankingPointsSum;
+ private int id;
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/repositories/User_InfoRepository.java b/src/main/java/hhn/labsw/bugageocaching/repositories/User_InfoRepository.java
index a96b12d..309cc41 100644
--- a/src/main/java/hhn/labsw/bugageocaching/repositories/User_InfoRepository.java
+++ b/src/main/java/hhn/labsw/bugageocaching/repositories/User_InfoRepository.java
@@ -1,8 +1,13 @@
package hhn.labsw.bugageocaching.repositories;
+import hhn.labsw.bugageocaching.entities.User;
import hhn.labsw.bugageocaching.entities.User_Info;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
-public interface User_InfoRepository extends CrudRepository {
+import java.util.List;
+import java.util.Optional;
+public interface User_InfoRepository extends CrudRepository {
+ User_Info findUser_InfoByUser(User user);
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java
index a79d112..4fc883c 100644
--- a/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java
+++ b/src/main/java/hhn/labsw/bugageocaching/util/FinderUtil.java
@@ -35,6 +35,53 @@ public class FinderUtil {
static TeamInviteRepository teamInviteRepository;
+
+ @Autowired
+ public void setCacheRepository(CacheRepository cacheRepository) {
+ FinderUtil.cacheRepository = cacheRepository;
+ }
+
+ @Autowired
+ public void setRewardRepository(RewardRepository rewardRepository) {
+ FinderUtil.rewardRepository = rewardRepository;
+ }
+
+ @Autowired
+ public void setStationRepository(StationRepository stationRepository) {
+ FinderUtil.stationRepository = stationRepository;
+ }
+
+ @Autowired
+ public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) {
+ FinderUtil.bearbeitetRepository = bearbeitetRepository;
+ }
+
+ @Autowired
+ public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) {
+ FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository;
+ }
+
+ @Autowired
+ public void setTeamRepository(TeamRepository teamRepository) {
+ FinderUtil.teamRepository = teamRepository;
+ }
+
+ @Autowired
+ public void setUserRepository(UserRepository userRepository) {
+ FinderUtil.userRepository = userRepository;
+ }
+
+ @Autowired
+ public void setUser_infoRepository(User_InfoRepository user_infoRepository) {
+ FinderUtil.user_infoRepository = user_infoRepository;
+ }
+
+ @Autowired
+ public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
+ FinderUtil.teamInviteRepository = teamInviteRepository;
+ }
+
+
public static ResponseEntity findCacheById(String cacheID) {
Optional cacheOptional = cacheRepository.findById(Integer.valueOf(cacheID));
@@ -75,15 +122,6 @@ public class FinderUtil {
}
}
- public static ResponseEntity findUser_InfoByID(String infoID) {
- Optional user_InfoOptional = user_infoRepository.findById(Integer.valueOf(infoID));
- if (user_InfoOptional.isPresent()) {
- return ResponseEntity.status(200).body(user_InfoOptional.get());
- } else {
- return ResponseEntity.status(404).body("Couldnt find User_Info " + infoID);
- }
- }
-
public static ResponseEntity findUserFromClaim(Claims claims) {
try {
@@ -151,50 +189,4 @@ public class FinderUtil {
return ResponseEntity.status(404).body("Couldnt find Team member of Team " + name);
}
}
-
- @Autowired
- public void setCacheRepository(CacheRepository cacheRepository) {
- FinderUtil.cacheRepository = cacheRepository;
- }
-
- @Autowired
- public void setRewardRepository(RewardRepository rewardRepository) {
- FinderUtil.rewardRepository = rewardRepository;
- }
-
- @Autowired
- public void setStationRepository(StationRepository stationRepository) {
- FinderUtil.stationRepository = stationRepository;
- }
-
- @Autowired
- public void setBearbeitetRepository(BearbeitetRepository bearbeitetRepository) {
- FinderUtil.bearbeitetRepository = bearbeitetRepository;
- }
-
- @Autowired
- public void setCacheAccesDefinitionRepository(CacheAccesDefinitionRepository cacheAccesDefinitionRepository) {
- FinderUtil.cacheAccesDefinitionRepository = cacheAccesDefinitionRepository;
- }
-
- @Autowired
- public void setTeamRepository(TeamRepository teamRepository) {
- FinderUtil.teamRepository = teamRepository;
- }
-
- @Autowired
- public void setUserRepository(UserRepository userRepository) {
- FinderUtil.userRepository = userRepository;
- }
-
- @Autowired
- public void setUser_infoRepository(User_InfoRepository user_infoRepository) {
- FinderUtil.user_infoRepository = user_infoRepository;
- }
-
- @Autowired
- public void setTeamInviteRepository(TeamInviteRepository teamInviteRepository) {
- FinderUtil.teamInviteRepository = teamInviteRepository;
- }
-
}
diff --git a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java
index b29ae41..4fac803 100644
--- a/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java
+++ b/src/main/java/hhn/labsw/bugageocaching/util/VerificationUtil.java
@@ -20,7 +20,7 @@ public class VerificationUtil {
public static void fetchPublicKey() {
RestTemplate restTemplate = new RestTemplate();
try {
- PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:8090/buga19usermanagement/token/publickey", PublicKey.class);
+ PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:9080/buga19usermanagement/token/publickey", PublicKey.class);
byte[] decodedKey = Base64.getDecoder().decode(response.getMessage());
KeyFactory factory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(decodedKey);
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 87fb0b7..6dee0a4 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -5,4 +5,5 @@ spring.jmx.default-domain=buga19geocaching
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jooq.sql-dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.hibernate.ddl-auto=update
-spring.jpa.show-sql=true
\ No newline at end of file
+spring.jpa.show-sql=true
+debug=true
\ No newline at end of file