test_class.declarator: configurator
test_class.modifier: private
test_class.original_string: private WebServerActivityResourceConfigurator configurator;
test_class.type: WebServerActivityResourceConfigurator
test_class.var_name: configurator
test_class.declarator: webServer
test_class.modifier: private
test_class.original_string: private WebServer webServer;
test_class.type: WebServer
test_class.var_name: webServer
test_class.declarator: activity
test_class.modifier: private
test_class.original_string: private Activity activity;
test_class.type: Activity
test_class.var_name: activity
test_class.declarator: configuration
test_class.modifier: private
test_class.original_string: private SimpleConfiguration configuration;
test_class.type: SimpleConfiguration
test_class.var_name: configuration
test_class.declarator: filesystem
test_class.modifier: private
test_class.original_string: private ActivityFilesystem filesystem;
test_class.type: ActivityFilesystem
test_class.var_name: filesystem
test_class.declarator: installDirectory = new File(".").getAbsoluteFile()
test_class.modifier: private
test_class.original_string: private File installDirectory = new File(".").getAbsoluteFile();
test_class.type: File
test_class.var_name: installDirectory
test_class.declarator: activityName = "testActivity"
test_class.modifier: private
test_class.original_string: private String activityName = "testActivity";
test_class.type: String
test_class.var_name: activityName
test_class.file: activityapi/interactivespaces-activity-core/src/test/java/interactivespaces/activity/configuration/WebServerActivityResourceConfiguratorTest.java
test_class.identifier: WebServerActivityResourceConfiguratorTest
test_case.body: @Test
    public void testConfigure() {
      int testPort = WebServerActivityResourceConfigurator.WEB_SERVER_PORT_DEFAULT + 100;
      String webSocketUri = "foo/bar/bletch";
      String initialUrl = "snafu";
      String query = "oorgle";
  
      configuration.setValue("space.activity.webapp.web.server.port", Integer.toString(testPort));
      configuration.setValue("space.activity.webapp.content.location", "webapp");
      configuration.setValue("space.activity.webapp.web.server.websocket.uri", webSocketUri);
      configuration.setValue("space.activity.webapp.url.initial", initialUrl);
      configuration.setValue("space.activity.webapp.url.query_string", query);
  
      configurator.configure(null, activity, webServer);
  
      Mockito.verify(webServer).setPort(testPort);
      Mockito.verify(webServer).addStaticContentHandler("/" + activityName, new File(installDirectory, "webapp"));
  
      Assert.assertEquals(webSocketUri, configurator.getWebSocketUriPrefix());
      String webBaseUrl = "http://localhost:" + testPort;
      String webContentUrl = webBaseUrl + "/" + activityName;
      Assert.assertEquals(webBaseUrl, configurator.getWebBaseUrl());
      Assert.assertEquals(webContentUrl, configurator.getWebContentUrl());
      Assert.assertEquals(webContentUrl + "/" + initialUrl + "?" + query, configurator.getWebInitialPage());
    }
test_case.class_method_signature: WebServerActivityResourceConfiguratorTest.testConfigure()
test_case.full_signature: @Test public void testConfigure()
test_case.identifier: testConfigure
test_case.invocations: setValue toString setValue setValue setValue setValue configure setPort verify addStaticContentHandler verify assertEquals getWebSocketUriPrefix assertEquals getWebBaseUrl assertEquals getWebContentUrl assertEquals getWebInitialPage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testConfigure()
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_PORT = ".web.server.port"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_PORT = ".web.server.port";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_PORT
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_WEBSOCKET_URI = ".web.server.websocket.uri"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_WEBSOCKET_URI = ".web.server.websocket.uri";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_WEBSOCKET_URI
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_CONTENT_LOCATION = ".content.location"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_CONTENT_LOCATION = ".content.location";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_CONTENT_LOCATION
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_ENABLE_CROSS_ORIGIN = ".enable.cross.origin"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_ENABLE_CROSS_ORIGIN = ".enable.cross.origin";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_ENABLE_CROSS_ORIGIN
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_SECURE = ".web.server.secure"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_SECURE = ".web.server.secure";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_SECURE
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_SSL_CERTIFICATE = ".ssl.certificate"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_SSL_CERTIFICATE = ".ssl.certificate";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_SSL_CERTIFICATE
focal_class.declarator: CONFIGURATION_SUFFIX_WEBAPP_SSL_PRIVATE_KEY = ".ssl.privatekey"
focal_class.modifier: public static final
focal_class.original_string: public static final String CONFIGURATION_SUFFIX_WEBAPP_SSL_PRIVATE_KEY = ".ssl.privatekey";
focal_class.type: String
focal_class.var_name: CONFIGURATION_SUFFIX_WEBAPP_SSL_PRIVATE_KEY
focal_class.declarator: WEB_SERVER_PORT_DEFAULT = 9000
focal_class.modifier: public static final
focal_class.original_string: public static final int WEB_SERVER_PORT_DEFAULT = 9000;
focal_class.type: int
focal_class.var_name: WEB_SERVER_PORT_DEFAULT
focal_class.declarator: WEB_SERVER_DEFAULT_HOST = "localhost"
focal_class.modifier: public static final
focal_class.original_string: public static final String WEB_SERVER_DEFAULT_HOST = "localhost";
focal_class.type: String
focal_class.var_name: WEB_SERVER_DEFAULT_HOST
focal_class.declarator: WEB_SERVER_DEFAULT_ENABLE_CROSS_ORIGIN = true
focal_class.modifier: public static final
focal_class.original_string: public static final boolean WEB_SERVER_DEFAULT_ENABLE_CROSS_ORIGIN = true;
focal_class.type: boolean
focal_class.var_name: WEB_SERVER_DEFAULT_ENABLE_CROSS_ORIGIN
focal_class.declarator: webBaseUrl
focal_class.modifier: private
focal_class.original_string: private String webBaseUrl;
focal_class.type: String
focal_class.var_name: webBaseUrl
focal_class.declarator: webContentUrl
focal_class.modifier: private
focal_class.original_string: private String webContentUrl;
focal_class.type: String
focal_class.var_name: webContentUrl
focal_class.declarator: webServerPort
focal_class.modifier: private
focal_class.original_string: private int webServerPort;
focal_class.type: int
focal_class.var_name: webServerPort
focal_class.declarator: webContentPath
focal_class.modifier: private
focal_class.original_string: private String webContentPath;
focal_class.type: String
focal_class.var_name: webContentPath
focal_class.declarator: webContentBaseDir
focal_class.modifier: private
focal_class.original_string: private File webContentBaseDir;
focal_class.type: File
focal_class.var_name: webContentBaseDir
focal_class.declarator: webSocketUriPrefix
focal_class.modifier: private
focal_class.original_string: private String webSocketUriPrefix;
focal_class.type: String
focal_class.var_name: webSocketUriPrefix
focal_class.declarator: webInitialPage
focal_class.modifier: private
focal_class.original_string: private String webInitialPage;
focal_class.type: String
focal_class.var_name: webInitialPage
focal_class.declarator: crossOriginAllowed
focal_class.modifier: private
focal_class.original_string: private boolean crossOriginAllowed;
focal_class.type: boolean
focal_class.var_name: crossOriginAllowed
focal_class.file: activityapi/interactivespaces-activity-core/src/main/java/interactivespaces/activity/configuration/WebServerActivityResourceConfigurator.java
focal_class.identifier: WebServerActivityResourceConfigurator
focal_class.interfaces: implements ActivityResourceConfigurator<WebServer>
focal_class.class_method_signature: WebServerActivityResourceConfigurator.configure(String resourceName, Activity activity, WebServer webServer)
focal_class.full_signature: @Override public void configure(String resourceName, Activity activity, WebServer webServer)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (String resourceName, Activity activity, WebServer webServer)
focal_class.return: void
focal_class.signature: void configure(String resourceName, Activity activity, WebServer webServer)
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebBaseUrl()
focal_class.full_signature: public String getWebBaseUrl()
focal_class.identifier: getWebBaseUrl
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWebBaseUrl()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebContentUrl()
focal_class.full_signature: public String getWebContentUrl()
focal_class.identifier: getWebContentUrl
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWebContentUrl()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebServerPort()
focal_class.full_signature: public int getWebServerPort()
focal_class.identifier: getWebServerPort
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getWebServerPort()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebContentPath()
focal_class.full_signature: public String getWebContentPath()
focal_class.identifier: getWebContentPath
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWebContentPath()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebContentBaseDir()
focal_class.full_signature: public File getWebContentBaseDir()
focal_class.identifier: getWebContentBaseDir
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: File
focal_class.signature: File getWebContentBaseDir()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebSocketUriPrefix()
focal_class.full_signature: public String getWebSocketUriPrefix()
focal_class.identifier: getWebSocketUriPrefix
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWebSocketUriPrefix()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.setWebSocketUriPrefix(String webSocketUriPrefix)
focal_class.full_signature: public void setWebSocketUriPrefix(String webSocketUriPrefix)
focal_class.identifier: setWebSocketUriPrefix
focal_class.modifiers: public
focal_class.parameters: (String webSocketUriPrefix)
focal_class.return: void
focal_class.signature: void setWebSocketUriPrefix(String webSocketUriPrefix)
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getWebInitialPage()
focal_class.full_signature: public String getWebInitialPage()
focal_class.identifier: getWebInitialPage
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getWebInitialPage()
focal_class.class_method_signature: WebServerActivityResourceConfigurator.getCrossOriginAllowed()
focal_class.full_signature: public boolean getCrossOriginAllowed()
focal_class.identifier: getCrossOriginAllowed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean getCrossOriginAllowed()
focal_method.body: @Override
    public void configure(String resourceName, Activity activity, WebServer webServer) {
      resourceName = resourceName != null ? resourceName.trim() : "";
      String configurationPrefix =
          resourceName.isEmpty() ? WebActivityConfiguration.CONFIGURATION_PREFIX_WEBAPP
              : WebActivityConfiguration.CONFIGURATION_PREFIX_WEBAPP + "." + resourceName;
  
      Configuration configuration = activity.getConfiguration();
  
      webSocketUriPrefix =
          configuration.getPropertyString(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_WEBSOCKET_URI);
  
      webServerPort =
          configuration.getPropertyInteger(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_PORT,
              WEB_SERVER_PORT_DEFAULT);
      webServer.setPort(webServerPort);
  
      String serverName =
          (resourceName.isEmpty()) ? String.format("%sWebServer", activity.getName()) : String.format("%s_%s_WebServer",
              activity.getName(), resourceName);
      webServer.setServerName(serverName);
  
      boolean secure =
          configuration.getPropertyBoolean(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_WEB_SERVER_SECURE, false);
      webServer.setSecureServer(secure);
  
      if (secure) {
        String certificatePath =
            configuration.getPropertyString(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_SSL_CERTIFICATE);
        String privateKeyPath =
            configuration.getPropertyString(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_SSL_PRIVATE_KEY);
  
        boolean hasCertificatePath = certificatePath != null && !certificatePath.trim().isEmpty();
        boolean hasPrivateKeyPath = privateKeyPath != null && !privateKeyPath.trim().isEmpty();
  
        if (hasCertificatePath && hasPrivateKeyPath) {
          webServer.setSslCertificates(new File(certificatePath.trim()), new File(privateKeyPath.trim()));
        } else if (hasCertificatePath ^ hasPrivateKeyPath) {
          throw new SimpleInteractiveSpacesException(
              "Both a certificate chain file and a private key file must be supplied.");
        }
      }
  
      boolean debugMode =
          configuration.getPropertyBoolean(WebActivityConfiguration.CONFIGURATION_WEBAPP_DEBUG, false);
      webServer.setDebugMode(debugMode);
  
      crossOriginAllowed =
          configuration.getPropertyBoolean(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_ENABLE_CROSS_ORIGIN,
              WEB_SERVER_DEFAULT_ENABLE_CROSS_ORIGIN);
  
      String webServerHost =
          configuration.getPropertyString(InteractiveSpacesEnvironment.CONFIGURATION_HOST_ADDRESS,
              WEB_SERVER_DEFAULT_HOST);
  
      webContentPath = "/" + activity.getName();
      webBaseUrl = ((secure) ? "https" : "http") + "://" + webServerHost + ":" + webServerPort;
      webContentUrl = webBaseUrl + webContentPath;
  
      StringBuilder webInitialPageBuilder = new StringBuilder();
      webInitialPageBuilder
          .append(webContentUrl)
          .append(WebActivityConfiguration.WEB_PATH_SEPARATOR)
          .append(
              configuration.getPropertyString(configurationPrefix
                  + WebActivityConfiguration.CONFIGURATION_SUFFIX_INITIAL_PAGE,
                  WebActivityConfiguration.DEFAULT_INITIAL_PAGE));
  
      String queryString =
          configuration.getPropertyString(configurationPrefix
              + WebActivityConfiguration.CONFIGURATION_SUFFIX_INITIAL_URL_QUERY_STRING);
      if (queryString != null) {
        webInitialPageBuilder.append(WebActivityConfiguration.WEB_QUERY_STRING_SEPARATOR).append(queryString.trim());
      }
  
      webInitialPage = webInitialPageBuilder.toString();
  
      String contentLocation =
          configuration.getPropertyString(configurationPrefix + CONFIGURATION_SUFFIX_WEBAPP_CONTENT_LOCATION);
      if (contentLocation != null) {
        webContentBaseDir = new File(activity.getActivityFilesystem().getInstallDirectory(), contentLocation);
  
        webServer.addStaticContentHandler(webContentPath, webContentBaseDir);
      }
    }
focal_method.class_method_signature: WebServerActivityResourceConfigurator.configure(String resourceName, Activity activity, WebServer webServer)
focal_method.full_signature: @Override public void configure(String resourceName, Activity activity, WebServer webServer)
focal_method.identifier: configure
focal_method.invocations: trim isEmpty getConfiguration getPropertyString getPropertyInteger setPort isEmpty format getName format getName setServerName getPropertyBoolean setSecureServer getPropertyString getPropertyString isEmpty trim isEmpty trim setSslCertificates trim trim getPropertyBoolean setDebugMode getPropertyBoolean getPropertyString getName append append append getPropertyString getPropertyString append append trim toString getPropertyString getInstallDirectory getActivityFilesystem addStaticContentHandler
focal_method.modifiers: @Override public
focal_method.parameters: (String resourceName, Activity activity, WebServer webServer)
focal_method.return: void
focal_method.signature: void configure(String resourceName, Activity activity, WebServer webServer)