From 02f4f14d28fd2e59868f9258b2735910140486f4 Mon Sep 17 00:00:00 2001 From: Sun Howwrongbum Date: Thu, 24 Nov 2016 07:39:15 +0530 Subject: Update as per code review - remove unnecessary variables and imports - change preliminary config variable names --- src/org/traccar/api/resource/UserResource.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src') 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); -- cgit v1.2.3