diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-30 22:48:37 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-30 22:48:37 +1200 |
commit | 1ac0692d07898889156a18848a23d6af889fa6c5 (patch) | |
tree | c9a2d83ac7e1970dc7ca90d213861dc5052f6809 /src/org | |
parent | 09ab10ae55444bbd5e09a82fbb41d2f4903a9029 (diff) | |
download | traccar-server-1ac0692d07898889156a18848a23d6af889fa6c5.tar.gz traccar-server-1ac0692d07898889156a18848a23d6af889fa6c5.tar.bz2 traccar-server-1ac0692d07898889156a18848a23d6af889fa6c5.zip |
Fix database init sequence
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/Context.java | 2 | ||||
-rw-r--r-- | src/org/traccar/database/DataManager.java | 9 | ||||
-rw-r--r-- | src/org/traccar/http/DeviceServlet.java | 2 | ||||
-rw-r--r-- | src/org/traccar/http/UserServlet.java | 3 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 64fb296e8..0a4da1172 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -90,6 +90,7 @@ public class Context { } dataManager = new DataManager(properties); + connectionManager = new ConnectionManager(); if (!Boolean.valueOf(properties.getProperty("web.old"))) { permissionsManager = new PermissionsManager(); @@ -112,7 +113,6 @@ public class Context { serverManager = new ServerManager(); - dataManager.initDatabaseSchema(); connectionManager.init(dataManager); serverManager.init(); } diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 07e50ff5d..d4351d316 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Properties; import javax.naming.InitialContext; import javax.sql.DataSource; - import org.traccar.Context; import org.traccar.helper.DriverDelegate; import org.traccar.helper.Log; @@ -60,6 +59,7 @@ public class DataManager { this.properties = properties; if (properties != null) { initDatabase(properties); + initDatabaseSchema(); // Refresh delay String refreshDelay = properties.getProperty("database.refreshDelay"); @@ -138,7 +138,7 @@ public class DataManager { return query; } - public void initDatabaseSchema() throws SQLException { + private void initDatabaseSchema() throws SQLException { if (!Boolean.valueOf(properties.getProperty("web.old"))) { @@ -231,7 +231,6 @@ public class DataManager { user.setId(QueryBuilder.create(dataSource, getQuery("database.insertUser"), true) .setObject(user) .executeUpdate()); - Context.getPermissionsManager().refresh(); } public void updateUser(User user) throws SQLException { @@ -243,14 +242,12 @@ public class DataManager { .setObject(user) .executeUpdate(); } - Context.getPermissionsManager().refresh(); } public void removeUser(User user) throws SQLException { QueryBuilder.create(dataSource, getQuery("database.deleteUser")) .setObject(user) .executeUpdate(); - Context.getPermissionsManager().refresh(); } public Collection<Permission> getPermissions() throws SQLException { @@ -285,7 +282,6 @@ public class DataManager { QueryBuilder.create(dataSource, getQuery("database.deleteDevice")) .setObject(device) .executeUpdate(); - Context.getPermissionsManager().refresh(); AsyncServlet.sessionRefreshDevice(device.getId()); } @@ -294,7 +290,6 @@ public class DataManager { .setLong("userId", userId) .setLong("deviceId", deviceId) .executeUpdate(); - Context.getPermissionsManager().refresh(); AsyncServlet.sessionRefreshUser(userId); } diff --git a/src/org/traccar/http/DeviceServlet.java b/src/org/traccar/http/DeviceServlet.java index 1e8e1f047..2a3e15a80 100644 --- a/src/org/traccar/http/DeviceServlet.java +++ b/src/org/traccar/http/DeviceServlet.java @@ -47,6 +47,7 @@ public class DeviceServlet extends BaseServlet { Device device = JsonConverter.objectFromJson(req.getReader(), new Device()); Context.getDataManager().addDevice(device); Context.getDataManager().linkDevice(getUserId(req), device.getId()); + Context.getPermissionsManager().refresh(); sendResponse(resp.getWriter(), JsonConverter.objectToJson(device)); } @@ -61,6 +62,7 @@ public class DeviceServlet extends BaseServlet { Device device = JsonConverter.objectFromJson(req.getReader(), new Device()); Context.getPermissionsManager().checkDevice(getUserId(req), device.getId()); Context.getDataManager().removeDevice(device); + Context.getPermissionsManager().refresh(); sendResponse(resp.getWriter(), true); } diff --git a/src/org/traccar/http/UserServlet.java b/src/org/traccar/http/UserServlet.java index 19a70ac93..71af74485 100644 --- a/src/org/traccar/http/UserServlet.java +++ b/src/org/traccar/http/UserServlet.java @@ -48,6 +48,7 @@ public class UserServlet extends BaseServlet { User user = JsonConverter.objectFromJson(req.getReader(), new User()); Context.getPermissionsManager().checkUser(getUserId(req), user.getId()); Context.getDataManager().addUser(user); + Context.getPermissionsManager().refresh(); sendResponse(resp.getWriter(), JsonConverter.objectToJson(user)); } @@ -59,6 +60,7 @@ public class UserServlet extends BaseServlet { Context.getPermissionsManager().checkUser(getUserId(req), user.getId()); } Context.getDataManager().updateUser(user); + Context.getPermissionsManager().refresh(); sendResponse(resp.getWriter(), true); } @@ -66,6 +68,7 @@ public class UserServlet extends BaseServlet { User user = JsonConverter.objectFromJson(req.getReader(), new User()); Context.getPermissionsManager().checkUser(getUserId(req), user.getId()); Context.getDataManager().removeUser(user); + Context.getPermissionsManager().refresh(); sendResponse(resp.getWriter(), true); } |