From 7546048a58c16ad083d732aacd2af2d4a200b47c Mon Sep 17 00:00:00 2001 From: Philipp Prangenberg Date: Tue, 6 Dec 2016 11:45:05 +0100 Subject: Updating HashMap groupsByName in group-access methods --- src/org/traccar/database/DeviceManager.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index 403953d56..a75b0616c 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -313,17 +313,24 @@ public class DeviceManager implements IdentityManager { checkGroupCycles(group); dataManager.addGroup(group); groupsById.put(group.getId(), group); + groupsByName.put(group.getName(), group); } public void updateGroup(Group group) throws SQLException { + String oldGroupName = groupsById.get(group.getId()).getName(); checkGroupCycles(group); dataManager.updateGroup(group); groupsById.put(group.getId(), group); + if (!oldGroupName.equals(group.getName())) { + groupsByName.remove(oldGroupName); + } + groupsByName.put(group.getName(), group); } public void removeGroup(long groupId) throws SQLException { dataManager.removeGroup(groupId); groupsById.remove(groupId); + groupsByName.remove(getGroupById(groupId).getName()); } public boolean lookupAttributeBoolean( -- cgit v1.2.3