From eaffa34a7061232601668c2493a5f18e1b1c80f5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Oct 2020 21:15:12 -0700 Subject: Save original config key --- src/main/java/org/traccar/ExtendedObjectDecoder.java | 5 +++-- src/main/java/org/traccar/config/Keys.java | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/ExtendedObjectDecoder.java b/src/main/java/org/traccar/ExtendedObjectDecoder.java index dad52d3ff..46720da52 100644 --- a/src/main/java/org/traccar/ExtendedObjectDecoder.java +++ b/src/main/java/org/traccar/ExtendedObjectDecoder.java @@ -21,6 +21,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.util.ReferenceCountUtil; +import org.traccar.config.Keys; import org.traccar.helper.DataConverter; import org.traccar.model.Position; @@ -31,14 +32,14 @@ import java.util.Collection; public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter { private void saveOriginal(Object decodedMessage, Object originalMessage) { - if (Context.getConfig().getBoolean("database.saveOriginal") && decodedMessage instanceof Position) { + if (Context.getConfig().getBoolean(Keys.DATABASE_SAVE_ORIGINAL) && decodedMessage instanceof Position) { Position position = (Position) decodedMessage; if (originalMessage instanceof ByteBuf) { ByteBuf buf = (ByteBuf) originalMessage; position.set(Position.KEY_ORIGINAL, ByteBufUtil.hexDump(buf, 0, buf.writerIndex())); } else if (originalMessage instanceof String) { position.set(Position.KEY_ORIGINAL, DataConverter.printHex( - ((String) originalMessage).getBytes(StandardCharsets.US_ASCII))); + ((String) originalMessage).getBytes(StandardCharsets.US_ASCII))); } } } diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index d9e03517c..77b42943b 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -75,6 +75,12 @@ public final class Keys { public static final ConfigKey EXTRA_HANDLERS = new ConfigKey( "extra.handlers", String.class); + /** + * Store original HEX or string data as "raw" attribute in the corresponding position. + */ + public static final ConfigKey DATABASE_SAVE_ORIGINAL = new ConfigKey( + "database.saveOriginal", Boolean.class); + /** * Enable positions forwarding to other web server. */ -- cgit v1.2.3