diff options
-rw-r--r-- | src/org/traccar/notification/EventForwarder.java | 11 | ||||
-rw-r--r-- | src/org/traccar/notification/FormTypeEventForwarder.java | 15 |
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));
}
}
|