From 4e9ab9892ac2712914a7d6ab865f6255bfcd2218 Mon Sep 17 00:00:00 2001 From: Evgeny S Maksimov Date: Sun, 16 Dec 2018 23:13:19 +0300 Subject: Added group arg --- src/org/traccar/WebDataHandler.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index 3e47ada70..49033fc3a 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -24,6 +24,7 @@ import org.traccar.database.IdentityManager; import org.traccar.helper.Checksum; import org.traccar.model.Device; import org.traccar.model.Position; +import org.traccar.model.Group; import javax.inject.Inject; import javax.ws.rs.client.Client; @@ -139,7 +140,16 @@ public class WebDataHandler extends BaseDataHandler { request = request.replace("{gprmc}", formatSentence(position)); } - return request; + String deviceGroupName = ""; + + if (device.getGroupId() != 0) { + Group group = Context.getGroupsManager().getById(device.getGroupId()); + if (group != null) { + deviceGroupName = group.getName(); + } + } + + return request.replace("{group}", URLEncoder.encode(deviceGroupName, StandardCharsets.UTF_8.name())); } @Override -- cgit v1.2.3 From 132b3b21bb7f56fa880a7024d581f36b98b78a7f Mon Sep 17 00:00:00 2001 From: Evgeny S Maksimov Date: Mon, 17 Dec 2018 12:12:56 +0300 Subject: Added check of the group parameter. --- src/org/traccar/WebDataHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index 49033fc3a..c7ce7485d 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -140,16 +140,19 @@ public class WebDataHandler extends BaseDataHandler { request = request.replace("{gprmc}", formatSentence(position)); } - String deviceGroupName = ""; - - if (device.getGroupId() != 0) { - Group group = Context.getGroupsManager().getById(device.getGroupId()); - if (group != null) { + if (request.contains("{group}")) { + String deviceGroupName = ""; + if (device.getGroupId() != 0) { + Group group = Context.getGroupsManager().getById(device.getGroupId()); + if (group != null) { deviceGroupName = group.getName(); + } } + + request = request.replace("{group}", URLEncoder.encode(deviceGroupName, StandardCharsets.UTF_8.name())); } - return request.replace("{group}", URLEncoder.encode(deviceGroupName, StandardCharsets.UTF_8.name())); + return request; } @Override -- cgit v1.2.3 From 4a634885212d80f5e2c7dd5ca0847fac287d02b9 Mon Sep 17 00:00:00 2001 From: Evgeny S Maksimov Date: Mon, 17 Dec 2018 13:30:50 +0300 Subject: Fixed indent --- src/org/traccar/WebDataHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index c7ce7485d..a8e20c698 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -145,7 +145,7 @@ public class WebDataHandler extends BaseDataHandler { if (device.getGroupId() != 0) { Group group = Context.getGroupsManager().getById(device.getGroupId()); if (group != null) { - deviceGroupName = group.getName(); + deviceGroupName = group.getName(); } } -- cgit v1.2.3