예제 #1
0
 protected void ensureContentAvailable() {
   if (!isContentAvailable()) {
     DicomInputStream dis = null;
     try {
       List<org.dcm4chee.archive.entity.File> files =
           ((TCQueryLocal) JNDIUtils.lookup(TCQueryLocal.JNDI_NAME))
               .findInstanceByUID(getSOPInstanceUID())
               .getFiles();
       String fsId = files.get(0).getFileSystem().getDirectoryPath();
       String fileId = files.get(0).getFilePath();
       dis =
           new DicomInputStream(
               fsId.startsWith("tar:")
                   ? TarRetrieveDelegate.getInstance().retrieveFileFromTar(fsId, fileId)
                   : FileUtils.resolve(new File(fsId, fileId)));
       metaData = dis.readDicomObject();
     } catch (Exception e) {
       log.error("Unable to retrieve instance!", e); // $NON-NLS-1$
     } finally {
       if (dis != null) {
         try {
           dis.close();
         } catch (Exception e2) {
         }
       }
     }
   }
 }
예제 #2
0
 private void fixRecursive(File source, File target, int[] counts) {
   if (!source.exists()) {
     System.err.println("no such file or directory `" + source + "'");
   } else if (source.isDirectory()) {
     if (!target.exists()) {
       if (!target.mkdir()) System.err.println("failed to create directory `" + target + "'");
     }
     if (target.isFile()) {
       System.err.println(
           "cannot overwrite non-directory `" + target + "' with directory `" + source + "'");
       return;
     }
     String[] ss = source.list();
     for (String s : ss) {
       fixRecursive(new File(source, s), new File(target, s), counts);
     }
   } else if (target.isDirectory()) {
     System.err.println(
         "cannot overwrite directory `" + target + "' with non-directory `" + source + "'");
   } else {
     Replacements replacements = new Replacements();
     try {
       counts[0]++;
       DicomInputStream din = new DicomInputStream(source);
       try {
         din.setHandler(replacements);
         din.readDicomObject();
       } finally {
         try {
           din.close();
         } catch (IOException ignore) {
         }
       }
       if (replacements.numItems == 0) throw new NoFixException("no Pixel Data Fragments");
       replacements.applyTo(source, target);
       counts[1]++;
       System.out.println(
           "PATCHED " + source + ": JPEG-LS " + replacements.bitsStored + "-bit -> " + target);
     } catch (Exception e) {
       System.out.println("skipped " + source + ": " + e.getMessage());
     }
   }
 }
예제 #3
0
    private byte[] getDocumentContent() {
      if (data != null) {
        return data;
      } else if (dicomFile != null) {
        DicomInputStream dis = null;
        try {
          dis = new DicomInputStream(dicomFile);
          return dis.readDicomObject().getBytes(Tag.EncapsulatedDocument);
        } catch (Exception e) {
          log.error("Unable to get content of encapsulated document!", e);
        } finally {
          if (dis != null) {
            try {
              dis.close();
            } catch (Exception e) {
              log.error(null, e);
            }
          }
        }
      }

      return null;
    }