aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/reports
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/reports')
-rw-r--r--src/main/java/org/traccar/reports/EventsReportProvider.java6
-rw-r--r--src/main/java/org/traccar/reports/RouteReportProvider.java6
-rw-r--r--src/main/java/org/traccar/reports/StopsReportProvider.java6
-rw-r--r--src/main/java/org/traccar/reports/SummaryReportProvider.java4
-rw-r--r--src/main/java/org/traccar/reports/TripsReportProvider.java6
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java12
6 files changed, 30 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/reports/EventsReportProvider.java b/src/main/java/org/traccar/reports/EventsReportProvider.java
index b1f7149a2..4db842fdb 100644
--- a/src/main/java/org/traccar/reports/EventsReportProvider.java
+++ b/src/main/java/org/traccar/reports/EventsReportProvider.java
@@ -74,9 +74,10 @@ public class EventsReportProvider {
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Collection<String> types, Date from, Date to) throws StorageException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<Event> result = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<Event> events = getEvents(deviceId, from, to);
boolean all = types.isEmpty() || types.contains(Event.ALL_EVENTS);
for (Event event : events) {
@@ -98,12 +99,13 @@ public class EventsReportProvider {
OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Collection<String> types, Date from, Date to) throws StorageException, IOException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<DeviceReportSection> devicesEvents = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
HashMap<Long, String> geofenceNames = new HashMap<>();
HashMap<Long, String> maintenanceNames = new HashMap<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<Event> events = getEvents(deviceId, from, to);
boolean all = types.isEmpty() || types.contains(Event.ALL_EVENTS);
for (Iterator<Event> iterator = events.iterator(); iterator.hasNext();) {
diff --git a/src/main/java/org/traccar/reports/RouteReportProvider.java b/src/main/java/org/traccar/reports/RouteReportProvider.java
index 903dfe369..b4401bc87 100644
--- a/src/main/java/org/traccar/reports/RouteReportProvider.java
+++ b/src/main/java/org/traccar/reports/RouteReportProvider.java
@@ -59,9 +59,10 @@ public class RouteReportProvider {
public Collection<Position> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<Position> result = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
result.addAll(PositionUtil.getPositions(storage, deviceId, from, to));
}
return result;
@@ -71,10 +72,11 @@ public class RouteReportProvider {
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException, IOException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<DeviceReportSection> devicesRoutes = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
var positions = PositionUtil.getPositions(storage, deviceId, from, to);
DeviceReportSection deviceRoutes = new DeviceReportSection();
Device device = Context.getIdentityManager().getById(deviceId);
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java
index b9d36eb97..a63d7ee21 100644
--- a/src/main/java/org/traccar/reports/StopsReportProvider.java
+++ b/src/main/java/org/traccar/reports/StopsReportProvider.java
@@ -67,9 +67,10 @@ public class StopsReportProvider {
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<StopReportItem> result = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
result.addAll(detectStops(deviceId, from, to));
}
return result;
@@ -79,10 +80,11 @@ public class StopsReportProvider {
OutputStream outputStream, long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException, IOException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<DeviceReportSection> devicesStops = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<StopReportItem> stops = detectStops(deviceId, from, to);
DeviceReportSection deviceStops = new DeviceReportSection();
Device device = Context.getIdentityManager().getById(deviceId);
diff --git a/src/main/java/org/traccar/reports/SummaryReportProvider.java b/src/main/java/org/traccar/reports/SummaryReportProvider.java
index 68976b987..86d76b4e3 100644
--- a/src/main/java/org/traccar/reports/SummaryReportProvider.java
+++ b/src/main/java/org/traccar/reports/SummaryReportProvider.java
@@ -146,9 +146,10 @@ public class SummaryReportProvider {
long userId, Collection<Long> deviceIds,
Collection<Long> groupIds, Date from, Date to, boolean daily) throws StorageException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<SummaryReportItem> result = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<SummaryReportItem> deviceResults = calculateSummaryResults(userId, deviceId, from, to, daily);
for (SummaryReportItem summaryReport : deviceResults) {
if (summaryReport.getStartTime() != null && summaryReport.getEndTime() != null) {
@@ -162,7 +163,6 @@ public class SummaryReportProvider {
public void getExcel(OutputStream outputStream,
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to, boolean daily) throws StorageException, IOException {
- reportUtils.checkPeriodLimit(from, to);
Collection<SummaryReportItem> summaries = getObjects(userId, deviceIds, groupIds, from, to, daily);
File file = Paths.get(config.getString(Keys.TEMPLATES_ROOT), "export", "summary.xlsx").toFile();
diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java
index 97cfccf74..bec4c39fd 100644
--- a/src/main/java/org/traccar/reports/TripsReportProvider.java
+++ b/src/main/java/org/traccar/reports/TripsReportProvider.java
@@ -67,9 +67,10 @@ public class TripsReportProvider {
public Collection<TripReportItem> getObjects(long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<TripReportItem> result = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
result.addAll(detectTrips(deviceId, from, to));
}
return result;
@@ -79,10 +80,11 @@ public class TripsReportProvider {
long userId, Collection<Long> deviceIds, Collection<Long> groupIds,
Date from, Date to) throws StorageException, IOException {
reportUtils.checkPeriodLimit(from, to);
+ reportUtils.checkPermissions(userId, deviceIds, groupIds);
+
ArrayList<DeviceReportSection> devicesTrips = new ArrayList<>();
ArrayList<String> sheetNames = new ArrayList<>();
for (long deviceId: reportUtils.getDeviceList(deviceIds, groupIds)) {
- Context.getPermissionsManager().checkDevice(userId, deviceId);
Collection<TripReportItem> trips = detectTrips(deviceId, from, to);
DeviceReportSection deviceTrips = new DeviceReportSection();
Device device = Context.getIdentityManager().getById(deviceId);
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index 95c43f8a0..84866a67b 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -38,8 +38,10 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.helper.model.PositionUtil;
import org.traccar.helper.model.UserUtil;
import org.traccar.model.BaseModel;
+import org.traccar.model.Device;
import org.traccar.model.Driver;
import org.traccar.model.Event;
+import org.traccar.model.Group;
import org.traccar.model.Position;
import org.traccar.model.User;
import org.traccar.reports.model.BaseReportItem;
@@ -109,6 +111,16 @@ public class ReportUtils {
}
}
+ public void checkPermissions(
+ long userId, Collection<Long> deviceIds, Collection<Long> groupIds) throws StorageException {
+ for (long deviceId : deviceIds) {
+ permissionsService.checkPermission(Device.class, userId, deviceId);
+ }
+ for (long groupId : groupIds) {
+ permissionsService.checkPermission(Group.class, userId, groupId);
+ }
+ }
+
public Collection<Long> getDeviceList(Collection<Long> deviceIds, Collection<Long> groupIds) {
Collection<Long> result = new LinkedHashSet<>(deviceIds);
for (long groupId : groupIds) {