Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / bin / Cache.java
index 19aa800..3c919cb 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.schemes.UserColourScheme;
 import jalview.structure.StructureImportSettings;
 import jalview.urls.IdOrgSettings;
 import jalview.util.ColorUtils;
+import jalview.util.Platform;
 import jalview.ws.sifts.SiftsSettings;
 
 import java.awt.Color;
@@ -277,7 +278,8 @@ public class Cache
   /** Default file is ~/.jalview_properties */
   static String propertiesFile;
 
-  private static boolean propsAreReadOnly = false;
+  private static boolean propsAreReadOnly = /** @j2sNative true || */
+          false;
 
   public static void initLogger()
   {
@@ -386,6 +388,8 @@ public class Cache
     }
 
     // LOAD THE AUTHORS FROM THE authors.props file
+    boolean ignore = Platform.isJS();
+    if (!ignore)
     try
     {
       String authorDetails = "jar:"
@@ -397,17 +401,25 @@ 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 = "jar:".concat(Cache.class.getProtectionDomain()
@@ -422,7 +434,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");
@@ -610,18 +626,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;
   }
 
   /**
@@ -1063,4 +1074,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);
+                */
+       }
 }