Example #1
0
 private JSONReader parseJSON(String fname, Attributes attrs) throws IOException {
   InputStream in = new FileInputStream(fname);
   try {
     JSONReader reader = new JSONReader(Json.createParser(new InputStreamReader(in, "UTF-8")));
     reader.readDataset(attrs);
     return reader;
   } finally {
     if (in != System.in) SafeClose.close(in);
   }
 }
Example #2
0
 public void retrieve(File f) throws IOException, InterruptedException {
   Attributes attrs = new Attributes();
   DicomInputStream dis = null;
   try {
     attrs.addSelected(new DicomInputStream(f).readDataset(-1, -1), inFilter);
   } finally {
     SafeClose.close(dis);
   }
   attrs.addAll(keys);
   retrieve(attrs);
 }
  @Override
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    try {
      addJBossDirURLSystemProperties();
      String ldapPropertiesURL =
          StringUtils.replaceSystemProperties(
                  System.getProperty(
                      "org.dcm4chee.proxy.ldapPropertiesURL",
                      config.getInitParameter("ldapPropertiesURL")))
              .replace('\\', '/');
      String deviceName =
          System.getProperty(
              "org.dcm4chee.proxy.deviceName", config.getInitParameter("deviceName"));
      String jmxName =
          System.getProperty("org.dcm4chee.proxy.jmxName", config.getInitParameter("jmxName"));
      InputStream ldapConf = null;
      try {
        ldapConf = new URL(ldapPropertiesURL).openStream();
        Properties p = new Properties();
        p.load(ldapConf);
        LOG.info("Using LDAP Configuration Backend");
        LdapDicomConfiguration ldapConfig = new LdapDicomConfiguration(p);
        LdapHL7Configuration hl7Conf = new LdapHL7Configuration();
        ldapConfig.addDicomConfigurationExtension(hl7Conf);
        ldapConfig.addDicomConfigurationExtension(new LdapProxyConfigurationExtension());
        ldapConfig.addDicomConfigurationExtension(new LdapAuditLoggerConfiguration());
        ldapConfig.addDicomConfigurationExtension(new LdapAuditRecordRepositoryConfiguration());
        dicomConfig = ldapConfig;
        this.hl7Config = hl7Conf;
      } catch (FileNotFoundException e) {
        // check if there is an implementation of PrefsFactory provided and construct
        // DicomConfiguration accordingly
        PreferencesDicomConfiguration prefsConfig;
        if (!prefsFactoryInstance.isUnsatisfied()) {
          Preferences prefs = prefsFactoryInstance.get().getPreferences();
          LOG.info("Using custom Preferences implementation {}", prefs.getClass().toString());
          prefsConfig = new PreferencesDicomConfiguration(prefs);
        } else {
          prefsConfig = new PreferencesDicomConfiguration();
          LOG.info(
              "Using default Preferences implementation {}",
              prefsConfig.getRootPrefs().getClass().toString());
        }

        PreferencesHL7Configuration hl7Conf = new PreferencesHL7Configuration();
        prefsConfig.addDicomConfigurationExtension(hl7Conf);
        prefsConfig.addDicomConfigurationExtension(new PreferencesProxyConfigurationExtension());
        prefsConfig.addDicomConfigurationExtension(new PreferencesAuditLoggerConfiguration());
        prefsConfig.addDicomConfigurationExtension(
            new PreferencesAuditRecordRepositoryConfiguration());
        dicomConfig = prefsConfig;
        this.hl7Config = hl7Conf;
      } finally {
        SafeClose.close(ldapConf);
      }
      proxy = new Proxy(dicomConfig, hl7Config, deviceName);
      proxy.start();
      ProxyDeviceExtension proxyDev =
          proxy.getDevice().getDeviceExtension(ProxyDeviceExtension.class);
      mbean =
          ManagementFactory.getPlatformMBeanServer().registerMBean(proxy, new ObjectName(jmxName));
    } catch (Exception e) {
      if (LOG.isDebugEnabled()) e.printStackTrace();
      destroy();
      throw new ServletException(e);
    }
  }