[Webfunds-commits] java/webfunds/sox/value WebFundsData.java SOXServerStore.java StoreAccountStore.java ValueManager.java StoreReceiptStore.java

Ian Grigg iang@cypherpunks.ai
Mon, 26 Mar 2001 21:48:37 -0400 (AST)


iang        01/03/26 21:48:37

  Modified:    webfunds/sox/value SOXServerStore.java
                        StoreAccountStore.java ValueManager.java
  Added:       webfunds/sox/value WebFundsData.java
  Removed:     webfunds/sox/value StoreReceiptStore.java
  Log:
  get constructors right, fiddling with names, compiles but not yet tested.

Revision  Changes    Path
1.13      +13 -1     java/webfunds/sox/value/SOXServerStore.java

Index: SOXServerStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/value/SOXServerStore.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SOXServerStore.java	2001/03/24 23:57:23	1.12
+++ SOXServerStore.java	2001/03/27 01:48:36	1.13
@@ -1,5 +1,5 @@
 /*
- * $Id: SOXServerStore.java,v 1.12 2001/03/24 23:57:23 iang Exp $
+ * $Id: SOXServerStore.java,v 1.13 2001/03/27 01:48:36 iang Exp $
  *
  * Copyright (c) 1995-2000 Systemics Inc. on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -24,6 +24,18 @@
 {
 
     Store store;
+
+    public SOXServerStore(Store store)
+    {
+        super();
+        // debug(bug, "     ssS: ");
+
+        if (store == null)
+            throw new RuntimeException("SOXServerStore store == null");
+        this.store = store;
+        readInStore();
+        logmsg("SOXServerStore Open!");
+    }
 
     public SOXServerStore(Store store, PrintWriter bug)
     {



1.26      +2 -2      java/webfunds/sox/value/StoreAccountStore.java

Index: StoreAccountStore.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/value/StoreAccountStore.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- StoreAccountStore.java	2001/03/26 03:29:54	1.25
+++ StoreAccountStore.java	2001/03/27 01:48:36	1.26
@@ -1,5 +1,5 @@
 /*
- * $Id: StoreAccountStore.java,v 1.25 2001/03/26 03:29:54 iang Exp $
+ * $Id: StoreAccountStore.java,v 1.26 2001/03/27 01:48:36 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -42,7 +42,7 @@
     
         
     public Account[] getAllAccounts()
-        throws StoreException
+        throws StoreException  // doesn't currently, but should
     {
         Account[] retval = new Account[store.size()];
         int i = 0;



1.3       +7 -22     java/webfunds/sox/value/ValueManager.java

Index: ValueManager.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/value/ValueManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ValueManager.java	2001/03/26 03:29:54	1.2
+++ ValueManager.java	2001/03/27 01:48:36	1.3
@@ -1,4 +1,4 @@
-/* $Id: ValueManager.java,v 1.2 2001/03/26 03:29:54 iang Exp $
+/* $Id: ValueManager.java,v 1.3 2001/03/27 01:48:36 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -60,7 +60,7 @@
  *
  *  (Was the SOXWallet -- attempt to separate and make simple!)
  *
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public class ValueManager
     extends Debug
@@ -109,15 +109,16 @@
      * Construction is complicated by class loader, hence separate init.
      */
     public void init(SecureRandom sr, Store store,
-                     ContractStore contracts, Properties properties)
+                     IssuerFinder finder, Properties properties)
         throws StoreException
     {
         if (Crypto.sr == null)
             Crypto.setSecureRandom(sr);
 
         this.properties = properties;
+        this.finder = finder;
 
-        setStore(store, contracts);
+        setStore(store);
     }
 
 
@@ -137,27 +138,11 @@
      *  This is the only access we have to persistant storage.
      *  Unfortunately, it's quite limiting.
      */
-    protected void setStore(Store store, ContractStore contracts)
+    protected void setStore(Store store)
         throws StoreException
     {
         this.store   = store;
 
-        //
-        //  The SOX server file Store.
-        //
-        Store soxstore = null;
-        try {
-            soxstore = store.getStore("SOXServers", SepFileStore.APPEND);
-        } catch (StoreException ex) {  // should delete and start again
-            // ex.printStackTrace(err());
-            logmsg("Failed to get SOXServers store: " + ex);
-            // System.exit(1);
-            throw ex ;
-        }
-
-        soxes = new SOXServerStore(soxstore, getDebug());
-        soxes.setContractStore(contracts);
-        finder = (IssuerFinder)soxes;
 
         //
         //  Account store.
@@ -364,8 +349,6 @@
 
     public long getValue(AccountId acct, ItemId item, boolean pending)
     {
-        // I moved the contents to StoreReceiptStore, which better knows
-        // about changes.  There were some logical ???s in the old one.
         try
         {
             if (pending)
@@ -817,7 +800,7 @@
      *  @throw AccountException if the target account does not exist, or
      *                          does not include the item as a subaccount
      */
-    public Receipt doDeposit(AbstractPayment pay, AccountId accountid, 
+    public Receipt deposit(AbstractPayment pay, AccountId accountid, 
                              byte[] desc, String idempotentId)
         throws DepositException, AccountException
     {
@@ -1680,9 +1663,11 @@
     }
 
 
+////////////////  Miscellaneous   ///////////////////////////////
 
     public String toString()
     {
         return shortname;
     }
+     
 }



1.1                  java/webfunds/sox/value/WebFundsData.java

Index: WebFundsData.java
===================================================================
/* $Id: WebFundsData.java,v 1.1 2001/03/27 01:48:36 iang Exp $
 *
 * Copyright (c) Systemics Inc. 1995-2000 on behalf of
 * The WebFunds Development Team.  All Rights Reserved.
 */
package webfunds.sox.value;


// JDK
import java.io.File;

import java.security.SecureRandom;

import webfunds.sox.IssuerFinder;

import webfunds.ricardian.Contract;
import webfunds.ricardian.ContractStore;
import webfunds.ricardian.DirContractStore;
import webfunds.ricardian.ContractDirectoryException;

import webfunds.ricardian.SOXStore;
import webfunds.ricardian.DirSOXStore;
import webfunds.ricardian.SOXServerException;

import webfunds.store.Store;
import webfunds.store.StoreException;
import webfunds.store.SepFileStore;



/**
 *  The paramaters for the SOX Value Manager.
 *
 *  Static data that identifies where files are, in
 *  the WebFunds v2 existance.
 *
 *  @version $Revision: 1.1 $
 */
public class WebFundsData
{
    private final String userDirName;
    private       File soxDir, userDir;
    private       Store soxWalletStore;
    private       ContractStore contracts;

    public WebFundsData(String userDirName)
    {
        this.userDirName = userDirName;
        this.userDir    = new File(userDirName);
        File dataDir    = new File(userDir, "data2");
        File walletDir  = new File(dataDir, "WalletManager");
        this.soxDir     = new File(walletDir, "SOX");


    }

    /**
     *  Hard-coded historical path.
     *  There is no "proper" place for this as it is part of
     *  the WebFunds application, and we don't want to be
     *  dependant on that package here.
     */
    public Store getSOXWalletStore()
    {
        if (soxWalletStore == null)
        {
            soxWalletStore  = SepFileStore.getInstance(soxDir);
        }
        return soxWalletStore;
    }

    public ContractStore getContractStore()
        throws ContractDirectoryException
    {
        if (contracts == null)
        {
            File contractDir        = new File(userDir, "contract");
            ContractStore contracts = new DirContractStore(contractDir);
        }
        return contracts;
    }


    public IssuerFinder getIssuerFinder()
        throws StoreException, ContractDirectoryException
    {
        Store soxWallet = getSOXWalletStore();
        //
        //  The SOX server file Store.
        //
        Store soxstore = soxWallet.getStore("SOXServers", SepFileStore.APPEND);
        SOXServerStore soxes = new SOXServerStore(soxstore);
        soxes.setContractStore(getContractStore());
        return (IssuerFinder)soxes;
    }

}