[Webfunds-commits] java/webfunds/sox/value SSDStore.java

Ian Grigg iang@cypherpunks.ai
Thu, 12 Apr 2001 21:46:08 -0400 (AST)


iang        01/04/12 21:46:08

  Modified:    webfunds/sox/value SSDStore.java
  Log:
  now reads old SOXServer objects

Revision  Changes    Path
1.4       +38 -7     java/webfunds/sox/value/SSDStore.java

Index: SSDStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/value/SSDStore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SSDStore.java	2001/04/12 04:51:06	1.3
+++ SSDStore.java	2001/04/13 01:46:08	1.4
@@ -1,5 +1,5 @@
 /*
- * $Id: SSDStore.java,v 1.3 2001/04/12 04:51:06 iang Exp $
+ * $Id: SSDStore.java,v 1.4 2001/04/13 01:46:08 iang Exp $
  *
  * Copyright (c) 1995-2000 Systemics Inc. on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -21,8 +21,14 @@
 import webfunds.sox.SOXLaterException;
 import webfunds.store.Store;
 
-import webfunds.comms.*;
-import webfunds.ricardian.*;
+import webfunds.comms.CommsManager;
+
+import webfunds.ricardian.ContractStore;
+import webfunds.ricardian.Contract;
+import webfunds.ricardian.ContractException;
+import webfunds.ricardian.SSDFields;
+import webfunds.ricardian.SOXServer;     // XXX: deprecated!
+
 import webfunds.sox.server.*;
 
 public class SSDStore
@@ -56,16 +62,41 @@
 
     protected void readInStore()
     {
-        int i = 0;
-        for (Enumeration e = store.elements(); e.hasMoreElements(); i++)
+        int ok = 0;
+        int total = 0;
+        for (Enumeration e = store.elements(); e.hasMoreElements();)
         {
-            SSD sox = (SSD)e.nextElement();
-            addSSD(sox);
+            Object obj = e.nextElement();
+            SSD ssd;
+            total++;
+
+            if (obj instanceof SSD)
+                ssd = (SSD)obj;
+            else if (obj instanceof SOXServer)   // XXX: deprecated!
+            {
+                SOXServer ss = (SOXServer)obj;
+                byte[] old = ss.getData();
+                try {
+                    ssd = new SSD(old, null, (Log)bug);
+                } catch (SSDException ex) {
+                    logmsg("SOXServer FAILED: " + ss + ":\n" + ex);
+                    continue ;
+                }
+            }
+            else
+            {
+                logmsg("strange object in SSD Store: " + obj.getClass());
+                logmsg("object: " + obj);
+                continue ;
+            }
+            addSSD(ssd);
         }
+
         if (store.checkErrors())
         {
             logmsg("Couldn't read in SSDs");
         }
+        logmsg("Read in " + ok + " SSDs out of " + total + " attempts.");
     }