Fixed problem

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2021-01-09 17:35:53 +01:00
parent 3335155cd8
commit b0a1d929e4
Signed by: y0rune
GPG Key ID: F204C385F57EB348
2 changed files with 9 additions and 31 deletions

View File

@ -79,20 +79,12 @@ public class UserService {
*/ */
public User login(User authority) throws UserNotFoundException { public User login(User authority) throws UserNotFoundException {
final String token = UUID.randomUUID().toString(); final String token = UUID.randomUUID().toString();
System.out.println(token);
if ((authority.getName() == null || authority.getSurname() == null) && authority.getUsosId() != null) { if ((authority.getName() == null || authority.getSurname() == null) && authority.getUsosId() != null) {
System.out.println("IF");
final UserApiResponse resp = this.service.getUserData(authority.getUsosId()); final UserApiResponse resp = this.service.getUserData(authority.getUsosId());
System.out.println("W IFIE");
authority.updateWithUsosData(resp); authority.updateWithUsosData(resp);
System.out.println("PRAWIE WYCHODZE Z IFA");
} }
try { try {
System.out.println("TRY!!!!");
authority.setToken(token); authority.setToken(token);
System.out.println(authority.getToken());
System.out.println(authority.getName());
System.out.println(authority.getSurname());
this.repo.save(authority); this.repo.save(authority);
} catch (Exception e) { } catch (Exception e) {
throw new UserNotFoundException(e.getMessage()); throw new UserNotFoundException(e.getMessage());

View File

@ -55,28 +55,14 @@ public class UsosApiService {
final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId); final OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl + "/services/users/user?user_id=" + usosId);
service.signRequest(new OAuth1AccessToken("", ""), request); service.signRequest(new OAuth1AccessToken("", ""), request);
System.out.println("PRZED TRY");
try (Response response = service.execute(request)) { try (Response response = service.execute(request)) {
System.out.println("TRY");
final String json = response.getBody(); 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")){ if (!json.equals("null")){
System.out.println(json);
System.out.println(json.getClass());
System.out.println("Przed Object");
final ObjectMapper mapper = new ObjectMapper(); final ObjectMapper mapper = new ObjectMapper();
System.out.println("Przed mapą");
Map<String, String> map = mapper.readValue(json, new TypeReference<Map<String, String>>() { Map<String, String> map = mapper.readValue(json, new TypeReference<Map<String, String>>() {
}); });
System.out.println(map.size());
System.out.println("FIELD");
apiResponse.setName(map.get(NAME_FIELD)); apiResponse.setName(map.get(NAME_FIELD));
System.out.println(map.get(NAME_FIELD));
apiResponse.setSurname(map.get(SURNAME_FIELD)); apiResponse.setSurname(map.get(SURNAME_FIELD));
System.out.println(map.get(SURNAME_FIELD));
} }
} }
} catch (IOException | InterruptedException | ExecutionException e) { } catch (IOException | InterruptedException | ExecutionException e) {