@@ -7,6 +7,8 @@ import no.nav.klage.document.repositories.CommentRepository
7
7
import no.nav.klage.document.repositories.DocumentRepository
8
8
import no.nav.klage.document.repositories.DocumentVersionRepository
9
9
import no.nav.klage.document.util.TokenUtil
10
+ import no.nav.klage.document.util.getLogger
11
+ import no.nav.klage.document.util.getSecureLogger
10
12
import org.springframework.stereotype.Service
11
13
import org.springframework.transaction.annotation.Transactional
12
14
import java.time.LocalDateTime
@@ -21,6 +23,12 @@ class DocumentService(
21
23
private val tokenUtil : TokenUtil ,
22
24
) {
23
25
26
+ companion object {
27
+ @Suppress(" JAVA_CLASS_ON_COMPANION" )
28
+ private val logger = getLogger(javaClass.enclosingClass)
29
+ private val secureLogger = getSecureLogger()
30
+ }
31
+
24
32
fun createDocument (json : String ): DocumentVersion {
25
33
val now = LocalDateTime .now()
26
34
@@ -43,9 +51,14 @@ class DocumentService(
43
51
)
44
52
}
45
53
46
- fun updateDocument (documentId : UUID , json : String ): DocumentVersion {
54
+ fun updateDocument (documentId : UUID , json : String , currentVersion : Int? ): DocumentVersion {
47
55
val now = LocalDateTime .now()
48
56
val latestVersionNumber = documentVersionRepository.findLatestVersionNumber(documentId = documentId)
57
+
58
+ if (currentVersion != null && latestVersionNumber != currentVersion) {
59
+ logger.warn(" latest version {} does not match clients current version {}" , latestVersionNumber, currentVersion)
60
+ }
61
+
49
62
val documentVersion = documentVersionRepository.findByDocumentIdAndVersion(documentId = documentId, version = latestVersionNumber)
50
63
return documentVersionRepository.save(
51
64
DocumentVersion (
0 commit comments