@Override
  protected void mergeChilds(Device prev, Device device, Preferences deviceNode)
      throws BackingStoreException {
    ImageWriterExtension prevExt = prev.getDeviceExtension(ImageWriterExtension.class);
    ImageWriterExtension ext = device.getDeviceExtension(ImageWriterExtension.class);
    if (ext == null && prevExt == null) return;

    Preferences factoryNode = deviceNode.node("dcmImageWriterFactory");
    if (ext == null) factoryNode.removeNode();
    else if (prevExt == null) storeTo(ext.getImageWriterFactory(), factoryNode);
    else storeDiffs(factoryNode, prevExt.getImageWriterFactory(), ext.getImageWriterFactory());
  }
 private Device createDevice(
     String name,
     Issuer issuer,
     Code institutionCode,
     String aet,
     String host,
     int port,
     int tlsPort)
     throws Exception {
   Device device = init(new Device(name), issuer, institutionCode);
   ApplicationEntity ae = new ApplicationEntity(aet);
   ae.setAssociationAcceptor(true);
   device.addApplicationEntity(ae);
   Connection dicom = new Connection("dicom", host, port);
   device.addConnection(dicom);
   ae.addConnection(dicom);
   Connection dicomTLS = new Connection("dicom-tls", host, tlsPort);
   dicomTLS.setTlsCipherSuites(
       Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
   device.addConnection(dicomTLS);
   ae.addConnection(dicomTLS);
   return device;
 }
 private Device init(Device device, Issuer issuer, Code institutionCode) throws Exception {
   String name = device.getDeviceName();
   device.setThisNodeCertificates(
       config.deviceRef(name), (X509Certificate) keystore.getCertificate(name));
   device.setIssuerOfPatientID(issuer);
   device.setIssuerOfAccessionNumber(issuer);
   if (institutionCode != null) {
     device.setInstitutionNames(institutionCode.getCodeMeaning());
     device.setInstitutionCodes(institutionCode);
   }
   return device;
 }
 @Override
 protected List<ModificationItem> storeDiffs(Device a, Device b, List<ModificationItem> mods) {
   super.storeDiffs(a, b, mods);
   storeDiff(
       mods,
       "dcmLimitOpenAssociations",
       a.getLimitOpenAssociations(),
       b.getLimitOpenAssociations());
   storeDiff(mods, "dcmTrustStoreURL", a.getTrustStoreURL(), b.getTrustStoreURL());
   storeDiff(mods, "dcmTrustStoreType", a.getTrustStoreType(), b.getTrustStoreType());
   storeDiff(mods, "dcmTrustStorePin", a.getTrustStorePin(), b.getTrustStorePin());
   storeDiff(
       mods,
       "dcmTrustStorePinProperty",
       a.getTrustStorePinProperty(),
       b.getTrustStorePinProperty());
   storeDiff(mods, "dcmKeyStoreURL", a.getKeyStoreURL(), b.getKeyStoreURL());
   storeDiff(mods, "dcmKeyStoreType", a.getKeyStoreType(), b.getKeyStoreType());
   storeDiff(mods, "dcmKeyStorePin", a.getKeyStorePin(), b.getKeyStorePin());
   storeDiff(
       mods, "dcmKeyStorePinProperty", a.getKeyStorePinProperty(), b.getKeyStorePinProperty());
   storeDiff(mods, "dcmKeyStoreKeyPin", a.getKeyStoreKeyPin(), b.getKeyStoreKeyPin());
   storeDiff(
       mods,
       "dcmKeyStoreKeyPinProperty",
       a.getKeyStoreKeyPinProperty(),
       b.getKeyStoreKeyPinProperty());
   return mods;
 }
  @Override
  protected void loadFrom(Device device, Attributes attrs)
      throws NamingException, CertificateException {
    super.loadFrom(device, attrs);
    if (!hasObjectClass(attrs, "dcmDevice")) return;

    device.setLimitOpenAssociations(intValue(attrs.get("dcmLimitOpenAssociations"), 0));
    device.setTrustStoreURL(stringValue(attrs.get("dcmTrustStoreURL"), null));
    device.setTrustStoreType(stringValue(attrs.get("dcmTrustStoreType"), null));
    device.setTrustStorePin(stringValue(attrs.get("dcmTrustStorePin"), null));
    device.setTrustStorePinProperty(stringValue(attrs.get("dcmTrustStorePinProperty"), null));
    device.setKeyStoreURL(stringValue(attrs.get("dcmKeyStoreURL"), null));
    device.setKeyStoreType(stringValue(attrs.get("dcmKeyStoreType"), null));
    device.setKeyStorePin(stringValue(attrs.get("dcmKeyStorePin"), null));
    device.setKeyStorePinProperty(stringValue(attrs.get("dcmKeyStorePinProperty"), null));
    device.setKeyStoreKeyPin(stringValue(attrs.get("dcmKeyStoreKeyPin"), null));
    device.setKeyStoreKeyPinProperty(stringValue(attrs.get("dcmKeyStoreKeyPinProperty"), null));
  }
 @Override
 protected Attributes storeTo(Device device, Attributes attrs) {
   super.storeTo(device, attrs);
   storeNotDef(attrs, "dcmLimitOpenAssociations", device.getLimitOpenAssociations(), 0);
   storeNotNull(attrs, "dcmTrustStoreURL", device.getTrustStoreURL());
   storeNotNull(attrs, "dcmTrustStoreType", device.getTrustStoreType());
   storeNotNull(attrs, "dcmTrustStorePin", device.getTrustStorePin());
   storeNotNull(attrs, "dcmTrustStorePinProperty", device.getTrustStorePinProperty());
   storeNotNull(attrs, "dcmKeyStoreURL", device.getKeyStoreURL());
   storeNotNull(attrs, "dcmKeyStoreType", device.getKeyStoreType());
   storeNotNull(attrs, "dcmKeyStorePin", device.getKeyStorePin());
   storeNotNull(attrs, "dcmKeyStorePinProperty", device.getKeyStorePinProperty());
   storeNotNull(attrs, "dcmKeyStoreKeyPin", device.getKeyStoreKeyPin());
   storeNotNull(attrs, "dcmKeyStoreKeyPinProperty", device.getKeyStoreKeyPinProperty());
   return attrs;
 }
 public void setDestinationDevice(Device destDevice) {
   this.requestedIssuerOfPatientID = destDevice.getIssuerOfPatientID();
   this.requestedIssuerOfAccessionNumber = destDevice.getIssuerOfAccessionNumber();
 }
 @Override
 protected void storeChilds(Device device, Preferences deviceNode) {
   ImageWriterExtension ext = device.getDeviceExtension(ImageWriterExtension.class);
   if (ext != null) storeTo(ext.getImageWriterFactory(), deviceNode.node("dcmImageWriterFactory"));
 }