From 1682448627b9272139712d8efe249f324333c6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 15:19:45 +0100 Subject: [PATCH 01/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UserService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java index 64cbe9d..a026bed 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java @@ -79,12 +79,18 @@ public class UserService { */ 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) { final UserApiResponse resp = this.service.getUserData(authority.getUsosId()); 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()); From ad0d9e40c1395d9a1a2e7382bb02be5b8b921408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 15:28:59 +0100 Subject: [PATCH 02/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UserService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java index a026bed..b9ce071 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java @@ -81,6 +81,7 @@ public class UserService { 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()); authority.updateWithUsosData(resp); System.out.println("PRAWIE WYCHODZE Z IFA"); From c6c67e7e29b35d18b43290a1b5f0238d13c1e616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 15:53:15 +0100 Subject: [PATCH 03/12] Poprawki --- .../src/main/java/com/plannaplan/services/UserService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java index b9ce071..d447321 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UserService.java @@ -83,6 +83,7 @@ public class UserService { 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"); } From 149796c42a44c3b60bb5c66877d48717190d3c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 16:03:35 +0100 Subject: [PATCH 04/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../java/com/plannaplan/services/UsosApiService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 86643ad..f36df9e 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -51,18 +51,22 @@ public class UsosApiService { final UserApiResponse apiResponse = new UserApiResponse(); try { final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret) - .build(UsosOauth1Service.instance()); - + .build(UsosOauth1Service.instance()); + 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(); final ObjectMapper mapper = new ObjectMapper(); Map map = mapper.readValue(json, new TypeReference>() { }); + 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) { e.printStackTrace(); From a25843ebfdadb30df2336be20ac445253936cfe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 16:17:24 +0100 Subject: [PATCH 05/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UsosApiService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index f36df9e..0d775a5 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -3,6 +3,7 @@ package com.plannaplan.services; import java.io.IOException; import java.util.Map; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.type.TypeReference; @@ -62,6 +63,7 @@ public class UsosApiService { final ObjectMapper mapper = new ObjectMapper(); 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)); From bbf14b0ff9979f07ce3af79da2c8a4dfe9c6ca85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 16:26:47 +0100 Subject: [PATCH 06/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UsosApiService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 0d775a5..18c0452 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -60,7 +60,9 @@ public class UsosApiService { try (Response response = service.execute(request)) { System.out.println("TRY"); final String json = response.getBody(); + 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()); From 756e854f31bfcce8fd47811c6455201f10c15fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Fri, 8 Jan 2021 16:33:02 +0100 Subject: [PATCH 07/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UsosApiService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 18c0452..17b3c70 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -60,6 +60,7 @@ public class UsosApiService { try (Response response = service.execute(request)) { System.out.println("TRY"); final String json = response.getBody(); + System.out.println(json); System.out.println("Przed Object"); final ObjectMapper mapper = new ObjectMapper(); System.out.println("Przed mapą"); From 11d21be6274da3ab50241d4b50c29a2cf6cf7da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sat, 9 Jan 2021 13:11:10 +0100 Subject: [PATCH 08/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../src/main/java/com/plannaplan/services/UsosApiService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 17b3c70..d856383 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -3,7 +3,6 @@ package com.plannaplan.services; import java.io.IOException; import java.util.Map; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.core.type.TypeReference; @@ -60,6 +59,7 @@ public class UsosApiService { try (Response response = service.execute(request)) { System.out.println("TRY"); final String json = response.getBody(); + if (json != null){ System.out.println(json); System.out.println("Przed Object"); final ObjectMapper mapper = new ObjectMapper(); @@ -72,6 +72,7 @@ public class UsosApiService { 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) { e.printStackTrace(); From 2320d66a351d6628d93f51137bb6814ef713c187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sat, 9 Jan 2021 14:00:29 +0100 Subject: [PATCH 09/12] Proba naprawienia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../main/java/com/plannaplan/services/UsosApiService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index d856383..5e56033 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -43,7 +43,7 @@ public class UsosApiService { /** * /services/users/user - * + * * @param usosId user id in usos * @return UserApiResponse modle contatining desired values */ @@ -52,14 +52,16 @@ public class UsosApiService { try { final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret) .build(UsosOauth1Service.instance()); - + 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(); - if (json != null){ + System.out.println(json == null); + System.out.println(json == "null"); + if (json != "null" && json != null){ System.out.println(json); System.out.println("Przed Object"); final ObjectMapper mapper = new ObjectMapper(); From df90a5771592ce150e3195a69c14986f5e1cb76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sat, 9 Jan 2021 14:17:39 +0100 Subject: [PATCH 10/12] Proba naprawienia] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../plannaplan/services/UsosApiService.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 5e56033..364211b 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -61,19 +61,23 @@ public class UsosApiService { 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.equals(null)); + System.out.println(json); if (json != "null" && json != null){ - System.out.println(json); - 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)); + 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) { From 3335155cd8dfcab599cbf9e4984667a0c1167ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Wo=C5=BAniak?= Date: Sat, 9 Jan 2021 17:05:00 +0100 Subject: [PATCH 11/12] Proba naprawienia] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Woźniak --- .../plannaplan/services/UsosApiService.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java index 364211b..015c61d 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java @@ -48,23 +48,22 @@ public class UsosApiService { * @return UserApiResponse modle contatining desired values */ public UserApiResponse getUserData(String usosId) { - final UserApiResponse apiResponse = new UserApiResponse(); - try { - final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret) - .build(UsosOauth1Service.instance()); + final UserApiResponse apiResponse = new UserApiResponse(); + try { + final OAuth10aService service = new ServiceBuilder(apikey).apiSecret(apisecret) + .build(UsosOauth1Service.instance()); - 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(); + 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.equals(null)); System.out.println(json); - if (json != "null" && json != null){ + if (!json.equals("null")){ System.out.println(json); System.out.println(json.getClass()); System.out.println("Przed Object"); @@ -78,13 +77,13 @@ public class UsosApiService { 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) { - e.printStackTrace(); - } + } + } + } catch (IOException | InterruptedException | ExecutionException e) { + e.printStackTrace(); + } - return apiResponse; + return apiResponse; } } 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 12/12] 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) {