Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public List<MessageParameterTuple> chunkAndEncode(
messageHeaderParameters.validate();
payloadParameters.validate();

if (messageHeaderParameters.getTechnicalMessageType().getNeedsChunking()) {
if (messageHeaderParameters.getTechnicalMessageType().needsBase64EncodingAndHasToBeChunkedIfNecessary()) {
if (payloadParameters.shouldBeChunked()) {
getNativeLogger()
.debug(
Expand Down Expand Up @@ -169,29 +169,11 @@ public List<MessageParameterTuple> 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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<gson.version>2.8.6</gson.version>
<jersey-client.version>2.30.1</jersey-client.version>
<httpcore.version>4.4.13</httpcore.version>
<protobuf.version>3.11.4</protobuf.version>
<protobuf.version>3.16.1</protobuf.version>
<htmlunit.version>2.38.0</htmlunit.version>
<activation.version>1.1.1</activation.version>
<kotlin.version>1.3.71</kotlin.version>
Expand Down