aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/EventForwarder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-20 22:54:58 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-20 22:54:58 -0800
commitcb4ba475c71cd83a2bde40938216b55e8f686207 (patch)
tree30b4c8050a65d5e962249dd2d1ad049fc4bd229d /src/org/traccar/notification/EventForwarder.java
parent81d4920ba7e45d762f7e276195b9b085e88249a4 (diff)
downloadtrackermap-server-cb4ba475c71cd83a2bde40938216b55e8f686207.tar.gz
trackermap-server-cb4ba475c71cd83a2bde40938216b55e8f686207.tar.bz2
trackermap-server-cb4ba475c71cd83a2bde40938216b55e8f686207.zip
Support headers for forwarding
Diffstat (limited to 'src/org/traccar/notification/EventForwarder.java')
-rw-r--r--src/org/traccar/notification/EventForwarder.java20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java
index b8990d84f..c0010ebbd 100644
--- a/src/org/traccar/notification/EventForwarder.java
+++ b/src/org/traccar/notification/EventForwarder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
*/
package org.traccar.notification;
-import org.apache.commons.collections4.MultiValuedMap;
-import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.traccar.Context;
import org.traccar.model.Device;
import org.traccar.model.Event;
@@ -52,25 +50,15 @@ public abstract class EventForwarder {
Invocation.Builder requestBuilder = Context.getClient().target(url).request();
if (header != null && !header.isEmpty()) {
- for (Map.Entry<String, String> entry : splitKeyValues(header, ":").entries()) {
- requestBuilder = requestBuilder.header(entry.getKey(), entry.getValue());
+ for (String line: header.split("\\r?\\n")) {
+ String[] values = line.split(":", 2);
+ requestBuilder.header(values[0].trim(), values[1].trim());
}
}
executeRequest(event, position, users, requestBuilder.async());
}
- protected MultiValuedMap<String, String> splitKeyValues(String params, String separator) {
- MultiValuedMap<String, String> data = new ArrayListValuedHashMap<>();
- for (String line: params.split("\\r?\\n")) {
- String[] values = line.split(separator, 2);
- if (values.length == 2) {
- data.put(values[0].trim(), values[1].trim());
- }
- }
- return data;
- }
-
protected Map<String, Object> preparePayload(Event event, Position position, Set<Long> users) {
Map<String, Object> data = new HashMap<>();
data.put(KEY_EVENT, event);