Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

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

set status ignore if nothing is found

parent 43cde44f
Pipeline #22156 passed with stages
in 3 minutes and 26 seconds
......@@ -18,7 +18,7 @@
package ch.memobase
import ch.memobase.models.{ProcessedRecord, ProcessingFatal, ProcessingSuccess}
import ch.memobase.models.{ProcessedRecord, ProcessingFatal, ProcessingIgnore, ProcessingSuccess}
import org.apache.logging.log4j.scala.Logging
import java.io.File
......@@ -30,6 +30,7 @@ trait BinaryHandler {
self: Logging with AppSettings =>
def deleteBinaries(record: ProcessedRecord): ProcessedRecord = {
if (record.binaries.nonEmpty) {
val result = record.binaries
.map(_.replaceFirst("file://", ""))
.map(fileName => (new File(fileName), fileName))
......@@ -52,5 +53,8 @@ trait BinaryHandler {
logger.warn(s"Deletion of binaries for record ${record.recordId} failed")
record.setBinariesStatus(ProcessingFatal, result.mkString("; "))
}
} else {
record.setBinariesStatus(ProcessingIgnore, "No attached local binaries")
}
}
}
......@@ -18,7 +18,7 @@
package ch.memobase
import ch.memobase.models.{ProcessedRecord, ProcessingFatal, ProcessingIgnore, ProcessingSuccess}
import ch.memobase.models._
import org.apache.logging.log4j.scala.Logging
import java.sql.{Connection, DriverManager}
......@@ -27,13 +27,16 @@ import scala.util.{Failure, Success, Try}
trait MariadbClient {
self: Logging with AppSettings =>
type DeletionResult =
private type DeletionResult =
Try[(Option[String], Boolean, Boolean, Boolean, Boolean)]
private val noRows = Success((None, false, false, false, false))
private var connection = getConnection
private def getConnection: Connection = {
val c = DriverManager.getConnection(mariaDBHost, mariaDBUser, mariaDBPassword)
val c =
DriverManager.getConnection(mariaDBHost, mariaDBUser, mariaDBPassword)
c.setAutoCommit(false)
c
}
......@@ -111,9 +114,11 @@ trait MariadbClient {
ProcessingFatal,
s"Snippet entries deletion failed: ${e.getMessage}"
)
case (`noRows`, `noRows`) =>
record.setThumbnailStatus(ProcessingIgnore, "No thumbnails found")
case (
Success((uri, entities, metadata, manifestV2, manifestV3)),
Success((None, false, false, false, false))
`noRows`
) =>
(if (uri.isDefined && isLocalFile(uri.get)) {
record.addBinary(uri.get)
......@@ -131,7 +136,7 @@ trait MariadbClient {
)
)
case (
Success((None, false, false, false, false)),
`noRows`,
Success((uri, entities, metadata, manifestV2, manifestV3))
) =>
(if (uri.isDefined && isLocalFile(uri.get)) {
......@@ -150,8 +155,10 @@ trait MariadbClient {
)
)
case (_, _) =>
record.setThumbnailStatus(ProcessingIgnore, "No thumbnails found")
// No poster, no snippet
record.setThumbnailStatus(
ProcessingWarning,
"Snippets and posters found. This should not happen!"
)
}
}
......
......@@ -18,17 +18,12 @@
package ch.memobase
import ch.memobase.models.{ProcessedRecord, ProcessingFatal, ProcessingSuccess}
import ch.memobase.models.{ProcessedRecord, ProcessingFatal, ProcessingIgnore, ProcessingSuccess}
import com.sksamuel.elastic4s
import com.sksamuel.elastic4s.ElasticApi.deleteById
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.http.JavaClient
import com.sksamuel.elastic4s.{
ElasticClient,
ElasticProperties,
RequestFailure,
RequestSuccess
}
import com.sksamuel.elastic4s.{ElasticClient, ElasticProperties, RequestFailure, RequestSuccess}
import org.apache.logging.log4j.scala.Logging
import scala.concurrent.ExecutionContext.Implicits.global
......@@ -48,12 +43,19 @@ trait MemobaseElasticClient {
deleteById(esIndex, record.recordId)
}
.map {
case success: RequestSuccess[_] =>
case success: RequestSuccess[_] if success.status < 400 =>
logger.debug(s"Deletion of record ${record.recordId} successful")
record.setRecordStatus(
ProcessingSuccess,
"Record deletion in Elasticsearch successful"
)
case success: RequestSuccess[_] =>
logger.debug(s"Deletion of record ${record.recordId} failed since record does not exists")
record.setRecordStatus(
ProcessingIgnore,
"Record does not exist in Elasticearch"
)
case failure: RequestFailure =>
logger.warn(s"Deletion of record ${record.recordId} failed: ${failure.error.reason}")
record.setRecordStatus(
......
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