aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/api/BaseResource.java9
-rw-r--r--src/org/traccar/api/resource/AttributeResource.java3
-rw-r--r--src/org/traccar/api/resource/CalendarResource.java3
-rw-r--r--src/org/traccar/api/resource/DeviceResource.java3
-rw-r--r--src/org/traccar/api/resource/DriverResource.java3
-rw-r--r--src/org/traccar/api/resource/GeofenceResource.java3
-rw-r--r--src/org/traccar/api/resource/GroupResource.java3
7 files changed, 12 insertions, 15 deletions
diff --git a/src/org/traccar/api/BaseResource.java b/src/org/traccar/api/BaseResource.java
index 502591efe..4e1db7831 100644
--- a/src/org/traccar/api/BaseResource.java
+++ b/src/org/traccar/api/BaseResource.java
@@ -15,13 +15,8 @@
*/
package org.traccar.api;
-import java.sql.SQLException;
-
import javax.ws.rs.core.SecurityContext;
-import org.traccar.Context;
-import org.traccar.model.BaseModel;
-import org.traccar.model.User;
public class BaseResource {
@@ -35,8 +30,4 @@ public class BaseResource {
}
return 0;
}
-
- protected void linkNewEntity(BaseModel entity) throws SQLException {
- Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
- }
}
diff --git a/src/org/traccar/api/resource/AttributeResource.java b/src/org/traccar/api/resource/AttributeResource.java
index 7e6947d26..7b81d3ffb 100644
--- a/src/org/traccar/api/resource/AttributeResource.java
+++ b/src/org/traccar/api/resource/AttributeResource.java
@@ -38,6 +38,7 @@ import org.traccar.api.BaseResource;
import org.traccar.database.AttributesManager;
import org.traccar.model.Attribute;
import org.traccar.model.Position;
+import org.traccar.model.User;
import org.traccar.processing.ComputedAttributesHandler;
@Path("attributes/computed")
@@ -87,7 +88,7 @@ public class AttributeResource extends BaseResource {
private Response add(Attribute entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getAttributesManager().addItem(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getAttributesManager().refreshUserItems();
return Response.ok(entity).build();
}
diff --git a/src/org/traccar/api/resource/CalendarResource.java b/src/org/traccar/api/resource/CalendarResource.java
index 30f5df6b8..a0f8656af 100644
--- a/src/org/traccar/api/resource/CalendarResource.java
+++ b/src/org/traccar/api/resource/CalendarResource.java
@@ -35,6 +35,7 @@ import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.database.CalendarManager;
import org.traccar.model.Calendar;
+import org.traccar.model.User;
@Path("calendars")
@Produces(MediaType.APPLICATION_JSON)
@@ -66,7 +67,7 @@ public class CalendarResource extends BaseResource {
public Response add(Calendar entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getCalendarManager().addItem(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getCalendarManager().refreshUserItems();
return Response.ok(entity).build();
}
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java
index 0d6e4f09c..a6b3ef964 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;
@@ -77,7 +78,7 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkDeviceReadonly(getUserId());
Context.getPermissionsManager().checkDeviceLimit(getUserId());
Context.getDeviceManager().addDevice(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getPermissionsManager().refreshPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
return Response.ok(entity).build();
diff --git a/src/org/traccar/api/resource/DriverResource.java b/src/org/traccar/api/resource/DriverResource.java
index cf80bf7df..72eadb711 100644
--- a/src/org/traccar/api/resource/DriverResource.java
+++ b/src/org/traccar/api/resource/DriverResource.java
@@ -37,6 +37,7 @@ import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.database.DriversManager;
import org.traccar.model.Driver;
+import org.traccar.model.User;
@Path("drivers")
@Produces(MediaType.APPLICATION_JSON)
@@ -86,7 +87,7 @@ public class DriverResource extends BaseResource {
public Response add(Driver entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getDriversManager().addItem(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getDriversManager().refreshUserItems();
return Response.ok(entity).build();
}
diff --git a/src/org/traccar/api/resource/GeofenceResource.java b/src/org/traccar/api/resource/GeofenceResource.java
index 341180cf8..47f889e9c 100644
--- a/src/org/traccar/api/resource/GeofenceResource.java
+++ b/src/org/traccar/api/resource/GeofenceResource.java
@@ -19,6 +19,7 @@ import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.database.GeofenceManager;
import org.traccar.model.Geofence;
+import org.traccar.model.User;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -85,7 +86,7 @@ public class GeofenceResource extends BaseResource {
public Response add(Geofence entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getGeofenceManager().addItem(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getGeofenceManager().refreshUserItems();
return Response.ok(entity).build();
}
diff --git a/src/org/traccar/api/resource/GroupResource.java b/src/org/traccar/api/resource/GroupResource.java
index 402e687e6..f20c95327 100644
--- a/src/org/traccar/api/resource/GroupResource.java
+++ b/src/org/traccar/api/resource/GroupResource.java
@@ -18,6 +18,7 @@ package org.traccar.api.resource;
import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.model.Group;
+import org.traccar.model.User;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -61,7 +62,7 @@ public class GroupResource extends BaseResource {
public Response add(Group entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getDeviceManager().addGroup(entity);
- linkNewEntity(entity);
+ Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
Context.getPermissionsManager().refreshPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
return Response.ok(entity).build();