Ejemplo n.º 1
0
  /**
   * @param sor
   * @throws XdsPatientIdDoesNotMatchException
   * @throws XdsDeprecatedException
   * @throws XdsUnknownPatientIdException
   * @throws MetadataException
   * @throws MetadataValidationException
   * @throws XDSNonIdenticalHashException
   * @throws XdsInternalException
   * @throws XdsException
   */
  void handleSubmitObjectsRequest(OMElement sor)
      throws XdsPatientIdDoesNotMatchException, XDSNonIdenticalHashException,
          XdsDeprecatedException, MetadataValidationException, MetadataException,
          XdsInternalException, XdsException {
    // Run XML schema validation.
    RegistryUtility.schema_validate_local(sor, MetadataTypes.METADATA_TYPE_Rb);
    boolean commitCompleted = false;

    // Get backend registry instance.
    BackendRegistry backendRegistry = new BackendRegistry(log_message);
    try {
      // Create metadata instance from SOR.
      Metadata m = new Metadata(sor);
      this.logMetadata(m);

      SubmitObjectsRequestStoredQuerySupport sqSupport =
          new SubmitObjectsRequestStoredQuerySupport(response, log_message, backendRegistry);

      // Run validations.
      RegistryObjectValidator rov =
          new RegistryObjectValidator(response, log_message, backendRegistry);
      rov.validate(m, true /* isSubmit */, response.registryErrorList, this.getConfigActor());
      if (!response.has_errors()) {
        // Only continue if response does not have any errors (a bit ugly).

        // Change symbolic names to UUIDs.
        IdParser idParser = new IdParser(m);
        idParser.compileSymbolicNamesIntoUuids();

        // If this submission includes a DocumentEntry replace and the original DocumentEntry is in
        // a folder
        // then the replacement document must be put into the folder as well.  This must happen here
        // so the following logic to update folder lastUpdateTime can be triggered.
        this.updateFolderContentsOnDocumentReplace(m, backendRegistry);

        // if this submission adds a document to a folder then update that folder's lastUpdateTime
        // Slot
        this.updateFoldersLastUpdateTimeSlot(m, sqSupport, backendRegistry);

        m.setStatusOnApprovableObjects();

        // Finally, make the actual submission:
        this.submitRegistryRequest(m, backendRegistry, "SubmitObjectsRequest");

        // Approve
        // this.approveObjects(m, backendRegistry);

        // Deprecate
        this.deprecateObjects(m, sqSupport, backendRegistry);
      }

      backendRegistry.commit();
      commitCompleted = true;
    } finally {
      if (!commitCompleted) {
        backendRegistry.rollback();
      }
    }
  }