aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/EventForwarder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-19 08:01:20 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-19 08:01:20 +1300
commit54e738d3281a463a0ea3fcf2026c2464529a9b58 (patch)
tree65e924f480d6489a5939d2f289c354240fd68e59 /src/org/traccar/notification/EventForwarder.java
parent99f09134fb9c710114296d603c97a76f5cfb0d2a (diff)
downloadtrackermap-server-54e738d3281a463a0ea3fcf2026c2464529a9b58.tar.gz
trackermap-server-54e738d3281a463a0ea3fcf2026c2464529a9b58.tar.bz2
trackermap-server-54e738d3281a463a0ea3fcf2026c2464529a9b58.zip
Remove own JSON converter
Diffstat (limited to 'src/org/traccar/notification/EventForwarder.java')
-rw-r--r--src/org/traccar/notification/EventForwarder.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java
index 9bd116339..b39a9155f 100644
--- a/src/org/traccar/notification/EventForwarder.java
+++ b/src/org/traccar/notification/EventForwarder.java
@@ -15,19 +15,18 @@
*/
package org.traccar.notification;
-import java.nio.charset.StandardCharsets;
-
-import javax.json.Json;
-import javax.json.JsonObjectBuilder;
-
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder;
import org.traccar.Context;
+import org.traccar.helper.Log;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Position;
-import org.traccar.web.JsonConverter;
-import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
public final class EventForwarder {
@@ -67,24 +66,29 @@ public final class EventForwarder {
}
private byte[] preparePayload(Event event, Position position) {
- JsonObjectBuilder json = Json.createObjectBuilder();
- json.add(KEY_EVENT, JsonConverter.objectToJson(event));
+ Map<String, Object> data = new HashMap<>();
+ data.put(KEY_EVENT, event);
if (position != null) {
- json.add(KEY_POSITION, JsonConverter.objectToJson(position));
+ data.put(KEY_POSITION, position);
}
if (event.getDeviceId() != 0) {
Device device = Context.getIdentityManager().getDeviceById(event.getDeviceId());
if (device != null) {
- json.add(KEY_DEVICE, JsonConverter.objectToJson(device));
+ data.put(KEY_DEVICE, device);
}
}
if (event.getGeofenceId() != 0) {
Geofence geofence = Context.getGeofenceManager().getGeofence(event.getGeofenceId());
if (geofence != null) {
- json.add(KEY_GEOFENCE, JsonConverter.objectToJson(geofence));
+ data.put(KEY_GEOFENCE, geofence);
}
}
- return json.build().toString().getBytes(StandardCharsets.UTF_8);
+ try {
+ return Context.getObjectMapper().writeValueAsString(data).getBytes(StandardCharsets.UTF_8);
+ } catch (JsonProcessingException e) {
+ Log.warning(e);
+ return null;
+ }
}
}