Search in sources :

Example 1 with URL

use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.

the class AbstractODOTest method triggerDebugSession.

public static void triggerDebugSession(String eclipseProjectName, String project, String application, String component, String urlSuffix) throws IOException, InterruptedException, ExecutionException {
    String path = ResourcesPlugin.getWorkspace().getRoot().getProject(eclipseProjectName).getLocation().toOSString();
    List<URL> urls = OdoCliFactory.getInstance().getOdo().get().listURLs(project, application, path, component);
    java.net.URL url = new java.net.URL("http://" + urls.get(0).getHost() + urlSuffix);
    new Thread(new Runnable() {

        public void run() {
            try {
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.connect();
                connection.getResponseCode();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }).start();
}
Also used : HttpURLConnection(java.net.HttpURLConnection) URL(org.jboss.tools.openshift.core.odo.URL) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException)

Example 2 with URL

use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.

the class OdoCli method parseURLs.

private static List<URL> parseURLs(String json) {
    List<URL> result = new ArrayList<>();
    try {
        JsonNode root = JSON_MAPPER.readTree(json);
        JsonNode items = root.get("items");
        if (items != null) {
            items.forEach(item -> {
                // odo incorrecly reports urls created with the web ui without names
                if (item.get("metadata").has("name")) {
                    result.add(URL.of(item.get("metadata").get("name").asText(), item.get("spec").has("protocol") ? item.get("spec").get("protocol").asText() : "", item.get("spec").has("host") ? item.get("spec").get("host").asText() : "", item.get("spec").has("port") ? item.get("spec").get("port").asText() : "0", item.get("status").get("state").asText(), item.get("spec").get("secure").asBoolean()));
                }
            });
        }
    } catch (IOException e) {
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) URL(org.jboss.tools.openshift.core.odo.URL)

Example 3 with URL

use of org.jboss.tools.openshift.core.odo.URL in project jbosstools-openshift by jbosstools.

the class OdoCli method loadSwagger.

private void loadSwagger() {
    try {
        Request req = new Request.Builder().get().url(new java.net.URL(client.getMasterUrl(), "/openapi/v2")).build();
        Response response = client.adapt(OkHttpClient.class).newCall(req).execute();
        if (response.isSuccessful()) {
            swagger = new JSonParser(new ObjectMapper().readTree(response.body().charStream()));
        }
    } catch (IOException e) {
        OpenShiftUIActivator.log(IStatus.ERROR, e.getLocalizedMessage(), e);
    }
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) IOException(java.io.IOException) JSonParser(org.jboss.tools.openshift.core.odo.JSonParser) URL(org.jboss.tools.openshift.core.odo.URL) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

IOException (java.io.IOException)3 URL (org.jboss.tools.openshift.core.odo.URL)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HttpURLConnection (java.net.HttpURLConnection)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)1 JSonParser (org.jboss.tools.openshift.core.odo.JSonParser)1