aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorVitaliy Gergel <vitaliy.gergel@zoomdata.com>2020-03-04 21:54:55 +0200
committerVitaliy Gergel <vitaliy.gergel@zoomdata.com>2020-03-04 21:54:55 +0200
commit0270f5b639166b385ac779c0d2caa41d7c408771 (patch)
tree1bb5dbb37cfe4378cf75c0d0df69df9f1ecb756f /src/main/java/org
parente7c04c8dfaa67e5bef2d3b9c5ba8924e85045ffc (diff)
downloadtraccar-server-0270f5b639166b385ac779c0d2caa41d7c408771.tar.gz
traccar-server-0270f5b639166b385ac779c0d2caa41d7c408771.tar.bz2
traccar-server-0270f5b639166b385ac779c0d2caa41d7c408771.zip
Adding property to enable URL parameter in json mode
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/WebDataHandler.java4
-rw-r--r--src/main/java/org/traccar/config/Keys.java7
2 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/WebDataHandler.java b/src/main/java/org/traccar/WebDataHandler.java
index 858b00aad..1af1af48a 100644
--- a/src/main/java/org/traccar/WebDataHandler.java
+++ b/src/main/java/org/traccar/WebDataHandler.java
@@ -67,6 +67,7 @@ public class WebDataHandler extends BaseDataHandler {
private final String url;
private final String header;
private final boolean json;
+ private final boolean jsonUrlVariables;
private final boolean retryEnabled;
private final int retryDelay;
@@ -85,6 +86,7 @@ public class WebDataHandler extends BaseDataHandler {
this.url = config.getString(Keys.FORWARD_URL);
this.header = config.getString(Keys.FORWARD_HEADER);
this.json = config.getBoolean(Keys.FORWARD_JSON);
+ this.jsonUrlVariables = config.getBoolean(Keys.FORWARD_JSON_URL_VARIABLES);
this.retryEnabled = config.getBoolean(Keys.FORWARD_RETRY_ENABLE);
this.retryDelay = config.getInteger(Keys.FORWARD_RETRY_DELAY, 100);
@@ -192,7 +194,7 @@ public class WebDataHandler extends BaseDataHandler {
String formattedUrl;
try {
- formattedUrl = formatRequest(position);
+ formattedUrl = (json && !jsonUrlVariables) ? url : formatRequest(position);
} catch (UnsupportedEncodingException | JsonProcessingException e) {
throw new RuntimeException("Forwarding formatting error", e);
}
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index d88b36d28..a5b7b780c 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -101,6 +101,13 @@ public final class Keys {
"forward.json", Boolean.class);
/**
+ * Boolean value to enable URL parameters in json mode. For example, {uniqueId} for device identifier,
+ * {latitude} and {longitude} for coordinates.
+ */
+ public static final ConfigKey FORWARD_JSON_URL_VARIABLES = new ConfigKey(
+ "forward.json.url.variables", Boolean.class);
+
+ /**
* Position forwarding retrying enable. When enabled, additional attempts are made to deliver positions. If initial
* delivery fails, because of an unreachable server or an HTTP response different from '2xx', the software waits
* for 'forward.retry.delay' milliseconds to retry delivery. On subsequent failures, this delay is duplicated.