KafkaMessage.scala 1.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * Extracts media files from Fedora repository
 * Copyright (C) 2020  Memoriav
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

19
package ch.memobase
20
21
22

import spray.json._

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
23
24
25
26
27
28
29
30
31
32

case class KafkaMessage(objectId: String,
                        objectPath: String,
                        objectTypes: Seq[String],
                        eventId: String,
                        eventType: String,
                        eventTimestamp: String) {
  // TODO: Implement real check
  def isBinaryObject: Boolean = objectTypes.contains("https://binaryObject")
}
33
34
35
36


//noinspection TypeAnnotation
object KafkaMessageProtocol extends DefaultJsonProtocol {
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
37
  implicit val kafkaMessageFormat = jsonFormat6(KafkaMessage)
38
39
}

Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
40

41
object KafkaMessageLoader {
Sebastian Schüpbach's avatar
Sebastian Schüpbach committed
42

43
44
45
46
47
48
49
50
  import KafkaMessageProtocol._

  def load(msg: String): KafkaMessage = {
    msg.parseJson.convertTo[KafkaMessage]
  }

}