aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 11:44:40 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 11:44:40 -0700
commit03b50c61afd7c9d7e19a76feb261147dd0f69588 (patch)
tree575f1737e3006c66844c1fa9e06a3323bac7746c /src/main/java/org/traccar/protocol
parentddbe4d7de6ae7590e2b927066312597efa129393 (diff)
downloadtrackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.tar.gz
trackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.tar.bz2
trackermap-server-03b50c61afd7c9d7e19a76feb261147dd0f69588.zip
Remove identity manager
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/CastelProtocolEncoder.java4
-rw-r--r--src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java7
-rw-r--r--src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java2
-rw-r--r--src/main/java/org/traccar/protocol/Pt502ProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java8
8 files changed, 14 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java b/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java
index 0fb4bf8b4..61dde3e80 100644
--- a/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class CastelProtocolEncoder extends BaseProtocolEncoder {
private ByteBuf encodeContent(long deviceId, short type, ByteBuf content) {
ByteBuf buf = Unpooled.buffer(0);
- String uniqueId = getIdentityManager().getById(deviceId).getUniqueId();
+ String uniqueId = getUniqueId(deviceId);
buf.writeByte('@');
buf.writeByte('@');
diff --git a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
index a2ba7b029..bf14d47e0 100644
--- a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -320,14 +320,13 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
} else {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
- String uniqueId = getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
getLastLocation(position, null);
- position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
photo.release();
photo = null;
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 4b9757874..c53fbfe5a 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -31,7 +31,6 @@ import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
-import org.traccar.model.Device;
import org.traccar.model.Network;
import org.traccar.model.Position;
import org.traccar.model.WifiAccessPoint;
@@ -1026,8 +1025,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (photo.writableBytes() > 0) {
sendPhotoRequest(channel, pictureId);
} else {
- Device device = getIdentityManager().getById(deviceSession.getDeviceId());
- position.set(Position.KEY_IMAGE, writeMediaFile(device.getUniqueId(), photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
photos.remove(pictureId).release();
}
@@ -1262,8 +1260,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
getLastLocation(position, new Date(timestamp));
- Device device = getIdentityManager().getById(deviceSession.getDeviceId());
- position.set(Position.KEY_IMAGE, writeMediaFile(device.getUniqueId(), photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
photos.remove(mediaId).release();
}
}
diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 0b6bf8663..f3b56973a 100644
--- a/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -468,10 +468,9 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
} else if (command == MSG_POSITION_IMAGE) {
byte imageIndex = buf.readByte();
buf.readUnsignedByte(); // image upload type
- String uniqueId = getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
ByteBuf photo = photos.remove(imageIndex);
try {
- position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
} finally {
photo.release();
}
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
index 30689436d..87459d3fc 100644
--- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.model.Device;
import org.traccar.session.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
@@ -203,7 +204,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + i, parser.nextHexInt());
}
- String deviceModel = getIdentityManager().getById(deviceSession.getDeviceId()).getModel();
+ String deviceModel = getCacheManager().getObject(Device.class, deviceSession.getDeviceId()).getModel();
if (deviceModel == null) {
deviceModel = "";
}
diff --git a/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java b/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java
index 106ba9537..a109e7a07 100644
--- a/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java
@@ -34,7 +34,7 @@ public class PretraceProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- String uniqueId = getIdentityManager().getById(command.getDeviceId()).getUniqueId();
+ String uniqueId = getUniqueId(command.getDeviceId());
switch (command.getType()) {
case Command.TYPE_CUSTOM:
diff --git a/src/main/java/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Pt502ProtocolDecoder.java
index 21b91203f..2a6a81a65 100644
--- a/src/main/java/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -174,14 +174,13 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
} else {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
- String uniqueId = getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
getLastLocation(position, null);
- position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
photo.release();
photo = null;
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index f91eef837..77047fe26 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -119,7 +119,8 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
return printable;
}
- private void decodeSerial(Channel channel, SocketAddress remoteAddress, Position position, ByteBuf buf) {
+ private void decodeSerial(
+ Channel channel, SocketAddress remoteAddress, DeviceSession deviceSession, Position position, ByteBuf buf) {
getLastLocation(position, null);
@@ -148,10 +149,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
channel, remoteAddress, photoId,
photo.writerIndex(), Math.min(IMAGE_PACKET_MAX, photo.writableBytes()));
} else {
- String uniqueId = getIdentityManager().getById(position.getDeviceId()).getUniqueId();
photos.remove(photoId);
try {
- position.set(Position.KEY_IMAGE, writeMediaFile(uniqueId, photo, "jpg"));
+ position.set(Position.KEY_IMAGE, writeMediaFile(deviceSession.getUniqueId(), photo, "jpg"));
} finally {
photo.release();
}
@@ -601,7 +601,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
ByteBufUtil.hexDump(buf.readSlice(length)));
}
} else if (codec == CODEC_12) {
- decodeSerial(channel, remoteAddress, position, buf);
+ decodeSerial(channel, remoteAddress, deviceSession, position, buf);
} else {
decodeLocation(position, buf, codec);
}