diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-01 15:20:05 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-12-01 15:20:05 +1300 |
commit | ef2ae4103726dae12a0153886219d4ac43d20ae0 (patch) | |
tree | 79291f74ce2631a4a9a176b7e510028e534a23d4 /src/org/traccar/database | |
parent | c6692703c8099577cb86c3eace5d8d1bc11f212d (diff) | |
parent | 53f70085891cdb0feae56df8990c1245091352a1 (diff) | |
download | trackermap-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.tar.gz trackermap-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.tar.bz2 trackermap-server-ef2ae4103726dae12a0153886219d4ac43d20ae0.zip |
Merge branch 'rest' into master
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 15 | ||||
-rw-r--r-- | src/org/traccar/database/PermissionsManager.java | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index da87c6c27..978f08ef3 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -277,12 +277,19 @@ public class DataManager implements IdentityManager { } } + @Deprecated public void removeUser(User user) throws SQLException { QueryBuilder.create(dataSource, getQuery("database.deleteUser")) .setObject(user) .executeUpdate(); } + public void removeUser(long userId) throws SQLException { + QueryBuilder.create(dataSource, getQuery("database.deleteUser")) + .setLong("id", userId) + .executeUpdate(); + } + public Collection<Permission> getPermissions() throws SQLException { return QueryBuilder.create(dataSource, getQuery("database.getPermissionsAll")) .executeQuery(new Permission()); @@ -317,6 +324,7 @@ public class DataManager implements IdentityManager { .executeUpdate(); } + @Deprecated public void removeDevice(Device device) throws SQLException { QueryBuilder.create(dataSource, getQuery("database.deleteDevice")) .setObject(device) @@ -324,6 +332,13 @@ public class DataManager implements IdentityManager { AsyncServlet.sessionRefreshDevice(device.getId()); } + public void removeDevice(long deviceId) throws SQLException { + QueryBuilder.create(dataSource, getQuery("database.deleteDevice")) + .setLong("id", deviceId) + .executeUpdate(); + AsyncServlet.sessionRefreshDevice(deviceId); + } + public void linkDevice(long userId, long deviceId) throws SQLException { QueryBuilder.create(dataSource, getQuery("database.linkDevice")) .setLong("userId", userId) diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index a38a29c32..0a43f4ff4 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.traccar.helper.Log; +import org.traccar.model.Device; import org.traccar.model.Permission; import org.traccar.model.User; @@ -82,4 +83,11 @@ public class PermissionsManager { } } + public <T> void check(Class<T> clazz, long userId, long entityId) throws SecurityException { + if (clazz.equals(User.class)) { + checkUser(userId, entityId); + } else if (clazz.equals(Device.class)) { + checkDevice(userId, entityId); + } + } } |