Search in sources :

Example 6 with WebServer

use of net.sourceforge.processdash.net.http.WebServer in project processdash by dtuma.

the class TeamStartBootstrap method testContinuation.

/** Attempt to open the continuation page, to make certain it will
     * succeed when the user visits it in their browser.
     * 
     * @return an error message if the page cannot be opened, null if
     *     all is well.
     */
private String testContinuation(String prefix, String continuationURI) {
    if (prefix != null)
        continuationURI = WebServer.urlEncodePath(prefix) + "/" + continuationURI;
    try {
        WebServer ws = getTinyWebServer();
        String continuationURL = "http://" + ws.getHostName(false) + ":" + ws.getPort() + continuationURI;
        URL u = new URL(continuationURL);
        logger.finer("Testing continuation URL " + continuationURL);
        HttpURLConnection conn = (HttpURLConnection) u.openConnection();
        conn.connect();
        int status = conn.getResponseCode();
        if (status == 200)
            return null;
        logger.warning("Received response code of " + status + " for " + continuationURL);
    } catch (Exception e) {
        logger.log(Level.WARNING, "Received exception when contacting " + continuationURI, e);
    }
    return resources.getString("Errors.Cannot_Use_Process");
}
Also used : HttpURLConnection(java.net.HttpURLConnection) WebServer(net.sourceforge.processdash.net.http.WebServer) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

WebServer (net.sourceforge.processdash.net.http.WebServer)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 MalformedURLException (java.net.MalformedURLException)2 Method (java.lang.reflect.Method)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 MissingResourceException (java.util.MissingResourceException)1 ServletException (javax.servlet.ServletException)1 DataRepository (net.sourceforge.processdash.data.repository.DataRepository)1 DashHierarchy (net.sourceforge.processdash.hier.DashHierarchy)1 Resources (net.sourceforge.processdash.i18n.Resources)1 WorkingTimeLog (net.sourceforge.processdash.log.time.WorkingTimeLog)1 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)1 SnippetDefinition (net.sourceforge.processdash.ui.snippet.SnippetDefinition)1