aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/DriverResource.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-07-28 16:15:08 +1200
committerGitHub <noreply@github.com>2017-07-28 16:15:08 +1200
commitd3021c9ae11b177fe05b79e98f1e560e8c3cbaf5 (patch)
treebeb996f62fe8580360b823367aa04692d02dc3be /src/org/traccar/api/resource/DriverResource.java
parent5d6dec7818a8059c958fc896eb1de838fda52a8c (diff)
parent34d02fbb63eb3d0cfbbcf63de50561831b0ab38d (diff)
downloadtrackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.tar.gz
trackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.tar.bz2
trackermap-server-d3021c9ae11b177fe05b79e98f1e560e8c3cbaf5.zip
Merge pull request #3396 from Abyss777/combine_resources
Combine PUT/POST/DELETE functions in object resources
Diffstat (limited to 'src/org/traccar/api/resource/DriverResource.java')
-rw-r--r--src/org/traccar/api/resource/DriverResource.java41
1 files changed, 6 insertions, 35 deletions
diff --git a/src/org/traccar/api/resource/DriverResource.java b/src/org/traccar/api/resource/DriverResource.java
index d44979998..185f4a0dc 100644
--- a/src/org/traccar/api/resource/DriverResource.java
+++ b/src/org/traccar/api/resource/DriverResource.java
@@ -22,27 +22,25 @@ import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.traccar.Context;
-import org.traccar.api.BaseResource;
+import org.traccar.api.BaseObjectResource;
import org.traccar.database.DriversManager;
import org.traccar.model.Driver;
-import org.traccar.model.User;
@Path("drivers")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-public class DriverResource extends BaseResource {
+public class DriverResource extends BaseObjectResource<Driver> {
+
+ public DriverResource() {
+ super(Driver.class);
+ }
@GET
public Collection<Driver> get(
@@ -83,31 +81,4 @@ public class DriverResource extends BaseResource {
}
- @POST
- public Response add(Driver entity) throws SQLException {
- Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getDriversManager().addItem(entity);
- Context.getDataManager().linkObject(User.class, getUserId(), entity.getClass(), entity.getId(), true);
- Context.getDriversManager().refreshUserItems();
- return Response.ok(entity).build();
- }
-
- @Path("{id}")
- @PUT
- public Response update(Driver entity) throws SQLException {
- Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkPermission(Driver.class, getUserId(), entity.getId());
- Context.getDriversManager().updateItem(entity);
- return Response.ok(entity).build();
- }
-
- @Path("{id}")
- @DELETE
- public Response remove(@PathParam("id") long id) throws SQLException {
- Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkPermission(Driver.class, getUserId(), id);
- Context.getDriversManager().removeItem(id);
- return Response.noContent().build();
- }
-
}