From 5a9811c3771d92832c9bba718b5ec935844978e8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 2 Jun 2018 14:17:51 +1200 Subject: Remove async HTTP client dependency --- src/org/traccar/database/StatisticsManager.java | 37 ++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/org/traccar/database') 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(); -- cgit v1.2.3