Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Smelov committed Sep 11, 2023
1 parent 4df3772 commit 25164f6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
16 changes: 6 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import com.github.jk1.license.render.JsonReportRenderer

plugins {
id "com.palantir.docker" version "0.25.0"
id "org.jetbrains.kotlin.jvm" version "${kotlin_version}"
id "org.jetbrains.kotlin.kapt" version "${kotlin_version}"
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
id "org.jetbrains.kotlin.kapt" version "$kotlin_version"
id "application"
id "org.owasp.dependencycheck" version "8.4.0"
id "com.gorylenko.gradle-git-properties" version "2.4.1"
id 'com.github.jk1.dependency-license-report' version "2.5"
id "com.github.jk1.dependency-license-report" version "2.5"
id "de.undercouch.download" version "5.5.0"
}

Expand Down Expand Up @@ -139,18 +139,14 @@ sourceSets {
}

compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
kotlinOptions.jvmTarget = '11'
}

compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
kotlinOptions.jvmTarget = '11'
}

clean {+6
clean {
delete sharedDir
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/com/exactpro/th2/codec/xml/XmlPipelineCodec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.exactpro.th2.common.schema.message.impl.rabbitmq.transport.ParsedMess
import com.exactpro.th2.common.schema.message.impl.rabbitmq.transport.RawMessage
import com.exactpro.th2.common.schema.message.impl.rabbitmq.transport.toByteArray
import com.github.underscore.Xml
import com.google.protobuf.ByteString
import com.google.protobuf.UnsafeByteOperations
import io.netty.buffer.Unpooled
import mu.KotlinLogging
import java.nio.charset.Charset
Expand Down Expand Up @@ -84,33 +84,33 @@ open class XmlPipelineCodec(private val settings: XmlPipelineCodecSettings, xsdM

private fun encodeOne(message: ProtoMessage): ProtoRawMessage {
val map = message.toMap()
val xmlString = Xml.toXml(map)
val xmlStringBuffer = Xml.toXml(map).toByteArray(xmlCharset)

validator.validate(xmlString.toByteArray())
validator.validate(xmlStringBuffer)
LOGGER.debug { "Validation of incoming parsed message complete: ${message.messageType}" }

return ProtoRawMessage.newBuilder().apply {
if (message.hasParentEventId()) parentEventId = message.parentEventId
metadataBuilder.putAllProperties(message.metadata.propertiesMap)
metadataBuilder.protocol = XmlPipelineCodecFactory.PROTOCOL
metadataBuilder.id = message.metadata.id
body = ByteString.copyFrom(xmlString, xmlCharset)
body = UnsafeByteOperations.unsafeWrap(xmlStringBuffer)
}.build()
}

private fun encodeOne(message: ParsedMessage): RawMessage {
val map = message.body
val xmlString = Xml.toXml(map)
val xmlStringBuffer = Xml.toXml(map).toByteArray(xmlCharset)

validator.validate(xmlString.toByteArray())
validator.validate(xmlStringBuffer)
LOGGER.debug { "Validation of incoming parsed message complete: ${message.type}" }

return RawMessage(
id = message.id,
eventId = message.eventId,
metadata = message.metadata,
protocol = XmlPipelineCodecFactory.PROTOCOL,
body = Unpooled.copiedBuffer(xmlString, xmlCharset)
body = Unpooled.wrappedBuffer(xmlStringBuffer)
)
}

Expand Down

0 comments on commit 25164f6

Please sign in to comment.