aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/MainEventHandler.java2
-rw-r--r--src/main/java/org/traccar/api/resource/DeviceResource.java12
2 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/MainEventHandler.java b/src/main/java/org/traccar/MainEventHandler.java
index 965421d2f..06791c540 100644
--- a/src/main/java/org/traccar/MainEventHandler.java
+++ b/src/main/java/org/traccar/MainEventHandler.java
@@ -89,8 +89,6 @@ public class MainEventHandler extends ChannelInboundHandlerAdapter {
new Condition.Equals("id", "id")));
cacheManager.updatePosition(position);
- cacheManager.getObject(Device.class, position.getDeviceId()).setPositionId(position.getId());
-
connectionManager.updatePosition(position);
}
} catch (StorageException error) {
diff --git a/src/main/java/org/traccar/api/resource/DeviceResource.java b/src/main/java/org/traccar/api/resource/DeviceResource.java
index 74e133f44..ff682d1d1 100644
--- a/src/main/java/org/traccar/api/resource/DeviceResource.java
+++ b/src/main/java/org/traccar/api/resource/DeviceResource.java
@@ -21,6 +21,7 @@ import org.traccar.model.Device;
import org.traccar.model.DeviceAccumulators;
import org.traccar.model.Position;
import org.traccar.model.User;
+import org.traccar.session.ConnectionManager;
import org.traccar.session.cache.CacheManager;
import org.traccar.storage.StorageException;
import org.traccar.storage.query.Columns;
@@ -48,6 +49,9 @@ public class DeviceResource extends BaseObjectResource<Device> {
@Inject
private CacheManager cacheManager;
+ @Inject
+ private ConnectionManager connectionManager;
+
public DeviceResource() {
super(Device.class);
}
@@ -125,7 +129,13 @@ public class DeviceResource extends BaseObjectResource<Device> {
new Columns.Include("positionId"),
new Condition.Equals("id", "id")));
- cacheManager.updatePosition(position);
+ try {
+ cacheManager.addDevice(position.getDeviceId());
+ cacheManager.updatePosition(position);
+ connectionManager.updatePosition(position);
+ } finally {
+ cacheManager.removeDevice(position.getDeviceId());
+ }
} else {
throw new IllegalArgumentException();
}