예제 #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();
      }
    }
  }
예제 #2
0
  /**
   * @param m
   * @param sqSupport
   * @param backendRegistry
   * @throws XdsException
   */
  private void updateFoldersLastUpdateTimeSlot(
      Metadata m, SubmitObjectsRequestStoredQuerySupport sqSupport, BackendRegistry backendRegistry)
      throws XdsException {
    // Update any folders "lastUpdateTime" slot with the current time:
    m.updateFoldersLastUpdateTimeSlot();

    // if this submission adds a document to a folder then update that folder's lastUpdateTime Slot
    for (OMElement assoc : m.getAssociations()) {
      if (MetadataSupport.xdsB_eb_assoc_type_has_member.equals(m.getAssocType(assoc))) {
        String sourceId = m.getAssocSource(assoc);
        if (!m.getSubmissionSetId().equals(sourceId) && !m.getFolderIds().contains(sourceId)) {
          // Assoc src not part of the submission
          logger.info("Adding to Folder (1)" + sourceId);
          if (this.isFolder(sourceId, sqSupport)) {
            logger.info("Adding to Folder (2)" + sourceId);
            OMElement res =
                backendRegistry.basicQuery(
                    "SELECT * from RegistryPackage rp WHERE rp.id='" + sourceId + "'", true);
            // Update any folders "lastUpdateTime" slot:
            Metadata fm = MetadataParser.parseNonSubmission(res);
            fm.updateFoldersLastUpdateTimeSlot();
            // OMElement to_backend = fm.getV3SubmitObjectsRequest();
            // log_message.addOtherParam("From Registry Adaptor", to_backend);
            this.submitRegistryRequest(fm, backendRegistry, "Update Folder LastUpdateTime Slot");
          }
        }
      }
    }
  }
예제 #3
0
 /**
  * @param backendRegistry
  * @param objectIds
  * @throws XdsInternalException
  */
 private void submitDeprecateObjectsRequest(
     BackendRegistry backendRegistry, List<String> objectIds) throws XdsInternalException {
   backendRegistry.submitDeprecateObjectsRequest(objectIds);
 }
예제 #4
0
 /**
  * @param m
  * @param backendRegistry
  * @throws XdsInternalException
  */
 private void submitRegistryRequest(Metadata m, BackendRegistry backendRegistry, String reason)
     throws XdsInternalException {
   backendRegistry.setReason(reason);
   backendRegistry.submit(m);
   backendRegistry.setReason("");
 }