diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2022-02-13 23:34:25 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2022-02-13 23:34:25 -0800 |
commit | 1c73bae2e23242673e0a07cdbc2493700f134ceb (patch) | |
tree | d1105368628b5f64fabb657682df58f1641e4d54 /src/main/java/org/traccar/api/resource/ReportResource.java | |
parent | de110b28ce8adb6ba875d88ede6e8f86dae4dd48 (diff) | |
download | trackermap-server-1c73bae2e23242673e0a07cdbc2493700f134ceb.tar.gz trackermap-server-1c73bae2e23242673e0a07cdbc2493700f134ceb.tar.bz2 trackermap-server-1c73bae2e23242673e0a07cdbc2493700f134ceb.zip |
New storage implementation
Diffstat (limited to 'src/main/java/org/traccar/api/resource/ReportResource.java')
-rw-r--r-- | src/main/java/org/traccar/api/resource/ReportResource.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/api/resource/ReportResource.java b/src/main/java/org/traccar/api/resource/ReportResource.java index 23ffaf54c..03df0d03a 100644 --- a/src/main/java/org/traccar/api/resource/ReportResource.java +++ b/src/main/java/org/traccar/api/resource/ReportResource.java @@ -18,7 +18,6 @@ package org.traccar.api.resource; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.sql.SQLException; import java.util.Collection; import java.util.Date; import java.util.List; @@ -51,6 +50,7 @@ import org.traccar.reports.model.SummaryReport; import org.traccar.reports.model.TripReport; import org.traccar.reports.Route; import org.traccar.reports.Stops; +import org.traccar.storage.StorageException; @Path("reports") @Produces(MediaType.APPLICATION_JSON) @@ -63,11 +63,11 @@ public class ReportResource extends BaseResource { private static final String CONTENT_DISPOSITION_VALUE_XLSX = "attachment; filename=report.xlsx"; private interface ReportExecutor { - void execute(ByteArrayOutputStream stream) throws SQLException, IOException; + void execute(ByteArrayOutputStream stream) throws StorageException, IOException; } private Response executeReport( - long userId, boolean mail, ReportExecutor executor) throws SQLException, IOException { + long userId, boolean mail, ReportExecutor executor) throws StorageException, IOException { final ByteArrayOutputStream stream = new ByteArrayOutputStream(); if (mail) { new Thread(() -> { @@ -82,7 +82,7 @@ public class ReportResource extends BaseResource { Context.getMailManager().sendMessage( userId, "Report", "The report is in the attachment.", attachment); - } catch (SQLException | IOException | MessagingException e) { + } catch (StorageException | IOException | MessagingException e) { LOGGER.warn("Report failed", e); } }).start(); @@ -98,7 +98,7 @@ public class ReportResource extends BaseResource { @GET public Collection<Position> getRoute( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, - @QueryParam("from") Date from, @QueryParam("to") Date to) throws SQLException { + @QueryParam("from") Date from, @QueryParam("to") Date to) throws StorageException { Context.getPermissionsManager().checkDisableReports(getUserId()); LogAction.logReport(getUserId(), "route", from, to, deviceIds, groupIds); return Route.getObjects(getUserId(), deviceIds, groupIds, from, to); @@ -110,7 +110,7 @@ public class ReportResource extends BaseResource { public Response getRouteExcel( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("mail") boolean mail) - throws SQLException, IOException { + throws StorageException, IOException { Context.getPermissionsManager().checkDisableReports(getUserId()); return executeReport(getUserId(), mail, stream -> { LogAction.logReport(getUserId(), "route", from, to, deviceIds, groupIds); @@ -123,7 +123,7 @@ public class ReportResource extends BaseResource { public Collection<Event> getEvents( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("type") final List<String> types, - @QueryParam("from") Date from, @QueryParam("to") Date to) throws SQLException { + @QueryParam("from") Date from, @QueryParam("to") Date to) throws StorageException { Context.getPermissionsManager().checkDisableReports(getUserId()); LogAction.logReport(getUserId(), "events", from, to, deviceIds, groupIds); return Events.getObjects(getUserId(), deviceIds, groupIds, types, from, to); @@ -136,7 +136,7 @@ public class ReportResource extends BaseResource { @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("type") final List<String> types, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("mail") boolean mail) - throws SQLException, IOException { + throws StorageException, IOException { Context.getPermissionsManager().checkDisableReports(getUserId()); return executeReport(getUserId(), mail, stream -> { LogAction.logReport(getUserId(), "events", from, to, deviceIds, groupIds); @@ -149,7 +149,7 @@ public class ReportResource extends BaseResource { public Collection<SummaryReport> getSummary( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("daily") boolean daily) - throws SQLException { + throws StorageException { Context.getPermissionsManager().checkDisableReports(getUserId()); LogAction.logReport(getUserId(), "summary", from, to, deviceIds, groupIds); return Summary.getObjects(getUserId(), deviceIds, groupIds, from, to, daily); @@ -162,7 +162,7 @@ public class ReportResource extends BaseResource { @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("daily") boolean daily, @QueryParam("mail") boolean mail) - throws SQLException, IOException { + throws StorageException, IOException { Context.getPermissionsManager().checkDisableReports(getUserId()); return executeReport(getUserId(), mail, stream -> { LogAction.logReport(getUserId(), "summary", from, to, deviceIds, groupIds); @@ -175,7 +175,7 @@ public class ReportResource extends BaseResource { @Produces(MediaType.APPLICATION_JSON) public Collection<TripReport> getTrips( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, - @QueryParam("from") Date from, @QueryParam("to") Date to) throws SQLException { + @QueryParam("from") Date from, @QueryParam("to") Date to) throws StorageException { Context.getPermissionsManager().checkDisableReports(getUserId()); LogAction.logReport(getUserId(), "trips", from, to, deviceIds, groupIds); return Trips.getObjects(getUserId(), deviceIds, groupIds, from, to); @@ -187,7 +187,7 @@ public class ReportResource extends BaseResource { public Response getTripsExcel( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("mail") boolean mail) - throws SQLException, IOException { + throws StorageException, IOException { Context.getPermissionsManager().checkDisableReports(getUserId()); return executeReport(getUserId(), mail, stream -> { LogAction.logReport(getUserId(), "trips", from, to, deviceIds, groupIds); @@ -200,7 +200,7 @@ public class ReportResource extends BaseResource { @Produces(MediaType.APPLICATION_JSON) public Collection<StopReport> getStops( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, - @QueryParam("from") Date from, @QueryParam("to") Date to) throws SQLException { + @QueryParam("from") Date from, @QueryParam("to") Date to) throws StorageException { Context.getPermissionsManager().checkDisableReports(getUserId()); LogAction.logReport(getUserId(), "stops", from, to, deviceIds, groupIds); return Stops.getObjects(getUserId(), deviceIds, groupIds, from, to); @@ -212,7 +212,7 @@ public class ReportResource extends BaseResource { public Response getStopsExcel( @QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds, @QueryParam("from") Date from, @QueryParam("to") Date to, @QueryParam("mail") boolean mail) - throws SQLException, IOException { + throws StorageException, IOException { Context.getPermissionsManager().checkDisableReports(getUserId()); return executeReport(getUserId(), mail, stream -> { LogAction.logReport(getUserId(), "stops", from, to, deviceIds, groupIds); |