diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-02 14:17:51 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-02 14:17:51 +1200 |
commit | 5a9811c3771d92832c9bba718b5ec935844978e8 (patch) | |
tree | 6c2f5024fb0297c66d9eb184fab259e7c3017927 /src/org/traccar/database | |
parent | bfc7cb8efcaa9f9ec7bf24fd528b370a10c4f0ac (diff) | |
download | traccar-server-5a9811c3771d92832c9bba718b5ec935844978e8.tar.gz traccar-server-5a9811c3771d92832c9bba718b5ec935844978e8.tar.bz2 traccar-server-5a9811c3771d92832c9bba718b5ec935844978e8.zip |
Remove async HTTP client dependency
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/StatisticsManager.java | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/org/traccar/database/StatisticsManager.java b/src/org/traccar/database/StatisticsManager.java index 9a3ff06bd..452cdffa0 100644 --- a/src/org/traccar/database/StatisticsManager.java +++ b/src/org/traccar/database/StatisticsManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ package org.traccar.database; -import com.ning.http.client.Request; -import com.ning.http.client.RequestBuilder; import org.joda.time.format.ISODateTimeFormat; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.Statistics; +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.Form; import java.sql.SQLException; import java.util.Calendar; import java.util.Date; @@ -70,22 +70,21 @@ public class StatisticsManager { String url = Context.getConfig().getString("server.statistics"); if (url != null) { String time = ISODateTimeFormat.dateTime().print(statistics.getCaptureTime().getTime()); - Request request = new RequestBuilder("POST") - .setUrl(url) - .addHeader("Content-Type", "application/x-www-form-urlencoded") - .addFormParam("version", Log.getAppVersion()) - .addFormParam("captureTime", time) - .addFormParam("activeUsers", String.valueOf(statistics.getActiveUsers())) - .addFormParam("activeDevices", String.valueOf(statistics.getActiveDevices())) - .addFormParam("requests", String.valueOf(statistics.getRequests())) - .addFormParam("messagesReceived", String.valueOf(statistics.getMessagesReceived())) - .addFormParam("messagesStored", String.valueOf(statistics.getMessagesStored())) - .addFormParam("mailSent", String.valueOf(statistics.getMailSent())) - .addFormParam("smsSent", String.valueOf(statistics.getSmsSent())) - .addFormParam("geocoderRequests", String.valueOf(statistics.getGeocoderRequests())) - .addFormParam("geolocationRequests", String.valueOf(statistics.getGeolocationRequests())) - .build(); - Context.getAsyncHttpClient().prepareRequest(request).execute(); + + Form form = new Form(); + form.param("version", Log.getAppVersion()); + form.param("captureTime", time); + form.param("activeUsers", String.valueOf(statistics.getActiveUsers())); + form.param("activeDevices", String.valueOf(statistics.getActiveDevices())); + form.param("requests", String.valueOf(statistics.getRequests())); + form.param("messagesReceived", String.valueOf(statistics.getMessagesReceived())); + form.param("messagesStored", String.valueOf(statistics.getMessagesStored())); + form.param("mailSent", String.valueOf(statistics.getMailSent())); + form.param("smsSent", String.valueOf(statistics.getSmsSent())); + form.param("geocoderRequests", String.valueOf(statistics.getGeocoderRequests())); + form.param("geolocationRequests", String.valueOf(statistics.getGeolocationRequests())); + + Context.getClient().target(url).request().async().post(Entity.form(form)); } users.clear(); |