Skip to content

Commit

Permalink
BZ-1100150 - Cannot open 'Process & Task Dashboard' under NAT environ…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
dgutierr committed Sep 3, 2014
1 parent 47ba88c commit 9b81fe8
Showing 1 changed file with 14 additions and 7 deletions.
Expand Up @@ -17,6 +17,12 @@
@ApplicationScoped
public class DashboardRendererServiceImpl implements DashboardRendererService {

/**
* Maximum amount of time (in milliseconds) a ping alive request to the dashbuilder remote URL may last.
* <p>The system property <i>dashbuilder.bind.timeout</i> can be used to set a custom value.</p>
*/
public static int PING_TIMEOUT = 1000;

@Override
public ConnectionStatus getAppStatus(String theUrl) {
ConnectionStatus connectionStatus = new ConnectionStatus();
Expand All @@ -30,7 +36,7 @@ public ConnectionStatus getAppStatus(String theUrl) {
int status = pingUrl(anUrl);
connectionStatus.setStatus(status);
return connectionStatus;
} catch (Exception e){
} catch (Exception e) {
exc = e;
}
}
Expand All @@ -40,8 +46,15 @@ public ConnectionStatus getAppStatus(String theUrl) {
}

protected int pingUrl(String anUrl) throws Exception {
int timeout = PING_TIMEOUT;
String bindTimeout = System.getProperty("dashbuilder.bind.timeout");
if (!StringUtils.isBlank(bindTimeout)) {
timeout = Integer.parseInt(bindTimeout);
}

URL url = new URL(anUrl);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setConnectTimeout(timeout);
return urlConnection.getResponseCode();
}

Expand Down Expand Up @@ -78,10 +91,4 @@ protected List<String> explodeUrl(String anUrl) {
return results;
}

public static void main(String[] args) {
DashboardRendererServiceImpl s = new DashboardRendererServiceImpl();
for (String s1 : s.explodeUrl("http://localhost:8080/dashbuilder/workspace")) {
System.out.println(s1);
}
}
}

0 comments on commit 9b81fe8

Please sign in to comment.