From f92b5cd97a5d2159a890fb4817238f4c1bbb2a12 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Sun, 23 Jul 2017 08:19:48 +0500 Subject: Remove proxy function --- src/org/traccar/api/BaseResource.java | 9 --------- src/org/traccar/api/resource/AttributeResource.java | 3 ++- src/org/traccar/api/resource/CalendarResource.java | 3 ++- src/org/traccar/api/resource/DeviceResource.java | 3 ++- src/org/traccar/api/resource/DriverResource.java | 3 ++- src/org/traccar/api/resource/GeofenceResource.java | 3 ++- src/org/traccar/api/resource/GroupResource.java | 3 ++- 7 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/org/traccar/api') 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(); -- cgit v1.2.3