From 5a5a0e43d3b123780775f723c1c35a417a4e8265 Mon Sep 17 00:00:00 2001 From: meysamrt <46737899+MeysamRT76@users.noreply.github.com> Date: Sun, 18 Feb 2024 16:44:28 +0330 Subject: Refactor: Remove duplicated code in get function (ServerResource.java) Eliminate duplicated code in get function to enhance maintainability and readability. --- src/main/java/org/traccar/api/resource/ServerResource.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java index 66ecc74e1..76c8e14c7 100644 --- a/src/main/java/org/traccar/api/resource/ServerResource.java +++ b/src/main/java/org/traccar/api/resource/ServerResource.java @@ -93,15 +93,10 @@ public class ServerResource extends BaseResource { server.setOpenIdEnabled(openIdProvider != null); server.setOpenIdForce(openIdProvider != null && openIdProvider.getForce()); User user = permissionsService.getUser(getUserId()); - if (user != null) { - if (user.getAdministrator()) { - server.setStorageSpace(Log.getStorageSpace()); - } - } else { - server.setNewServer(UserUtil.isEmpty(storage)); - } if (user != null && user.getAdministrator()) { server.setStorageSpace(Log.getStorageSpace()); + } else { + server.setNewServer(UserUtil.isEmpty(storage)); } return server; } -- cgit v1.2.3 From 15a478a959ea6ff4000c6b14d54edc9d2c37e06d Mon Sep 17 00:00:00 2001 From: meysamrt <46737899+MeysamRT76@users.noreply.github.com> Date: Mon, 19 Feb 2024 08:54:26 +0330 Subject: Update ServerResource.java --- src/main/java/org/traccar/api/resource/ServerResource.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java index 76c8e14c7..2a72d2773 100644 --- a/src/main/java/org/traccar/api/resource/ServerResource.java +++ b/src/main/java/org/traccar/api/resource/ServerResource.java @@ -93,8 +93,10 @@ public class ServerResource extends BaseResource { server.setOpenIdEnabled(openIdProvider != null); server.setOpenIdForce(openIdProvider != null && openIdProvider.getForce()); User user = permissionsService.getUser(getUserId()); - if (user != null && user.getAdministrator()) { - server.setStorageSpace(Log.getStorageSpace()); + if (user != null) { + if (user.getAdministrator()) { + server.setStorageSpace(Log.getStorageSpace()); + } } else { server.setNewServer(UserUtil.isEmpty(storage)); } -- cgit v1.2.3