JAL-1432 updated copyright notices
[jalview.git] / src / jalview / ws / dbsources / das / datamodel / DasSourceRegistry.java
index 7b3435f..52e8db5 100644 (file)
@@ -1,5 +1,20 @@
-/**
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
+ * 
+ * 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 <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.ws.dbsources.das.datamodel;
 
@@ -7,20 +22,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.HashSet;
 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;
@@ -172,13 +179,21 @@ public class DasSourceRegistry implements DasSourceRegistryI,
     {
       // get local sources from properties and initialise the local source list
       String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
+
       if (local != null)
       {
+        int n = 1;
         StringTokenizer st = new StringTokenizer(local, "\t");
         while (st.hasMoreTokens())
         {
           String token = st.nextToken();
           int bar = token.indexOf("|");
+          if (bar == -1)
+          {
+            System.err
+                    .println("Warning: DAS user local source appears to have no nickname (expected a '|' followed by nickname)\nOffending definition: '"
+                            + token + "'");
+          }
           String url = token.substring(bar + 1);
           boolean features = true, sequence = false;
           if (url.startsWith("sequence:"))
@@ -187,8 +202,25 @@ public class DasSourceRegistry implements DasSourceRegistryI,
             // this source also serves sequences as well as features
             sequence = true;
           }
-          createLocalSource(url, token.substring(0, bar), sequence,
-                  features);
+          try
+          {
+            if (bar > -1)
+            {
+              createLocalSource(url, token.substring(0, bar), sequence,
+                      features);
+            }
+            else
+            {
+              createLocalSource(url, "User Source" + n, sequence, features);
+            }
+          } catch (Exception q)
+          {
+            System.err
+                    .println("Unexpected exception when creating local source from '"
+                            + token + "'");
+            q.printStackTrace();
+          }
+          n++;
         }
       }
     }