public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String pathInfo = request.getPathInfo();
    String action = "Path info '" + pathInfo + "' not understood. Did nothing to";
    Proxy streamingServerProxy = EndToEndFramework.getInstance().getStreamingServerProxy();
    Proxy streamingServerProxyTwo = EndToEndFramework.getInstance().getStreamingServerProxyTwo();

    if (pathInfo.contains("startTwo")) {
      if (streamingServerProxyTwo.isStopped()) {
        streamingServerProxyTwo.start();
      }
      action = "Started";
    } else if (pathInfo.contains("stopTwo")) {
      if (!streamingServerProxyTwo.isStopped()) {
        streamingServerProxyTwo.stop();
      }
      action = "Stopped";
    } else if (pathInfo.contains("start")) {
      if (streamingServerProxy.isStopped()) {
        streamingServerProxy.start();
      }
      action = "Started";
    } else if (pathInfo.contains("stop")) {
      if (!streamingServerProxy.isStopped()) {
        streamingServerProxy.stop();
      }
      action = "Stopped";
    }

    outputResponse(request, response, action);
  }
Ejemplo n.º 2
0
  @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);
    }
  }