diff options
Diffstat (limited to 'src/org/traccar/api/resource')
5 files changed, 15 insertions, 0 deletions
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index 1fae92dc7..fda96a09d 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -18,6 +18,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseObjectResource; import org.traccar.database.DeviceManager; +import org.traccar.helper.LogAction; import org.traccar.model.Device; import org.traccar.model.DeviceTotalDistance; @@ -85,6 +86,7 @@ public class DeviceResource extends BaseObjectResource<Device> { public Response updateTotalDistance(DeviceTotalDistance entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getDeviceManager().resetTotalDistance(entity); + LogAction.resetTotalDistance(getUserId(), entity.getDeviceId()); return Response.noContent().build(); } diff --git a/src/org/traccar/api/resource/PermissionsResource.java b/src/org/traccar/api/resource/PermissionsResource.java index 9b9f65ad1..b89d9d376 100644 --- a/src/org/traccar/api/resource/PermissionsResource.java +++ b/src/org/traccar/api/resource/PermissionsResource.java @@ -29,6 +29,7 @@ import javax.ws.rs.core.Response; import org.traccar.Context; import org.traccar.api.BaseResource; +import org.traccar.helper.LogAction; import org.traccar.model.Device; import org.traccar.model.Permission; import org.traccar.model.User; @@ -61,6 +62,8 @@ public class PermissionsResource extends BaseResource { checkPermission(permission, true); Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId(), true); + LogAction.link(getUserId(), permission.getOwnerClass(), permission.getOwnerId(), + permission.getPropertyClass(), permission.getPropertyId()); Context.getPermissionsManager().refreshPermissions(permission); return Response.noContent().build(); } @@ -72,6 +75,8 @@ public class PermissionsResource extends BaseResource { checkPermission(permission, false); Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(), permission.getPropertyClass(), permission.getPropertyId(), false); + LogAction.unlink(getUserId(), permission.getOwnerClass(), permission.getOwnerId(), + permission.getPropertyClass(), permission.getPropertyId()); Context.getPermissionsManager().refreshPermissions(permission); return Response.noContent().build(); } diff --git a/src/org/traccar/api/resource/ServerResource.java b/src/org/traccar/api/resource/ServerResource.java index c0914995b..61d3221f0 100644 --- a/src/org/traccar/api/resource/ServerResource.java +++ b/src/org/traccar/api/resource/ServerResource.java @@ -17,6 +17,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; +import org.traccar.helper.LogAction; import org.traccar.model.Server; import javax.annotation.security.PermitAll; @@ -45,6 +46,7 @@ public class ServerResource extends BaseResource { public Response update(Server entity) throws SQLException { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getPermissionsManager().updateServer(entity); + LogAction.edit(getUserId(), entity); return Response.ok(entity).build(); } diff --git a/src/org/traccar/api/resource/SessionResource.java b/src/org/traccar/api/resource/SessionResource.java index fa2a14c6f..3f7842626 100644 --- a/src/org/traccar/api/resource/SessionResource.java +++ b/src/org/traccar/api/resource/SessionResource.java @@ -17,6 +17,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; +import org.traccar.helper.LogAction; import org.traccar.model.User; import javax.annotation.security.PermitAll; @@ -103,6 +104,7 @@ public class SessionResource extends BaseResource { User user = Context.getPermissionsManager().login(email, password); if (user != null) { request.getSession().setAttribute(USER_ID_KEY, user.getId()); + LogAction.login(user.getId()); return user; } else { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); @@ -111,6 +113,7 @@ public class SessionResource extends BaseResource { @DELETE public Response remove() { + LogAction.logout(getUserId()); request.getSession().removeAttribute(USER_ID_KEY); return Response.noContent().build(); } diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java index 0f6f6edba..0b42d8d92 100644 --- a/src/org/traccar/api/resource/UserResource.java +++ b/src/org/traccar/api/resource/UserResource.java @@ -18,6 +18,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseObjectResource; import org.traccar.database.UsersManager; +import org.traccar.helper.LogAction; import org.traccar.model.ManagedUser; import org.traccar.model.User; @@ -81,8 +82,10 @@ public class UserResource extends BaseObjectResource<User> { } } Context.getUsersManager().addItem(entity); + LogAction.create(getUserId(), entity); if (Context.getPermissionsManager().getUserManager(getUserId())) { Context.getDataManager().linkObject(User.class, getUserId(), ManagedUser.class, entity.getId(), true); + LogAction.link(getUserId(), User.class, getUserId(), ManagedUser.class, entity.getId()); } Context.getUsersManager().refreshUserItems(); return Response.ok(entity).build(); |