[Webfunds-commits] java/webfunds/sox ValueAccount.java

Ian Grigg iang@cypherpunks.ai
Sun, 16 Jul 2000 15:35:33 -0400 (AST)


iang        00/07/16 15:35:33

  Modified:    webfunds/sox ValueAccount.java
  Log:
  comments, added the suggested idempotentId capability, reports NO_NET

Revision  Changes    Path
1.17      +19 -14    java/webfunds/sox/ValueAccount.java

Index: ValueAccount.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/ValueAccount.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ValueAccount.java	2000/07/10 17:37:55	1.16
+++ ValueAccount.java	2000/07/16 19:35:33	1.17
@@ -1,5 +1,5 @@
 /*
- * $Id: ValueAccount.java,v 1.16 2000/07/10 17:37:55 iang Exp $
+ * $Id: ValueAccount.java,v 1.17 2000/07/16 19:35:33 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -39,21 +39,26 @@
 ////// Deposit ////////////////////////////////// 
 
     /**
-     * Deposit a payment.
-     * The deposit is what makes this a ValueAccount, over the
-     * top of the standard SOXAccount.
-     * @throws SOXArgsException if item in payment is invalid
-     * @throws SOXLaterException if there is no ability to talk to the server
-     * @throws SOXSubAccountException if something goes wrong with access
-     * @throws SOXKeyException if something goes wrong with signing
+     *  Deposit a payment.
+     *  The deposit is what makes this a ValueAccount, over the
+     *  top of the standard SOXAccount.
+     *
+     *  @param payment to deposit
+     *  @param desc is binary description
+     *  @param did is a suggested idempotent Id to use, ignore if invalid
+     *
+     *  @throws SOXArgsException if item in payment is invalid
+     *  @throws SOXLaterException if there is no ability to talk to the server
+     *  @throws SOXSubAccountException if something goes wrong with access
+     *  @throws SOXKeyException if something goes wrong with signing
      */
-    public MailItem[] deposit(Payment payment, String desc)
+    public MailItem[] deposit(Payment payment, String desc, String did)
           throws SOXSubAccountException, SOXLaterException, SOXKeyException,
                  SOXArgsException, SOXDepositException
     {
         checkFrozen("deposit");
         if (!NetWatcher.netAvailability())
-            throw new SOXLaterException(SOXLaterException.NET, "No Net");
+            throw new SOXLaterException(SOXLaterException.LATER_NET, "No Net");
         if (isNew())          // also see retry code in doDepositGetMail()
             register();
 
@@ -64,7 +69,8 @@
             throw new SOXArgsException(s);
         }
 
-        String did = "D" + System.currentTimeMillis();
+        if (did == null || (did.length() == 0))
+            did = "D" + System.currentTimeMillis();
         String num = "" + reqNo++;
         DepositRequest req = new DepositRequest(num, acct.getId(),
                                                 payment, did, desc.getBytes());
@@ -77,7 +83,6 @@
         byte[] sig;
         try {
             sig = acct.sign(reqData);
-            // sig = Crypto.sign(acct.getKey(), req.encode());
         } catch (java.security.KeyException kex) {
             kex.printStackTrace(System.err);
             throw new SOXKeyException("KeyException: " + kex);
@@ -224,7 +229,7 @@
     {
         checkFrozen("cancel");
         if (!NetWatcher.netAvailability())
-            throw new SOXLaterException(SOXLaterException.NET, "No Net");
+            throw new SOXLaterException(SOXLaterException.LATER_NET, "No Net");
 
         String cancelId = payment.getId();
         Payment cancel = new Payment(cancelId, acct.getId(),
@@ -248,7 +253,7 @@
     {
         checkFrozen("cancel");
         if (!NetWatcher.netAvailability())
-            throw new SOXLaterException(SOXLaterException.NET, "No Net");
+            throw new SOXLaterException(SOXLaterException.LATER_NET, "No Net");
 
         byte[] paymentData = cancel.encode();