aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/BaseResource.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-21 13:06:18 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-21 13:06:18 +0500
commit55d91ec7a86777bb0427422c15c2b8a60aa00071 (patch)
tree55d989c8241b18891aa0b479f8e14533cc35d625 /src/org/traccar/api/BaseResource.java
parent4b51fef3521e5b0bf338f631ad99e7affe9a1837 (diff)
downloadtrackermap-server-55d91ec7a86777bb0427422c15c2b8a60aa00071.tar.gz
trackermap-server-55d91ec7a86777bb0427422c15c2b8a60aa00071.tar.bz2
trackermap-server-55d91ec7a86777bb0427422c15c2b8a60aa00071.zip
Implement type constants
Diffstat (limited to 'src/org/traccar/api/BaseResource.java')
-rw-r--r--src/org/traccar/api/BaseResource.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/org/traccar/api/BaseResource.java b/src/org/traccar/api/BaseResource.java
index 9ac30f5a7..4ad1477c2 100644
--- a/src/org/traccar/api/BaseResource.java
+++ b/src/org/traccar/api/BaseResource.java
@@ -22,6 +22,7 @@ import java.util.Map;
import javax.ws.rs.core.SecurityContext;
import org.traccar.Context;
+import org.traccar.database.DataManager;
import org.traccar.model.BaseModel;
public class BaseResource {
@@ -44,19 +45,21 @@ public class BaseResource {
Iterator<String> iterator = entity.keySet().iterator();
String owner = iterator.next();
String property = iterator.next();
+
long ownerId = entity.get(owner);
long propertyId = entity.get(property);
- if (!link && owner.equals("userId") && property.equals("deviceId")) {
+ if (!link && DataManager.makeName(owner).equals(Context.TYPE_USER)
+ && DataManager.makeName(property).equals(Context.TYPE_DEVICE)) {
if (getUserId() != ownerId) {
Context.getPermissionsManager().checkUser(getUserId(), ownerId);
} else {
Context.getPermissionsManager().checkAdmin(getUserId());
}
} else {
- Context.getPermissionsManager().checkPermission(owner.replace("Id", ""), getUserId(), ownerId);
+ Context.getPermissionsManager().checkPermission(owner, getUserId(), ownerId);
}
- Context.getPermissionsManager().checkPermission(property.replace("Id", ""), getUserId(), propertyId);
+ Context.getPermissionsManager().checkPermission(property, getUserId(), propertyId);
Context.getDataManager().linkObject(owner, ownerId, property, propertyId, link);
}