aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <atananaev@lyft.com>2020-12-28 13:55:59 -0800
committerAnton Tananaev <atananaev@lyft.com>2020-12-28 13:55:59 -0800
commit6bb57ebef4371459f8912a6d264d69431815d1f6 (patch)
treefca8fda0366404d4a5441403eff76eea61442297 /src/main/java
parentf54ec00be2611c274e442cd6b2fd5ccdcf433ae5 (diff)
downloadtrackermap-server-6bb57ebef4371459f8912a6d264d69431815d1f6.tar.gz
trackermap-server-6bb57ebef4371459f8912a6d264d69431815d1f6.tar.bz2
trackermap-server-6bb57ebef4371459f8912a6d264d69431815d1f6.zip
Remove unnecessary code
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/api/BaseObjectResource.java2
-rw-r--r--src/main/java/org/traccar/database/GroupsManager.java24
2 files changed, 2 insertions, 24 deletions
diff --git a/src/main/java/org/traccar/api/BaseObjectResource.java b/src/main/java/org/traccar/api/BaseObjectResource.java
index 07d631ba6..71f3939cb 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -171,7 +171,7 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
}
if (baseClass.equals(Group.class) || baseClass.equals(Device.class) || baseClass.equals(User.class)) {
if (baseClass.equals(Group.class)) {
- Context.getGroupsManager().updateGroupCache(true);
+ Context.getGroupsManager().refreshItems();
Context.getDeviceManager().updateDeviceCache(true);
}
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
diff --git a/src/main/java/org/traccar/database/GroupsManager.java b/src/main/java/org/traccar/database/GroupsManager.java
index 81f1968aa..c35f35f93 100644
--- a/src/main/java/org/traccar/database/GroupsManager.java
+++ b/src/main/java/org/traccar/database/GroupsManager.java
@@ -19,24 +19,14 @@ package org.traccar.database;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.model.Group;
public class GroupsManager extends BaseObjectManager<Group> implements ManagableObjects {
- private static final Logger LOGGER = LoggerFactory.getLogger(GroupsManager.class);
-
- private AtomicLong groupsLastUpdate = new AtomicLong();
- private final long dataRefreshDelay;
-
public GroupsManager(DataManager dataManager) {
super(dataManager, Group.class);
- dataRefreshDelay = Context.getConfig().getLong("database.refreshDelay",
- DeviceManager.DEFAULT_REFRESH_DELAY) * 1000;
}
private void checkGroupCycles(Group group) {
@@ -50,23 +40,11 @@ public class GroupsManager extends BaseObjectManager<Group> implements Managable
}
}
- public void updateGroupCache(boolean force) throws SQLException {
- long lastUpdate = groupsLastUpdate.get();
- if ((force || System.currentTimeMillis() - lastUpdate > dataRefreshDelay)
- && groupsLastUpdate.compareAndSet(lastUpdate, System.currentTimeMillis())) {
- refreshItems();
- }
- }
-
@Override
public Set<Long> getAllItems() {
Set<Long> result = super.getAllItems();
if (result.isEmpty()) {
- try {
- updateGroupCache(true);
- } catch (SQLException e) {
- LOGGER.warn("Update group cache error", e);
- }
+ refreshItems();
result = super.getAllItems();
}
return result;