diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-08 19:34:42 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-08 19:34:42 +1200 |
commit | a169ff4eb6c1de110ddcedebdec77fb7aae05a33 (patch) | |
tree | f2a3482f0214d04ec31bd898c375d38c7b89a9be /src/org/traccar/WebDataHandler.java | |
parent | ae1b5bd74b69a7e8222af39e3c62aa217ba94d29 (diff) | |
parent | 5a9811c3771d92832c9bba718b5ec935844978e8 (diff) | |
download | trackermap-server-a169ff4eb6c1de110ddcedebdec77fb7aae05a33.tar.gz trackermap-server-a169ff4eb6c1de110ddcedebdec77fb7aae05a33.tar.bz2 trackermap-server-a169ff4eb6c1de110ddcedebdec77fb7aae05a33.zip |
Merge pull request #3920 from traccar/remove-http-client
Remove async HTTP client dependency
Diffstat (limited to 'src/org/traccar/WebDataHandler.java')
-rw-r--r-- | src/org/traccar/WebDataHandler.java | 23 |
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; } + } |