JAL-715 store/reset .jalview_properties setting for RSBS service list
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 30 Aug 2011 12:58:50 +0000 (13:58 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 30 Aug 2011 12:58:50 +0000 (13:58 +0100)
src/jalview/ws/rest/RestClient.java

index ee23790..0d56e87 100644 (file)
@@ -15,6 +15,7 @@ import javax.swing.JOptionPane;
 import javax.swing.event.MenuEvent;
 import javax.swing.event.MenuListener;
 
+import jalview.bin.Cache;
 import jalview.datamodel.AlignmentView;
 import jalview.gui.AlignFrame;
 import jalview.gui.AlignViewport;
@@ -343,13 +344,14 @@ public class RestClient extends WSClient implements WSClientI,
   }
 
   protected static Vector<String> services=null;
+  public static final String RSBS_SERVICES="RSBS_SERVICES";
   public static RestClient[] getRestClients()
   {
     if (services==null)
     {
       services = new Vector<String>();
       try {
-      for (RestServiceDescription descr: RestServiceDescription.parseDescriptions(jalview.bin.Cache.getDefault("RSBS_SERVICES",makeShmmrRestClient().service.toString()))) 
+      for (RestServiceDescription descr: RestServiceDescription.parseDescriptions(jalview.bin.Cache.getDefault(RSBS_SERVICES,makeShmmrRestClient().service.toString()))) 
       {
         services.add(descr.toString());
       }
@@ -412,8 +414,21 @@ public class RestClient extends WSClient implements WSClientI,
 
   public static void setRsbsServices(Vector<String> rsbsUrls)
   {
-    // TODO: consider validating services ?
-    services = new Vector<String>(rsbsUrls);    
+    if (rsbsUrls!=null)
+    {
+      // TODO: consider validating services ?
+      services = new Vector<String>(rsbsUrls);
+      StringBuffer sprop = new StringBuffer();
+      for (String s:services)
+      {
+        sprop.append(s);
+      }
+      Cache.setProperty(RSBS_SERVICES, sprop.toString());
+    } 
+    else
+    {
+      Cache.removeProperty(RSBS_SERVICES);
+    }
   }
 
 }