Skip to content

Commit

Permalink
Merge pull request #16 from zfi/master
Browse files Browse the repository at this point in the history
Update logging messages. Correct an error in a URI.
  • Loading branch information
zfi authored Sep 7, 2018
2 parents c0d54ee + e167bad commit 41d9215
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -102,17 +102,17 @@ 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<String, String> data = new HashMap<>();
data.put("token", token);
data.put("idUser", String.valueOf(idUser));
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()) {
Expand All @@ -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);
}
}
Expand All @@ -143,13 +144,12 @@ public List<String> 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<String> tokens = new ArrayList<>();

for (JsonElement token : jsonTokens) {
tokens.add(token.getAsString());
}
Expand All @@ -158,7 +158,7 @@ public List<String> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -232,15 +232,19 @@ 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();
if (response == null) {
throw new ServerException("No response from server.");
}

LOG.info("Cloud Session server says: {}", response);

JsonElement jelement = new JsonParser().parse(response);
JsonObject responseObject = jelement.getAsJsonObject();

Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 41d9215

Please sign in to comment.