aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/StatisticsManager.java37
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();