diff --git a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/ContentMessageType.kt b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/ContentMessageType.kt index b937f4b8..97da6763 100644 --- a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/ContentMessageType.kt +++ b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/ContentMessageType.kt @@ -6,21 +6,21 @@ import agrirouter.technicalmessagetype.Gps * Enum containing all the content message types the AR is supporting. */ @Suppress("unused") -enum class ContentMessageType(private val key: String, private val typeUrl: String, private val needsChunkinng: Boolean, private val needsBase64Encoding: Boolean) : TechnicalMessageType { - ISO_11783_TASKDATA_ZIP("iso:11783:-10:taskdata:zip", "", true, true), - SHP_SHAPE_ZIP("shp:shape:zip", "", true, true), - DOC_PDF("doc:pdf", "", true, true), - IMG_JPEG("img:jpeg", "", true, true), - IMG_PNG("img:png", "", true, true), - IMG_BMP("img:bmp", "", true, true), - VID_AVI("vid:avi", "", true, true), - VID_MP4("vid:mp4", "", true, true), - VID_WMV("vid:wmv", "", true, true), - GPS_INFO("gps:info", Gps.GPSList.getDescriptor().fullName, false, false), +enum class ContentMessageType(private val key: String, private val typeUrl: String, private val needsBase64Encoding: Boolean) : TechnicalMessageType { + ISO_11783_TASKDATA_ZIP("iso:11783:-10:taskdata:zip", "", true), + SHP_SHAPE_ZIP("shp:shape:zip", "", true), + DOC_PDF("doc:pdf", "", true), + IMG_JPEG("img:jpeg", "", true), + IMG_PNG("img:png", "", true), + IMG_BMP("img:bmp", "", true), + VID_AVI("vid:avi", "", true), + VID_MP4("vid:mp4", "", true), + VID_WMV("vid:wmv", "", true), + GPS_INFO("gps:info", Gps.GPSList.getDescriptor().fullName, false), //FIXME Since the spec is not public, we can only use those literals. - ISO_11783_DEVICE_DESCRIPTION("iso:11783:-10:device_description:protobuf", "types.agrirouter.com\\efdi.ISO11783_TaskData", false, false), - ISO_11783_TIME_LOG("iso:11783:-10:time_log:protobuf", "types.agrirouter.com\\efdi.TimeLog", false, false); + ISO_11783_DEVICE_DESCRIPTION("iso:11783:-10:device_description:protobuf", "types.agrirouter.com\\efdi.ISO11783_TaskData", false), + ISO_11783_TIME_LOG("iso:11783:-10:time_log:protobuf", "types.agrirouter.com\\efdi.TimeLog", false); override fun getKey(): String { return key @@ -30,11 +30,7 @@ enum class ContentMessageType(private val key: String, private val typeUrl: Stri return typeUrl } - override fun getNeedsChunking(): Boolean { - return needsChunkinng - } - - override fun getNeedsBase64Encoding(): Boolean { + override fun needsBase64EncodingAndHasToBeChunkedIfNecessary(): Boolean { return needsBase64Encoding } diff --git a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/SystemMessageType.kt b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/SystemMessageType.kt index b6abe0a5..a3f11ecf 100644 --- a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/SystemMessageType.kt +++ b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/SystemMessageType.kt @@ -31,11 +31,7 @@ enum class SystemMessageType(private val key: String, private val typeUrl: Strin return typeUrl } - override fun getNeedsChunking(): Boolean { - return false - } - - override fun getNeedsBase64Encoding(): Boolean { + override fun needsBase64EncodingAndHasToBeChunkedIfNecessary(): Boolean { return false } } diff --git a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/TechnicalMessageType.kt b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/TechnicalMessageType.kt index 181139b6..79f8e7d5 100644 --- a/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/TechnicalMessageType.kt +++ b/agrirouter-sdk-java-api/src/main/kotlin/com/dke/data/agrirouter/api/enums/TechnicalMessageType.kt @@ -15,14 +15,9 @@ interface TechnicalMessageType { */ fun getTypeUrl(): String - /** - * Indicates whether the technical message type needs chunking or not. - */ - fun getNeedsChunking(): Boolean - /** * Indicates whether the technical message type needs base64 encoding or not. */ - fun getNeedsBase64Encoding(): Boolean; + fun needsBase64EncodingAndHasToBeChunkedIfNecessary(): Boolean } diff --git a/agrirouter-sdk-java-impl/src/main/java/com/dke/data/agrirouter/impl/messaging/encoding/EncodeMessageServiceImpl.java b/agrirouter-sdk-java-impl/src/main/java/com/dke/data/agrirouter/impl/messaging/encoding/EncodeMessageServiceImpl.java index 4c0f89d2..27142c7e 100644 --- a/agrirouter-sdk-java-impl/src/main/java/com/dke/data/agrirouter/impl/messaging/encoding/EncodeMessageServiceImpl.java +++ b/agrirouter-sdk-java-impl/src/main/java/com/dke/data/agrirouter/impl/messaging/encoding/EncodeMessageServiceImpl.java @@ -106,7 +106,7 @@ public List chunkAndEncode( messageHeaderParameters.validate(); payloadParameters.validate(); - if (messageHeaderParameters.getTechnicalMessageType().getNeedsChunking()) { + if (messageHeaderParameters.getTechnicalMessageType().needsBase64EncodingAndHasToBeChunkedIfNecessary()) { if (payloadParameters.shouldBeChunked()) { getNativeLogger() .debug( @@ -169,29 +169,11 @@ public List chunkAndEncode( new MessageParameterTuple(messageHeaderParameters, payload)); } } else { - if (messageHeaderParameters.getTechnicalMessageType().getNeedsBase64Encoding()) { - getNativeLogger() - .debug( - "The message type needs to be base64 encoded, therefore we are encoding the raw value."); - final PayloadParameters payload = new PayloadParameters(); - payload.copyFrom(payloadParameters); - payload.setValue( - ByteString.copyFromUtf8( - Base64.getEncoder() - .encodeToString( - payloadParameters - .getValue() - .toStringUtf8() - .getBytes(StandardCharsets.UTF_8)))); - return Collections.singletonList( - new MessageParameterTuple(messageHeaderParameters, payload)); - } else { - getNativeLogger() - .debug( - "The message type does not need base 64 encoding, we are returning the tuple 'as it is'."); - return Collections.singletonList( - new MessageParameterTuple(messageHeaderParameters, payloadParameters)); - } + getNativeLogger() + .debug( + "The message type does not need chunking and base 64 encoding, we are returning the tuple 'as it is'."); + return Collections.singletonList( + new MessageParameterTuple(messageHeaderParameters, payloadParameters)); } } diff --git a/pom.xml b/pom.xml index 5e3f16a6..8c185a92 100644 --- a/pom.xml +++ b/pom.xml @@ -82,7 +82,7 @@ 2.8.6 2.30.1 4.4.13 - 3.11.4 + 3.16.1 2.38.0 1.1.1 1.3.71