aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-06-23 16:17:25 +0500
committerAbyss777 <abyss@fox5.ru>2016-06-23 16:17:25 +0500
commitbd2e0fdc6fe222316e9e740aa265b6d132d407b6 (patch)
tree0e146fde0b2a7556c380a4b715cb88e42b97d8cb
parenta445733519b4b38b52b03fbb63a55c7270cb9221 (diff)
downloadtrackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.tar.gz
trackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.tar.bz2
trackermap-server-bd2e0fdc6fe222316e9e740aa265b6d132d407b6.zip
Added possibility to disable event and geofence subsystems
-rw-r--r--debug.xml5
-rw-r--r--setup/unix/traccar.xml4
-rw-r--r--setup/windows/traccar.xml4
-rw-r--r--src/org/traccar/BaseEventHandler.java6
-rw-r--r--src/org/traccar/BasePipelineFactory.java22
-rw-r--r--src/org/traccar/Context.java8
-rw-r--r--src/org/traccar/database/ConnectionManager.java4
-rw-r--r--src/org/traccar/database/NotificationManager.java4
-rw-r--r--src/org/traccar/web/WebServer.java11
-rw-r--r--web/app/controller/Root.js7
-rw-r--r--web/app/view/DevicesController.js2
-rw-r--r--web/app/view/GroupsController.js2
-rw-r--r--web/app/view/UsersController.js2
13 files changed, 55 insertions, 26 deletions
diff --git a/debug.xml b/debug.xml
index f04ceb271..674099c2f 100644
--- a/debug.xml
+++ b/debug.xml
@@ -41,6 +41,8 @@
<entry key='logger.level'>all</entry>
<entry key='logger.file'>target/tracker-server.log</entry>
+ <entry key='event.enable'>true</entry>
+
<entry key='event.suppressRepeated'>60</entry>
<entry key='event.overspeedHandler'>true</entry>
@@ -48,9 +50,10 @@
<entry key='event.motionHandler'>true</entry>
-
<entry key='event.geofenceHandler'>true</entry>
+ <entry key='geofence.enable'>true</entry>
+
<!-- DATABASE CONFIG -->
<!--<entry key='database.driverFile'>hsqldb.jar</entry>-->
diff --git a/setup/unix/traccar.xml b/setup/unix/traccar.xml
index ab739e4d6..747b30d52 100644
--- a/setup/unix/traccar.xml
+++ b/setup/unix/traccar.xml
@@ -17,6 +17,8 @@
<entry key='logger.level'>all</entry>
<entry key='logger.file'>/opt/traccar/logs/tracker-server.log</entry>
+ <entry key='event.enable'>true</entry>
+
<entry key='event.suppressRepeated'>60</entry>
<entry key='event.overspeedHandler'>true</entry>
@@ -26,6 +28,8 @@
<entry key='event.geofenceHandler'>true</entry>
+ <entry key='geofence.enable'>true</entry>
+
<!-- DATABASE CONFIG -->
<entry key='database.driver'>org.h2.Driver</entry>
diff --git a/setup/windows/traccar.xml b/setup/windows/traccar.xml
index 17f2ab4f3..7801912f9 100644
--- a/setup/windows/traccar.xml
+++ b/setup/windows/traccar.xml
@@ -17,6 +17,8 @@
<entry key='logger.level'>all</entry>
<entry key='logger.file'>[LOG]</entry>
+ <entry key='event.enable'>true</entry>
+
<entry key='event.suppressRepeated'>60</entry>
<entry key='event.overspeedHandler'>true</entry>
@@ -26,6 +28,8 @@
<entry key='event.geofenceHandler'>true</entry>
+ <entry key='geofence.enable'>true</entry>>
+
<!-- DATABASE CONFIG -->
<entry key='database.driver'>org.h2.Driver</entry>
diff --git a/src/org/traccar/BaseEventHandler.java b/src/org/traccar/BaseEventHandler.java
index 1ae9d2c6d..82e78c6b3 100644
--- a/src/org/traccar/BaseEventHandler.java
+++ b/src/org/traccar/BaseEventHandler.java
@@ -26,10 +26,8 @@ public abstract class BaseEventHandler extends BaseDataHandler {
protected Position handlePosition(Position position) {
Collection<Event> events = analyzePosition(position);
- if (events != null) {
- for (Event event : events) {
- Context.getNotificationManager().updateEvent(event, position);
- }
+ if (events != null && Context.getNotificationManager() != null) {
+ Context.getNotificationManager().updateEvents(events, position);
}
return position;
}
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index b61d95171..9de9b3a52 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -132,20 +132,22 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
hemisphereHandler = new HemisphereHandler();
}
- commandResultEventHandler = new CommandResultEventHandler();
+ if (Context.getConfig().getBoolean("event.enable")) {
+ commandResultEventHandler = new CommandResultEventHandler();
- if (Context.getConfig().getBoolean("event.overspeedHandler")) {
- overspeedEventHandler = new OverspeedEventHandler();
- }
+ if (Context.getConfig().getBoolean("event.overspeedHandler")) {
+ overspeedEventHandler = new OverspeedEventHandler();
+ }
- if (Context.getConfig().getBoolean("event.motionHandler")) {
- motionEventHandler = new MotionEventHandler();
- }
+ if (Context.getConfig().getBoolean("event.motionHandler")) {
+ motionEventHandler = new MotionEventHandler();
+ }
- if (Context.getConfig().getBoolean("event.geofenceHandler")) {
- geofenceEventHandler = new GeofenceEventHandler();
+ if (Context.getConfig().getBoolean("geofence.enable")
+ && Context.getConfig().getBoolean("event.geofenceHandler")) {
+ geofenceEventHandler = new GeofenceEventHandler();
+ }
}
-
}
protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index f40db72e5..7d22ac681 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -193,9 +193,13 @@ public final class Context {
connectionManager = new ConnectionManager(dataManager);
- geofenceManager = new GeofenceManager(dataManager);
+ if (config.getBoolean("geofence.enable")) {
+ geofenceManager = new GeofenceManager(dataManager);
+ }
- notificationManager = new NotificationManager(dataManager);
+ if (config.getBoolean("event.enable")) {
+ notificationManager = new NotificationManager(dataManager);
+ }
serverManager = new ServerManager();
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 8a1debdfa..8796673b1 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -94,7 +94,9 @@ public class ConnectionManager {
if (status.equals(Device.STATUS_ONLINE)) {
event.setType(Event.TYPE_DEVICE_ONLINE);
}
- Context.getNotificationManager().updateEvent(event, null);
+ if (Context.getNotificationManager() != null) {
+ Context.getNotificationManager().updateEvent(event, null);
+ }
}
device.setStatus(status);
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 7593367a3..ab6b2230a 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -41,8 +41,8 @@ public class NotificationManager {
Set<Long> users = Context.getPermissionsManager().getDeviceUsers(event.getDeviceId());
for (Long userId : users) {
- if (event.getGeofenceId() == 0
- || Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) {
+ if (event.getGeofenceId() == 0 || Context.getGeofenceManager() != null
+ && Context.getGeofenceManager().checkGeofence(userId, event.getGeofenceId())) {
Context.getConnectionManager().updateEvent(userId, event, position);
}
}
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index c06ee5d35..2fa5c1a80 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -29,6 +29,7 @@ import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.traccar.Config;
+import org.traccar.Context;
import org.traccar.api.AsyncSocketServlet;
import org.traccar.api.CorsResponseFilter;
import org.traccar.api.ObjectMapperProvider;
@@ -154,8 +155,14 @@ public class WebServer {
resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
GroupPermissionResource.class, DevicePermissionResource.class, UserResource.class,
GroupResource.class, DeviceResource.class, PositionResource.class,
- CommandTypeResource.class, EventResource.class, GeofenceResource.class,
- DeviceGeofenceResource.class, GeofencePermissionResource.class, GroupGeofenceResource.class);
+ CommandTypeResource.class);
+ if (Context.getConfig().getBoolean("event.enable")) {
+ resourceConfig.registerClasses(EventResource.class);
+ }
+ if (Context.getConfig().getBoolean("geofence.enable")) {
+ resourceConfig.registerClasses(GeofenceResource.class, DeviceGeofenceResource.class,
+ GeofencePermissionResource.class, GroupGeofenceResource.class);
+ }
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 56a076edd..8ae348ca4 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -75,6 +75,11 @@ Ext.define('Traccar.controller.Root', {
loadApp: function () {
Ext.getStore('Groups').load();
Ext.getStore('Devices').load();
+ Ext.getStore('Geofences').getProxy().on('exception', function(proxy, response, operation) {
+ if (operation && operation.error.status === 404) {
+ Traccar.app.withoutGeofences = true;
+ }
+ });
Ext.getStore('Geofences').load();
Ext.get('attribution').remove();
if (this.isPhone) {
@@ -148,7 +153,7 @@ Ext.define('Traccar.controller.Root', {
text = typeKey;
}
}
- if (array[i].geofenceId !== 0) {
+ if (array[i].geofenceId !== 0 && !Traccar.app.withoutGeofences) {
geofence = Ext.getStore('Geofences').getById(array[i].geofenceId);
if (typeof geofence != "undefined") {
text += ' \"' + geofence.getData().name + '"';
diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js
index cf31dd7bb..8b35fd859 100644
--- a/web/app/view/DevicesController.js
+++ b/web/app/view/DevicesController.js
@@ -125,7 +125,7 @@ Ext.define('Traccar.view.DevicesController', {
var empty = selected.getCount() === 0;
this.lookupReference('toolbarEditButton').setDisabled(empty);
this.lookupReference('toolbarRemoveButton').setDisabled(empty);
- this.lookupReference('toolbarGeofencesButton').setDisabled(empty);
+ this.lookupReference('toolbarGeofencesButton').setDisabled(empty || Traccar.app.withoutGeofences);
this.lookupReference('deviceCommandButton').setDisabled(empty || (selected.getLastSelected().get('status') !== 'online'));
if (!empty) {
this.fireEvent('selectDevice', selected.getLastSelected(), true);
diff --git a/web/app/view/GroupsController.js b/web/app/view/GroupsController.js
index bc713bb6d..ecacdb7f6 100644
--- a/web/app/view/GroupsController.js
+++ b/web/app/view/GroupsController.js
@@ -79,6 +79,6 @@ Ext.define('Traccar.view.GroupsController', {
var disabled = selected.length > 0;
this.lookupReference('toolbarEditButton').setDisabled(disabled);
this.lookupReference('toolbarRemoveButton').setDisabled(disabled);
- this.lookupReference('toolbarGeofencesButton').setDisabled(disabled);
+ this.lookupReference('toolbarGeofencesButton').setDisabled(disabled || Traccar.app.withoutGeofences);
}
});
diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js
index acba66b4d..d8e42570d 100644
--- a/web/app/view/UsersController.js
+++ b/web/app/view/UsersController.js
@@ -120,6 +120,6 @@ Ext.define('Traccar.view.UsersController', {
this.lookupReference('toolbarRemoveButton').setDisabled(disabled);
this.lookupReference('userDevicesButton').setDisabled(disabled);
this.lookupReference('userGroupsButton').setDisabled(disabled);
- this.lookupReference('userGeofencesButton').setDisabled(disabled);
+ this.lookupReference('userGeofencesButton').setDisabled(disabled || Traccar.app.withoutGeofences);
}
});