From b0a1d929e43764d27d41d3525c56faa2f9f7c294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sat, 9 Jan 2021 17:35:53 +0100 Subject: [PATCH] Fixed problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../com/plannaplan/services/UserService.java | 26 +++++++------------ .../plannaplan/services/UsosApiService.java | 14 ---------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java index d447321..84663e7 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java @@ -32,7 +32,7 @@ public class UserService { /** * checks if user exist and return him or creates new one with student role * otherwise - * + * * @param email user email in usos * @param usosId user id in usos * @return user entity instace containing changes saved in database @@ -43,7 +43,7 @@ public class UserService { /** * checks if user exist and creates new one if doesn't - * + * * @param email user email in usos * @param usosId user id in usos * @param roleIfNotExist role to be set in case user is not in database yet @@ -72,27 +72,19 @@ public class UserService { /** * generates token for user and if user don't have name in database it will * attemp to obtain these from usos api and saves changes in database - * + * * @param authority user we want to login * @return user with changed values after save in db * @throws UserNotFoundException throwed if user doesn't exist */ public User login(User authority) throws UserNotFoundException { final String token = UUID.randomUUID().toString(); - System.out.println(token); if ((authority.getName() == null || authority.getSurname() == null) && authority.getUsosId() != null) { - System.out.println("IF"); final UserApiResponse resp = this.service.getUserData(authority.getUsosId()); - System.out.println("W IFIE"); authority.updateWithUsosData(resp); - System.out.println("PRAWIE WYCHODZE Z IFA"); } try { - System.out.println("TRY!!!!"); authority.setToken(token); - System.out.println(authority.getToken()); - System.out.println(authority.getName()); - System.out.println(authority.getSurname()); this.repo.save(authority); } catch (Exception e) { throw new UserNotFoundException(e.getMessage()); @@ -102,7 +94,7 @@ public class UserService { /** * sacves user to databse and return instatnce with id - * + * * @param user to be saved * @return instatnce with bd id */ @@ -111,7 +103,7 @@ public class UserService { } /** - * + * * @param email of user to be find * @return user with given mail * @throws UserNotFoundException throwed if user doesn't exist @@ -124,7 +116,7 @@ public class UserService { /** * return user by given authority - * + * * @param authority user usosId or email * @return optional with user if found */ @@ -138,7 +130,7 @@ public class UserService { /** * search for user with given query - * + * * @param query string that will be matched to users name and surname * @return list opf results */ @@ -168,7 +160,7 @@ public class UserService { /** * get students sorted by their ranking - * + * * @return list of students */ public List getStudentsSortedByRanking() { @@ -177,4 +169,4 @@ public class UserService { }).collect(Collectors.toList()); } -} \ No newline at end of file +} diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 015c61d..fcf08d8 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -55,28 +55,14 @@ public class UsosApiService { final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId); service.signRequest(new OAuth1AccessToken("", ""), request); - System.out.println("PRZED TRY"); try (Response response = service.execute(request)) { - System.out.println("TRY"); final String json = response.getBody(); - System.out.println(json == null); - System.out.println(json == "null"); - System.out.println(json.equals("null")); - System.out.println(json); if (!json.equals("null")){ - System.out.println(json); - System.out.println(json.getClass()); - System.out.println("Przed Object"); final ObjectMapper mapper = new ObjectMapper(); - System.out.println("Przed mapą"); Map map = mapper.readValue(json, new TypeReference>() { }); - System.out.println(map.size()); - System.out.println("FIELD"); apiResponse.setName(map.get(NAME_FIELD)); - System.out.println(map.get(NAME_FIELD)); apiResponse.setSurname(map.get(SURNAME_FIELD)); - System.out.println(map.get(SURNAME_FIELD)); } } } catch (IOException | InterruptedException | ExecutionException e) {