remove /derived part from poster file name

parent 4f4f11dc
......@@ -27,19 +27,19 @@ object FileUtils {
val rootPath = "/data"
def createVideoFile(id: String, mimeType: MimeType): String =
s"$rootPath/$id.${getFileTypeExtension(mimeType).get}"
val videoFilePath: (String, MimeType) => String =
(id, mimeType) => s"$rootPath/$id.${getFileTypeExtension(mimeType).get}"
def createVideoPosterFile(id: String): String =
s"$rootPath/$id-poster.jp2"
val videoPosterPath: String => String =
id => s"$rootPath/${id.replace("/derived", "")}-poster.jp2"
def createAudioFile(id: String): String =
s"$rootPath/$id.mp4"
val audioFilePath: String => String =
id => s"$rootPath/$id.mp4"
def createAudioSnippetFile(id: String): String =
s"$rootPath/$id-intro.mp3"
val audioSnippetPath: String => String =
id => s"$rootPath/$id-intro.mp3"
def createImageFile(id: String): String =
s"$rootPath/$id.jp2"
val imageFilePath: String => String =
id => s"$rootPath/$id.jp2"
}
......@@ -89,19 +89,19 @@ class RecordProcessor(fileHandler: DisseminationCopyHandler,
mimeType: MimeType,
instantiationType: Instantiation): List[ProcessOutcome] = mimeType match {
case _: AudioFile =>
List(createAudioFile(id), createAudioSnippetFile(id))
List(audioFilePath(id), audioSnippetPath(id))
.map(path => (fileHandler.deleteAudioCopy(path), path))
.flatMap(x => deleteOutcome(x._1, id, x._2))
case mT: VideoFile =>
val destFile = createVideoFile(id, mT)
val destFile = videoFilePath(id, mT)
val res = fileHandler.deleteVideoCopy(destFile)
deleteOutcome(res, id, destFile)
case _: ImageFile if instantiationType == DigitalObject =>
val destFile = createImageFile(id)
val destFile = imageFilePath(id)
val res = fileHandler.deleteImageCopy(destFile)
deleteOutcome(res, id, destFile)
case _: ImageFile if instantiationType == Thumbnail =>
val destFile = createVideoPosterFile(id)
val destFile = videoPosterPath(id)
val res = fileHandler.deleteImageCopy(destFile)
deleteOutcome(res, id, destFile)
}
......@@ -111,19 +111,19 @@ class RecordProcessor(fileHandler: DisseminationCopyHandler,
instantiationType: Instantiation,
data: ByteArrayOutputStream): List[ProcessOutcome] = mimeType match {
case mT: AudioFile =>
List((createAudioFile(id), false), (createAudioSnippetFile(id), true))
List((audioFilePath(id), false), (audioSnippetPath(id), true))
.map(path => (fileHandler.createAudioCopy(data, path._1, mT, path._2), path._1))
.flatMap(x => createOutcome(x._1, id, x._2))
case mT: VideoFile =>
val destFile = createVideoFile(id, mT)
val destFile = videoFilePath(id, mT)
val res = fileHandler.createVideoCopy(data, destFile, mT)
createOutcome(res, id, destFile)
case mT: ImageFile if instantiationType == DigitalObject =>
val destFile = createImageFile(id)
val destFile = imageFilePath(id)
val res = fileHandler.createImageCopy(data, destFile, mT)
createOutcome(res, id, destFile)
case mT: ImageFile if instantiationType == Thumbnail =>
val destFile = createVideoPosterFile(id)
val destFile = videoPosterPath(id)
val res = fileHandler.createImageCopy(data, destFile, mT)
createOutcome(res, id, destFile)
}
......
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