aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrk <watertext@hotmail.it>2017-11-20 22:18:00 +0100
committerSrk <watertext@hotmail.it>2017-11-20 22:18:00 +0100
commit07eae46acf26e2d978655f8ec0e5fd09c47c1546 (patch)
treee71be19ed23e69115e5bf3b98e6ba277688366ed
parent2092b8ffbe6341d4256ee269cfff59df9612d7a7 (diff)
downloadtrackermap-server-07eae46acf26e2d978655f8ec0e5fd09c47c1546.tar.gz
trackermap-server-07eae46acf26e2d978655f8ec0e5fd09c47c1546.tar.bz2
trackermap-server-07eae46acf26e2d978655f8ec0e5fd09c47c1546.zip
Refactoring: parameters only for one mode of eventForwarder
-rw-r--r--src/org/traccar/notification/EventForwarder.java11
-rw-r--r--src/org/traccar/notification/FormTypeEventForwarder.java15
2 files changed, 12 insertions, 14 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java
index aa3ce177a..cc83aefbc 100644
--- a/src/org/traccar/notification/EventForwarder.java
+++ b/src/org/traccar/notification/EventForwarder.java
@@ -36,14 +36,10 @@ public abstract class EventForwarder {
private final String url;
private final String header;
- private final String payloadParamName;
- private final String additionalParams;
public EventForwarder() {
url = Context.getConfig().getString("event.forward.url", "http://localhost/");
header = Context.getConfig().getString("event.forward.header", "");
- payloadParamName = Context.getConfig().getString("event.forward.paramMode.payloadParamName", "payload");
- additionalParams = Context.getConfig().getString("event.forward.paramMode.additionalParams", "");
}
private static final String KEY_POSITION = "position";
@@ -109,13 +105,6 @@ public abstract class EventForwarder {
}
}
- protected String getPayloadParamName() {
- return payloadParamName;
- }
- protected String getAdditionalParams() {
- return additionalParams;
- }
-
protected abstract String getContentType();
protected abstract void setContent(Event event, Position position, BoundRequestBuilder requestBuilder);
diff --git a/src/org/traccar/notification/FormTypeEventForwarder.java b/src/org/traccar/notification/FormTypeEventForwarder.java
index dede95707..1478faa03 100644
--- a/src/org/traccar/notification/FormTypeEventForwarder.java
+++ b/src/org/traccar/notification/FormTypeEventForwarder.java
@@ -1,5 +1,6 @@
package org.traccar.notification;
+import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -7,6 +8,14 @@ import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder;
public class FormTypeEventForwarder extends EventForwarder {
+ private final String payloadParamName;
+ private final String additionalParams;
+
+ public FormTypeEventForwarder() {
+ payloadParamName = Context.getConfig().getString("event.forward.paramMode.payloadParamName", "payload");
+ additionalParams = Context.getConfig().getString("event.forward.paramMode.additionalParams", "");
+ }
+
@Override
protected String getContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
@@ -14,11 +23,11 @@ public class FormTypeEventForwarder extends EventForwarder {
@Override
protected void setContent(Event event, Position position, BoundRequestBuilder requestBuilder) {
- if (!getAdditionalParams().equals("")) {
- requestBuilder.setFormParams(splitParams(getAdditionalParams(), "="));
+ if (!additionalParams.equals("")) {
+ requestBuilder.setFormParams(splitParams(additionalParams, "="));
}
- requestBuilder.addFormParam(getPayloadParamName(), prepareJsonPayload(event, position));
+ requestBuilder.addFormParam(payloadParamName, prepareJsonPayload(event, position));
}
}