Commit 7831d2f9 authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

MEMO-637: Only send report per record

parent d55ac68c
......@@ -53,38 +53,32 @@ class Ingester(
val recordOutput = StringWriter()
val recordPair = rdfHandler.getRecord()
recordPair.second.write(recordOutput, "NTRIPLES")
try {
val data = recordOutput.toString()
fedoraClient.createOrUpdateRdfResource(URI(recordPair.first), data, RdfContentTypes.NTRIPLES)
log.info("Ingested record ${recordPair.first}.")
producer.sendReport(
Report(recordPair.first, ReportStatus.success, "Ingested record in fedora.")
)
} catch (ex: FcrepoOperationFailedException) {
log.error("Ingestion of record ${recordPair.first} failed: ${ex.localizedMessage}.")
producer.sendReport(
Report(recordPair.first, ReportStatus.failure, ex.localizedMessage)
)
}
// FIXME: correct for ingest:
// 1 binaries
// 2 instantiations
// 3 records
val data = recordOutput.toString()
log.info("Ingesting record ${recordPair.first}.")
fedoraClient.createOrUpdateRdfResource(URI(recordPair.first), data, RdfContentTypes.NTRIPLES)
log.info("Ingested record ${recordPair.first}.")
// FIXME: extract into separate method
rdfHandler.getInstantiations().forEach { instantiationPair ->
val instantiationOutput = StringWriter()
instantiationPair.second.write(instantiationOutput, "NTRIPLES")
try {
val data = instantiationOutput.toString()
fedoraClient.createOrUpdateRdfResource(URI(instantiationPair.first), data, RdfContentTypes.NTRIPLES)
val instantiationData = instantiationOutput.toString()
log.info("Ingesting instantiation ${instantiationPair.first}.")
fedoraClient.createOrUpdateRdfResource(URI(instantiationPair.first), instantiationData, RdfContentTypes.NTRIPLES)
log.info("Ingested instantiation ${instantiationPair.first}.")
producer.sendReport(
Report(instantiationPair.first, ReportStatus.success, "Ingested an instantiation in fedora.")
)
} catch (ex: FcrepoOperationFailedException) {
log.error("Ingestion of instantiation ${instantiationPair.first} failed: ${ex.localizedMessage}.")
producer.sendReport(
Report(instantiationPair.first, ReportStatus.failure, ex.localizedMessage)
)
throw ex
}
}
// FIXME: extract into separate method
rdfHandler.getSftpLocators().forEach {
val digitalInstantiationUrl = it.first
it.second.let { path ->
......@@ -97,14 +91,9 @@ class Ingester(
}.second
log.info("Ingesting binary $binaryUri with mime type $mimeType.")
fedoraClient.createOrUpdateBinaryResource(URI(binaryUri), stream, mimeType)
producer.sendReport(
Report(binaryUri, ReportStatus.success, "Ingested a binary in fedora.")
)
} catch (ex: FcrepoOperationFailedException) {
log.error("Ingestion of binary $binaryUri failed: ${ex.localizedMessage}.")
producer.sendReport(
Report(binaryUri, ReportStatus.failure, ex.localizedMessage)
)
throw ex
}
}
}
......@@ -129,6 +118,7 @@ class Ingester(
message = ReportMessages.ingestedRecord(record.key())
)
} catch (e: FcrepoOperationFailedException) {
log.error("Ingestion of record ${record.key()} failed: ${e.localizedMessage}.")
Report(
id = record.key(),
status = ReportStatus.failure,
......
......@@ -30,7 +30,6 @@ import org.memobase.sftp.SftpClient
class Service(fileName: String = "app.yml") {
companion object {
const val JOB_REPORT_ID = "fedora-ingest"
const val FEDORA_PROPERTIES_PREFIX = "fedora"
fun createFedoraClient(appSettings: Properties): FedoraClient {
......
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