diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-08 07:52:59 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-08 07:52:59 -0700 |
commit | cd229daa23cfc43ad5056c45c4aaecefdbbf826c (patch) | |
tree | 4dd8932cda394d20e59143e5e44714695f21c549 /src/main/java/org/traccar/api/resource | |
parent | 5890e03199142f041dc19160329a740b4d01450d (diff) | |
download | trackermap-server-cd229daa23cfc43ad5056c45c4aaecefdbbf826c.tar.gz trackermap-server-cd229daa23cfc43ad5056c45c4aaecefdbbf826c.tar.bz2 trackermap-server-cd229daa23cfc43ad5056c45c4aaecefdbbf826c.zip |
Improve cache invalidation
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r-- | src/main/java/org/traccar/api/resource/PermissionsResource.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/api/resource/PermissionsResource.java b/src/main/java/org/traccar/api/resource/PermissionsResource.java index 484c61e66..a4db6754c 100644 --- a/src/main/java/org/traccar/api/resource/PermissionsResource.java +++ b/src/main/java/org/traccar/api/resource/PermissionsResource.java @@ -20,8 +20,10 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.helper.LogAction; import org.traccar.model.Permission; +import org.traccar.session.cache.CacheManager; import org.traccar.storage.StorageException; +import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; @@ -40,6 +42,9 @@ import java.util.Set; @Consumes(MediaType.APPLICATION_JSON) public class PermissionsResource extends BaseResource { + @Inject + private CacheManager cacheManager; + private void checkPermission(Permission permission, boolean link) throws StorageException { if (permissionsService.notAdmin(getUserId())) { permissionsService.checkPermission(permission.getOwnerClass(), getUserId(), permission.getOwnerId()); @@ -67,6 +72,8 @@ public class PermissionsResource extends BaseResource { checkPermission(permission, true); Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId(), true); + cacheManager.invalidate(permission.getOwnerClass(), permission.getOwnerId(), + permission.getPropertyClass(), permission.getPropertyId()); LogAction.link(getUserId(), permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId()); } @@ -91,6 +98,8 @@ public class PermissionsResource extends BaseResource { checkPermission(permission, false); Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId(), false); + cacheManager.invalidate(permission.getOwnerClass(), permission.getOwnerId(), + permission.getPropertyClass(), permission.getPropertyId()); LogAction.unlink(getUserId(), permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId()); } |