X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2Fdas%2Fdatamodel%2FDasSourceRegistry.java;h=9d044bc5cf94a0ade1a9dd83c99de45787c16b80;hb=48eed205662848798c4ff2d21d3e184d135b9e83;hp=7257d0c47492c6ea2472d9d1b0ab4831749a31fa;hpb=831ad693b1320d74143011e1fe510496876e148a;p=jalview.git
diff --git a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java b/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java
index 7257d0c..9d044bc 100644
--- a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java
+++ b/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java
@@ -1,5 +1,19 @@
-/**
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
*
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
*/
package jalview.ws.dbsources.das.datamodel;
@@ -7,19 +21,12 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import org.apache.http.auth.InvalidCredentialsException;
import org.biodas.jdas.client.ConnectionPropertyProviderI;
import org.biodas.jdas.client.SourcesClient;
import org.biodas.jdas.client.threads.MultipleConnectionPropertyProviderI;
@@ -46,7 +53,7 @@ public class DasSourceRegistry implements DasSourceRegistryI,
private Hashtable localSources = null;
- public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";
+ public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das/";
/**
* true if thread is running and we are talking to DAS registry service
@@ -69,6 +76,14 @@ public class DasSourceRegistry implements DasSourceRegistryI,
DEFAULT_REGISTRY);
registry = DEFAULT_REGISTRY;
}
+ if (registry.lastIndexOf("sources.xml") == registry.length() - 11)
+ {
+ // no trailing sources.xml document for registry in JDAS
+ jalview.bin.Cache.setProperty(
+ jalview.bin.Cache.DAS_REGISTRY_URL,
+ registry = registry.substring(0,
+ registry.lastIndexOf("sources.xml")));
+ }
return registry;
}
@@ -82,7 +97,7 @@ public class DasSourceRegistry implements DasSourceRegistryI,
private List getDASSources()
{
- return getDASSources(getDasRegistryURL());
+ return getDASSources(getDasRegistryURL(), this);
}
/**
@@ -91,7 +106,8 @@ public class DasSourceRegistry implements DasSourceRegistryI,
* @param registryURL
* return sources from registryURL
*/
- private static List getDASSources(String registryURL)
+ private static List getDASSources(String registryURL,
+ MultipleConnectionPropertyProviderI registry)
{
try
{
@@ -103,9 +119,29 @@ public class DasSourceRegistry implements DasSourceRegistryI,
List dassources = sources.getSOURCE();
ArrayList dsrc = new ArrayList();
+ HashMap latests = new HashMap();
+ Integer latest;
for (SOURCE src : dassources)
{
- dsrc.add(new JalviewSource(src, false));
+ JalviewSource jsrc = new JalviewSource(src, registry, false);
+ latest = latests.get(jsrc.getSourceURL());
+ if (latest != null)
+ {
+ if (jsrc.isNewerThan(dsrc.get(latest.intValue())))
+ {
+ dsrc.set(latest.intValue(), jsrc);
+ }
+ else
+ {
+ System.out.println("Debug: Ignored older source "
+ + jsrc.getTitle());
+ }
+ }
+ else
+ {
+ latests.put(jsrc.getSourceURL(), Integer.valueOf(dsrc.size()));
+ dsrc.add(jsrc);
+ }
}
return dsrc;
} catch (Exception ex)
@@ -207,7 +243,7 @@ public class DasSourceRegistry implements DasSourceRegistryI,
{
localSources = new Hashtable();
}
- jalviewSourceI src = new JalviewSource(local, true);
+ jalviewSourceI src = new JalviewSource(local, this, true);
localSources.put(local.getTitle(), src);
return src;
}