Skip to content

Commit

Permalink
🐛 Fix the validator for versioned canonical URL validation. Ignore ex…
Browse files Browse the repository at this point in the history
…isting mata.versionId of resource during initialization because we maintain numeric versions internally and this meta versioning is managed by the resource server.
  • Loading branch information
sinaci committed Sep 20, 2024
1 parent 5471818 commit 79c5049
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.slf4j.{Logger, LoggerFactory}
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContextExecutor, Future}
import scala.language.postfixOps
import scala.util.Try

/**
* Created by tuncay on 11/15/2016.
Expand Down Expand Up @@ -128,9 +129,9 @@ class MongoDBInitializer(resourceManager: ResourceManager) extends BaseDBInitial
//If it is conformance
if(resources.length ==1 && FHIRUtil.extractValueOption[String](resources.head, FHIR_COMMON_FIELDS.ID).contains(SERVER_CONFORMANCE_STATEMENT_ID)) {
Map(SERVER_CONFORMANCE_STATEMENT_ID -> (
FHIRUtil
Try(FHIRUtil
.extractValueOptionByPath[String](resources.head, s"${FHIR_COMMON_FIELDS.META}.${FHIR_COMMON_FIELDS.VERSION_ID}")
.map(_.toLong).getOrElse(1L),
.map(_.toLong)).toOption.flatten.getOrElse(1L),
resources.head
))
} else {
Expand All @@ -141,9 +142,9 @@ class MongoDBInitializer(resourceManager: ResourceManager) extends BaseDBInitial
val rid = url.split('/').last
rid ->
(
FHIRUtil
Try(FHIRUtil
.extractValueOptionByPath[String](resource, s"${FHIR_COMMON_FIELDS.META}.${FHIR_COMMON_FIELDS.VERSION_ID}")
.map(_.toLong).getOrElse(1L),
.map(_.toLong)).toOption.flatten.getOrElse(1L),
FHIRUtil.setId(resource, rid)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ object FhirContentValidator {
private val TIME_REGEX: Regex = """\A([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?$""".r
private val OID_REGEX: Regex = """\Aurn:oid:[0-2](\.[1-9]\d*)+$""".r
private val UUID_REGEX: Regex = """\Aurn:uuid:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$""".r
private val VERSION_REGEX: Regex = """\A[0-9]+(\.[0-9]+)*$""".r
// private val VERSION_REGEX: Regex = """\A[0-9]+(\.[0-9]+)*$""".r

/**
* Construction of the class
Expand Down Expand Up @@ -1505,7 +1505,7 @@ object FhirContentValidator {
case FHIR_DATA_TYPES.CANONICAL => value.extract[String].split('|') match {
case Array(url) => Try(new URI(url)).isSuccess
case Array(url, version) =>
Try(new URI(url)).isSuccess && VERSION_REGEX.findFirstMatchIn(version).isDefined
Try(new URI(url)).isSuccess
case _ => false
}
case FHIR_DATA_TYPES.BOOLEAN => value.isInstanceOf[JBool]
Expand Down

0 comments on commit 79c5049

Please sign in to comment.