Skip to content

Commit

Permalink
EbmsAcknowledgment + ebmsmessage tabel
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Petrov <[email protected]>
Co-authored-by: Chris Olsen <[email protected]>
  • Loading branch information
alpet and RettIProd committed Sep 22, 2023
1 parent e65191e commit 61cd5e0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 40 deletions.
96 changes: 56 additions & 40 deletions ebms-provider/src/main/kotlin/no/nav/emottak/ebms/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,70 @@ import no.nav.emottak.ebms.processing.EbmsMessageProcessor
import no.nav.emottak.ebms.xml.xmlMarshaller
import org.xmlsoap.schemas.soap.envelope.Envelope


val processor = EbmsMessageProcessor()
fun main() {

val processor = EbmsMessageProcessor()

val database = Database(mapHikariConfig(DatabaseConfig()))
database.migrate()

embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello, world!")
}
post("/ebms") {
val allParts = call.receiveMultipart().readAllParts()
val dokument = allParts.find {
it.contentType?.toString() == "text/xml" && it.contentDisposition == null
}
val attachments = allParts.filter { it.contentDisposition == ContentDisposition.Attachment}
val dokumentWithAttachment = EbMSDocument("",(dokument as PartData.FormItem).payload(),attachments.map { EbMSAttachment( (it as PartData.FormItem).payload(), it.contentType!!.contentType ,"contentId") })
processor.process(dokumentWithAttachment)
println(dokumentWithAttachment)
embeddedServer(Netty, port = 8080, module = Application::myApplicationModule).start(wait = true)
}

call.respondText("Hello")
}
post("/ebmsTest") {
val allParts = call.receiveMultipart().readAllParts()
val dokument = allParts.find {
it.contentType?.toString() == "text/xml" && it.contentDisposition == null
}
val envelope = xmlMarshaller.unmarshal(String((dokument as PartData.FormItem).payload()), Envelope::class.java)
fun PartData.FormItem.payload() : ByteArray {
return java.util.Base64.getMimeDecoder().decode(this.value)
}

val conversationId = envelope.getConversationId()
println(conversationId)
val attachmentId = envelope.getAttachmentId()
println(attachmentId)
val attachments = allParts
.filter { it.contentDisposition == ContentDisposition.Attachment }
.filter { it.headers.get("Content-Id")?.contains(attachmentId, true) ?: false }
.map { (it as PartData.FormItem).payload() }
.first()
println(
String(attachments)
)
call.respondText("Hello2")
fun Application.myApplicationModule() {
routing {
get("/") {
call.respondText("Hello, world!")
}
post("/ebms") {
val allParts = call.receiveMultipart().readAllParts()
val dokument = allParts.find {
it.contentType?.toString() == "text/xml" && it.contentDisposition == null
}
val attachments = allParts.filter { it.contentDisposition == ContentDisposition.Attachment }
val dokumentWithAttachment = EbMSDocument(
"",
(dokument as PartData.FormItem).payload(),
attachments.map {
EbMSAttachment(
(it as PartData.FormItem).payload(),
it.contentType!!.contentType,
"contentId"
)
})
processor.process(dokumentWithAttachment)
println(dokumentWithAttachment)

call.respondText("Hello")
}
}.start(wait = true)
}

fun PartData.FormItem.payload() : ByteArray {
return java.util.Base64.getMimeDecoder().decode(this.value)

post("/ebmsTest") {
val allParts = call.receiveMultipart().readAllParts()
val dokument = allParts.find {
it.contentType?.toString() == "text/xml" && it.contentDisposition == null
}
val envelope =
xmlMarshaller.unmarshal(String((dokument as PartData.FormItem).payload()), Envelope::class.java)

val conversationId = envelope.getConversationId()
println(conversationId)
val attachmentId = envelope.getAttachmentId()
println(attachmentId)
val attachments = allParts
.filter { it.contentDisposition == ContentDisposition.Attachment }
.filter { it.headers.get("Content-Id")?.contains(attachmentId, true) ?: false }
.map { (it as PartData.FormItem).payload() }
.first()
println(
String(attachments)
)
call.respondText("Hello2")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package no.nav.emottak.ebms.model

import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.Acknowledgment
import org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.MessageHeader

class EbmsAcknowledgment(override val messageHeader: MessageHeader,
val acknowledgment: Acknowledgment) : EbMSBaseMessage {


}
15 changes: 15 additions & 0 deletions ebms-provider/src/main/resources/db/migrations/V1_ebms_message.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE ebms_message
(
cpa_id VARCHAR(256) NOT NULL,
conversation_id VARCHAR(256) NOT NULL,
message_id VARCHAR(256) NOT NULL,
ref_to_message_id VARCHAR(256) NULL,
from_party_id VARCHAR(256) NOT NULL,
from_role VARCHAR(256) NULL,
to_party_id VARCHAR(256) NOT NULL,
to_role VARCHAR(256) NULL,
service VARCHAR(256) NOT NULL,
action VARCHAR(256) NOT NULL,
content TEXT NULL
PRIMARY KEY (message_id,message_nr)
);

0 comments on commit 61cd5e0

Please sign in to comment.