removing cyclic call
[jalview.git] / src / jalview / bin / Cache.java
index d374682..888dc29 100755 (executable)
@@ -28,8 +28,7 @@ import jalview.schemes.UserColourScheme;
 import jalview.structure.StructureImportSettings;
 import jalview.urls.IdOrgSettings;
 import jalview.util.ColorUtils;
-import jalview.ws.dbsources.das.api.DasSourceRegistryI;
-import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
+import jalview.util.Platform;
 import jalview.ws.sifts.SiftsSettings;
 
 import java.awt.Color;
@@ -398,10 +397,11 @@ public class Cache
     }
 
     // LOAD THE AUTHORS FROM THE authors.props file
+    boolean ignore = Platform.isJS();
+    if (!ignore)
     try
     {
-      String authorDetails = /** @j2sNative "xxx" || */
-              "jar:"
+      String authorDetails = "jar:"
               .concat(Cache.class.getProtectionDomain().getCodeSource()
                       .getLocation().toString().concat("!/authors.props"));
 
@@ -410,21 +410,28 @@ public class Cache
       InputStream in = localJarFileURL.openStream();
       applicationProperties.load(in);
       in.close();
+      
     } catch (Exception ex)
     {
       System.out.println("Error reading author details: " + ex);
-      applicationProperties.remove("AUTHORS");
-      applicationProperties.remove("AUTHORFNAMES");
-      applicationProperties.remove("YEAR");
+      ignore = true;
     }
 
+    if (ignore) {
+        applicationProperties.remove("AUTHORS");
+        applicationProperties.remove("AUTHORFNAMES");
+        applicationProperties.remove("YEAR");
+    }
+    
     // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
     // MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE
     // VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW
+    // BH 2019.01.25 switching to Platform.isJS()
+    ignore = Platform.isJS();
+    if (!ignore)
     try
     {
-      String buildDetails = /** @j2sNative "xxx" || */
-              "jar:".concat(Cache.class.getProtectionDomain()
+      String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
               .getCodeSource().getLocation().toString()
               .concat("!/.build_properties"));
 
@@ -436,7 +443,11 @@ public class Cache
     } catch (Exception ex)
     {
       System.out.println("Error reading build details: " + ex);
-      applicationProperties.remove("VERSION");
+      ignore = true;
+    }
+    
+    if (ignore) {
+        applicationProperties.remove("VERSION");
     }
 
     String jnlpVersion = System.getProperty("jalview.version");
@@ -606,18 +617,13 @@ public class Cache
   }
 
   /**
-   * These methods are used when checking if the saved preference is different
-   * to the default setting
+   * Answers the value of the given property, or the supplied default value if
+   * the property is not set
    */
   public static String getDefault(String property, String def)
   {
-    String string = getProperty(property);
-    if (string != null)
-    {
-      return string;
-    }
-
-    return def;
+    String value = getProperty(property);
+    return value == null ? def : value;
   }
 
   /**
@@ -985,22 +991,6 @@ public class Cache
     return null;
   }
 
-  private static DasSourceRegistryI sourceRegistry = null;
-
-  /**
-   * initialise and ..
-   * 
-   * @return instance of the das source registry
-   */
-  public static DasSourceRegistryI getDasSourceRegistry()
-  {
-    if (sourceRegistry == null)
-    {
-      sourceRegistry = new DasSourceRegistry();
-    }
-    return sourceRegistry;
-  }
-
   /**
    * Set the specified value, or remove it if null or empty. Does not save the
    * properties file.
@@ -1075,4 +1065,19 @@ public class Cache
       }
     }
   }
+
+       /**
+        * Add a known domain that implements access-control-allow-origin:* bh 2018
+        * 
+        * @param defaultUniprotDomain
+        */
+       public static void addJ2SDirectDatabaseCall(String domain) 
+       {
+
+               /**
+                * @j2sNative
+                * 
+                *                      J2S.addDirectDatabaseCall(domain);
+                */
+       }
 }