From 7243db3d99cc1760c2d4802f3005b4f86d1b4bd6 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 11 May 2012 14:22:08 +0100 Subject: [PATCH] JAL-972 workaround for working out source URL for pre DAS 1.6 sources. note - certain sources currently in registry have invalid URLs in their capability elements (missing '/' between URL and command) --- .../ws/dbsources/das/datamodel/JalviewSource.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java b/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java index 11bdf02..139bafe 100644 --- a/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java +++ b/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java @@ -311,9 +311,23 @@ public class JalviewSource implements jalviewSourceI { try { - String url = new RegistrySourceAdapter(source) - .getOriginalDataSourceUri(); - return url; + // kind of dumb, since org.biodas.jdas.dassources.utils.VersionAdapter.getSourceUriFromQueryUri() does this, + // but this way, we can access non DAS 1.6 compliant sources (which have to have a URL like /das/ and cause a validation exception) + + for (CAPABILITY cap : getVersion().getCAPABILITY()) + { + String capname = cap.getType().substring( + cap.getType().indexOf(":") + 1); + int p=cap.getQueryUri().lastIndexOf(capname); + if (p<-1) { + throw new Exception("Invalid das source: "+source.getUri()); + } + if (cap.getQueryUri().charAt(p)=='/') + { + p--; + } + return cap.getQueryUri().substring(0,p); + } } catch (Exception x) { System.err.println("Serious: Couldn't get the URL for source " -- 1.7.10.2