diff options
author | Simon Rettberg | 2020-04-30 16:38:56 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-04-30 16:38:56 +0200 |
commit | 1e336d71e963bdcae917381683f1ed9a62ac9d4f (patch) | |
tree | e0011e15fdf231a35ae724950854e1d645b9691a /src | |
parent | Logging (diff) | |
download | bwlp-guacamole-ext-1e336d71e963bdcae917381683f1ed9a62ac9d4f.tar.gz bwlp-guacamole-ext-1e336d71e963bdcae917381683f1ed9a62ac9d4f.tar.xz bwlp-guacamole-ext-1e336d71e963bdcae917381683f1ed9a62ac9d4f.zip |
Adapt to new json format
Diffstat (limited to 'src')
4 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java b/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java index 0132e43..f1ad057 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/ConnectionManager.java @@ -131,13 +131,23 @@ public class ConnectionManager { private static void populateList(byte[] data) { ObjectMapper mapper = new ObjectMapper(); JsonClient[] list; + JsonRoot root; try { - list = mapper.readValue(data, JsonClient[].class); + root = mapper.readValue(data, JsonRoot.class); } catch (Exception e) { LOGGER.warn("Could not deserialize JSON from Connection Pool", e); LOGGER.warn("Not updating local list"); return; } + list = root.clients; + if (list == null) { + LOGGER.info("Client list null"); + } + if (root.locations != null) { + for (JsonLocation l : root.locations) { + LOGGER.info("Location " + l.name + " with pw " + l.password); + } + } synchronized (clientPool) { for (JsonClient cnew : list) { if (cnew.password == null || cnew.clientip == null) diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java index dee8fae..09a80e4 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java @@ -6,6 +6,8 @@ public class JsonClient { public String password; + public int locationid; + public State state; public boolean wol_in_progress; diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/JsonLocation.java b/src/main/java/de/bwlehrpool/bwlp_guac/JsonLocation.java new file mode 100644 index 0000000..6bf9d1c --- /dev/null +++ b/src/main/java/de/bwlehrpool/bwlp_guac/JsonLocation.java @@ -0,0 +1,13 @@ +package de.bwlehrpool.bwlp_guac; + +public class JsonLocation { + + public int id; + + public int[] locationids; + + public String name; + + public String password; + +} diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/JsonRoot.java b/src/main/java/de/bwlehrpool/bwlp_guac/JsonRoot.java new file mode 100644 index 0000000..e89eb64 --- /dev/null +++ b/src/main/java/de/bwlehrpool/bwlp_guac/JsonRoot.java @@ -0,0 +1,9 @@ +package de.bwlehrpool.bwlp_guac; + +public class JsonRoot { + + public JsonClient[] clients; + + public JsonLocation[] locations; + +} |