JAL-2069 update spike branch with latest
[jalview.git] / src / jalview / urls / CustomUrlProvider.java
index 07f4068..86d5660 100644 (file)
@@ -149,8 +149,7 @@ public class CustomUrlProvider extends UrlProviderImpl
     {
       Map.Entry<String, String> pair = it.next();
       urls.put(pair.getKey(),
- new UrlLink(pair.getKey(), pair.getValue(),
-              pair.getKey()));
+              new UrlLink(pair.getKey(), pair.getValue(), pair.getKey()));
     }
     upgradeOldLinks(urls);
     return urls;
@@ -161,10 +160,24 @@ public class CustomUrlProvider extends UrlProviderImpl
    */
   private void upgradeOldLinks(HashMap<String, UrlLink> urls)
   {
+    boolean upgrade = false;
     // upgrade old SRS link
     if (urls.containsKey(SRS_LABEL))
     {
       urls.remove(SRS_LABEL);
+      upgrade = true;
+    }
+    // upgrade old EBI link - easier just to remove and re-add than faffing
+    // around checking exact url
+    if (urls.containsKey(UrlConstants.DEFAULT_LABEL))
+    {
+      // note because this is called separately for selected and nonselected
+      // urls, the default url will not always be present
+      urls.remove(UrlConstants.DEFAULT_LABEL);
+      upgrade = true;
+    }
+    if (upgrade)
+    {
       UrlLink link = new UrlLink(UrlConstants.DEFAULT_STRING);
       link.setLabel(UrlConstants.DEFAULT_LABEL);
       urls.put(UrlConstants.DEFAULT_LABEL, link);
@@ -296,15 +309,13 @@ public class CustomUrlProvider extends UrlProviderImpl
         }
         if (link.getIsSelected())
         {
-          selurls.put(link.getId(),
-                  new UrlLink(link.getDescription(), link.getUrl(), link.getDescription()));
+          selurls.put(link.getId(), new UrlLink(link.getDescription(),
+                  link.getUrl(), link.getDescription()));
         }
         else
         {
-          unselurls
-                  .put(link.getId(),
-                          new UrlLink(link.getDescription(), link.getUrl(), link
-                                  .getDescription()));
+          unselurls.put(link.getId(), new UrlLink(link.getDescription(),
+                  link.getUrl(), link.getDescription()));
         }
         // sort out primary and selected ids
         if (link.getIsPrimary())
@@ -336,7 +347,8 @@ public class CustomUrlProvider extends UrlProviderImpl
   @Override
   public boolean contains(String id)
   {
-    return (selectedUrls.containsKey(id) || nonselectedUrls.containsKey(id));
+    return (selectedUrls.containsKey(id)
+            || nonselectedUrls.containsKey(id));
   }
 
 }