aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-23 14:48:01 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-23 14:48:01 +0500
commit21bf1014e55ab8049e18ee991c6ee80b23d1789c (patch)
tree1b69c9e0e303773fc5d85958ac6bd369471b9637 /src/org/traccar/api/resource
parent5536fbe00c022c151007ad077d911b5162201cd4 (diff)
downloadtraccar-server-21bf1014e55ab8049e18ee991c6ee80b23d1789c.tar.gz
traccar-server-21bf1014e55ab8049e18ee991c6ee80b23d1789c.tar.bz2
traccar-server-21bf1014e55ab8049e18ee991c6ee80b23d1789c.zip
Implement cache for users objects
Diffstat (limited to 'src/org/traccar/api/resource')
-rw-r--r--src/org/traccar/api/resource/DevicePermissionResource.java4
-rw-r--r--src/org/traccar/api/resource/DeviceResource.java4
-rw-r--r--src/org/traccar/api/resource/GroupPermissionResource.java4
-rw-r--r--src/org/traccar/api/resource/GroupResource.java4
-rw-r--r--src/org/traccar/api/resource/SessionResource.java4
-rw-r--r--src/org/traccar/api/resource/UserResource.java11
6 files changed, 14 insertions, 17 deletions
diff --git a/src/org/traccar/api/resource/DevicePermissionResource.java b/src/org/traccar/api/resource/DevicePermissionResource.java
index 7de050074..7faa1ab09 100644
--- a/src/org/traccar/api/resource/DevicePermissionResource.java
+++ b/src/org/traccar/api/resource/DevicePermissionResource.java
@@ -37,7 +37,7 @@ public class DevicePermissionResource extends BaseResource {
public Response add(DevicePermission entity) throws SQLException {
Context.getPermissionsManager().checkAdmin(getUserId());
Context.getDataManager().linkDevice(entity.getUserId(), entity.getDeviceId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
@@ -48,7 +48,7 @@ public class DevicePermissionResource extends BaseResource {
public Response remove(DevicePermission entity) throws SQLException {
Context.getPermissionsManager().checkAdmin(getUserId());
Context.getDataManager().unlinkDevice(entity.getUserId(), entity.getDeviceId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java
index f48df7553..b12ab8c36 100644
--- a/src/org/traccar/api/resource/DeviceResource.java
+++ b/src/org/traccar/api/resource/DeviceResource.java
@@ -59,7 +59,7 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getDeviceManager().addDevice(entity);
Context.getDataManager().linkDevice(getUserId(), entity.getId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
@@ -84,7 +84,7 @@ public class DeviceResource extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getPermissionsManager().checkDevice(getUserId(), id);
Context.getDeviceManager().removeDevice(id);
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
diff --git a/src/org/traccar/api/resource/GroupPermissionResource.java b/src/org/traccar/api/resource/GroupPermissionResource.java
index 1fbf37a2b..94100362b 100644
--- a/src/org/traccar/api/resource/GroupPermissionResource.java
+++ b/src/org/traccar/api/resource/GroupPermissionResource.java
@@ -37,7 +37,7 @@ public class GroupPermissionResource extends BaseResource {
public Response add(GroupPermission entity) throws SQLException {
Context.getPermissionsManager().checkAdmin(getUserId());
Context.getDataManager().linkGroup(entity.getUserId(), entity.getGroupId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
@@ -48,7 +48,7 @@ public class GroupPermissionResource extends BaseResource {
public Response remove(GroupPermission entity) throws SQLException {
Context.getPermissionsManager().checkAdmin(getUserId());
Context.getDataManager().unlinkGroup(entity.getUserId(), entity.getGroupId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
diff --git a/src/org/traccar/api/resource/GroupResource.java b/src/org/traccar/api/resource/GroupResource.java
index eec28e325..6b722ef6d 100644
--- a/src/org/traccar/api/resource/GroupResource.java
+++ b/src/org/traccar/api/resource/GroupResource.java
@@ -58,7 +58,7 @@ public class GroupResource extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getDeviceManager().addGroup(entity);
Context.getDataManager().linkGroup(getUserId(), entity.getId());
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
@@ -83,7 +83,7 @@ public class GroupResource extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getPermissionsManager().checkGroup(getUserId(), id);
Context.getDeviceManager().removeGroup(id);
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().refreshPermissions();
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refresh();
}
diff --git a/src/org/traccar/api/resource/SessionResource.java b/src/org/traccar/api/resource/SessionResource.java
index 49670c1f9..deed70b37 100644
--- a/src/org/traccar/api/resource/SessionResource.java
+++ b/src/org/traccar/api/resource/SessionResource.java
@@ -73,7 +73,7 @@ public class SessionResource extends BaseResource {
}
if (userId != null) {
- return Context.getDataManager().getUser(userId);
+ return Context.getPermissionsManager().getUser(userId);
} else {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
@@ -83,7 +83,7 @@ public class SessionResource extends BaseResource {
@POST
public User add(
@FormParam("email") String email, @FormParam("password") String password) throws SQLException {
- User user = Context.getDataManager().login(email, password);
+ User user = Context.getPermissionsManager().login(email, password);
if (user != null) {
request.getSession().setAttribute(USER_ID_KEY, user.getId());
return user;
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java
index da72c7f47..2d187fe9d 100644
--- a/src/org/traccar/api/resource/UserResource.java
+++ b/src/org/traccar/api/resource/UserResource.java
@@ -41,7 +41,7 @@ public class UserResource extends BaseResource {
@GET
public Collection<User> get() throws SQLException {
Context.getPermissionsManager().checkAdmin(getUserId());
- return Context.getDataManager().getUsers();
+ return Context.getPermissionsManager().getUsers();
}
@PermitAll
@@ -50,8 +50,7 @@ public class UserResource extends BaseResource {
if (!Context.getPermissionsManager().isAdmin(getUserId())) {
Context.getPermissionsManager().checkRegistration(getUserId());
}
- Context.getDataManager().addUser(entity);
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().addUser(entity);
if (Context.getNotificationManager() != null) {
Context.getNotificationManager().refresh();
}
@@ -66,8 +65,7 @@ public class UserResource extends BaseResource {
} else {
Context.getPermissionsManager().checkUser(getUserId(), entity.getId());
}
- Context.getDataManager().updateUser(entity);
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().updateUser(entity);
if (Context.getNotificationManager() != null) {
Context.getNotificationManager().refresh();
}
@@ -78,8 +76,7 @@ public class UserResource extends BaseResource {
@DELETE
public Response remove(@PathParam("id") long id) throws SQLException {
Context.getPermissionsManager().checkUser(getUserId(), id);
- Context.getDataManager().removeUser(id);
- Context.getPermissionsManager().refresh();
+ Context.getPermissionsManager().removeUser(id);
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshUserGeofences();
}