Пример #1
0
  private void readMetadata() throws IOException {
    if (metadata != null) return;

    if (iis == null) throw new IllegalStateException("Input not set");

    dis = new DicomInputStream(new ImageInputStreamAdapter(iis));
    dis.setIncludeBulkData(IncludeBulkData.URI);
    dis.setBulkDataDescriptor(BulkDataDescriptor.PIXELDATA);
    dis.setURI("java:iis"); // avoid copy of pixeldata to temporary file
    Attributes fmi = dis.readFileMetaInformation();
    Attributes ds = dis.readDataset(-1, -1);
    metadata = new DicomMetaData(fmi, ds);
    Object pixeldata = ds.getValue(Tag.PixelData, pixeldataVR);
    if (pixeldata != null) {
      frames = ds.getInt(Tag.NumberOfFrames, 1);
      width = ds.getInt(Tag.Columns, 0);
      height = ds.getInt(Tag.Rows, 0);
      samples = ds.getInt(Tag.SamplesPerPixel, 1);
      banded = samples > 1 && ds.getInt(Tag.PlanarConfiguration, 0) != 0;
      bitsAllocated = ds.getInt(Tag.BitsAllocated, 8);
      bitsStored = ds.getInt(Tag.BitsStored, bitsAllocated);
      dataType = bitsAllocated <= 8 ? DataBuffer.TYPE_BYTE : DataBuffer.TYPE_USHORT;
      pmi =
          PhotometricInterpretation.fromString(
              ds.getString(Tag.PhotometricInterpretation, "MONOCHROME2"));
      if (pixeldata instanceof BulkData) {
        iis.setByteOrder(ds.bigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
        this.frameLength = pmi.frameLength(width, height, samples, bitsAllocated);
        this.pixeldata = (BulkData) pixeldata;
      } else {
        String tsuid = dis.getTransferSyntax();
        ImageReaderParam param = ImageReaderFactory.getImageReaderParam(tsuid);
        if (param == null) throw new IOException("Unsupported Transfer Syntax: " + tsuid);
        this.decompressor = ImageReaderFactory.getImageReader(param);
        this.patchJpegLS = param.patchJPEGLS;
        this.pixeldataFragments = (Fragments) pixeldata;
      }
    }
  }
  public Device createArchiveDevice(String name, Device arrDevice, boolean sampleConfig)
      throws Exception {
    Device device = new Device(name);

    Connection dicom = new Connection("dicom", "localhost", 11112);
    dicom.setBindAddress("0.0.0.0");
    dicom.setClientBindAddress("0.0.0.0");
    dicom.setMaxOpsInvoked(0);
    dicom.setMaxOpsPerformed(0);
    device.addConnection(dicom);

    Connection dicomTLS = null;
    if (sampleConfig) {
      dicomTLS = new Connection("dicom-tls", "localhost", 2762);
      dicomTLS.setBindAddress("0.0.0.0");
      dicomTLS.setClientBindAddress("0.0.0.0");
      dicomTLS.setMaxOpsInvoked(0);
      dicomTLS.setMaxOpsPerformed(0);
      dicomTLS.setTlsCipherSuites(
          Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
      device.addConnection(dicomTLS);
    }

    addArchiveDeviceExtension(device, sampleConfig);
    addHL7DeviceExtension(device, sampleConfig);
    addAuditLogger(device, arrDevice);
    device.addDeviceExtension(new ImageReaderExtension(ImageReaderFactory.getDefault()));
    device.addDeviceExtension(new ImageWriterExtension(ImageWriterFactory.getDefault()));

    device.setManufacturer("dcm4che.org");
    device.setManufacturerModelName("dcm4chee-arc");
    device.setSoftwareVersions("5.0.1");
    device.setKeyStoreURL(DCM4CHEE_ARC_KEY_JKS);
    device.setKeyStoreType("JKS");
    device.setKeyStorePin("secret");
    device.setThisNodeCertificates(
        config.deviceRef(name), (X509Certificate) keyStore.getCertificate(name));
    if (sampleConfig)
      for (String other : OTHER_DEVICES)
        device.setAuthorizedNodeCertificates(
            config.deviceRef(other), (X509Certificate) keyStore.getCertificate(other));

    device.addApplicationEntity(
        createAE(
            "DCM4CHEE",
            "Hide instances rejected for Quality Reasons",
            dicom,
            dicomTLS,
            HIDE_REJECTED_VIEW,
            true,
            true));
    device.addApplicationEntity(
        createAE(
            "DCM4CHEE_ADMIN",
            "Show instances rejected for Quality Reasons",
            dicom,
            dicomTLS,
            REGULAR_USE_VIEW,
            false,
            true));
    device.addApplicationEntity(
        createAE(
            "DCM4CHEE_TRASH",
            "Show rejected instances only",
            dicom,
            dicomTLS,
            TRASH_VIEW,
            false,
            false));

    return device;
  }