Class PreviousResourceVersionRestorer

java.lang.Object
ca.uhn.fhir.replacereferences.PreviousResourceVersionRestorer

This is a class to restore resources to their previous versions based on the provided versioned resource references. It is used in the context of undoing changes made by the $hapi.fhir.replace-references operation.
  • Constructor Details

  • Method Details

    • restoreToPreviousVersionsInTrx

      public void restoreToPreviousVersionsInTrx(List<org.hl7.fhir.r4.model.Reference> theReferences, Set<org.hl7.fhir.r4.model.Reference> theReferencesToUndelete, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, RequestPartitionId thePartitionId)
      Given a list of versioned resource references, this method restores each resource to its previous version if the resource's current version is the same as specified in the given reference (i.e. the resource was not updated since the reference was created). This method is transactional and will attempt to restore all resources in a single transaction. Note that this method updates a resource using its previous version's content, so it will actually cause a new version to be created (i.e. it does not rewrite the history).
      Parameters:
      theReferences - a list of versioned resource references to restore
      theReferencesToUndelete - the references that is expected to be deleted, and is ok to undelete
      theRequestDetails - the request details for the operation
      thePartitionId - the partition ID for the operation
      Throws:
      IllegalArgumentException - if a given reference is versionless
      IllegalArgumentException - a given reference has version 1, so it cannot have a previous version to restore to.
      ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException - if the current version of the resource does not match the version specified in the reference.