aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/WebDataHandler.java
diff options
context:
space:
mode:
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;
}
+
}