From 61f8fc0da6d4062db34fcfe1d9609698a0de951a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 2 May 2016 10:54:53 +1200 Subject: Always initialize permissions manager --- src/org/traccar/Context.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index e87f78d20..1aba24b8c 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -172,10 +172,11 @@ public final class Context { } if (config.getBoolean("web.enable")) { - permissionsManager = new PermissionsManager(dataManager); webServer = new WebServer(config, dataManager.getDataSource()); } + permissionsManager = new PermissionsManager(dataManager); + connectionManager = new ConnectionManager(dataManager); serverManager = new ServerManager(); -- cgit v1.2.3 From 360269eb2e32f8177d3c759ccbd3a72ac8964d81 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 2 May 2016 17:11:33 +1200 Subject: Update swagger documentation file --- swagger.json | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 209 insertions(+), 16 deletions(-) diff --git a/swagger.json b/swagger.json index f8269a2da..12b5020c7 100644 --- a/swagger.json +++ b/swagger.json @@ -1,7 +1,7 @@ { "swagger": "2.0", "info": { - "version": "3.3", + "version": "3.5", "title": "traccar" }, "host": "traccar.org", @@ -159,7 +159,180 @@ } } }, - "/permissions": { + "/groups": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "all", + "in": "query", + "required": true, + "type": "boolean" + }, + { + "name": "userId", + "in": "query", + "required": true, + "type": "integer" + } + ], + "responses": { + "200": { + "description": "OK", + "headers": {}, + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/Group" + } + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Group" + } + } + ], + "responses": { + "200": { + "description": "OK", + "headers": {}, + "schema": { + "$ref": "#/definitions/Group" + } + } + } + } + }, + "/groups/{id}": { + "put": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "integer" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/Group" + } + } + ], + "responses": { + "200": { + "description": "OK", + "headers": {}, + "schema": { + "$ref": "#/definitions/Group" + } + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "type": "integer" + } + ], + "responses": { + "204": { + "description": "No Content", + "headers": {} + } + } + } + }, + "/permissions/devices": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DevicePermission" + } + } + ], + "responses": { + "200": { + "description": "OK", + "headers": {}, + "schema": { + "$ref": "#/definitions/DevicePermission" + } + } + } + }, + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/DevicePermission" + } + } + ], + "responses": { + "204": { + "description": "No Content", + "headers": {} + } + } + } + }, + "/permissions/groups": { "post": { "consumes": [ "application/json" @@ -173,7 +346,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Permission" + "$ref": "#/definitions/GroupPermission" } } ], @@ -182,7 +355,7 @@ "description": "OK", "headers": {}, "schema": { - "$ref": "#/definitions/Permission" + "$ref": "#/definitions/GroupPermission" } } } @@ -200,7 +373,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/Permission" + "$ref": "#/definitions/GroupPermission" } } ], @@ -556,13 +729,7 @@ "password": { "type": "string" }, - "hashedPassword": { - "type": "string" - }, - "salt": { - "type": "string" - }, - "passwordValid": { + "twelveHourFormat": { "type": "boolean" } } @@ -587,9 +754,6 @@ "mapUrl": { "type": "string" }, - "language": { - "type": "string" - }, "distanceUnit": { "type": "string" }, @@ -604,6 +768,9 @@ }, "zoom": { "type": "number" + }, + "twelveHourFormat": { + "type": "boolean" } } }, @@ -629,10 +796,26 @@ }, "positionId": { "type": "number" + }, + "groupId": { + "type": "number" + } + } + }, + "Group": { + "properties": { + "id": { + "type": "number" + }, + "name": { + "type": "string" + }, + "groupId": { + "type": "number" } } }, - "Permission": { + "DevicePermission": { "properties": { "userId": { "type": "number" @@ -641,6 +824,16 @@ "type": "number" } } + }, + "GroupPermission": { + "properties": { + "userId": { + "type": "number" + }, + "groupId": { + "type": "number" + } + } } } } -- cgit v1.2.3 From d0d7c5a12ca7f9b3af7689c86dff7c7928e86d1d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 3 May 2016 19:37:32 +1200 Subject: Add new astra unit test case --- test/org/traccar/protocol/AstraProtocolDecoderTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/org/traccar/protocol/AstraProtocolDecoderTest.java b/test/org/traccar/protocol/AstraProtocolDecoderTest.java index 93a939879..e8a9b12b5 100644 --- a/test/org/traccar/protocol/AstraProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AstraProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class AstraProtocolDecoderTest extends ProtocolTest { AstraProtocolDecoder decoder = new AstraProtocolDecoder(new AstraProtocol()); + verifyPositions(decoder, binary( + "4b00320524c1da58769e6d0322617effe874024453065600a800000100080000643e0000000000000000000000069500e7bb")); + verifyPositions(decoder, binary( "4b013c02213aec35c501ad031368b8ffcd1ad043e5c4500c79000100003101005c490c001c0009020200020015069600ae03136801ffcd1af143e5c452125e000100003101005c491200090011010000020015068500af0313629effcd1f4b43e5c45d1e46000100003101005c491e00080409040500040015068700b0031359d5ffcd35ad43e5c47b2a3b000001003101005c492a1b1a0d0b0f0b00080015068700b103134984ffcd4b1e43e5c4913354000100003101005c49340b0103090606000f0015067700b203132e1affcd5a5a43e5c4af3348000001003101005c4935070a08000a070017001505f700b30313192cffcd7af143e5c4cd3733000001003101005c4937091206050a0800200015058600b403130debffcda88743e5c4eb2c3e000001003101005c493707030601080600290015058600b377")); -- cgit v1.2.3 From 2d920ecec746615281802e068044a3122a0ae90b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 12:00:39 +1200 Subject: Support for GT06 command response --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 23 +++++++++++++++++++++- .../traccar/protocol/Gt06ProtocolDecoderTest.java | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index e83ced668..d55ff1f83 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import java.net.SocketAddress; +import java.nio.charset.Charset; import java.util.TimeZone; import org.jboss.netty.buffer.ChannelBuffer; @@ -203,7 +204,27 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } else if (hasDeviceId()) { - if (isSupported(type)) { + if (type == MSG_STRING) { + + Position position = new Position(); + position.setDeviceId(getDeviceId()); + position.setProtocol(getProtocolName()); + + getLastLocation(position, null); + + int commandLength = buf.readUnsignedByte(); + + buf.readUnsignedByte(); // server flag (reserved) + + position.set("command", buf.readBytes(commandLength - 1).toString(Charset.defaultCharset())); + + buf.readUnsignedShort(); // language + + sendResponse(channel, type, buf.readUnsignedShort()); + + return position; + + } else if (isSupported(type)) { Position position = new Position(); position.setDeviceId(getDeviceId()); diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index d925ffec3..3bcd2ec3a 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -16,6 +16,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyAttributes(decoder, binary( + "78782d152500000000437574206f666620746865206675656c20737570706c793a2053756363657373210002013b898a0d0a")); + + verifyAttributes(decoder, binary( + "787829152100000000526573746f7265206675656c20737570706c793a2053756363657373210002014077ce0d0a")); + verifyNothing(decoder, binary( "78780D01012345678901234500018CDD0D0A")); -- cgit v1.2.3 From 4b4d68a4e6ee3bad66e00bd9905c572ad9c7b91b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 13:26:16 +1200 Subject: Explicitly use ASCII charset --- src/org/traccar/BasePipelineFactory.java | 3 +- src/org/traccar/BaseProtocol.java | 5 +-- src/org/traccar/BaseProtocolDecoder.java | 8 ++--- src/org/traccar/DistanceHandler.java | 5 +-- src/org/traccar/ExtendedObjectDecoder.java | 9 +++--- src/org/traccar/Main.java | 3 +- src/org/traccar/MainEventHandler.java | 1 + src/org/traccar/Protocol.java | 3 +- src/org/traccar/RemoteAddressHandler.java | 5 +-- src/org/traccar/StringProtocolEncoder.java | 3 +- src/org/traccar/TrackerServer.java | 5 +-- src/org/traccar/WebDataHandler.java | 14 ++++----- src/org/traccar/api/BaseResource.java | 3 -- src/org/traccar/api/CorsResponseFilter.java | 2 +- src/org/traccar/api/SecurityRequestFilter.java | 8 ++--- src/org/traccar/api/UserSecurityContext.java | 2 +- src/org/traccar/api/resource/DeviceResource.java | 6 ++-- src/org/traccar/api/resource/UserResource.java | 12 ++++---- src/org/traccar/database/ActiveDevice.java | 3 +- src/org/traccar/database/ConnectionManager.java | 20 ++++++------ src/org/traccar/database/DataManager.java | 36 +++++++++++----------- src/org/traccar/database/PermissionsManager.java | 11 ++++--- src/org/traccar/database/QueryBuilder.java | 15 ++++----- src/org/traccar/geocode/JsonReverseGeocoder.java | 9 +++--- src/org/traccar/helper/Checksum.java | 6 ++-- src/org/traccar/helper/Hashing.java | 4 +-- src/org/traccar/helper/Log.java | 14 ++++----- src/org/traccar/helper/StringFinder.java | 4 +-- src/org/traccar/model/MiscFormatter.java | 11 ++++--- src/org/traccar/protocol/AdmProtocolDecoder.java | 4 +-- src/org/traccar/protocol/ApelProtocolDecoder.java | 15 ++++----- .../traccar/protocol/AplicomProtocolDecoder.java | 7 +++-- .../traccar/protocol/AppelloProtocolDecoder.java | 6 ++-- .../traccar/protocol/AquilaProtocolDecoder.java | 5 +-- .../traccar/protocol/Ardi01ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/AstraProtocolDecoder.java | 4 +-- .../traccar/protocol/AtrackProtocolDecoder.java | 13 ++++---- .../traccar/protocol/AutoFonProtocolDecoder.java | 11 ++++--- .../traccar/protocol/Avl301ProtocolDecoder.java | 3 +- src/org/traccar/protocol/BceProtocolDecoder.java | 11 ++++--- .../traccar/protocol/BlackKiteProtocolDecoder.java | 19 ++++++------ src/org/traccar/protocol/BoxProtocolDecoder.java | 5 +-- .../traccar/protocol/CalAmpProtocolDecoder.java | 5 +-- .../traccar/protocol/CarTrackProtocolDecoder.java | 5 +-- .../traccar/protocol/CarscopProtocolDecoder.java | 5 +-- .../traccar/protocol/CastelProtocolDecoder.java | 13 ++++---- .../protocol/CellocatorProtocolDecoder.java | 5 +-- .../traccar/protocol/CityeasyProtocolDecoder.java | 9 +++--- .../traccar/protocol/EasyTrackProtocolDecoder.java | 5 +-- .../traccar/protocol/EelinkProtocolDecoder.java | 5 +-- .../traccar/protocol/EnforaProtocolDecoder.java | 11 ++++--- src/org/traccar/protocol/FlextrackProtocol.java | 3 +- .../traccar/protocol/FlextrackProtocolDecoder.java | 5 +-- .../traccar/protocol/FreedomProtocolDecoder.java | 5 +-- .../traccar/protocol/GalileoProtocolDecoder.java | 19 ++++++------ src/org/traccar/protocol/GatorProtocolDecoder.java | 3 +- src/org/traccar/protocol/Gl100ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Gl200ProtocolDecoder.java | 10 +++--- .../traccar/protocol/GlobalSatProtocolDecoder.java | 5 +-- src/org/traccar/protocol/GoSafeProtocol.java | 3 +- .../traccar/protocol/GoSafeProtocolDecoder.java | 11 ++++--- src/org/traccar/protocol/GotopProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Gps103Protocol.java | 3 +- .../traccar/protocol/Gps103ProtocolDecoder.java | 5 +-- .../traccar/protocol/GpsGateProtocolDecoder.java | 6 ++-- .../traccar/protocol/GpsMarkerProtocolDecoder.java | 5 +-- .../traccar/protocol/GpsmtaProtocolDecoder.java | 7 +++-- src/org/traccar/protocol/Gt02ProtocolDecoder.java | 3 +- src/org/traccar/protocol/Gt06Protocol.java | 3 +- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 10 +++--- src/org/traccar/protocol/Gt06ProtocolEncoder.java | 4 +-- src/org/traccar/protocol/H02ProtocolDecoder.java | 11 ++++--- .../traccar/protocol/HaicomProtocolDecoder.java | 5 +-- .../traccar/protocol/HuabaoProtocolDecoder.java | 4 +-- .../protocol/IntellitracProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Jt600FrameDecoder.java | 3 +- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 9 +++--- src/org/traccar/protocol/KenjiProtocolDecoder.java | 5 +-- src/org/traccar/protocol/KhdProtocolDecoder.java | 3 +- .../traccar/protocol/LaipacProtocolDecoder.java | 5 +-- src/org/traccar/protocol/M2mProtocolDecoder.java | 5 ++- .../traccar/protocol/ManPowerProtocolDecoder.java | 5 +-- src/org/traccar/protocol/MegastekFrameDecoder.java | 4 +-- .../traccar/protocol/MegastekProtocolDecoder.java | 5 +-- src/org/traccar/protocol/MeiligaoProtocol.java | 3 +- .../traccar/protocol/MeiligaoProtocolDecoder.java | 13 ++++---- .../traccar/protocol/MeiligaoProtocolEncoder.java | 4 +-- src/org/traccar/protocol/MeitrackFrameDecoder.java | 5 +-- src/org/traccar/protocol/MeitrackProtocol.java | 6 ++-- .../traccar/protocol/MeitrackProtocolDecoder.java | 21 +++++++------ .../protocol/MiniFinderProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Mta6Protocol.java | 3 +- src/org/traccar/protocol/Mta6ProtocolDecoder.java | 15 ++++----- src/org/traccar/protocol/MtxProtocolDecoder.java | 5 +-- src/org/traccar/protocol/MxtFrameDecoder.java | 3 +- src/org/traccar/protocol/MxtProtocolDecoder.java | 3 +- .../traccar/protocol/NavigilProtocolDecoder.java | 7 +++-- src/org/traccar/protocol/NavisProtocolDecoder.java | 27 ++++++++-------- src/org/traccar/protocol/NoranProtocolDecoder.java | 19 ++++++------ src/org/traccar/protocol/NoranProtocolEncoder.java | 8 ++--- src/org/traccar/protocol/NvsProtocolDecoder.java | 6 ++-- src/org/traccar/protocol/OrionProtocolDecoder.java | 7 +++-- .../traccar/protocol/OsmAndProtocolDecoder.java | 17 +++++----- .../traccar/protocol/PiligrimProtocolDecoder.java | 15 +++++---- .../traccar/protocol/ProgressProtocolDecoder.java | 17 +++++----- .../traccar/protocol/Pt3000ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/RitiProtocolDecoder.java | 9 +++--- .../traccar/protocol/RuptelaProtocolDecoder.java | 9 +++--- src/org/traccar/protocol/SanavProtocolDecoder.java | 5 +-- .../traccar/protocol/SkypatrolProtocolDecoder.java | 9 +++--- .../traccar/protocol/Stl060ProtocolDecoder.java | 5 +-- .../traccar/protocol/SuntechProtocolDecoder.java | 5 +-- .../traccar/protocol/SupermateProtocolDecoder.java | 4 +-- src/org/traccar/protocol/T55ProtocolDecoder.java | 7 +++-- src/org/traccar/protocol/TaipProtocolDecoder.java | 7 +++-- src/org/traccar/protocol/TelicProtocolDecoder.java | 5 +-- .../traccar/protocol/TeltonikaProtocolDecoder.java | 13 ++++---- .../traccar/protocol/ThinkRaceProtocolDecoder.java | 4 +-- src/org/traccar/protocol/Tk102ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Tk103ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Tlt2hProtocolDecoder.java | 9 +++--- .../protocol/TopflytechProtocolDecoder.java | 7 ++--- src/org/traccar/protocol/TotemFrameDecoder.java | 7 +++-- src/org/traccar/protocol/TotemProtocol.java | 4 +-- src/org/traccar/protocol/TotemProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Tr20ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Tr900ProtocolDecoder.java | 5 +-- .../traccar/protocol/TrackboxProtocolDecoder.java | 5 +-- src/org/traccar/protocol/TramigoFrameDecoder.java | 3 +- .../traccar/protocol/TramigoProtocolDecoder.java | 23 +++++++------- src/org/traccar/protocol/TytanProtocolDecoder.java | 14 ++++----- src/org/traccar/protocol/TzoneProtocol.java | 3 +- src/org/traccar/protocol/TzoneProtocolDecoder.java | 3 +- .../traccar/protocol/UlbotechProtocolDecoder.java | 11 ++++--- src/org/traccar/protocol/V680ProtocolDecoder.java | 5 +-- .../traccar/protocol/VisiontekProtocolDecoder.java | 5 +-- src/org/traccar/protocol/WatchProtocolEncoder.java | 2 -- .../traccar/protocol/WialonProtocolDecoder.java | 11 ++++--- .../traccar/protocol/WondexProtocolDecoder.java | 5 +-- src/org/traccar/protocol/XexunProtocol.java | 3 +- src/org/traccar/protocol/XexunProtocolDecoder.java | 5 +-- src/org/traccar/protocol/XirgoProtocolDecoder.java | 5 +-- src/org/traccar/protocol/Xt013ProtocolDecoder.java | 5 +-- src/org/traccar/protocol/YwtProtocolDecoder.java | 5 +-- src/org/traccar/web/JsonConverter.java | 26 ++++++++-------- src/org/traccar/web/WebServer.java | 16 +++++----- test/org/traccar/ProtocolTest.java | 3 +- test/org/traccar/helper/ChecksumTest.java | 3 +- test/org/traccar/helper/StringFinderTest.java | 3 +- .../traccar/protocol/Jt600ProtocolDecoderTest.java | 4 +-- 151 files changed, 606 insertions(+), 505 deletions(-) diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index 31d3fe420..c166f47f4 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -15,7 +15,6 @@ */ package org.traccar; -import java.net.InetSocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.ChannelEvent; @@ -32,6 +31,8 @@ import org.jboss.netty.handler.logging.LoggingHandler; import org.jboss.netty.handler.timeout.IdleStateHandler; import org.traccar.helper.Log; +import java.net.InetSocketAddress; + public abstract class BasePipelineFactory implements ChannelPipelineFactory { private final TrackerServer server; diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index 3af39a07c..7714f18db 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -15,11 +15,12 @@ */ package org.traccar; +import org.traccar.database.ActiveDevice; +import org.traccar.model.Command; + import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import org.traccar.database.ActiveDevice; -import org.traccar.model.Command; public abstract class BaseProtocol implements Protocol { diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java index 3bd39d594..53297c2bc 100644 --- a/src/org/traccar/BaseProtocolDecoder.java +++ b/src/org/traccar/BaseProtocolDecoder.java @@ -15,15 +15,15 @@ */ package org.traccar; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.util.Date; - import org.jboss.netty.channel.Channel; import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.Position; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.util.Date; + public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { private final Protocol protocol; diff --git a/src/org/traccar/DistanceHandler.java b/src/org/traccar/DistanceHandler.java index c737457f6..c26ac786f 100644 --- a/src/org/traccar/DistanceHandler.java +++ b/src/org/traccar/DistanceHandler.java @@ -16,12 +16,13 @@ */ package org.traccar; -import java.math.BigDecimal; -import java.math.RoundingMode; import org.traccar.helper.DistanceCalculator; import org.traccar.model.Event; import org.traccar.model.Position; +import java.math.BigDecimal; +import java.math.RoundingMode; + public class DistanceHandler extends BaseDataHandler { private Position getLastPosition(long deviceId) { diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java index 329490d29..2734f5469 100644 --- a/src/org/traccar/ExtendedObjectDecoder.java +++ b/src/org/traccar/ExtendedObjectDecoder.java @@ -15,10 +15,6 @@ */ package org.traccar; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Collection; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -31,6 +27,9 @@ import org.traccar.model.Event; import org.traccar.model.Position; import javax.xml.bind.DatatypeConverter; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Collection; public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler { @@ -41,7 +40,7 @@ public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler { 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()))); + ((String) originalMessage).getBytes(StandardCharsets.US_ASCII))); } } } diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 7ff93fda6..1b8d93e34 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -15,9 +15,10 @@ */ package org.traccar; -import java.util.Locale; import org.traccar.helper.Log; +import java.util.Locale; + public final class Main { private Main() { diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java index 1be20c291..16c4fd7be 100644 --- a/src/org/traccar/MainEventHandler.java +++ b/src/org/traccar/MainEventHandler.java @@ -25,6 +25,7 @@ import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; import org.jboss.netty.handler.timeout.IdleStateEvent; import org.traccar.helper.Log; import org.traccar.model.Position; + import java.text.SimpleDateFormat; public class MainEventHandler extends IdleStateAwareChannelHandler { diff --git a/src/org/traccar/Protocol.java b/src/org/traccar/Protocol.java index 002a8b4d2..edf9bfb36 100644 --- a/src/org/traccar/Protocol.java +++ b/src/org/traccar/Protocol.java @@ -1,9 +1,10 @@ package org.traccar; -import java.util.List; import org.traccar.database.ActiveDevice; import org.traccar.model.Command; +import java.util.List; + public interface Protocol { String getName(); diff --git a/src/org/traccar/RemoteAddressHandler.java b/src/org/traccar/RemoteAddressHandler.java index 8bf2478a0..1bbe87567 100644 --- a/src/org/traccar/RemoteAddressHandler.java +++ b/src/org/traccar/RemoteAddressHandler.java @@ -15,12 +15,13 @@ */ package org.traccar; -import java.net.InetSocketAddress; -import java.net.SocketAddress; import org.jboss.netty.channel.Channel; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.InetSocketAddress; +import java.net.SocketAddress; + public class RemoteAddressHandler extends ExtendedObjectDecoder { @Override diff --git a/src/org/traccar/StringProtocolEncoder.java b/src/org/traccar/StringProtocolEncoder.java index 17e57cf8e..119b40cc4 100644 --- a/src/org/traccar/StringProtocolEncoder.java +++ b/src/org/traccar/StringProtocolEncoder.java @@ -15,9 +15,10 @@ */ package org.traccar; -import java.util.Map; import org.traccar.model.Command; +import java.util.Map; + public abstract class StringProtocolEncoder extends BaseProtocolEncoder { public interface ValueFormatter { diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java index 596d6097a..ba1703e86 100644 --- a/src/org/traccar/TrackerServer.java +++ b/src/org/traccar/TrackerServer.java @@ -15,8 +15,6 @@ */ package org.traccar; -import java.net.InetSocketAddress; -import java.nio.ByteOrder; import org.jboss.netty.bootstrap.Bootstrap; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; @@ -28,6 +26,9 @@ import org.jboss.netty.channel.group.ChannelGroup; import org.jboss.netty.channel.group.ChannelGroupFuture; import org.jboss.netty.channel.group.DefaultChannelGroup; +import java.net.InetSocketAddress; +import java.nio.ByteOrder; + /** * Tracker server */ diff --git a/src/org/traccar/WebDataHandler.java b/src/org/traccar/WebDataHandler.java index 7f241b3d9..efef8d2e1 100644 --- a/src/org/traccar/WebDataHandler.java +++ b/src/org/traccar/WebDataHandler.java @@ -15,6 +15,13 @@ */ package org.traccar; +import org.traccar.helper.Checksum; +import org.traccar.helper.Log; +import org.traccar.model.Device; +import org.traccar.model.Event; +import org.traccar.model.MiscFormatter; +import org.traccar.model.Position; + import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -23,13 +30,6 @@ import java.util.Formatter; import java.util.Locale; import java.util.TimeZone; -import org.traccar.helper.Checksum; -import org.traccar.helper.Log; -import org.traccar.model.Device; -import org.traccar.model.Event; -import org.traccar.model.MiscFormatter; -import org.traccar.model.Position; - public class WebDataHandler extends BaseDataHandler { private final String url; diff --git a/src/org/traccar/api/BaseResource.java b/src/org/traccar/api/BaseResource.java index 4dafc084c..97f5c074d 100644 --- a/src/org/traccar/api/BaseResource.java +++ b/src/org/traccar/api/BaseResource.java @@ -15,9 +15,6 @@ */ package org.traccar.api; -import javax.annotation.security.PermitAll; -import javax.ws.rs.OPTIONS; -import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; public class BaseResource { diff --git a/src/org/traccar/api/CorsResponseFilter.java b/src/org/traccar/api/CorsResponseFilter.java index 67d312504..459fcee66 100644 --- a/src/org/traccar/api/CorsResponseFilter.java +++ b/src/org/traccar/api/CorsResponseFilter.java @@ -18,10 +18,10 @@ package org.traccar.api; import org.jboss.netty.handler.codec.http.HttpHeaders; import org.traccar.Context; -import java.io.IOException; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; +import java.io.IOException; public class CorsResponseFilter implements ContainerResponseFilter { diff --git a/src/org/traccar/api/SecurityRequestFilter.java b/src/org/traccar/api/SecurityRequestFilter.java index 0f0de2dec..f0dd363db 100644 --- a/src/org/traccar/api/SecurityRequestFilter.java +++ b/src/org/traccar/api/SecurityRequestFilter.java @@ -19,9 +19,6 @@ import org.traccar.Context; import org.traccar.api.resource.SessionResource; import org.traccar.model.User; -import java.lang.reflect.Method; -import java.nio.charset.Charset; -import java.sql.SQLException; import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.WebApplicationException; @@ -31,6 +28,9 @@ import javax.ws.rs.container.ResourceInfo; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.xml.bind.DatatypeConverter; +import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; +import java.sql.SQLException; public class SecurityRequestFilter implements ContainerRequestFilter { @@ -42,7 +42,7 @@ public class SecurityRequestFilter implements ContainerRequestFilter { auth = auth.replaceFirst("[B|b]asic ", ""); byte[] decodedBytes = DatatypeConverter.parseBase64Binary(auth); if (decodedBytes != null && decodedBytes.length > 0) { - return new String(decodedBytes, Charset.defaultCharset()).split(":", 2); + return new String(decodedBytes, StandardCharsets.US_ASCII).split(":", 2); } return null; } diff --git a/src/org/traccar/api/UserSecurityContext.java b/src/org/traccar/api/UserSecurityContext.java index 127aee4b3..0ff67a0f8 100644 --- a/src/org/traccar/api/UserSecurityContext.java +++ b/src/org/traccar/api/UserSecurityContext.java @@ -15,8 +15,8 @@ */ package org.traccar.api; -import java.security.Principal; import javax.ws.rs.core.SecurityContext; +import java.security.Principal; public class UserSecurityContext implements SecurityContext { diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index a4bfc1030..0017f13ee 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -17,9 +17,8 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; +import org.traccar.model.Device; -import java.sql.SQLException; -import java.util.Collection; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -31,7 +30,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.traccar.model.Device; +import java.sql.SQLException; +import java.util.Collection; @Path("devices") @Produces(MediaType.APPLICATION_JSON) diff --git a/src/org/traccar/api/resource/UserResource.java b/src/org/traccar/api/resource/UserResource.java index 9eb0d9597..0b307ab88 100644 --- a/src/org/traccar/api/resource/UserResource.java +++ b/src/org/traccar/api/resource/UserResource.java @@ -15,8 +15,10 @@ */ package org.traccar.api.resource; -import java.sql.SQLException; -import java.util.Collection; +import org.traccar.Context; +import org.traccar.api.BaseResource; +import org.traccar.model.User; + import javax.annotation.security.PermitAll; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -28,10 +30,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import org.traccar.Context; -import org.traccar.api.BaseResource; -import org.traccar.model.User; +import java.sql.SQLException; +import java.util.Collection; @Path("users") @Produces(MediaType.APPLICATION_JSON) diff --git a/src/org/traccar/database/ActiveDevice.java b/src/org/traccar/database/ActiveDevice.java index 571ebf465..746d3b393 100644 --- a/src/org/traccar/database/ActiveDevice.java +++ b/src/org/traccar/database/ActiveDevice.java @@ -15,11 +15,12 @@ */ package org.traccar.database; -import java.net.SocketAddress; import org.jboss.netty.channel.Channel; import org.traccar.Protocol; import org.traccar.model.Command; +import java.net.SocketAddress; + public class ActiveDevice { private final long deviceId; diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java index e91aa2d5b..bb9958232 100644 --- a/src/org/traccar/database/ConnectionManager.java +++ b/src/org/traccar/database/ConnectionManager.java @@ -15,6 +15,16 @@ */ package org.traccar.database; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.util.Timeout; +import org.jboss.netty.util.TimerTask; +import org.traccar.Context; +import org.traccar.GlobalTimer; +import org.traccar.Protocol; +import org.traccar.helper.Log; +import org.traccar.model.Device; +import org.traccar.model.Position; + import java.net.SocketAddress; import java.sql.SQLException; import java.util.Collection; @@ -27,16 +37,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jboss.netty.channel.Channel; -import org.jboss.netty.util.Timeout; -import org.jboss.netty.util.TimerTask; -import org.traccar.Context; -import org.traccar.GlobalTimer; -import org.traccar.Protocol; -import org.traccar.helper.Log; -import org.traccar.model.Device; -import org.traccar.model.Position; - public class ConnectionManager { private static final long DEFAULT_TIMEOUT = 600; diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index eb0be9274..5a233411b 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -16,23 +16,6 @@ package org.traccar.database; import com.mchange.v2.c3p0.ComboPooledDataSource; -import java.io.File; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.naming.InitialContext; -import javax.sql.DataSource; - import liquibase.Contexts; import liquibase.Liquibase; import liquibase.database.Database; @@ -44,13 +27,30 @@ import org.traccar.Config; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.Device; +import org.traccar.model.DevicePermission; import org.traccar.model.Group; import org.traccar.model.GroupPermission; -import org.traccar.model.DevicePermission; import org.traccar.model.Position; import org.traccar.model.Server; import org.traccar.model.User; +import javax.naming.InitialContext; +import javax.sql.DataSource; +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + public class DataManager implements IdentityManager { private static final long DEFAULT_REFRESH_DELAY = 300; diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 57307b58a..08d44b382 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -15,11 +15,6 @@ */ package org.traccar.database; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; import org.traccar.helper.Log; import org.traccar.model.Device; import org.traccar.model.DevicePermission; @@ -28,6 +23,12 @@ import org.traccar.model.GroupPermission; import org.traccar.model.Server; import org.traccar.model.User; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + public class PermissionsManager { private final DataManager dataManager; diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index d0c1c649f..c5a682b7e 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -15,6 +15,14 @@ */ package org.traccar.database; +import org.traccar.Context; +import org.traccar.helper.Log; +import org.traccar.model.MiscFormatter; + +import javax.json.Json; +import javax.json.JsonReader; +import javax.json.stream.JsonParsingException; +import javax.sql.DataSource; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -32,13 +40,6 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import javax.json.Json; -import javax.json.JsonReader; -import javax.json.stream.JsonParsingException; -import javax.sql.DataSource; -import org.traccar.Context; -import org.traccar.helper.Log; -import org.traccar.model.MiscFormatter; public final class QueryBuilder { diff --git a/src/org/traccar/geocode/JsonReverseGeocoder.java b/src/org/traccar/geocode/JsonReverseGeocoder.java index e07419d55..dcc880ef9 100644 --- a/src/org/traccar/geocode/JsonReverseGeocoder.java +++ b/src/org/traccar/geocode/JsonReverseGeocoder.java @@ -17,14 +17,15 @@ package org.traccar.geocode; import com.ning.http.client.AsyncCompletionHandler; import com.ning.http.client.Response; +import org.traccar.Context; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; import java.util.AbstractMap; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; -import org.traccar.Context; public abstract class JsonReverseGeocoder implements ReverseGeocoder { diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java index c156e53f7..6a0a35b16 100644 --- a/src/org/traccar/helper/Checksum.java +++ b/src/org/traccar/helper/Checksum.java @@ -16,7 +16,7 @@ package org.traccar.helper; import java.nio.ByteBuffer; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.zip.CRC32; public final class Checksum { @@ -158,7 +158,7 @@ public final class Checksum { public static String nmea(String msg) { int checksum = 0; - for (byte b : msg.getBytes(Charset.defaultCharset())) { + for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) { checksum ^= b; } return String.format("*%02x", checksum).toUpperCase(); @@ -166,7 +166,7 @@ public final class Checksum { public static String sum(String msg) { byte checksum = 0; - for (byte b : msg.getBytes(Charset.defaultCharset())) { + for (byte b : msg.getBytes(StandardCharsets.US_ASCII)) { checksum += b; } return String.format("%02X", checksum).toUpperCase(); diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java index 29020f3a7..38ae5813e 100644 --- a/src/org/traccar/helper/Hashing.java +++ b/src/org/traccar/helper/Hashing.java @@ -15,11 +15,11 @@ */ package org.traccar.helper; -import java.security.GeneralSecurityException; -import java.security.SecureRandom; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.xml.bind.DatatypeConverter; +import java.security.GeneralSecurityException; +import java.security.SecureRandom; public final class Hashing { diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java index 2b747734e..d13210a17 100644 --- a/src/org/traccar/helper/Log.java +++ b/src/org/traccar/helper/Log.java @@ -15,13 +15,6 @@ */ package org.traccar.helper; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryMXBean; -import java.lang.management.OperatingSystemMXBean; -import java.lang.management.RuntimeMXBean; -import java.nio.charset.Charset; - import org.apache.log4j.Appender; import org.apache.log4j.DailyRollingFileAppender; import org.apache.log4j.Layout; @@ -35,6 +28,13 @@ import org.jboss.netty.logging.InternalLogger; import org.jboss.netty.logging.InternalLoggerFactory; import org.traccar.Config; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.lang.management.OperatingSystemMXBean; +import java.lang.management.RuntimeMXBean; +import java.nio.charset.Charset; + public final class Log { private Log() { diff --git a/src/org/traccar/helper/StringFinder.java b/src/org/traccar/helper/StringFinder.java index da6a9bdc2..6c1dafcfd 100644 --- a/src/org/traccar/helper/StringFinder.java +++ b/src/org/traccar/helper/StringFinder.java @@ -18,7 +18,7 @@ package org.traccar.helper; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferIndexFinder; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class StringFinder implements ChannelBufferIndexFinder { @@ -35,7 +35,7 @@ public class StringFinder implements ChannelBufferIndexFinder { return false; } - return string.equals(buffer.toString(guessedIndex, string.length(), Charset.defaultCharset())); + return string.equals(buffer.toString(guessedIndex, string.length(), StandardCharsets.US_ASCII)); } } diff --git a/src/org/traccar/model/MiscFormatter.java b/src/org/traccar/model/MiscFormatter.java index 4f39c4013..9bb856400 100644 --- a/src/org/traccar/model/MiscFormatter.java +++ b/src/org/traccar/model/MiscFormatter.java @@ -15,17 +15,18 @@ */ package org.traccar.model; -import java.text.DecimalFormat; -import java.util.LinkedHashMap; -import java.util.Map; +import org.traccar.helper.Log; +import org.traccar.web.JsonConverter; + import javax.json.Json; import javax.json.JsonNumber; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.JsonString; import javax.json.JsonValue; -import org.traccar.helper.Log; -import org.traccar.web.JsonConverter; +import java.text.DecimalFormat; +import java.util.LinkedHashMap; +import java.util.Map; /** * Format extended tracker status diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java index 374dd8995..28d0b5105 100644 --- a/src/org/traccar/protocol/AdmProtocolDecoder.java +++ b/src/org/traccar/protocol/AdmProtocolDecoder.java @@ -24,7 +24,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Date; public class AdmProtocolDecoder extends BaseProtocolDecoder { @@ -49,7 +49,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder { int type = buf.readUnsignedByte(); if (type == MSG_IMEI) { - identify(buf.toString(buf.readerIndex(), 15, Charset.defaultCharset()), channel, remoteAddress); + identify(buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII), channel, remoteAddress); } if (hasDeviceId() && BitUtil.to(type, 2) == 0) { diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java index a72447883..b75bcbda3 100644 --- a/src/org/traccar/protocol/ApelProtocolDecoder.java +++ b/src/org/traccar/protocol/ApelProtocolDecoder.java @@ -15,12 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +24,13 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class ApelProtocolDecoder extends BaseProtocolDecoder { private long lastIndex; @@ -110,7 +111,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { int length = buf.readUnsignedShort(); buf.skipBytes(length); length = buf.readUnsignedShort(); - identify(buf.readBytes(length).toString(Charset.defaultCharset()), channel, remoteAddress); + identify(buf.readBytes(length).toString(StandardCharsets.US_ASCII), channel, remoteAddress); } else if (type == MSG_LAST_LOG_INDEX) { diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index c2eb8a1f5..e8e070d67 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.ArrayList; -import java.util.Date; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +26,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.ArrayList; +import java.util.Date; + public class AplicomProtocolDecoder extends BaseProtocolDecoder { public AplicomProtocolDecoder(AplicomProtocol protocol) { diff --git a/src/org/traccar/protocol/AppelloProtocolDecoder.java b/src/org/traccar/protocol/AppelloProtocolDecoder.java index d422a5aa1..48e624f40 100755 --- a/src/org/traccar/protocol/AppelloProtocolDecoder.java +++ b/src/org/traccar/protocol/AppelloProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; - import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class AppelloProtocolDecoder extends BaseProtocolDecoder { public AppelloProtocolDecoder(AppelloProtocol protocol) { diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java index 74b127bfe..0431e0a26 100644 --- a/src/org/traccar/protocol/AquilaProtocolDecoder.java +++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class AquilaProtocolDecoder extends BaseProtocolDecoder { public AquilaProtocolDecoder(AquilaProtocol protocol) { diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java index 8f449222b..2a7324127 100644 --- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Ardi01ProtocolDecoder extends BaseProtocolDecoder { public Ardi01ProtocolDecoder(Ardi01Protocol protocol) { diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index 8cfec95fe..d19b68761 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -26,7 +26,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; @@ -100,7 +100,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(reason, 6) || BitUtil.check(reason, 7)) { - position.set(Event.KEY_RFID, buf.readBytes(7).toString(Charset.defaultCharset())); + position.set(Event.KEY_RFID, buf.readBytes(7).toString(StandardCharsets.US_ASCII)); position.set(Event.KEY_ODOMETER, buf.readUnsignedMedium()); buf.readUnsignedShort(); // engine time diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 72a17eed2..27c5b8902 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +25,12 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class AtrackProtocolDecoder extends BaseProtocolDecoder { private static final int MIN_DATA_LENGTH = 40; @@ -72,7 +73,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { String result = null; int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0); if (index > buf.readerIndex()) { - result = buf.readBytes(index - buf.readerIndex()).toString(Charset.defaultCharset()); + result = buf.readBytes(index - buf.readerIndex()).toString(StandardCharsets.US_ASCII); } buf.readByte(); return result; diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java index c0c1f9616..a633005b4 100644 --- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java +++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java @@ -16,10 +16,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +25,11 @@ import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; + public class AutoFonProtocolDecoder extends BaseProtocolDecoder { public AutoFonProtocolDecoder(AutoFonProtocol protocol) { @@ -158,7 +159,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { ChannelBuffer response = ChannelBuffers.dynamicBuffer(); - response.writeBytes("resp_crc=".getBytes(Charset.defaultCharset())); + response.writeBytes("resp_crc=".getBytes(StandardCharsets.US_ASCII)); response.writeByte(buf.getByte(buf.writerIndex() - 1)); channel.write(response); } diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java index c0aefbeae..7f2e3ece7 100644 --- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java +++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -24,6 +23,8 @@ import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class Avl301ProtocolDecoder extends BaseProtocolDecoder { public Avl301ProtocolDecoder(Avl301Protocol protocol) { diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java index 5a5092ae0..fc0a9a3f4 100644 --- a/src/org/traccar/protocol/BceProtocolDecoder.java +++ b/src/org/traccar/protocol/BceProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -28,6 +23,12 @@ import org.traccar.helper.BitUtil; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class BceProtocolDecoder extends BaseProtocolDecoder { public BceProtocolDecoder(BceProtocol protocol) { diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java index 9f4724351..c4f2eaff9 100644 --- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java +++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java @@ -16,14 +16,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -33,6 +25,15 @@ import org.traccar.helper.Log; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + public class BlackKiteProtocolDecoder extends BaseProtocolDecoder { public BlackKiteProtocolDecoder(BlackKiteProtocol protocol) { @@ -96,7 +97,7 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder { switch (tag) { case TAG_IMEI: - String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset()); + String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII); buf.skipBytes(imei.length()); identify(imei, channel, remoteAddress); break; diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index 7cd9ad0f9..5edc23a80 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class BoxProtocolDecoder extends BaseProtocolDecoder { public BoxProtocolDecoder(BoxProtocol protocol) { diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java index bd648b0f9..292666c31 100644 --- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java +++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; + public class CalAmpProtocolDecoder extends BaseProtocolDecoder { public CalAmpProtocolDecoder(CalAmpProtocol protocol) { diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java index 9a0a98992..cd5269221 100644 --- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java @@ -16,8 +16,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class CarTrackProtocolDecoder extends BaseProtocolDecoder { public CarTrackProtocolDecoder(CarTrackProtocol protocol) { diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java index 9dce57b4e..250a4c564 100644 --- a/src/org/traccar/protocol/CarscopProtocolDecoder.java +++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class CarscopProtocolDecoder extends BaseProtocolDecoder { public CarscopProtocolDecoder(CarscopProtocol protocol) { diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index 9f332dd04..d3d505c86 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +25,12 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; + public class CastelProtocolDecoder extends BaseProtocolDecoder { public CastelProtocolDecoder(CastelProtocol protocol) { @@ -148,7 +149,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer id = buf.readBytes(20); int type = ChannelBuffers.swapShort(buf.readShort()); - if (!identify(id.toString(Charset.defaultCharset()).trim(), channel, remoteAddress)) { + if (!identify(id.toString(StandardCharsets.US_ASCII).trim(), channel, remoteAddress)) { return null; } diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java index 79db82bd1..0a3e4599f 100644 --- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java +++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; + public class CellocatorProtocolDecoder extends BaseProtocolDecoder { public CellocatorProtocolDecoder(CellocatorProtocol protocol) { diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java index 4ccd96a17..9aae900d9 100644 --- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java +++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +26,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class CityeasyProtocolDecoder extends BaseProtocolDecoder { public CityeasyProtocolDecoder(CityeasyProtocol protocol) { @@ -82,7 +83,7 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_LOCATION_REPORT || type == MSG_LOCATION_REQUEST) { - String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 8, Charset.defaultCharset()); + String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 8, StandardCharsets.US_ASCII); Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index cff90c7f1..320cb3a4f 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; @@ -26,6 +24,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { public EasyTrackProtocolDecoder(EasyTrackProtocol protocol) { diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 2aa18c20c..07dde53d7 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -25,6 +23,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; + public class EelinkProtocolDecoder extends BaseProtocolDecoder { public EelinkProtocolDecoder(EelinkProtocol protocol) { diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index 0153d254c..23cfb0093 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBufferIndexFinder; import org.jboss.netty.channel.Channel; @@ -28,6 +25,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.helper.StringFinder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class EnforaProtocolDecoder extends BaseProtocolDecoder { public EnforaProtocolDecoder(EnforaProtocol protocol) { @@ -75,7 +76,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { return null; } - String imei = buf.toString(index, IMEI_LENGTH, Charset.defaultCharset()); + String imei = buf.toString(index, IMEI_LENGTH, StandardCharsets.US_ASCII); if (!identify(imei, channel, remoteAddress)) { return null; } @@ -86,7 +87,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { return null; } - String sentence = buf.toString(start, buf.readableBytes() - start, Charset.defaultCharset()); + String sentence = buf.toString(start, buf.readableBytes() - start, StandardCharsets.US_ASCII); Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; diff --git a/src/org/traccar/protocol/FlextrackProtocol.java b/src/org/traccar/protocol/FlextrackProtocol.java index 3b1aaa3d8..c17099fc7 100644 --- a/src/org/traccar/protocol/FlextrackProtocol.java +++ b/src/org/traccar/protocol/FlextrackProtocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; @@ -24,6 +23,8 @@ import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; +import java.util.List; + public class FlextrackProtocol extends BaseProtocol { public FlextrackProtocol() { diff --git a/src/org/traccar/protocol/FlextrackProtocolDecoder.java b/src/org/traccar/protocol/FlextrackProtocolDecoder.java index 0f82e7c59..9bfac2537 100644 --- a/src/org/traccar/protocol/FlextrackProtocolDecoder.java +++ b/src/org/traccar/protocol/FlextrackProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class FlextrackProtocolDecoder extends BaseProtocolDecoder { public FlextrackProtocolDecoder(FlextrackProtocol protocol) { diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java index d7d704869..03ab894c5 100644 --- a/src/org/traccar/protocol/FreedomProtocolDecoder.java +++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -24,6 +22,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class FreedomProtocolDecoder extends BaseProtocolDecoder { public FreedomProtocolDecoder(FreedomProtocol protocol) { diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index ef7cd2ab1..f9c7fb935 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -15,9 +15,17 @@ */ package org.traccar.protocol; +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.helper.Log; +import org.traccar.model.Event; +import org.traccar.model.Position; + import java.net.SocketAddress; import java.nio.ByteOrder; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -25,13 +33,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.jboss.netty.channel.Channel; -import org.traccar.BaseProtocolDecoder; -import org.traccar.helper.Log; -import org.traccar.model.Event; -import org.traccar.model.Position; public class GalileoProtocolDecoder extends BaseProtocolDecoder { @@ -142,7 +143,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { switch (tag) { case TAG_IMEI: - String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset()); + String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII); buf.skipBytes(imei.length()); identify(imei, channel, remoteAddress); break; diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index e28da82ba..1c8e1f4e4 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -25,6 +24,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class GatorProtocolDecoder extends BaseProtocolDecoder { public GatorProtocolDecoder(GatorProtocol protocol) { diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java index db5e60838..31102a676 100644 --- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -24,6 +22,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Gl100ProtocolDecoder extends BaseProtocolDecoder { public Gl100ProtocolDecoder(Gl100Protocol protocol) { diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 4592ccdab..617f0f541 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Pattern; - import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; @@ -31,6 +26,11 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + public class Gl200ProtocolDecoder extends BaseProtocolDecoder { public Gl200ProtocolDecoder(Gl200Protocol protocol) { diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 589bb991a..8c378af90 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; @@ -27,6 +25,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { private String format0; diff --git a/src/org/traccar/protocol/GoSafeProtocol.java b/src/org/traccar/protocol/GoSafeProtocol.java index bc1ed14de..b45755fc3 100644 --- a/src/org/traccar/protocol/GoSafeProtocol.java +++ b/src/org/traccar/protocol/GoSafeProtocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; @@ -24,6 +23,8 @@ import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; +import java.util.List; + public class GoSafeProtocol extends BaseProtocol { public GoSafeProtocol() { diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java index 21441479b..e3ab37fbd 100644 --- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java +++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; @@ -30,6 +25,12 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + public class GoSafeProtocolDecoder extends BaseProtocolDecoder { public GoSafeProtocolDecoder(GoSafeProtocol protocol) { diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java index 594b4c958..65b694aaf 100644 --- a/src/org/traccar/protocol/GotopProtocolDecoder.java +++ b/src/org/traccar/protocol/GotopProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class GotopProtocolDecoder extends BaseProtocolDecoder { public GotopProtocolDecoder(GotopProtocol protocol) { diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java index d8ad0a8b7..6a2f8a7f9 100644 --- a/src/org/traccar/protocol/Gps103Protocol.java +++ b/src/org/traccar/protocol/Gps103Protocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; @@ -26,6 +25,8 @@ import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; import org.traccar.model.Command; +import java.util.List; + public class Gps103Protocol extends BaseProtocol { public Gps103Protocol() { diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index ce5a54141..f2d2ba5ba 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Gps103ProtocolDecoder extends BaseProtocolDecoder { public Gps103ProtocolDecoder(Gps103Protocol protocol) { diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java index b48fa6266..127c986a3 100644 --- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; - import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.Checksum; @@ -26,6 +23,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class GpsGateProtocolDecoder extends BaseProtocolDecoder { public GpsGateProtocolDecoder(GpsGateProtocol protocol) { diff --git a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java index 9313ad099..e08886938 100644 --- a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class GpsMarkerProtocolDecoder extends BaseProtocolDecoder { public GpsMarkerProtocolDecoder(GpsMarkerProtocol protocol) { diff --git a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java index 0ee207219..eee4afd36 100644 --- a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.Parser; @@ -25,6 +22,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; +import java.util.regex.Pattern; + public class GpsmtaProtocolDecoder extends BaseProtocolDecoder { public GpsmtaProtocolDecoder(GpsmtaProtocol protocol) { diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java index 0b015366e..05655d87f 100644 --- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -26,6 +25,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class Gt02ProtocolDecoder extends BaseProtocolDecoder { public Gt02ProtocolDecoder(Gt02Protocol protocol) { diff --git a/src/org/traccar/protocol/Gt06Protocol.java b/src/org/traccar/protocol/Gt06Protocol.java index 4630342a5..7f6d5d914 100644 --- a/src/org/traccar/protocol/Gt06Protocol.java +++ b/src/org/traccar/protocol/Gt06Protocol.java @@ -15,13 +15,14 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; import org.traccar.model.Command; +import java.util.List; + public class Gt06Protocol extends BaseProtocol { public Gt06Protocol() { diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index d55ff1f83..18524fcfa 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -15,10 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.TimeZone; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -31,6 +27,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.TimeZone; + public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private boolean forceTimeZone = false; @@ -216,7 +216,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // server flag (reserved) - position.set("command", buf.readBytes(commandLength - 1).toString(Charset.defaultCharset())); + position.set("command", buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII)); buf.readUnsignedShort(); // language diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java index 6b5f0fc6c..3ef9b1313 100644 --- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -22,7 +22,7 @@ import org.traccar.helper.Checksum; import org.traccar.helper.Log; import org.traccar.model.Command; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class Gt06ProtocolEncoder extends BaseProtocolEncoder { @@ -39,7 +39,7 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder { buf.writeByte(4 + content.length()); // command length buf.writeInt(0); - buf.writeBytes(content.getBytes(Charset.defaultCharset())); // command + buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII)); // command buf.writeShort(0); // message index diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index b316d8016..8230639e6 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +27,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class H02ProtocolDecoder extends BaseProtocolDecoder { public H02ProtocolDecoder(H02Protocol protocol) { @@ -193,12 +194,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { ChannelBuffer buf = (ChannelBuffer) msg; - String marker = buf.toString(0, 1, Charset.defaultCharset()); + String marker = buf.toString(0, 1, StandardCharsets.US_ASCII); // handle X mode? if (marker.equals("*")) { - return decodeText(buf.toString(Charset.defaultCharset()), channel, remoteAddress); + return decodeText(buf.toString(StandardCharsets.US_ASCII), channel, remoteAddress); } else if (marker.equals("$")) { return decodeBinary(buf, channel, remoteAddress); } diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java index 009c6046c..fd989cecb 100644 --- a/src/org/traccar/protocol/HaicomProtocolDecoder.java +++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; @@ -26,6 +24,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class HaicomProtocolDecoder extends BaseProtocolDecoder { public HaicomProtocolDecoder(HaicomProtocol protocol) { diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java index 6ed490c1a..1978fae94 100644 --- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -28,7 +28,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.TimeZone; public class HuabaoProtocolDecoder extends BaseProtocolDecoder { @@ -91,7 +91,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer response = ChannelBuffers.dynamicBuffer(); response.writeShort(index); response.writeByte(RESULT_SUCCESS); - response.writeBytes("authentication".getBytes(Charset.defaultCharset())); + response.writeBytes("authentication".getBytes(StandardCharsets.US_ASCII)); sendResponse(channel, remoteAddress, MSG_TERMINAL_REGISTER_RESPONSE, id, response); } else if (type == MSG_TERMINAL_AUTH) { diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index fbab27c17..11f7aab8d 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class IntellitracProtocolDecoder extends BaseProtocolDecoder { public IntellitracProtocolDecoder(IntellitracProtocol protocol) { diff --git a/src/org/traccar/protocol/Jt600FrameDecoder.java b/src/org/traccar/protocol/Jt600FrameDecoder.java index 5c6deaac4..cb7fce0c0 100644 --- a/src/org/traccar/protocol/Jt600FrameDecoder.java +++ b/src/org/traccar/protocol/Jt600FrameDecoder.java @@ -15,12 +15,13 @@ */ package org.traccar.protocol; -import java.text.ParseException; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; +import java.text.ParseException; + public class Jt600FrameDecoder extends FrameDecoder { @Override diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index 3cd6aedb7..5c247c08a 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +27,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class Jt600ProtocolDecoder extends BaseProtocolDecoder { public Jt600ProtocolDecoder(Jt600Protocol protocol) { @@ -141,7 +142,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { private Position decodeAlertMessage(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { - Parser parser = new Parser(PATTERN, buf.toString(Charset.defaultCharset())); + Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII)); if (!parser.matches()) { return null; } diff --git a/src/org/traccar/protocol/KenjiProtocolDecoder.java b/src/org/traccar/protocol/KenjiProtocolDecoder.java index e190af948..39bd72b48 100755 --- a/src/org/traccar/protocol/KenjiProtocolDecoder.java +++ b/src/org/traccar/protocol/KenjiProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class KenjiProtocolDecoder extends BaseProtocolDecoder { public KenjiProtocolDecoder(KenjiProtocol protocol) { diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java index 07db78c94..b54b8860f 100644 --- a/src/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/org/traccar/protocol/KhdProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -27,6 +26,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class KhdProtocolDecoder extends BaseProtocolDecoder { public KhdProtocolDecoder(KhdProtocol protocol) { diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index 292e8adbb..ba0dad4b4 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.Checksum; @@ -25,6 +23,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class LaipacProtocolDecoder extends BaseProtocolDecoder { public LaipacProtocolDecoder(LaipacProtocol protocol) { diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java index dbb73c469..ad9db9a0b 100644 --- a/src/org/traccar/protocol/M2mProtocolDecoder.java +++ b/src/org/traccar/protocol/M2mProtocolDecoder.java @@ -15,16 +15,15 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; - import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class M2mProtocolDecoder extends BaseProtocolDecoder { public M2mProtocolDecoder(M2mProtocol protocol) { diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java index 8c189eef9..dd3d72d42 100644 --- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java +++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class ManPowerProtocolDecoder extends BaseProtocolDecoder { public ManPowerProtocolDecoder(ManPowerProtocol protocol) { diff --git a/src/org/traccar/protocol/MegastekFrameDecoder.java b/src/org/traccar/protocol/MegastekFrameDecoder.java index a53468017..ba2cc1d25 100644 --- a/src/org/traccar/protocol/MegastekFrameDecoder.java +++ b/src/org/traccar/protocol/MegastekFrameDecoder.java @@ -21,7 +21,7 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.traccar.helper.StringFinder; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class MegastekFrameDecoder extends FrameDecoder { @@ -34,7 +34,7 @@ public class MegastekFrameDecoder extends FrameDecoder { } if (Character.isDigit(buf.getByte(buf.readerIndex()))) { - int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, Charset.defaultCharset())); + int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII)); if (buf.readableBytes() >= length) { return buf.readBytes(length); } diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index 2eebc8d2f..aa60dde58 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class MegastekProtocolDecoder extends BaseProtocolDecoder { public MegastekProtocolDecoder(MegastekProtocol protocol) { diff --git a/src/org/traccar/protocol/MeiligaoProtocol.java b/src/org/traccar/protocol/MeiligaoProtocol.java index 04e15fcee..bce9b3196 100644 --- a/src/org/traccar/protocol/MeiligaoProtocol.java +++ b/src/org/traccar/protocol/MeiligaoProtocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; @@ -23,6 +22,8 @@ import org.traccar.BaseProtocol; import org.traccar.TrackerServer; import org.traccar.model.Command; +import java.util.List; + public class MeiligaoProtocol extends BaseProtocol { public MeiligaoProtocol() { diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 5c17aab61..92df085a6 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -15,10 +15,6 @@ */ package org.traccar.protocol; -import java.net.InetSocketAddress; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -31,6 +27,11 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { public MeiligaoProtocolDecoder(MeiligaoProtocol protocol) { @@ -179,7 +180,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { case MSG_SERVER: if (channel != null) { response = ChannelBuffers.copiedBuffer( - getMeiligaoServer(channel), Charset.defaultCharset()); + getMeiligaoServer(channel), StandardCharsets.US_ASCII); sendResponse(channel, remoteAddress, id, MSG_SERVER, response); } return null; @@ -226,7 +227,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } Parser parser = new Parser( - pattern, buf.toString(buf.readerIndex(), buf.readableBytes() - 4, Charset.defaultCharset())); + pattern, buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII)); if (!parser.matches()) { return null; } diff --git a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java index a40ce9271..93399df60 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java @@ -23,7 +23,7 @@ import org.traccar.helper.Log; import org.traccar.model.Command; import javax.xml.bind.DatatypeConverter; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { @@ -81,7 +81,7 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { return encodeContent(command.getDeviceId(), MSG_MOVEMENT_ALARM, content); case Command.TYPE_SET_TIMEZONE: int offset = ((Number) attributes.get(Command.KEY_TIMEZONE)).intValue() / 60; - content.writeBytes(String.valueOf(offset).getBytes(Charset.defaultCharset())); + content.writeBytes(String.valueOf(offset).getBytes(StandardCharsets.US_ASCII)); return encodeContent(command.getDeviceId(), MSG_TIME_ZONE, content); case Command.TYPE_REBOOT_DEVICE: return encodeContent(command.getDeviceId(), MSG_REBOOT_GPS, content); diff --git a/src/org/traccar/protocol/MeitrackFrameDecoder.java b/src/org/traccar/protocol/MeitrackFrameDecoder.java index c2ab370a8..3c2d34394 100644 --- a/src/org/traccar/protocol/MeitrackFrameDecoder.java +++ b/src/org/traccar/protocol/MeitrackFrameDecoder.java @@ -15,12 +15,13 @@ */ package org.traccar.protocol; -import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; +import java.nio.charset.StandardCharsets; + public class MeitrackFrameDecoder extends FrameDecoder { @Override @@ -34,7 +35,7 @@ public class MeitrackFrameDecoder extends FrameDecoder { int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); if (index != -1) { int length = index - buf.readerIndex() + Integer.parseInt( - buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, Charset.defaultCharset())); + buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, StandardCharsets.US_ASCII)); if (buf.readableBytes() >= length) { return buf.readBytes(length); } diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java index a004d5cb6..01fdcc08c 100644 --- a/src/org/traccar/protocol/MeitrackProtocol.java +++ b/src/org/traccar/protocol/MeitrackProtocol.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.nio.ByteOrder; -import java.util.List; - import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; @@ -26,6 +23,9 @@ import org.traccar.BaseProtocol; import org.traccar.TrackerServer; import org.traccar.model.Command; +import java.nio.ByteOrder; +import java.util.List; + public class MeitrackProtocol extends BaseProtocol { public MeitrackProtocol() { diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index a920c6e76..bbd7c521c 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -15,12 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -32,6 +26,13 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + public class MeitrackProtocolDecoder extends BaseProtocolDecoder { public MeitrackProtocolDecoder(MeitrackProtocol protocol) { @@ -82,7 +83,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { private Position decodeRegularMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) { - Parser parser = new Parser(PATTERN, buf.toString(Charset.defaultCharset())); + Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII)); if (!parser.matches()) { return null; } @@ -159,10 +160,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { private List decodeBinaryMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) { List positions = new LinkedList<>(); - String flag = buf.toString(2, 1, Charset.defaultCharset()); + String flag = buf.toString(2, 1, StandardCharsets.US_ASCII); int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); - String imei = buf.toString(index + 1, 15, Charset.defaultCharset()); + String imei = buf.toString(index + 1, 15, StandardCharsets.US_ASCII); if (!identify(imei, channel, remoteAddress)) { return null; } @@ -237,7 +238,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); index = buf.indexOf(index + 1, buf.writerIndex(), (byte) ','); - String type = buf.toString(index + 1, 3, Charset.defaultCharset()); + String type = buf.toString(index + 1, 3, StandardCharsets.US_ASCII); switch (type) { case "D03": if (channel != null) { diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 631a4b56b..42962f2f0 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; @@ -26,6 +24,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { public MiniFinderProtocolDecoder(MiniFinderProtocol protocol) { diff --git a/src/org/traccar/protocol/Mta6Protocol.java b/src/org/traccar/protocol/Mta6Protocol.java index 607bf8118..ed578b2d7 100644 --- a/src/org/traccar/protocol/Mta6Protocol.java +++ b/src/org/traccar/protocol/Mta6Protocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.http.HttpRequestDecoder; @@ -24,6 +23,8 @@ import org.traccar.BaseProtocol; import org.traccar.Context; import org.traccar.TrackerServer; +import java.util.List; + public class Mta6Protocol extends BaseProtocol { public Mta6Protocol() { diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index bc8d95551..aea6cbddc 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -36,6 +31,12 @@ import org.traccar.helper.Log; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class Mta6ProtocolDecoder extends BaseProtocolDecoder { private final boolean simple; @@ -55,7 +56,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { HttpResponse response = new DefaultHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.OK); - ChannelBuffer begin = ChannelBuffers.copiedBuffer("#ACK#", Charset.defaultCharset()); + ChannelBuffer begin = ChannelBuffers.copiedBuffer("#ACK#", StandardCharsets.US_ASCII); ChannelBuffer end = ChannelBuffers.directBuffer(3); end.writeByte(packetId); end.writeByte(packetCount); @@ -282,7 +283,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes("id=".length()); int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '&'); - String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), Charset.defaultCharset()); + String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), StandardCharsets.US_ASCII); if (!identify(uniqueId, channel, remoteAddress)) { return null; } diff --git a/src/org/traccar/protocol/MtxProtocolDecoder.java b/src/org/traccar/protocol/MtxProtocolDecoder.java index 37a384be9..b524c23bb 100644 --- a/src/org/traccar/protocol/MtxProtocolDecoder.java +++ b/src/org/traccar/protocol/MtxProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class MtxProtocolDecoder extends BaseProtocolDecoder { public MtxProtocolDecoder(MtxProtocol protocol) { diff --git a/src/org/traccar/protocol/MxtFrameDecoder.java b/src/org/traccar/protocol/MxtFrameDecoder.java index 92723ec16..cb1d8ed8e 100644 --- a/src/org/traccar/protocol/MxtFrameDecoder.java +++ b/src/org/traccar/protocol/MxtFrameDecoder.java @@ -15,13 +15,14 @@ */ package org.traccar.protocol; -import java.nio.ByteOrder; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; +import java.nio.ByteOrder; + public class MxtFrameDecoder extends FrameDecoder { @Override diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index 53d5b8b09..600be753d 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -25,6 +24,8 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class MxtProtocolDecoder extends BaseProtocolDecoder { public MxtProtocolDecoder(MxtProtocol protocol) { diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java index 5b1d67a45..22ae7ddee 100644 --- a/src/org/traccar/protocol/NavigilProtocolDecoder.java +++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.util.Date; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -28,6 +25,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.util.Date; + public class NavigilProtocolDecoder extends BaseProtocolDecoder { public NavigilProtocolDecoder(NavigilProtocol protocol) { diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 0d740298d..06af49893 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,13 +25,17 @@ import org.traccar.helper.Log; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; + public class NavisProtocolDecoder extends BaseProtocolDecoder { private String prefix; private long deviceUniqueId, serverId; - private static final Charset CHARSET = Charset.defaultCharset(); - public NavisProtocolDecoder(NavisProtocol protocol) { super(protocol); } @@ -183,7 +182,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { ParseResult result = parsePosition(buf); ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8); - response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*> params = decoder.getParameters(); if (params.isEmpty()) { decoder = new QueryStringDecoder( - request.getContent().toString(Charset.defaultCharset()), false); + request.getContent().toString(StandardCharsets.US_ASCII), false); params = decoder.getParameters(); } diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java index 9cd2c1dc1..b191d2d1f 100644 --- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java +++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java @@ -15,12 +15,6 @@ */ package org.traccar.protocol; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.net.SocketAddress; -import java.util.LinkedList; -import java.util.List; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,13 +24,18 @@ import org.jboss.netty.handler.codec.http.HttpResponse; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpVersion; import org.jboss.netty.handler.codec.http.QueryStringDecoder; - import org.traccar.BaseProtocolDecoder; import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; + public class PiligrimProtocolDecoder extends BaseProtocolDecoder { public PiligrimProtocolDecoder(PiligrimProtocol protocol) { @@ -48,7 +47,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { HttpResponse response = new DefaultHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.OK); response.setContent(ChannelBuffers.copiedBuffer( - ByteOrder.BIG_ENDIAN, message, Charset.defaultCharset())); + ByteOrder.BIG_ENDIAN, message, StandardCharsets.US_ASCII)); channel.write(response); } } diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index eead2b4bb..e45cf313c 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -15,12 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +23,13 @@ import org.traccar.helper.BitUtil; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.ByteOrder; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class ProgressProtocolDecoder extends BaseProtocolDecoder { private long lastIndex; @@ -77,7 +78,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { length = buf.readUnsignedShort(); buf.skipBytes(length); length = buf.readUnsignedShort(); - String imei = buf.readBytes(length).toString(Charset.defaultCharset()); + String imei = buf.readBytes(length).toString(StandardCharsets.US_ASCII); identify(imei, channel, remoteAddress); } else if (hasDeviceId() && (type == MSG_POINT || type == MSG_ALARM || type == MSG_LOGMSG)) { @@ -135,7 +136,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { if (BitUtil.check(extraFlags, 1)) { int size = buf.readUnsignedShort(); - position.set("can", buf.toString(buf.readerIndex(), size, Charset.defaultCharset())); + position.set("can", buf.toString(buf.readerIndex(), size, StandardCharsets.US_ASCII)); buf.skipBytes(size); } diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java index d0476d66b..146e3f0a4 100644 --- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -24,6 +22,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { public Pt3000ProtocolDecoder(Pt3000Protocol protocol) { diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index faca2a620..5a1a97056 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -16,8 +16,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Pt502ProtocolDecoder extends BaseProtocolDecoder { public Pt502ProtocolDecoder(Pt502Protocol protocol) { diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java index 1b95bb8f6..5db126a83 100644 --- a/src/org/traccar/protocol/RitiProtocolDecoder.java +++ b/src/org/traccar/protocol/RitiProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -27,6 +24,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.regex.Pattern; + public class RitiProtocolDecoder extends BaseProtocolDecoder { public RitiProtocolDecoder(RitiProtocol protocol) { @@ -76,7 +77,7 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { // Parse GPRMC int end = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); - String gprmc = buf.toString(buf.readerIndex(), end - buf.readerIndex(), Charset.defaultCharset()); + String gprmc = buf.toString(buf.readerIndex(), end - buf.readerIndex(), StandardCharsets.US_ASCII); Parser parser = new Parser(PATTERN, gprmc); if (!parser.matches()) { return null; diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java index 3bb8ad1f4..ef54bdd19 100644 --- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -15,10 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -27,6 +23,11 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class RuptelaProtocolDecoder extends BaseProtocolDecoder { public RuptelaProtocolDecoder(RuptelaProtocol protocol) { diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java index 2adefcf3a..156e730a9 100644 --- a/src/org/traccar/protocol/SanavProtocolDecoder.java +++ b/src/org/traccar/protocol/SanavProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -24,6 +22,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class SanavProtocolDecoder extends BaseProtocolDecoder { public SanavProtocolDecoder(SanavProtocol protocol) { diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index 262bafa6e..087dc8841 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; @@ -27,6 +25,9 @@ import org.traccar.helper.Log; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; + public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { private final long defaultMask; @@ -75,10 +76,10 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { String id; if (BitUtil.check(mask, 23)) { - id = buf.toString(buf.readerIndex(), 8, Charset.defaultCharset()).trim(); + id = buf.toString(buf.readerIndex(), 8, StandardCharsets.US_ASCII).trim(); buf.skipBytes(8); } else if (BitUtil.check(mask, 2)) { - id = buf.toString(buf.readerIndex(), 22, Charset.defaultCharset()).trim(); + id = buf.toString(buf.readerIndex(), 22, StandardCharsets.US_ASCII).trim(); buf.skipBytes(22); } else { Log.warning("No device id field"); diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java index e85831b5d..59a76e4b2 100644 --- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java +++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Stl060ProtocolDecoder extends BaseProtocolDecoder { public Stl060ProtocolDecoder(Stl060Protocol protocol) { diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 89c8b2ebd..0203f8277 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class SuntechProtocolDecoder extends BaseProtocolDecoder { public SuntechProtocolDecoder(SuntechProtocol protocol) { diff --git a/src/org/traccar/protocol/SupermateProtocolDecoder.java b/src/org/traccar/protocol/SupermateProtocolDecoder.java index af0b1ac8e..cc02c8615 100755 --- a/src/org/traccar/protocol/SupermateProtocolDecoder.java +++ b/src/org/traccar/protocol/SupermateProtocolDecoder.java @@ -25,7 +25,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.regex.Pattern; @@ -116,7 +116,7 @@ public class SupermateProtocolDecoder extends BaseProtocolDecoder { String content = String.format("#1:%s:1:*,00000000,UP,%02x%02x%02x,%02x%02x%02x#", imei, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); - channel.write(ChannelBuffers.copiedBuffer(content, Charset.defaultCharset())); + channel.write(ChannelBuffers.copiedBuffer(content, StandardCharsets.US_ASCII)); } return position; diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index a71ef6b33..e4d94b0aa 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.socket.DatagramChannel; import org.traccar.BaseProtocolDecoder; @@ -27,6 +24,10 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; +import java.util.regex.Pattern; + public class T55ProtocolDecoder extends BaseProtocolDecoder { public T55ProtocolDecoder(T55Protocol protocol) { diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java index 3611544d5..3e1529338 100644 --- a/src/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/org/traccar/protocol/TaipProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.Date; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -28,6 +25,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.Date; +import java.util.regex.Pattern; + public class TaipProtocolDecoder extends BaseProtocolDecoder { private final boolean sendResponse; diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java index ba6d9c47e..0399271d6 100644 --- a/src/org/traccar/protocol/TelicProtocolDecoder.java +++ b/src/org/traccar/protocol/TelicProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class TelicProtocolDecoder extends BaseProtocolDecoder { public TelicProtocolDecoder(TelicProtocol protocol) { diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index f8266d076..f4c5c6932 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +24,12 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { public TeltonikaProtocolDecoder(TeltonikaProtocol protocol) { @@ -38,7 +39,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { private void parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) { int length = buf.readUnsignedShort(); - String imei = buf.toString(buf.readerIndex(), length, Charset.defaultCharset()); + String imei = buf.toString(buf.readerIndex(), length, StandardCharsets.US_ASCII); boolean result = identify(imei, channel, remoteAddress); if (channel != null) { diff --git a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java index 678f96f2a..ed8cd827a 100644 --- a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java +++ b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java @@ -24,7 +24,7 @@ import org.traccar.model.Event; import org.traccar.model.Position; import java.net.SocketAddress; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Date; public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder { @@ -63,7 +63,7 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder { int command = buf.readUnsignedByte(); // 0x00 - heartbeat if (command == 0x01) { - String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset()); + String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII); if (identify(imei, channel, remoteAddress) && channel != null) { ChannelBuffer response = ChannelBuffers.dynamicBuffer(); response.writeByte(0x48); response.writeByte(0x52); // header diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java index 70ee9bd84..8323d6a3d 100644 --- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -24,6 +22,9 @@ import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Tk102ProtocolDecoder extends BaseProtocolDecoder { public Tk102ProtocolDecoder(Tk102Protocol protocol) { diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 322ec9747..760b089de 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; @@ -28,6 +26,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Tk103ProtocolDecoder extends BaseProtocolDecoder { public Tk103ProtocolDecoder(Tk103Protocol protocol) { diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java index 802b00f1f..f78dbd5eb 100644 --- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -15,10 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -27,6 +23,11 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Pattern; + public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { public Tlt2hProtocolDecoder(Tlt2hProtocol protocol) { diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java index 231d71f24..7333c4c86 100644 --- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java +++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java @@ -15,17 +15,16 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; - import org.jboss.netty.channel.Channel; - import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class TopflytechProtocolDecoder extends BaseProtocolDecoder { public TopflytechProtocolDecoder(TopflytechProtocol protocol) { diff --git a/src/org/traccar/protocol/TotemFrameDecoder.java b/src/org/traccar/protocol/TotemFrameDecoder.java index 83c328173..374161758 100644 --- a/src/org/traccar/protocol/TotemFrameDecoder.java +++ b/src/org/traccar/protocol/TotemFrameDecoder.java @@ -15,13 +15,14 @@ */ package org.traccar.protocol; -import java.nio.charset.Charset; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.traccar.helper.StringFinder; +import java.nio.charset.StandardCharsets; + public class TotemFrameDecoder extends FrameDecoder { @Override @@ -43,9 +44,9 @@ public class TotemFrameDecoder extends FrameDecoder { int flagIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("AA")); if (flagIndex != -1 && flagIndex - beginIndex == 6) { - length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 4, Charset.defaultCharset())); + length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 4, StandardCharsets.US_ASCII)); } else { - length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 2, Charset.defaultCharset()), 16); + length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 2, StandardCharsets.US_ASCII), 16); } if (length <= buf.readableBytes()) { diff --git a/src/org/traccar/protocol/TotemProtocol.java b/src/org/traccar/protocol/TotemProtocol.java index 4d7f0a135..e573adcc6 100644 --- a/src/org/traccar/protocol/TotemProtocol.java +++ b/src/org/traccar/protocol/TotemProtocol.java @@ -18,12 +18,12 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; +import org.traccar.model.Command; import java.util.List; -import org.jboss.netty.handler.codec.string.StringEncoder; -import org.traccar.model.Command; public class TotemProtocol extends BaseProtocol { diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index bb72c2d64..95cb37138 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class TotemProtocolDecoder extends BaseProtocolDecoder { public TotemProtocolDecoder(TotemProtocol protocol) { diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java index 338c0533d..de16fafb6 100644 --- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Tr20ProtocolDecoder extends BaseProtocolDecoder { public Tr20ProtocolDecoder(Tr20Protocol protocol) { diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java index b3500d552..8e96df2bf 100644 --- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Tr900ProtocolDecoder extends BaseProtocolDecoder { public Tr900ProtocolDecoder(Tr900Protocol protocol) { diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java index f220972ad..63249e25e 100644 --- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java +++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class TrackboxProtocolDecoder extends BaseProtocolDecoder { public TrackboxProtocolDecoder(TrackboxProtocol protocol) { diff --git a/src/org/traccar/protocol/TramigoFrameDecoder.java b/src/org/traccar/protocol/TramigoFrameDecoder.java index aeeb4152c..4178fba8d 100644 --- a/src/org/traccar/protocol/TramigoFrameDecoder.java +++ b/src/org/traccar/protocol/TramigoFrameDecoder.java @@ -15,13 +15,14 @@ */ package org.traccar.protocol; -import java.nio.ByteOrder; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; +import java.nio.ByteOrder; + public class TramigoFrameDecoder extends LengthFieldBasedFrameDecoder { public TramigoFrameDecoder() { diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java index 1fd427ecf..6291ece14 100644 --- a/src/org/traccar/protocol/TramigoProtocolDecoder.java +++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java @@ -15,15 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -33,6 +24,16 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class TramigoProtocolDecoder extends BaseProtocolDecoder { public TramigoProtocolDecoder(TramigoProtocol protocol) { @@ -101,10 +102,10 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder { } else if (protocol == 0x80) { if (channel != null) { - channel.write(ChannelBuffers.copiedBuffer("gprs,ack," + index, Charset.defaultCharset())); + channel.write(ChannelBuffers.copiedBuffer("gprs,ack," + index, StandardCharsets.US_ASCII)); } - String sentence = buf.toString(Charset.defaultCharset()); + String sentence = buf.toString(StandardCharsets.US_ASCII); Pattern pattern = Pattern.compile("(-?\\d+\\.\\d+), (-?\\d+\\.\\d+)"); Matcher matcher = pattern.matcher(sentence); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 40861bacb..a30bd6763 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -15,12 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -30,6 +24,12 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + public class TytanProtocolDecoder extends BaseProtocolDecoder { public TytanProtocolDecoder(TytanProtocol protocol) { @@ -132,7 +132,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { ChannelBuffer response = ChannelBuffers.copiedBuffer( - "^" + index, Charset.defaultCharset()); + "^" + index, StandardCharsets.US_ASCII); channel.write(response, remoteAddress); } diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java index 79c73d418..2d98e3f79 100644 --- a/src/org/traccar/protocol/TzoneProtocol.java +++ b/src/org/traccar/protocol/TzoneProtocol.java @@ -15,13 +15,14 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; +import java.util.List; + public class TzoneProtocol extends BaseProtocol { public TzoneProtocol() { diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java index eb08664e5..01e42964d 100644 --- a/src/org/traccar/protocol/TzoneProtocolDecoder.java +++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -25,6 +24,8 @@ import org.traccar.helper.DateBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; + public class TzoneProtocolDecoder extends BaseProtocolDecoder { public TzoneProtocolDecoder(TzoneProtocol protocol) { diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index efa63bee2..60d8ba52d 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -15,9 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.nio.charset.Charset; -import java.util.Date; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -29,6 +26,10 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Date; + public class UlbotechProtocolDecoder extends BaseProtocolDecoder { private final long timeZone; @@ -204,11 +205,11 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { break; case DATA_VIN: - position.set(Event.KEY_VIN, buf.readBytes(length).toString(Charset.defaultCharset())); + position.set(Event.KEY_VIN, buf.readBytes(length).toString(StandardCharsets.US_ASCII)); break; case DATA_RFID: - position.set(Event.KEY_RFID, buf.readBytes(length - 1).toString(Charset.defaultCharset())); + position.set(Event.KEY_RFID, buf.readBytes(length - 1).toString(StandardCharsets.US_ASCII)); position.set("authorized", buf.readUnsignedByte() != 0); break; diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java index 3ba6c8f0e..aa1ae83fb 100644 --- a/src/org/traccar/protocol/V680ProtocolDecoder.java +++ b/src/org/traccar/protocol/V680ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class V680ProtocolDecoder extends BaseProtocolDecoder { public V680ProtocolDecoder(V680Protocol protocol) { diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index e4c9656f7..63f43fda8 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class VisiontekProtocolDecoder extends BaseProtocolDecoder { public VisiontekProtocolDecoder(VisiontekProtocol protocol) { diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java index b31c2e076..3e7f198ff 100644 --- a/src/org/traccar/protocol/WatchProtocolEncoder.java +++ b/src/org/traccar/protocol/WatchProtocolEncoder.java @@ -20,9 +20,7 @@ import org.traccar.helper.Log; import org.traccar.model.Command; import javax.xml.bind.DatatypeConverter; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index bfaa19954..bf6857ee9 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -15,11 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -28,6 +23,12 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class WialonProtocolDecoder extends BaseProtocolDecoder { public WialonProtocolDecoder(WialonProtocol protocol) { diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index f2c617898..def878727 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class WondexProtocolDecoder extends BaseProtocolDecoder { public WondexProtocolDecoder(WondexProtocol protocol) { diff --git a/src/org/traccar/protocol/XexunProtocol.java b/src/org/traccar/protocol/XexunProtocol.java index ea3ed8c10..f99a3a9ee 100644 --- a/src/org/traccar/protocol/XexunProtocol.java +++ b/src/org/traccar/protocol/XexunProtocol.java @@ -15,7 +15,6 @@ */ package org.traccar.protocol; -import java.util.List; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder; @@ -24,6 +23,8 @@ import org.traccar.BaseProtocol; import org.traccar.Context; import org.traccar.TrackerServer; +import java.util.List; + public class XexunProtocol extends BaseProtocol { public XexunProtocol() { diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 4d4831a20..3a1005f09 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class XexunProtocolDecoder extends BaseProtocolDecoder { private final boolean full; diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index 0f6ad50ba..38a14ffcf 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class XirgoProtocolDecoder extends BaseProtocolDecoder { public XirgoProtocolDecoder(XirgoProtocol protocol) { diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java index b5e20d92e..45897b4aa 100644 --- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -26,6 +24,9 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class Xt013ProtocolDecoder extends BaseProtocolDecoder { public Xt013ProtocolDecoder(Xt013Protocol protocol) { diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java index 2977e3cf8..384fe1184 100644 --- a/src/org/traccar/protocol/YwtProtocolDecoder.java +++ b/src/org/traccar/protocol/YwtProtocolDecoder.java @@ -15,8 +15,6 @@ */ package org.traccar.protocol; -import java.net.SocketAddress; -import java.util.regex.Pattern; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.helper.DateBuilder; @@ -25,6 +23,9 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.Event; import org.traccar.model.Position; +import java.net.SocketAddress; +import java.util.regex.Pattern; + public class YwtProtocolDecoder extends BaseProtocolDecoder { public YwtProtocolDecoder(YwtProtocol protocol) { diff --git a/src/org/traccar/web/JsonConverter.java b/src/org/traccar/web/JsonConverter.java index d018de101..4b7719fd2 100644 --- a/src/org/traccar/web/JsonConverter.java +++ b/src/org/traccar/web/JsonConverter.java @@ -15,6 +15,19 @@ */ package org.traccar.web; +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; +import org.traccar.helper.Log; +import org.traccar.model.MiscFormatter; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; +import javax.json.JsonReader; +import javax.json.JsonValue; import java.beans.Introspector; import java.io.Reader; import java.lang.reflect.InvocationTargetException; @@ -23,19 +36,6 @@ import java.text.ParseException; import java.util.Collection; import java.util.Date; import java.util.Map; -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonReader; -import javax.json.JsonValue; - -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; -import org.traccar.helper.Log; -import org.traccar.model.MiscFormatter; public final class JsonConverter { diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index dc933aa00..fc78dce65 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -15,13 +15,6 @@ */ package org.traccar.web; -import java.io.IOException; -import java.io.Writer; -import java.net.InetSocketAddress; -import javax.naming.InitialContext; -import javax.servlet.http.HttpServletRequest; -import javax.sql.DataSource; - import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.SessionManager; @@ -42,8 +35,8 @@ import org.traccar.api.ObjectMapperProvider; import org.traccar.api.ResourceErrorHandler; import org.traccar.api.SecurityRequestFilter; import org.traccar.api.resource.CommandResource; -import org.traccar.api.resource.DeviceResource; import org.traccar.api.resource.DevicePermissionResource; +import org.traccar.api.resource.DeviceResource; import org.traccar.api.resource.GroupPermissionResource; import org.traccar.api.resource.GroupResource; import org.traccar.api.resource.PositionResource; @@ -52,6 +45,13 @@ import org.traccar.api.resource.SessionResource; import org.traccar.api.resource.UserResource; import org.traccar.helper.Log; +import javax.naming.InitialContext; +import javax.servlet.http.HttpServletRequest; +import javax.sql.DataSource; +import java.io.IOException; +import java.io.Writer; +import java.net.InetSocketAddress; + public class WebServer { private Server server; diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 2f5f3962f..a8f3d13cf 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -15,6 +15,7 @@ import org.traccar.model.Position; import javax.xml.bind.DatatypeConverter; import java.nio.ByteOrder; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -87,7 +88,7 @@ public class ProtocolTest { } protected ChannelBuffer buffer(String... data) { - return ChannelBuffers.copiedBuffer(concatenateStrings(data), Charset.defaultCharset()); + return ChannelBuffers.copiedBuffer(concatenateStrings(data), StandardCharsets.US_ASCII); } protected DefaultHttpRequest request(String url) { diff --git a/test/org/traccar/helper/ChecksumTest.java b/test/org/traccar/helper/ChecksumTest.java index a2e69eb5a..82bae7346 100644 --- a/test/org/traccar/helper/ChecksumTest.java +++ b/test/org/traccar/helper/ChecksumTest.java @@ -6,12 +6,13 @@ import org.junit.Assert; import org.junit.Test; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class ChecksumTest { @Test public void testCrc16() { - ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", Charset.defaultCharset()); + ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", StandardCharsets.US_ASCII); Assert.assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer())); Assert.assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer())); diff --git a/test/org/traccar/helper/StringFinderTest.java b/test/org/traccar/helper/StringFinderTest.java index 71f9215db..1c8234db1 100644 --- a/test/org/traccar/helper/StringFinderTest.java +++ b/test/org/traccar/helper/StringFinderTest.java @@ -8,6 +8,7 @@ import org.junit.Assert; import org.junit.Test; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -17,7 +18,7 @@ public class StringFinderTest { @Test public void testFind() { - ChannelBuffer buf = ChannelBuffers.copiedBuffer("hello world", Charset.defaultCharset()); + ChannelBuffer buf = ChannelBuffers.copiedBuffer("hello world", StandardCharsets.US_ASCII); Assert.assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("bar"))); Assert.assertEquals(6, buf.indexOf(0, buf.writerIndex(), new StringFinder("world"))); diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java index 3969e8b2c..b95d8ddce 100644 --- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java @@ -32,10 +32,10 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest { "(3120820029,W01,02553.3555,E,2438.0997,S,A,171012,053339,0,8,20,6,31,5,20,20)")); /*verifyPosition(decoder, text( ChannelBuffers.copiedBuffer( - "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206)", Charset.defaultCharset()))); + "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206)", StandardCharsets.US_ASCII))); verifyPosition(decoder, text( ChannelBuffers.copiedBuffer( - "(6221107674,2,U09,129,2,A,280513113036,E,02711.0500,S,1721.0876,A,030613171243,E,02756.7618,S,2300.0325,3491,538200,14400,1)", Charset.defaultCharset())));*/ + "(6221107674,2,U09,129,2,A,280513113036,E,02711.0500,S,1721.0876,A,030613171243,E,02756.7618,S,2300.0325,3491,538200,14400,1)",StandardCharsets.US_ASCII))));*/ } -- cgit v1.2.3 From 17b8b50bfef6412cc41c08721aaf4a5e3a42eea7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 13:30:24 +1200 Subject: Use string buffer for concatenation --- src/org/traccar/protocol/H02ProtocolEncoder.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/org/traccar/protocol/H02ProtocolEncoder.java b/src/org/traccar/protocol/H02ProtocolEncoder.java index 948495b61..4045b46d4 100644 --- a/src/org/traccar/protocol/H02ProtocolEncoder.java +++ b/src/org/traccar/protocol/H02ProtocolEncoder.java @@ -1,5 +1,6 @@ /* * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) + * 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. @@ -27,16 +28,16 @@ public class H02ProtocolEncoder extends StringProtocolEncoder { private Object formatCommand(DateTime time, String uniqueId, String type, String... params) { - String result = String.format("*%s,%s,%s,%02d%02d%02d", - MARKER, uniqueId, type, time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute()); + StringBuilder result = new StringBuilder(String.format("*%s,%s,%s,%02d%02d%02d", + MARKER, uniqueId, type, time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute())); for (String param : params) { - result += "," + param; + result.append(",").append(param); } - result += "#"; + result.append("#"); - return result; + return result.toString(); } protected Object encodeCommand(Command command, DateTime time) { -- cgit v1.2.3 From 852343a73b52d3e2c924f1803a0fa2d3ca8443de Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 21:48:55 +1200 Subject: Update list of supported watch commands --- src/org/traccar/protocol/WatchProtocol.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/WatchProtocol.java b/src/org/traccar/protocol/WatchProtocol.java index 05308a7e2..325137c47 100644 --- a/src/org/traccar/protocol/WatchProtocol.java +++ b/src/org/traccar/protocol/WatchProtocol.java @@ -31,7 +31,15 @@ public class WatchProtocol extends BaseProtocol { public WatchProtocol() { super("watch"); setSupportedCommands( - Command.TYPE_REBOOT_DEVICE); + Command.TYPE_SOS_NUMBER, + Command.TYPE_ALARM_SOS, + Command.TYPE_ALARM_BATTERY, + Command.TYPE_REBOOT_DEVICE, + Command.TYPE_ALARM_REMOVE, + Command.TYPE_SILENCE_TIME, + Command.TYPE_ALARM_CLOCK, + Command.TYPE_SET_PHONEBOOK, + Command.TYPE_VOICE_MESSAGE); } @Override -- cgit v1.2.3 From 59f466092c9c875c2bbcb70a2a402aad0edd7639 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 May 2016 23:16:14 +1200 Subject: Decode Astra reason and status --- src/org/traccar/protocol/AstraProtocolDecoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index d19b68761..8f40abedf 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -78,8 +78,9 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { position.setCourse(buf.readUnsignedByte() * 2); int reason = buf.readUnsignedMedium(); - buf.readUnsignedShort(); // status + position.set(Event.KEY_EVENT, reason); + position.set(Event.KEY_STATUS, buf.readUnsignedShort()); position.set(Event.PREFIX_IO + 1, buf.readUnsignedByte()); position.set(Event.PREFIX_ADC + 1, buf.readUnsignedByte()); position.set(Event.KEY_BATTERY, buf.readUnsignedByte()); -- cgit v1.2.3