private Device createArchiveDevice(String name) throws Exception {
   ArchiveDevice device = new ArchiveDevice(name);
   device.setFuzzyAlgorithmClass("org.dcm4che.soundex.ESoundex");
   device.setConfigurationStaleTimeout(CONFIGURATION_STALE_TIMEOUT);
   setAttributeFilters(device);
   device.setKeyStoreURL("resource:dcm4chee-arc-key.jks");
   device.setKeyStoreType("JKS");
   device.setKeyStorePin("secret");
   device.setThisNodeCertificates(
       config.deviceRef(name), (X509Certificate) keystore.getCertificate(name));
   for (String other : OTHER_DEVICES)
     device.setAuthorizedNodeCertificates(
         config.deviceRef(other), (X509Certificate) keystore.getCertificate(other));
   Connection dicom = createConnection("dicom", "localhost", 11112);
   dicom.setMaxOpsInvoked(0);
   dicom.setMaxOpsPerformed(0);
   device.addConnection(dicom);
   Connection dicomTLS = new Connection("dicom-tls", "localhost", 2762);
   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);
   ArchiveApplicationEntity ae =
       createAE("DCM4CHEE", IMAGE_TSUIDS, VIDEO_TSUIDS, OTHER_TSUIDS, null, PIX_MANAGER);
   device.addApplicationEntity(ae);
   ae.addConnection(dicom);
   ae.addConnection(dicomTLS);
   ArchiveApplicationEntity adminAE =
       createAdminAE(
           "DCM4CHEE_ADMIN", IMAGE_TSUIDS, VIDEO_TSUIDS, OTHER_TSUIDS, null, PIX_MANAGER);
   device.addApplicationEntity(adminAE);
   adminAE.addConnection(dicom);
   adminAE.addConnection(dicomTLS);
   ArchiveHL7Application hl7App = new ArchiveHL7Application("*");
   hl7App.setAcceptedMessageTypes(HL7_MESSAGE_TYPES);
   hl7App.setHL7DefaultCharacterSet("8859/1");
   hl7App.addTemplatesURI("adt2dcm", "resource:dcm4chee-arc-hl7-adt2dcm.xsl");
   device.addHL7Application(hl7App);
   Connection hl7 = new Connection("hl7", "localhost", 2575);
   device.addConnection(hl7);
   hl7App.addConnection(hl7);
   Connection hl7TLS = new Connection("hl7-tls", "localhost", 12575);
   hl7TLS.setTlsCipherSuites(
       Connection.TLS_RSA_WITH_AES_128_CBC_SHA, Connection.TLS_RSA_WITH_3DES_EDE_CBC_SHA);
   device.addConnection(hl7TLS);
   hl7App.addConnection(hl7TLS);
   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;
 }