diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-22 11:16:14 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-22 11:16:14 +0500 |
commit | 4cb47c38af63696470acdc91d7b7d01512f6b2e7 (patch) | |
tree | a07ae10919ff97d8c5b91bd381508675d8fb8d6b /src/org/traccar/api/BaseResource.java | |
parent | 69c46399ee0f6b3dd2b0589cb412e9e17f040369 (diff) | |
download | trackermap-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.tar.gz trackermap-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.tar.bz2 trackermap-server-4cb47c38af63696470acdc91d7b7d01512f6b2e7.zip |
- Add Permission helper Class
- Reorganize permission check and link
- Optimize calendar retrieving
Diffstat (limited to 'src/org/traccar/api/BaseResource.java')
-rw-r--r-- | src/org/traccar/api/BaseResource.java | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/org/traccar/api/BaseResource.java b/src/org/traccar/api/BaseResource.java index 920bb3931..502591efe 100644 --- a/src/org/traccar/api/BaseResource.java +++ b/src/org/traccar/api/BaseResource.java @@ -16,15 +16,11 @@ package org.traccar.api; import java.sql.SQLException; -import java.util.Iterator; -import java.util.LinkedHashMap; import javax.ws.rs.core.SecurityContext; import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.model.BaseModel; -import org.traccar.model.Device; import org.traccar.model.User; public class BaseResource { @@ -40,32 +36,6 @@ public class BaseResource { return 0; } - protected void checkAndLinkPermission(LinkedHashMap<String, Long> entity, boolean link) - throws SQLException, ClassNotFoundException { - Iterator<String> iterator = entity.keySet().iterator(); - String owner = iterator.next(); - Class<?> ownerClass = DataManager.getClassByName(owner); - String property = iterator.next(); - Class<?> propertyClass = DataManager.getClassByName(property); - - long ownerId = entity.get(owner); - long propertyId = entity.get(property); - - if (!link && ownerClass.equals(User.class) - && propertyClass.equals(Device.class)) { - if (getUserId() != ownerId) { - Context.getPermissionsManager().checkUser(getUserId(), ownerId); - } else { - Context.getPermissionsManager().checkAdmin(getUserId()); - } - } else { - Context.getPermissionsManager().checkPermission(ownerClass, getUserId(), ownerId); - } - Context.getPermissionsManager().checkPermission(propertyClass, getUserId(), propertyId); - - Context.getDataManager().linkObject(ownerClass, ownerId, propertyClass, propertyId, link); - } - protected void linkNewEntity(BaseModel entity) throws SQLException { Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true); } |