aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/session
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-12-03 14:08:07 -0800
committerAnton Tananaev <anton@traccar.org>2023-12-03 14:08:07 -0800
commit8999283ee7344fd7ec33c8a6cb5a7999e0592074 (patch)
tree7d9c69c34b04b74560fabd1a89c4a6042398613c /src/main/java/org/traccar/session
parent1efe470d4df335dfaaad5a9e2c6417c24d8864e1 (diff)
downloadtrackermap-server-8999283ee7344fd7ec33c8a6cb5a7999e0592074.tar.gz
trackermap-server-8999283ee7344fd7ec33c8a6cb5a7999e0592074.tar.bz2
trackermap-server-8999283ee7344fd7ec33c8a6cb5a7999e0592074.zip
Update broadcast interface
Diffstat (limited to 'src/main/java/org/traccar/session')
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java5
-rw-r--r--src/main/java/org/traccar/session/cache/CacheManager.java18
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index 28214840d..0b13a5a72 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -330,8 +330,9 @@ public class ConnectionManager implements BroadcastInterface {
public synchronized void invalidatePermission(
boolean local,
Class<? extends BaseModel> clazz1, long id1,
- Class<? extends BaseModel> clazz2, long id2) {
- if (clazz1.equals(User.class) && clazz2.equals(Device.class)) {
+ Class<? extends BaseModel> clazz2, long id2,
+ boolean link) {
+ if (link && clazz1.equals(User.class) && clazz2.equals(Device.class)) {
if (listeners.containsKey(id1)) {
userDevices.get(id1).add(id2);
deviceUsers.put(id2, new HashSet<>(List.of(id1)));
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java
index 4b6422de2..c40916218 100644
--- a/src/main/java/org/traccar/session/cache/CacheManager.java
+++ b/src/main/java/org/traccar/session/cache/CacheManager.java
@@ -19,6 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.broadcast.BroadcastInterface;
import org.traccar.broadcast.BroadcastService;
+import org.traccar.broadcast.ObjectOperation;
import org.traccar.config.Config;
import org.traccar.model.Attribute;
import org.traccar.model.BaseModel;
@@ -201,12 +202,15 @@ public class CacheManager implements BroadcastInterface {
}
@Override
- public void invalidateObject(boolean local, Class<? extends BaseModel> clazz, long id) {
+ public void invalidateObject(
+ boolean local,
+ Class<? extends BaseModel> clazz, long id,
+ ObjectOperation operation) {
try {
var object = storage.getObject(clazz, new Request(
new Columns.All(), new Condition.Equals("id", id)));
if (object != null) {
- updateOrInvalidate(local, object);
+ updateOrInvalidate(local, object, operation);
} else {
invalidate(clazz, id);
}
@@ -215,9 +219,10 @@ public class CacheManager implements BroadcastInterface {
}
}
- public <T extends BaseModel> void updateOrInvalidate(boolean local, T object) throws StorageException {
+ public <T extends BaseModel> void updateOrInvalidate(
+ boolean local, T object, ObjectOperation operation) throws StorageException {
if (local) {
- broadcastService.invalidateObject(true, object.getClass(), object.getId());
+ broadcastService.invalidateObject(true, object.getClass(), object.getId(), operation);
}
if (object instanceof Server) {
@@ -262,9 +267,10 @@ public class CacheManager implements BroadcastInterface {
public void invalidatePermission(
boolean local,
Class<? extends BaseModel> clazz1, long id1,
- Class<? extends BaseModel> clazz2, long id2) {
+ Class<? extends BaseModel> clazz2, long id2,
+ boolean link) {
if (local) {
- broadcastService.invalidatePermission(true, clazz1, id1, clazz2, id2);
+ broadcastService.invalidatePermission(true, clazz1, id1, clazz2, id2, link);
}
try {