diff options
author | Srk <watertext@hotmail.it> | 2017-11-22 22:59:37 +0100 |
---|---|---|
committer | Srk <watertext@hotmail.it> | 2017-11-22 22:59:37 +0100 |
commit | 82da12c1218ca7f1e4e1562cc183cc8a059045e6 (patch) | |
tree | 923056148c8f0fc647cba3696ce4015e818df0f7 /src/org/traccar/notification/MultiPartEventForwarder.java | |
parent | 906d376b4f8c199b36064a0cd58cdf9c3ccb712f (diff) | |
download | traccar-server-82da12c1218ca7f1e4e1562cc183cc8a059045e6.tar.gz traccar-server-82da12c1218ca7f1e4e1562cc183cc8a059045e6.tar.bz2 traccar-server-82da12c1218ca7f1e4e1562cc183cc8a059045e6.zip |
Minor refactoring
Diffstat (limited to 'src/org/traccar/notification/MultiPartEventForwarder.java')
-rw-r--r-- | src/org/traccar/notification/MultiPartEventForwarder.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/org/traccar/notification/MultiPartEventForwarder.java b/src/org/traccar/notification/MultiPartEventForwarder.java index a77ad5975..6a3baecb3 100644 --- a/src/org/traccar/notification/MultiPartEventForwarder.java +++ b/src/org/traccar/notification/MultiPartEventForwarder.java @@ -1,10 +1,11 @@ package org.traccar.notification; -import java.nio.charset.StandardCharsets; +import static java.nio.charset.StandardCharsets.UTF_8; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.apache.commons.lang3.StringUtils; import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Position; @@ -19,7 +20,7 @@ public class MultiPartEventForwarder extends EventForwarder { public MultiPartEventForwarder() { payloadParamName = Context.getConfig().getString("event.forward.paramMode.payloadParamName", "payload"); - additionalParams = Context.getConfig().getString("event.forward.paramMode.additionalParams", ""); + additionalParams = Context.getConfig().getString("event.forward.paramMode.additionalParams"); } @Override @@ -30,18 +31,16 @@ public class MultiPartEventForwarder extends EventForwarder { @Override protected void setContent(Event event, Position position, BoundRequestBuilder requestBuilder) { - if (!additionalParams.equals("")) { - Map<String, List<String>> paramsToAdd = splitParams(additionalParams, "="); + if (StringUtils.isNotEmpty(additionalParams)) { + Map<String, List<String>> paramsToAdd = splitIntoKeyValues(additionalParams, "="); - for (Entry<String, List<String>> en : paramsToAdd.entrySet()) { - for (String value : en.getValue()) { - requestBuilder.addBodyPart(new StringPart(en.getKey(), value, null, StandardCharsets.UTF_8)); + for (Entry<String, List<String>> param : paramsToAdd.entrySet()) { + for (String singleParamValue : param.getValue()) { + requestBuilder.addBodyPart(new StringPart(param.getKey(), singleParamValue, null, UTF_8)); } } } requestBuilder.addBodyPart(new StringPart(payloadParamName, - prepareJsonPayload(event, position), - "application/json", - StandardCharsets.UTF_8)); + prepareJsonPayload(event, position), "application/json", UTF_8)); } } |