aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DeviceManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-10-16 15:28:48 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-10-16 15:28:48 +1300
commita10033d165293c349fc513e049583d3c0ac3e06c (patch)
tree3117a309b28b55e47396429272206a93570af7d3 /src/org/traccar/database/DeviceManager.java
parent017fbd08ecbffecd1557ec022d5adc49af73300c (diff)
downloadtrackermap-server-a10033d165293c349fc513e049583d3c0ac3e06c.tar.gz
trackermap-server-a10033d165293c349fc513e049583d3c0ac3e06c.tar.bz2
trackermap-server-a10033d165293c349fc513e049583d3c0ac3e06c.zip
Simplify base decoder dependencies
Diffstat (limited to 'src/org/traccar/database/DeviceManager.java')
-rw-r--r--src/org/traccar/database/DeviceManager.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java
index 34b02c0e2..ab2c142cc 100644
--- a/src/org/traccar/database/DeviceManager.java
+++ b/src/org/traccar/database/DeviceManager.java
@@ -68,6 +68,35 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
refreshLastPositions();
}
+ @Override
+ public long addUnknownDevice(String uniqueId) {
+ Device device = new Device();
+ device.setName(uniqueId);
+ device.setUniqueId(uniqueId);
+ device.setCategory(Context.getConfig().getString("database.registerUnknown.defaultCategory"));
+
+ long defaultGroupId = Context.getConfig().getLong("database.registerUnknown.defaultGroupId");
+ if (defaultGroupId != 0) {
+ device.setGroupId(defaultGroupId);
+ }
+
+ try {
+ addItem(device);
+
+ LOGGER.info("Automatically registered device " + uniqueId);
+
+ if (defaultGroupId != 0) {
+ Context.getPermissionsManager().refreshDeviceAndGroupPermissions();
+ Context.getPermissionsManager().refreshAllExtendedPermissions();
+ }
+
+ return device.getId();
+ } catch (SQLException e) {
+ LOGGER.warn("Automatic device registration error", e);
+ return 0;
+ }
+ }
+
public void updateDeviceCache(boolean force) throws SQLException {
long lastUpdate = devicesLastUpdate.get();
if ((force || System.currentTimeMillis() - lastUpdate > dataRefreshDelay)