X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws2%2Fslivka%2FSlivkaWSDiscoverer.java;h=98ce07935e687e3aa2d6c51b415186749d478973;hb=05aa2f3418a9425fba206d2f445d9d58ce93aabf;hp=fe5c040bb1b614754653126bf4121c307709cacd;hpb=12513d239162ffe5d3e8ece01545634c09bd5050;p=jalview.git diff --git a/src/jalview/ws2/slivka/SlivkaWSDiscoverer.java b/src/jalview/ws2/slivka/SlivkaWSDiscoverer.java index fe5c040..98ce079 100644 --- a/src/jalview/ws2/slivka/SlivkaWSDiscoverer.java +++ b/src/jalview/ws2/slivka/SlivkaWSDiscoverer.java @@ -37,7 +37,8 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer } @Override - public List getUrls() { + public List getUrls() + { String surls = Cache.getDefault(SLIVKA_HOST_URLS, DEFAULT_URL); String urls[] = surls.split(","); ArrayList valid = new ArrayList<>(urls.length); @@ -47,13 +48,13 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer { new URL(url); valid.add(url); - } - catch (MalformedURLException e) + } catch (MalformedURLException e) { - Cache.log.warn("Problem whilst trying to make a URL from '" + - Objects.toString(url, "") + "'. " + - "This was probably due to malformed comma-separated-list " + - "in the " + SLIVKA_HOST_URLS + " entry of ${HOME}/.jalview_properties"); + Cache.log.warn("Problem whilst trying to make a URL from '" + + Objects.toString(url, "") + "'. " + + "This was probably due to malformed comma-separated-list " + + "in the " + SLIVKA_HOST_URLS + + " entry of ${HOME}/.jalview_properties"); Cache.log.debug("Exception occurred while reading url list", e); } } @@ -61,53 +62,63 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer } @Override - public void setUrls(List wsUrls) { + public void setUrls(List wsUrls) + { if (wsUrls != null && !wsUrls.isEmpty()) { Cache.setProperty(SLIVKA_HOST_URLS, String.join(",", wsUrls)); } - else { + else + { Cache.removeProperty(SLIVKA_HOST_URLS); } } @Override - public boolean testUrl(URL url) { + public boolean testUrl(URL url) + { return getStatusForUrl(url.toString()) == STATUS_OK; } @Override - public int getStatusForUrl(String url) { + public int getStatusForUrl(String url) + { try { List services = new SlivkaClient(url).getServices(); return services.isEmpty() ? STATUS_NO_SERVICES : STATUS_OK; - } - catch (IOException e) + } catch (IOException e) { - Cache.log.error("Slivka could not retrieve services list from " + url, e); + Cache.log.error("Slivka could not retrieve services list from " + url, + e); return STATUS_INVALID; } } - public List getServices() { + public List getServices() + { return Collections.unmodifiableList(services); } - public boolean hasServices() { + public boolean hasServices() + { return !isRunning() && services.size() > 0; } - public boolean isRunning() { - for (Future task : discoveryTasks) { - if (!task.isDone()) { + public boolean isRunning() + { + for (Future task : discoveryTasks) + { + if (!task.isDone()) + { return false; } } return true; } - public boolean isDone() { + public boolean isDone() + { return !isRunning() && discoveryTasks.size() > 0; } @@ -130,17 +141,22 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer Cache.log.info("Reloading Slivka services"); fireServicesChanged(Collections.emptyList()); ArrayList allServices = new ArrayList<>(); - for (String url : getUrls()) { + for (String url : getUrls()) + { SlivkaClient client = new SlivkaClient(url); List services; - try { + try + { services = client.getServices(); - } catch (IOException e) { + } catch (IOException e) + { Cache.log.error("Unable to fetch services from " + url, e); continue; } - for (SlivkaService service : services) { - SlivkaWebService instance = new SlivkaWebService(client, service, service.getName()); + for (SlivkaService service : services) + { + SlivkaWebService instance = new SlivkaWebService(client, service, + service.getName()); for (String classifier : service.classifiers) { String[] path = classifier.split("\\s*::\\s*"); @@ -148,7 +164,8 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer && path[1].toLowerCase().equals("analysis")) { Operation op = null; - switch (path[path.length - 1].toLowerCase()) { + switch (path[path.length - 1].toLowerCase()) + { case "multiple sequence alignment": op = new AlignmentOperation(instance, instance::getAlignment); } @@ -156,7 +173,8 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer instance.addOperation(op); } } - if (instance.operations.size() > 0) { + if (instance.operations.size() > 0) + { allServices.add(instance); } } @@ -168,7 +186,8 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer } @Override - public String getErrorMessages() { + public String getErrorMessages() + { return ""; }