aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-27 10:34:51 +1300
committerGitHub <noreply@github.com>2017-12-27 10:34:51 +1300
commitc9e9d881e73d21287cd48fd14b5e2640902b92ca (patch)
tree78430c4f52efb6db4ea6ee09acf5764d9f181e6d /src/org/traccar
parent181d91bf2a7c86b443fcd14cf41a3aa6afe7e204 (diff)
parent992b8e14af92626724b581be23850fd74f7e4620 (diff)
downloadtrackermap-server-c9e9d881e73d21287cd48fd14b5e2640902b92ca.tar.gz
trackermap-server-c9e9d881e73d21287cd48fd14b5e2640902b92ca.tar.bz2
trackermap-server-c9e9d881e73d21287cd48fd14b5e2640902b92ca.zip
Merge pull request #3698 from nadezhdamosunova/master
Using JSON content for flespi protocol
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/FlespiProtocolDecoder.java17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/org/traccar/protocol/FlespiProtocolDecoder.java b/src/org/traccar/protocol/FlespiProtocolDecoder.java
index 976746472..6cba234e5 100644
--- a/src/org/traccar/protocol/FlespiProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlespiProtocolDecoder.java
@@ -18,10 +18,6 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.multipart.Attribute;
-import org.jboss.netty.handler.codec.http.multipart.DefaultHttpDataFactory;
-import org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
-import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.model.Position;
@@ -34,6 +30,7 @@ import javax.json.JsonString;
import javax.json.JsonValue;
import java.io.StringReader;
import java.net.SocketAddress;
+import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -50,16 +47,8 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder {
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
HttpRequest request = (HttpRequest) msg;
- HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request);
- InterfaceHttpData data = decoder.getBodyHttpData("data");
- if (data.getHttpDataType() != InterfaceHttpData.HttpDataType.Attribute) {
- sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
- return null;
- }
-
- Attribute attribute = (Attribute) data;
- String value = attribute.getValue();
- JsonArray result = Json.createReader(new StringReader(value)).readArray();
+ JsonArray result = Json.createReader(new StringReader(request.getContent().toString(StandardCharsets.UTF_8)))
+ .readArray();
List<Position> positions = new LinkedList<>();
for (int i = 0; i < result.size(); i++) {
JsonObject message = result.getJsonObject(i);