aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DataManager.java15
-rw-r--r--src/org/traccar/database/PermissionsManager.java8
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);
+ }
+ }
}