From 55d91ec7a86777bb0427422c15c2b8a60aa00071 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 21 Jul 2017 13:06:18 +0500 Subject: Implement type constants --- src/org/traccar/database/DataManager.java | 4 ++-- src/org/traccar/database/PermissionsManager.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 9d8167acc..3bb367ece 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -268,11 +268,11 @@ public class DataManager { .executeUpdate()); } - private String makeName(String object) { + public static String makeName(String object) { return object.substring(0, 1).toUpperCase() + object.replace("Id", "").substring(1); } - private String makeNameId(String object) { + public static String makeNameId(String object) { return object.substring(0, 1).toLowerCase() + object.substring(1) + (object.indexOf("Id") == -1 ? "Id" : ""); } diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 5f83a1274..56a12e941 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -299,26 +299,26 @@ public class PermissionsManager { public void checkPermission(String object, long userId, long objectId) throws SecurityException { SimpleObjectManager manager = null; - switch (object) { - case "device": + switch (DataManager.makeName(object)) { + case Context.TYPE_DEVICE: checkDevice(userId, objectId); break; - case "group": + case Context.TYPE_GROUP: checkGroup(userId, objectId); break; - case "user": + case Context.TYPE_USER: checkUser(userId, objectId); break; - case "geofence": + case Context.TYPE_GEOFENCE: manager = Context.getGeofenceManager(); break; - case "attribute": + case Context.TYPE_ATTRIBUTE: manager = Context.getAttributesManager(); break; - case "driver": + case Context.TYPE_DRIVER: manager = Context.getDriversManager(); break; - case "calendar": + case Context.TYPE_CALENDAR: manager = Context.getCalendarManager(); break; default: -- cgit v1.2.3