Beispiel #1
0
 /**
  * The DicomEventListener implementation. Listen for an event from the SCP, log the file, and move
  * it to the dicom-import directory for anonymization and export.
  *
  * @param event the event identifying the file that was received.
  */
 public void dicomEventOccurred(DicomEvent event) {
   if ((event.getStatus() == 0)
       && event.serviceAsString(event.getService()).equals("C_STORE_RQ")) {
     File inFile = new File(event.getFilename());
     Log.message(dicomImportServiceName + ": Image received: " + inFile.getName());
     // Make the output directory in case it doesn't exist.
     File outDir = new File(TrialConfig.basepath + TrialConfig.dicomImportDir);
     outDir.mkdirs();
     // Put the new file in it, using the overwrite attribute of the trial to determine
     // whether duplicate SOPInstanceUIDs are to be renamed so as not to lose them.
     FileObject fileObject = new FileObject(inFile);
     fileObject.moveToDirectory(outDir, TrialConfig.allowOverwrite());
   } else if (event.getStatus() != 0xff00)
     Log.message(dicomImportServiceName + ": unexpected status: " + event.toStringNoPath());
 }
Beispiel #2
0
  // Look through the http-import directory and process all
  // the files there, oldest first. Note that these are actual
  // files, not queue elements.
  private void processHttpImportFiles() {
    File importDirFile = new File(TrialConfig.basepath + TrialConfig.httpImportDir);
    if (!importDirFile.exists()) return;
    File[] files = importDirFile.listFiles();
    for (int k = 0; k < files.length; k++) {
      File next = files[k];
      if (next.canRead() && next.canWrite()) {
        FileObject fileObject = FileObject.getObject(next);
        if (preprocess(fileObject)) {
          process(fileObject);
          if (!queueForDatabase(fileObject))
            Log.message(Quarantine.file(next, processorServiceName));
          else Log.message(processorServiceName + ": Processing complete: " + next.getName());
        }

        // If the file still exists, then there must be a bug
        // somewhere; log it and quarantine the file so we don't
        // fall into an infinite loop.
        if (next.exists()) {
          logger.warn(
              "File still in queue after processing:\n" + next + "The file will be quarantined.");
          Log.message(Quarantine.file(next, processorServiceName));
        }
        Thread.currentThread().yield();
      }
    }
  }
Beispiel #3
0
 // Queue a file for the DatabaseExportService.
 private boolean queueForDatabase(FileObject fileObject) {
   if (TrialConfig.getDatabaseExportMode().equals("auto")) {
     File databaseExportDirectoryFile = TrialConfig.getDatabaseExportDirectoryFile();
     try {
       ExportQueueElement eqe = ExportQueueElement.createEQE(fileObject);
       eqe.queue(databaseExportDirectoryFile);
     } catch (Exception e) {
       Log.message(
           processorServiceName
               + ": Unable to queue "
               + fileObject.getFile().getName()
               + " for database export");
       logger.warn("Unable to queue " + fileObject.getFile().getName() + " for database export");
     }
   }
   return true;
 }
Beispiel #4
0
 // Process a FileObject.
 private void process(FileObject fileObject) {
   if (fileObject instanceof DicomObject) process((DicomObject) fileObject);
   else if (fileObject instanceof XmlObject) process((XmlObject) fileObject);
   else if (fileObject instanceof ZipObject) process((ZipObject) fileObject);
   else {
     try {
       // This is a file that can't be put into a MIRCdocument directory.
       // Put the file in the bullpen to get it out of the input queue
       // and to place it somewhere for the DatabaseExportService to find.
       fileObject.moveToDirectory(StorageConfig.getBullpenFile());
     } catch (Exception ex) {
     }
   }
 }