aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-27 16:46:52 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-27 16:46:52 +0500
commit5446776933ff412361a3c7812c2bb6de9a78ccaf (patch)
tree965af40404eba36cef53a12f166d7e3a601408e3 /src/org/traccar/api
parente8a758072e9368f6977880e1aa607351d7cf619a (diff)
downloadtrackermap-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.tar.gz
trackermap-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.tar.bz2
trackermap-server-5446776933ff412361a3c7812c2bb6de9a78ccaf.zip
Optimize a few IFs
Diffstat (limited to 'src/org/traccar/api')
-rw-r--r--src/org/traccar/api/BaseObjectResource.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/org/traccar/api/BaseObjectResource.java b/src/org/traccar/api/BaseObjectResource.java
index 11e9a5d01..ea5d4966f 100644
--- a/src/org/traccar/api/BaseObjectResource.java
+++ b/src/org/traccar/api/BaseObjectResource.java
@@ -34,7 +34,7 @@ import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.model.User;
-public class BaseObjectResource<T extends BaseModel> extends BaseResource {
+public abstract class BaseObjectResource<T extends BaseModel> extends BaseResource {
private Class<T> baseClass;
@@ -57,8 +57,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
if (manager instanceof SimpleObjectManager) {
((SimpleObjectManager<T>) manager).refreshUserItems();
- }
- if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
+ } else if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
}
@@ -71,8 +70,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
Context.getPermissionsManager().checkReadonly(getUserId());
if (baseClass.equals(Device.class)) {
Context.getPermissionsManager().checkDeviceReadonly(getUserId());
- }
- if (baseClass.equals(User.class)) {
+ } else if (baseClass.equals(User.class)) {
User before = Context.getPermissionsManager().getUser(entity.getId());
Context.getPermissionsManager().checkUserUpdate(getUserId(), before, (User) entity);
}
@@ -83,8 +81,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
if (baseClass.equals(Group.class) || baseClass.equals(Device.class)) {
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
- }
- if (baseClass.equals(User.class) && Context.getNotificationManager() != null) {
+ } else if (baseClass.equals(User.class) && Context.getNotificationManager() != null) {
Context.getNotificationManager().refresh();
}
return Response.ok(entity).build();
@@ -116,7 +113,7 @@ public class BaseObjectResource<T extends BaseModel> extends BaseResource {
Context.getPermissionsManager().refreshAllExtendedPermissions();
}
}
- // deprecated
+ // Next should be removed with Attribute Aliases
if (baseClass.equals(Device.class)) {
Context.getAliasesManager().removeDevice(id);
}