// 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) { } } }
/** * 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()); }