Commit b97ef272 authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

Only return sftp locators from RdfHandler.getSftpLocators

Previsiously this method return a Pair<uri, null> instead filtering
out the specific locator when a locator did not contain a reference
to a binary on the SFTP server.
parent 16c6fddf
Pipeline #22046 passed with stages
in 4 minutes and 23 seconds
......@@ -110,16 +110,14 @@ class RdfHandler(data: String, private val externalBaseUrl: String) {
log.info("Replaced sftp locator with fedora url: $replacementLocator.")
}
fun getSftpLocators(): List<Pair<String, String?>> {
fun getSftpLocators(): List<Pair<String, String>> {
return model.listResourcesWithProperty(RDF.type, RICO.Instantiation).filterKeep {
it.hasProperty(EBUCORE.locator)
it.hasProperty(EBUCORE.locator) && it.getProperty(EBUCORE.locator).`object`.isLiteral
}.filterKeep {
it.getProperty(EBUCORE.locator).`object`.asLiteral().string.startsWith(Service.SFTP_PREFIX)
}.mapWith {
val url = it.getProperty(EBUCORE.locator).`object`.asLiteral().string
if (url.startsWith(Service.SFTP_PREFIX)) {
Pair(it.uri, url.replace(Service.SFTP_PREFIX, ""))
} else {
Pair(it.uri, null)
}
}.toList()
}
......
......@@ -126,7 +126,6 @@ class TestRdfHandler {
}
private val resultPairs: List<Pair<String, String?>> = listOf(
Pair("https://memobase.ch/instantiation/digital/AFZ-IB_Becker_Audiovisuals_63-1", null),
Pair("https://memobase.ch/instantiation/digital/AFZ-IB_Becker_Audiovisuals_63-2", "/path/to/file/filename.jpg")
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment