Skip to content

Commit

Permalink
Revert "feat: save history in all environments"
Browse files Browse the repository at this point in the history
This reverts commit 6427651.
  • Loading branch information
NilsOveTen committed Sep 29, 2023
1 parent 6427651 commit 9ba6dd1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
data class ApplicationProperties(
val collectionBaseUri: String,
val historyServiceUri: String,
val adminServiceUri: String
val adminServiceUri: String,
val namespace: String
)
23 changes: 10 additions & 13 deletions src/main/kotlin/no/fdk/concept_catalog/service/ConceptService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,16 @@ class ConceptService(
return saveConceptsAndUpdateHistory(mapOf(Pair(patched, operations)), user, jwt).first()
}

private fun saveConceptsAndUpdateHistory(
conceptsAndOperations: Map<BegrepDBO, List<JsonPatchOperation>>,
user: User,
jwt: Jwt
): List<Begrep> {
val locations = conceptsAndOperations.map { historyService.updateHistory(it.key, it.value, user, jwt) }
try {
return conceptRepository.saveAll(conceptsAndOperations.keys).map { it.withHighestVersionDTO() }
} catch (ex: Exception) {
locations.filterNotNull().forEach { historyService.removeHistoryUpdate(it, jwt) }
throw ex
}
}
private fun saveConceptsAndUpdateHistory(conceptsAndOperations: Map<BegrepDBO, List<JsonPatchOperation>>, user: User, jwt: Jwt) =
if (applicationProperties.namespace == "staging") {
val locations = conceptsAndOperations.map { historyService.updateHistory(it.key, it.value, user, jwt) }
try {
conceptRepository.saveAll(conceptsAndOperations.keys).map { it.withHighestVersionDTO() }
} catch (ex: Exception) {
locations.filterNotNull().forEach { historyService.removeHistoryUpdate(it, jwt) }
throw ex
}
} else conceptRepository.saveAll(conceptsAndOperations.keys).map { it.withHighestVersionDTO() }

fun isPublishedAndNotValid(concept: Begrep): Boolean {
val published = getLastPublished(concept.originaltBegrep)
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ application:
collectionBaseUri: ${COLLECTION_BASE_URI:https://concept-catalog.fellesdatakatalog.digdir.no}
historyServiceUri: ${CATALOG_HISTORY_SERVICE_URI:http://localhost:9090}
adminServiceUri: ${CATALOG_ADMIN_SERVICE_URI:https://catalog-admin-service.fellesdatakatalog.digdir.no}
namespace: ${NAMESPACE:staging}

---
spring:
Expand Down

0 comments on commit 9ba6dd1

Please sign in to comment.