Unverified Commit 9735720b authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

make reports more verbose about processed resource

parent 4035f3c1
Pipeline #16116 passed with stages
in 12 minutes and 31 seconds
......@@ -68,25 +68,29 @@ object BinaryResourceMetadata {
.withFilter {
v => isDigitalObject(v.obj) || isPreviewImage(v.obj)
}
.map { v => Try (
v.obj match {
case v if isLocalRecord(v, baseUrl) && isProcessableMimeType(v) =>
getEventType(jsonldGraph) match {
case Some(UnknownEvent(e)) => throw new UnknownEventType(s"Event type `$e` not known")
case Some(eventType) =>
val instantiation = Instantiation(v("type").str)
BinaryResourceMetadata(
v("@id").str.substring(s"$baseUrl/digital/".length - 1),
v("locator").str,
if (instantiation == Thumbnail) {JpegFile} else {Conversions.getMediaFileType(v("hasMimeType").str).get},
instantiation,
eventType)
case None => throw new NoEventType
}
case v if isLocalRecord(v, baseUrl) => throw new UnmanageableMediaFileType("Media file type unknown")
case _ => throw new NoLocalBinary
}
.map { v => {
val id = v.obj.getOrElse("@id", Value("<unknown id>")).str
Try (
v.obj match {
case v if isLocalRecord(v, baseUrl) && isProcessableMimeType(v) =>
getEventType(jsonldGraph) match {
case Some(UnknownEvent(e)) => throw new UnknownEventType(s"Event type `$e` for $id not known")
case Some(eventType) =>
val instantiation = Instantiation(v("type").str)
BinaryResourceMetadata(
v("@id").str.substring(s"$baseUrl/digital/".length - 1),
v("locator").str,
if (instantiation == Thumbnail) {JpegFile} else {Conversions.getMediaFileType(v("hasMimeType").str).get},
instantiation,
eventType)
case None => throw new NoEventType(id)
}
case v if isLocalRecord(v, baseUrl) => throw new UnmanageableMediaFileType(s"Media file type for $id unknown")
case _ => throw new NoLocalBinary(id)
}
)
}
}.toList
private def isDigitalObject(obj: ujson.Obj): Boolean = {
......
......@@ -29,9 +29,9 @@ class UnmanageableMediaFileType(msg: String) extends Exception(msg)
class NoDigitalObject extends Exception("No digital object found")
class NoLocalBinary extends Exception("No reference to local binary found")
class NoLocalBinary(id: String) extends Exception(s"No reference to local binary in $id found")
class UnknownEventType(msg: String) extends Exception(msg)
class NoEventType extends Exception("No event type found")
class NoEventType(id: String) extends Exception(s"No event type for $id found")
Markdown is supported
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