diff options
Diffstat (limited to 'src/org/traccar/api')
-rw-r--r-- | src/org/traccar/api/MediaFilter.java | 4 | ||||
-rw-r--r-- | src/org/traccar/api/SecurityRequestFilter.java | 6 | ||||
-rw-r--r-- | src/org/traccar/api/resource/AttributeResource.java | 11 |
3 files changed, 14 insertions, 7 deletions
diff --git a/src/org/traccar/api/MediaFilter.java b/src/org/traccar/api/MediaFilter.java index 25e242b01..53539770f 100644 --- a/src/org/traccar/api/MediaFilter.java +++ b/src/org/traccar/api/MediaFilter.java @@ -30,7 +30,9 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.traccar.Context; +import org.traccar.Main; import org.traccar.api.resource.SessionResource; +import org.traccar.database.StatisticsManager; import org.traccar.helper.Log; import org.traccar.model.Device; @@ -51,7 +53,7 @@ public class MediaFilter implements Filter { userId = (Long) session.getAttribute(SessionResource.USER_ID_KEY); if (userId != null) { Context.getPermissionsManager().checkUserEnabled(userId); - Context.getStatisticsManager().registerRequest(userId); + Main.getInjector().getInstance(StatisticsManager.class).registerRequest(userId); } } if (userId == null) { diff --git a/src/org/traccar/api/SecurityRequestFilter.java b/src/org/traccar/api/SecurityRequestFilter.java index 195c1f72f..33b6b37df 100644 --- a/src/org/traccar/api/SecurityRequestFilter.java +++ b/src/org/traccar/api/SecurityRequestFilter.java @@ -18,7 +18,9 @@ package org.traccar.api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.traccar.Context; +import org.traccar.Main; import org.traccar.api.resource.SessionResource; +import org.traccar.database.StatisticsManager; import org.traccar.helper.DataConverter; import org.traccar.model.User; @@ -77,7 +79,7 @@ public class SecurityRequestFilter implements ContainerRequestFilter { String[] auth = decodeBasicAuth(authHeader); User user = Context.getPermissionsManager().login(auth[0], auth[1]); if (user != null) { - Context.getStatisticsManager().registerRequest(user.getId()); + Main.getInjector().getInstance(StatisticsManager.class).registerRequest(user.getId()); securityContext = new UserSecurityContext(new UserPrincipal(user.getId())); } } catch (SQLException e) { @@ -89,7 +91,7 @@ public class SecurityRequestFilter implements ContainerRequestFilter { Long userId = (Long) request.getSession().getAttribute(SessionResource.USER_ID_KEY); if (userId != null) { Context.getPermissionsManager().checkUserEnabled(userId); - Context.getStatisticsManager().registerRequest(userId); + Main.getInjector().getInstance(StatisticsManager.class).registerRequest(userId); securityContext = new UserSecurityContext(new UserPrincipal(userId)); } diff --git a/src/org/traccar/api/resource/AttributeResource.java b/src/org/traccar/api/resource/AttributeResource.java index d10ca4a72..de69d871c 100644 --- a/src/org/traccar/api/resource/AttributeResource.java +++ b/src/org/traccar/api/resource/AttributeResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,7 +33,7 @@ import org.traccar.Context; import org.traccar.api.ExtendedObjectResource; import org.traccar.model.Attribute; import org.traccar.model.Position; -import org.traccar.processing.ComputedAttributesHandler; +import org.traccar.handler.ComputedAttributesHandler; @Path("attributes/computed") @Produces(MediaType.APPLICATION_JSON) @@ -46,12 +46,15 @@ public class AttributeResource extends ExtendedObjectResource<Attribute> { @POST @Path("test") - public Response test(@QueryParam("deviceId") long deviceId, Attribute entity) throws SQLException { + public Response test(@QueryParam("deviceId") long deviceId, Attribute entity) { Context.getPermissionsManager().checkAdmin(getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Position last = Context.getIdentityManager().getLastPosition(deviceId); if (last != null) { - Object result = new ComputedAttributesHandler().computeAttribute(entity, last); + Object result = new ComputedAttributesHandler( + Context.getConfig(), + Context.getIdentityManager(), + Context.getAttributesManager()).computeAttribute(entity, last); if (result != null) { switch (entity.getType()) { case "number": |