@@ -7,6 +7,8 @@ import no.nav.klage.document.repositories.CommentRepository
77import no.nav.klage.document.repositories.DocumentRepository
88import no.nav.klage.document.repositories.DocumentVersionRepository
99import no.nav.klage.document.util.TokenUtil
10+ import no.nav.klage.document.util.getLogger
11+ import no.nav.klage.document.util.getSecureLogger
1012import org.springframework.stereotype.Service
1113import org.springframework.transaction.annotation.Transactional
1214import java.time.LocalDateTime
@@ -21,6 +23,12 @@ class DocumentService(
2123 private val tokenUtil : TokenUtil ,
2224) {
2325
26+ companion object {
27+ @Suppress(" JAVA_CLASS_ON_COMPANION" )
28+ private val logger = getLogger(javaClass.enclosingClass)
29+ private val secureLogger = getSecureLogger()
30+ }
31+
2432 fun createDocument (json : String ): DocumentVersion {
2533 val now = LocalDateTime .now()
2634
@@ -43,9 +51,14 @@ class DocumentService(
4351 )
4452 }
4553
46- fun updateDocument (documentId : UUID , json : String ): DocumentVersion {
54+ fun updateDocument (documentId : UUID , json : String , currentVersion : Int? ): DocumentVersion {
4755 val now = LocalDateTime .now()
4856 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+
4962 val documentVersion = documentVersionRepository.findByDocumentIdAndVersion(documentId = documentId, version = latestVersionNumber)
5063 return documentVersionRepository.save(
5164 DocumentVersion (
0 commit comments