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
postprocessing
Fedora Metadata Extractor
Commits
3967501d
Commit
3967501d
authored
Jul 21, 2020
by
Jonas Waeber
Browse files
Added exception handling to fedora client.
parent
8b957776
Pipeline
#11789
passed with stages
in 4 minutes and 45 seconds
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
src/main/kotlin/KafkaTopology.kt
View file @
3967501d
...
...
@@ -33,6 +33,7 @@ import org.apache.kafka.streams.StreamsBuilder
import
org.apache.kafka.streams.Topology
import
org.apache.kafka.streams.kstream.Predicate
import
org.apache.logging.log4j.LogManager
import
org.fcrepo.client.FcrepoOperationFailedException
import
org.memobase.fedora.FedoraClientImpl
import
org.memobase.fedora.RdfResponseTypes
import
org.memobase.model.EventMessage
...
...
@@ -68,7 +69,7 @@ class KafkaTopology(
)
objectBranches
[
0
]
.
m
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
flatM
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
mapValues
{
value
->
parseModel
(
value
)
}
.
mapValues
{
value
->
addEventType
(
value
)
}
.
mapValues
{
value
->
requestAdditionalRecordResources
(
value
)
}
...
...
@@ -77,7 +78,7 @@ class KafkaTopology(
.
to
(
settings
.
outputTopic
+
"-json-records"
)
objectBranches
[
1
]
.
m
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
flatM
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
mapValues
{
value
->
parseModel
(
value
)
}
.
mapValues
{
value
->
addEventType
(
value
)
}
.
mapValues
{
value
->
filterFedoraProperties
(
value
)
}
...
...
@@ -85,7 +86,7 @@ class KafkaTopology(
.
to
(
settings
.
outputTopic
+
"-json-institutions"
)
objectBranches
[
2
]
.
m
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
flatM
apValues
{
value
->
requestPrimaryResource
(
value
)
}
.
mapValues
{
value
->
parseModel
(
value
)
}
.
mapValues
{
value
->
addEventType
(
value
)
}
.
mapValues
{
value
->
filterFedoraProperties
(
value
)
}
...
...
@@ -108,8 +109,17 @@ class KafkaTopology(
}
}
private
fun
requestPrimaryResource
(
message
:
EventMessage
):
Pair
<
EventMessage
,
String
>
{
return
Pair
(
message
,
fedora
.
fetchRdfResourceIntoString
(
URI
.
create
(
message
.
objectPath
),
RdfResponseTypes
.
NTRIPLES
))
private
fun
requestPrimaryResource
(
message
:
EventMessage
):
List
<
Pair
<
EventMessage
,
String
>>
{
return
try
{
listOf
(
Pair
(
message
,
fedora
.
fetchRdfResourceIntoString
(
URI
.
create
(
message
.
objectPath
),
RdfResponseTypes
.
NTRIPLES
)))
}
catch
(
ex
:
FcrepoOperationFailedException
)
{
when
(
ex
.
statusCode
)
{
410
->
log
.
error
(
"Status: ${ex.statusCode} -> The resource at path ${message.objectPath} has been deleted."
)
404
->
log
.
error
(
"Status: ${ex.statusCode} -> No resource found at path ${message.objectPath}."
)
else
->
log
.
error
(
"Status: ${ex.statusCode} -> Unknown Error: ${ex.localizedMessage}."
)
}
emptyList
()
}
}
private
fun
parseModel
(
input
:
Pair
<
EventMessage
,
String
>):
Pair
<
EventMessage
,
Model
>
{
...
...
Write
Preview
Supports
Markdown
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