From e167bad57df47e73713dbc22fbb70baebef496d2 Mon Sep 17 00:00:00 2001 From: Jim Ewald Date: Fri, 7 Sep 2018 15:33:28 -0700 Subject: [PATCH] Update logging messages. Correct an error in a URI. --- ...loudSessionAuthenticationTokenService.java | 20 +++++++++---------- .../CloudSessionBucketService.java | 2 +- .../CloudSessionLocalUserService.java | 14 ++++++++----- .../CloudSessionOAuthService.java | 4 ++-- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/parallax/client/cloudsession/CloudSessionAuthenticationTokenService.java b/src/main/java/com/parallax/client/cloudsession/CloudSessionAuthenticationTokenService.java index 7ec3f5c..9ff91f5 100644 --- a/src/main/java/com/parallax/client/cloudsession/CloudSessionAuthenticationTokenService.java +++ b/src/main/java/com/parallax/client/cloudsession/CloudSessionAuthenticationTokenService.java @@ -87,7 +87,7 @@ public String request(Long idUser, String browser, String ipAddress) throws Unkn LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } } @@ -102,6 +102,8 @@ public String request(Long idUser, String browser, String ipAddress) throws Unkn * @throws ServerException */ public boolean doConfirm(String token, Long idUser, String browser, String ipAddress) throws ServerException { + String response = ""; + try { Map data = new HashMap<>(); data.put("token", token); @@ -109,10 +111,8 @@ public boolean doConfirm(String token, Long idUser, String browser, String ipAdd data.put("browser", browser); data.put("ipAddress", ipAddress); HttpRequest request = HttpRequest.post(getUrl("/authtoken/confirm")).header("server", SERVER).form(data); -// int responseCode = request.code(); -// System.out.println("Response code: " + responseCode); - String response = request.body(); -// System.out.println(response); + + response = request.body(); JsonElement jelement = new JsonParser().parse(response); JsonObject responseObject = jelement.getAsJsonObject(); if (responseObject.get("success").getAsBoolean()) { @@ -124,7 +124,8 @@ public boolean doConfirm(String token, Long idUser, String browser, String ipAdd LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error( + "Json syntax error: {} - {}",response, jse.getMessage()); throw new ServerException(jse); } } @@ -143,13 +144,12 @@ public List getTokens(Long idUser, String browser, String ipAddress) thr data.put("browser", browser); data.put("ipAddress", ipAddress); HttpRequest request = HttpRequest.post(getUrl("/authtoken/tokens/" + idUser)).header("server", SERVER).form(data); -// int responseCode = request.code(); -// System.out.println("Response code: " + responseCode); + String response = request.body(); -// System.out.println(response); JsonElement jelement = new JsonParser().parse(response); JsonArray jsonTokens = jelement.getAsJsonArray(); List tokens = new ArrayList<>(); + for (JsonElement token : jsonTokens) { tokens.add(token.getAsString()); } @@ -158,7 +158,7 @@ public List getTokens(Long idUser, String browser, String ipAddress) thr LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } } diff --git a/src/main/java/com/parallax/client/cloudsession/CloudSessionBucketService.java b/src/main/java/com/parallax/client/cloudsession/CloudSessionBucketService.java index a8054a6..5696a51 100644 --- a/src/main/java/com/parallax/client/cloudsession/CloudSessionBucketService.java +++ b/src/main/java/com/parallax/client/cloudsession/CloudSessionBucketService.java @@ -150,7 +150,7 @@ protected boolean handleResponse(String type, Long id, HttpRequest request) thro LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax service error: {}", jse.getMessage()); throw new ServerException(jse); } } diff --git a/src/main/java/com/parallax/client/cloudsession/CloudSessionLocalUserService.java b/src/main/java/com/parallax/client/cloudsession/CloudSessionLocalUserService.java index 353ac7a..b490f16 100644 --- a/src/main/java/com/parallax/client/cloudsession/CloudSessionLocalUserService.java +++ b/src/main/java/com/parallax/client/cloudsession/CloudSessionLocalUserService.java @@ -148,7 +148,7 @@ public boolean doPasswordReset( throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax service error", jse.getMessage()); throw new ServerException(jse); } } @@ -204,7 +204,7 @@ public boolean requestPasswordReset(String email) throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } catch (NullPointerException npe) { @@ -232,8 +232,10 @@ public boolean doConfirm(String email, String token) data.put("email", email); data.put("token", token); - HttpRequest request = HttpRequest.post( - getUrl(URI_CONFIRM_ACCOUNT)).form(data); + String url = getUrl(URI_CONFIRM_ACCOUNT); + LOG.info("Sending '{}' to Cloud Server", url); + + HttpRequest request = HttpRequest.post(url).form(data); // Get response from Cloud Session server String response = request.body(); @@ -241,6 +243,8 @@ public boolean doConfirm(String email, String token) throw new ServerException("No response from server."); } + LOG.info("Cloud Session server says: {}", response); + JsonElement jelement = new JsonParser().parse(response); JsonObject responseObject = jelement.getAsJsonObject(); @@ -266,7 +270,7 @@ public boolean doConfirm(String email, String token) throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } } diff --git a/src/main/java/com/parallax/client/cloudsession/CloudSessionOAuthService.java b/src/main/java/com/parallax/client/cloudsession/CloudSessionOAuthService.java index 20e1e04..a5ccdab 100644 --- a/src/main/java/com/parallax/client/cloudsession/CloudSessionOAuthService.java +++ b/src/main/java/com/parallax/client/cloudsession/CloudSessionOAuthService.java @@ -85,7 +85,7 @@ public User validateUser(String login, String authenticationSource) throws Unkno LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } } @@ -130,7 +130,7 @@ public Long registerUser(String email, String authenticationSource, String local LOG.error("Inter service error", hre); throw new ServerException(hre); } catch (JsonSyntaxException jse) { - LOG.error("Json syntace service error", jse); + LOG.error("Json syntax error: {}", jse.getMessage()); throw new ServerException(jse); } }