aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource
diff options
context:
space:
mode:
authorSun Howwrongbum <sun@adrenosapient.com>2016-11-24 07:39:15 +0530
committerSun Howwrongbum <sun@adrenosapient.com>2016-11-24 07:39:15 +0530
commit02f4f14d28fd2e59868f9258b2735910140486f4 (patch)
tree4f141059e7388cb1a51f828143c0fb3252a98692 /src/org/traccar/api/resource
parent73a8eb4f267615d865c2c2c5c0f462da983dd0a5 (diff)
downloadtrackermap-server-02f4f14d28fd2e59868f9258b2735910140486f4.tar.gz
trackermap-server-02f4f14d28fd2e59868f9258b2735910140486f4.tar.bz2
trackermap-server-02f4f14d28fd2e59868f9258b2735910140486f4.zip
Update as per code review
- remove unnecessary variables and imports - change preliminary config variable names
Diffstat (limited to 'src/org/traccar/api/resource')
-rw-r--r--src/org/traccar/api/resource/UserResource.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java
index bbbe465fc..5f940ebf1 100644
--- a/src/org/traccar/api/resource/UserResource.java
+++ b/src/org/traccar/api/resource/UserResource.java
@@ -16,7 +16,6 @@
package org.traccar.api.resource;
import org.traccar.Context;
-import org.traccar.Config;
import org.traccar.api.BaseResource;
import org.traccar.model.User;
@@ -34,7 +33,6 @@ import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
-import java.util.Calendar;
@Path("users")
@Produces(MediaType.APPLICATION_JSON)
@@ -53,17 +51,12 @@ public class UserResource extends BaseResource {
if (!Context.getPermissionsManager().isAdmin(getUserId())) {
Context.getPermissionsManager().checkRegistration(getUserId());
Context.getPermissionsManager().checkUserUpdate(getUserId(), new User(), entity);
- Config config = Context.getConfig();
- int deviceLimit = config.getInteger("default.deviceLimit");
- int expirationDuration = config.getInteger("default.expirationDuration");
- if (deviceLimit > 0) {
- entity.setDeviceLimit(deviceLimit);
- }
- if (expirationDuration > 0) {
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DATE, expirationDuration);
- Date expirationTime = cal.getTime();
- entity.setExpirationTime(expirationTime);
+ int deviceLimit = Context.getConfig().getInteger("users.defaultDeviceLimit");
+ int expirationDays = Context.getConfig().getInteger("users.defaultExpirationDays");
+ entity.setDeviceLimit(deviceLimit);
+ if (expirationDays > 0) {
+ entity.setExpirationTime(
+ new Date(System.currentTimeMillis() + (long) expirationDays * 24 * 3600 * 1000));
}
}
Context.getPermissionsManager().addUser(entity);