Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
XML Data Transform
Commits
41d7f0b2
Commit
41d7f0b2
authored
Aug 05, 2020
by
Jonas Waeber
Browse files
Fix sftp client issues
parent
9d8eb98f
Pipeline
#12329
passed with stages
in 4 minutes and 40 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/KafkaTopology.kt
View file @
41d7f0b2
...
...
@@ -79,7 +79,11 @@ class KafkaTopology(private val settings: SettingsLoader) {
val
transformedValue
=
errorFilter
[
1
]
.
mapValues
{
value
->
sftpClient
.
open
(
File
(
value
.
path
))
}
.
map
{
key
,
value
->
xmlTransformer
.
applyXSLT
(
key
,
value
)
}
.
map
{
key
,
value
->
value
.
use
{
xmlTransformer
.
applyXSLT
(
key
,
value
.
RemoteFileInputStream
())
}
}
streamOutput
(
transformedValue
)
...
...
src/main/kotlin/XMLTransformer.kt
View file @
41d7f0b2
...
...
@@ -17,7 +17,6 @@
*/
package
org.memobase
import
net.schmizz.sshj.sftp.RemoteFile
import
net.sf.saxon.s9api.Processor
import
net.sf.saxon.s9api.SAXDestination
import
net.sf.saxon.s9api.StaticError
...
...
@@ -60,14 +59,12 @@ class XMLTransformer(appSettings: Properties) {
}
}
fun
applyXSLT
(
key
:
String
,
data
:
RemoteFile
):
KeyValue
<
String
,
SAXContentHandler
>
{
fun
applyXSLT
(
key
:
String
,
data
:
InputStream
):
KeyValue
<
String
,
SAXContentHandler
>
{
val
contentHandler
=
SAXContentHandler
(
key
,
identifierFieldName
,
recordTag
)
data
.
use
{
file
->
file
.
RemoteFileInputStream
().
use
{
transformer
.
setSource
(
StreamSource
(
it
))
transformer
.
destination
=
SAXDestination
(
contentHandler
)
transformer
.
transform
()
}
data
.
use
{
stream
->
transformer
.
setSource
(
StreamSource
(
stream
))
transformer
.
destination
=
SAXDestination
(
contentHandler
)
transformer
.
transform
()
}
if
(
contentHandler
.
identifier
.
isEmpty
())
{
throw
Exception
(
"No valid identifier found in record $key in field $identifierFieldName."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment