aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/WebDataHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-02 14:17:51 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-02 14:17:51 +1200
commit5a9811c3771d92832c9bba718b5ec935844978e8 (patch)
tree6c2f5024fb0297c66d9eb184fab259e7c3017927 /src/org/traccar/WebDataHandler.java
parentbfc7cb8efcaa9f9ec7bf24fd528b370a10c4f0ac (diff)
downloadtrackermap-server-5a9811c3771d92832c9bba718b5ec935844978e8.tar.gz
trackermap-server-5a9811c3771d92832c9bba718b5ec935844978e8.tar.bz2
trackermap-server-5a9811c3771d92832c9bba718b5ec935844978e8.zip
Remove async HTTP client dependency
Diffstat (limited to 'src/org/traccar/WebDataHandler.java')
-rw-r--r--src/org/traccar/WebDataHandler.java23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java
index cdd9d0c11..79221de9a 100644
--- a/src/org/traccar/WebDataHandler.java
+++ b/src/org/traccar/WebDataHandler.java
@@ -16,12 +16,12 @@
package org.traccar;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.ning.http.client.AsyncHttpClient;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Position;
+import javax.ws.rs.client.Entity;
import java.util.HashMap;
import java.util.Map;
import java.io.UnsupportedEncodingException;
@@ -129,21 +129,14 @@ public class WebDataHandler extends BaseDataHandler {
@Override
protected Position handlePosition(Position position) {
if (json) {
- AsyncHttpClient.BoundRequestBuilder requestBuilder = Context.getAsyncHttpClient().preparePost(url);
- requestBuilder.setBodyEncoding(StandardCharsets.UTF_8.name());
-
- requestBuilder.addHeader("Content-Type", "application/json; charset=utf-8");
-
- requestBuilder.setBody(prepareJsonPayload(position));
- requestBuilder.execute();
-
+ Context.getClient().target(url).request().async().post(Entity.json(prepareJsonPayload(position)));
} else {
- Context.getAsyncHttpClient().prepareGet(formatRequest(position)).execute();
+ Context.getClient().target(formatRequest(position)).request().async().get();
}
return position;
}
- protected String prepareJsonPayload(Position position) {
+ protected Map<String, Object> prepareJsonPayload(Position position) {
Map<String, Object> data = new HashMap<>();
Device device = Context.getIdentityManager().getById(position.getDeviceId());
@@ -154,11 +147,7 @@ public class WebDataHandler extends BaseDataHandler {
data.put(KEY_DEVICE, device);
}
- try {
- return Context.getObjectMapper().writeValueAsString(data);
- } catch (JsonProcessingException e) {
- Log.warning(e);
- return null;
- }
+ return data;
}
+
}