aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/DeviceResource.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-23 18:29:36 +1200
committerGitHub <noreply@github.com>2017-07-23 18:29:36 +1200
commit4b2372336d0496c85befe099914434e5b68f05b3 (patch)
tree798de625a07c18287e829b3a037cacee179ebcff /src/org/traccar/api/resource/DeviceResource.java
parentba82047a492be54545961716814584d8880d28ae (diff)
parent5a65c0d6be8ffc2db0ffdb0c35ecedfb2b3750c7 (diff)
downloadtrackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.tar.gz
trackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.tar.bz2
trackermap-server-4b2372336d0496c85befe099914434e5b68f05b3.zip
Merge pull request #3373 from Abyss777/refactor_managers
Refactor managers, permissions etc
Diffstat (limited to 'src/org/traccar/api/resource/DeviceResource.java')
-rw-r--r--src/org/traccar/api/resource/DeviceResource.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java
index 2957d623c..6cf7a6219 100644
--- a/src/org/traccar/api/resource/DeviceResource.java
+++ b/src/org/traccar/api/resource/DeviceResource.java
@@ -19,6 +19,7 @@ import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.model.Device;
import org.traccar.model.DeviceTotalDistance;
+import org.traccar.model.User;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -83,11 +84,9 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkDeviceReadonly(getUserId());
Context.getPermissionsManager().checkDeviceLimit(getUserId());
Context.getDeviceManager().addDevice(entity);
- Context.getDataManager().linkDevice(getUserId(), entity.getId());
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getPermissionsManager().refreshPermissions();
- if (Context.getGeofenceManager() != null) {
- Context.getGeofenceManager().refresh();
- }
+ Context.getPermissionsManager().refreshAllExtendedPermissions();
return Response.ok(entity).build();
}
@@ -99,9 +98,7 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkDevice(getUserId(), entity.getId());
Context.getDeviceManager().updateDevice(entity);
Context.getPermissionsManager().refreshPermissions();
- if (Context.getGeofenceManager() != null) {
- Context.getGeofenceManager().refresh();
- }
+ Context.getPermissionsManager().refreshAllExtendedPermissions();
return Response.ok(entity).build();
}
@@ -113,9 +110,7 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkDevice(getUserId(), id);
Context.getDeviceManager().removeDevice(id);
Context.getPermissionsManager().refreshPermissions();
- if (Context.getGeofenceManager() != null) {
- Context.getGeofenceManager().refresh();
- }
+ Context.getPermissionsManager().refreshAllExtendedPermissions();
Context.getAliasesManager().removeDevice(id);
return Response.noContent().build();
}