From 22d3d0b95866dd273a5c4537d727758e8a1ddd15 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 22 Mar 2016 10:17:04 +1300 Subject: Fix minor issues in the code --- src/org/traccar/ExtendedObjectDecoder.java | 18 ++++++++---------- src/org/traccar/LocationProviderHandler.java | 2 +- src/org/traccar/ServerManager.java | 5 +---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java index 900b7bdbc..329490d29 100644 --- a/src/org/traccar/ExtendedObjectDecoder.java +++ b/src/org/traccar/ExtendedObjectDecoder.java @@ -16,6 +16,7 @@ package org.traccar; import java.net.SocketAddress; +import java.nio.charset.Charset; import java.util.Collection; import org.jboss.netty.buffer.ChannelBuffer; @@ -34,16 +35,13 @@ import javax.xml.bind.DatatypeConverter; public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler { private void saveOriginal(Object decodedMessage, Object originalMessage) { - if (Context.getConfig().getBoolean("database.saveOriginal")) { - if (decodedMessage instanceof Position) { - Position position = (Position) decodedMessage; - if (originalMessage instanceof ChannelBuffer) { - position.set(Event.KEY_ORIGINAL, - ChannelBuffers.hexDump((ChannelBuffer) originalMessage)); - } else if (originalMessage instanceof String) { - position.set(Event.KEY_ORIGINAL, - DatatypeConverter.printHexBinary(((String) originalMessage).getBytes())); - } + if (Context.getConfig().getBoolean("database.saveOriginal") && decodedMessage instanceof Position) { + Position position = (Position) decodedMessage; + if (originalMessage instanceof ChannelBuffer) { + position.set(Event.KEY_ORIGINAL, ChannelBuffers.hexDump((ChannelBuffer) originalMessage)); + } else if (originalMessage instanceof String) { + position.set(Event.KEY_ORIGINAL, DatatypeConverter.printHexBinary( + ((String) originalMessage).getBytes(Charset.defaultCharset()))); } } } diff --git a/src/org/traccar/LocationProviderHandler.java b/src/org/traccar/LocationProviderHandler.java index c59427474..3c0fcf522 100644 --- a/src/org/traccar/LocationProviderHandler.java +++ b/src/org/traccar/LocationProviderHandler.java @@ -45,7 +45,7 @@ public class LocationProviderHandler implements ChannelUpstreamHandler { Object message = e.getMessage(); if (message instanceof Position) { final Position position = (Position) message; - if (position.getOutdated() || (processInvalidPositions && !position.getValid())) { + if (position.getOutdated() || processInvalidPositions && !position.getValid()) { locationProvider.getLocation(position.getAttributes(), new LocationProvider.LocationProviderCallback() { @Override public void onSuccess(double latitude, double longitude) { diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 2fa44831f..cd6a071db 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,6 @@ import java.util.LinkedList; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import org.jboss.netty.bootstrap.ConnectionlessBootstrap; -import org.jboss.netty.bootstrap.ServerBootstrap; -import org.jboss.netty.channel.ChannelPipeline; public class ServerManager { -- cgit v1.2.3