You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(119) |
Oct
(111) |
Nov
(238) |
Dec
(395) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(239) |
Feb
(59) |
Mar
(354) |
Apr
(489) |
May
(23) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(5) |
Jun
(2) |
Jul
|
Aug
|
Sep
(3) |
Oct
(14) |
Nov
(17) |
Dec
(9) |
| 2007 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(7) |
May
(3) |
Jun
(6) |
Jul
(4) |
Aug
(3) |
Sep
(15) |
Oct
(13) |
Nov
(35) |
Dec
(40) |
| 2009 |
Jan
(19) |
Feb
(21) |
Mar
(16) |
Apr
(18) |
May
(36) |
Jun
(20) |
Jul
(32) |
Aug
(11) |
Sep
(3) |
Oct
(2) |
Nov
(2) |
Dec
(13) |
| 2010 |
Jan
(5) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(3) |
| 2012 |
Jan
(3) |
Feb
(3) |
Mar
(1) |
Apr
(4) |
May
(8) |
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
(8) |
Oct
(3) |
Nov
(8) |
Dec
(4) |
| 2013 |
Jan
(2) |
Feb
(1) |
Mar
(5) |
Apr
(6) |
May
(10) |
Jun
(5) |
Jul
(6) |
Aug
(7) |
Sep
(5) |
Oct
(2) |
Nov
(4) |
Dec
(4) |
| 2014 |
Jan
(13) |
Feb
(4) |
Mar
(7) |
Apr
(9) |
May
(20) |
Jun
(13) |
Jul
(10) |
Aug
(3) |
Sep
(5) |
Oct
(2) |
Nov
(2) |
Dec
(2) |
| 2015 |
Jan
(3) |
Feb
(3) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(3) |
| 2016 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(4) |
Sep
(3) |
Oct
(3) |
Nov
(4) |
Dec
(2) |
| 2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <pe...@us...> - 2003-10-29 16:40:05
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/passphraseagents In directory sc8-pr-cvs1:/tmp/cvs-serv5345/src/java/org/neuclear/passphraseagents Log Message: Directory /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/passphraseagents added to the repository |
|
From: <pe...@us...> - 2003-10-28 23:56:29
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers
In directory sc8-pr-cvs1:/tmp/cvs-serv10750/src/test/org/neuclear/signers
Modified Files:
SimpleSignerStoreTest.java
Log Message:
Fixed the SimpleSignerStore unit test to verify the next functionality of the SignerStore interface.
Index: SimpleSignerStoreTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/signers/SimpleSignerStoreTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SimpleSignerStoreTest.java 21 Oct 2003 22:31:15 -0000 1.3
--- SimpleSignerStoreTest.java 28 Oct 2003 23:56:04 -0000 1.4
***************
*** 1,4 ****
--- 1,7 ----
/* $Id$
* $Log$
+ * Revision 1.4 2003/10/28 23:56:04 pelle
+ * Fixed the SimpleSignerStore unit test to verify the next functionality of the SignerStore interface.
+ *
* Revision 1.3 2003/10/21 22:31:15 pelle
* Renamed NeudistException to NeuClearException and moved it to org.neuclear.commons where it makes more sense.
***************
*** 59,68 ****
import junit.framework.TestCase;
- import org.neudist.crypto.signerstores.SimpleSignerStore;
import org.neuclear.commons.NeuClearException;
import java.io.File;
import java.io.IOException;
! import java.security.*;
--- 62,76 ----
import junit.framework.TestCase;
import org.neuclear.commons.NeuClearException;
+ import org.neudist.crypto.CryptoException;
+ import org.neudist.crypto.CryptoTools;
+ import org.neudist.crypto.signerstores.SimpleSignerStore;
import java.io.File;
import java.io.IOException;
! import java.security.GeneralSecurityException;
! import java.security.KeyPair;
! import java.security.KeyPairGenerator;
! import java.security.SecureRandom;
***************
*** 70,78 ****
* @author pelleb
* @version $Revision$
! **/
public class SimpleSignerStoreTest extends TestCase {
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
! setUp();
}
--- 78,87 ----
* @author pelleb
* @version $Revision$
! */
public class SimpleSignerStoreTest extends TestCase {
public SimpleSignerStoreTest(String name) throws GeneralSecurityException, NeuClearException {
super(name);
! store = getSignerStoreInstance();
! generateKeys();
}
***************
*** 84,91 ****
}
- protected void setUp() throws NeuClearException, GeneralSecurityException {
- store = getSignerStoreInstance();
- generateKeys();
- }
protected static synchronized void generateKeys() throws GeneralSecurityException {
--- 93,96 ----
***************
*** 101,107 ****
}
- protected void tearDown() {
- store = null;
- }
public void testAddKey() throws NeuClearException, GeneralSecurityException, IOException {
--- 106,109 ----
***************
*** 118,127 ****
}
! public void testGetKey() throws NeuClearException, GeneralSecurityException, IOException {
boolean success = false;
! PrivateKey key = null;
try {
store.addKey("bob", "bob".toCharArray(), bob.getPrivate());
! key = store.getKey("bob", "bob".toCharArray());
success = true;
} catch (GeneralSecurityException e) {
--- 120,130 ----
}
! public void testSignData() throws NeuClearException, GeneralSecurityException, IOException, CryptoException {
boolean success = false;
! byte data[] = null;
try {
store.addKey("bob", "bob".toCharArray(), bob.getPrivate());
! data = store.sign("bob", "test".getBytes());
! assertTrue(CryptoTools.verify(bob.getPublic(), "test".getBytes(), data));
success = true;
} catch (GeneralSecurityException e) {
***************
*** 130,153 ****
e.printStackTrace();
}
! assertTrue("Managed to add and Fetch a key", success);
! assertNotNull("Key wasn't null", key);
! assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
}
- public static void main(String[] args) {
- try {
- SimpleSignerStoreTest test = new SimpleSignerStoreTest("SimpleSignerStoreTest");
- test.setUp();
- test.testGetKey();
- } catch (Exception e) {
- // if (e instanceof NeuClearException) {
- // ((NeuClearException)e).getParcel().printStackTrace();
- // } else
- e.printStackTrace();
-
- }
-
- // junit.textui.TestRunner.run (suite());
- }
private SimpleSignerStore store;
--- 133,141 ----
e.printStackTrace();
}
! assertTrue("Managed to add and sign some data", success);
! assertNotNull("Key wasn't null", data);
! //assertEquals("Gotten Key was the same as Stored Key", bob.getPrivate(), key);
}
private SimpleSignerStore store;
|
|
From: <pe...@us...> - 2003-10-28 23:44:44
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/signers/commandline
In directory sc8-pr-cvs1:/tmp/cvs-serv8821/src/java/org/neuclear/signers/commandline
Modified Files:
CommandLineSigner.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: CommandLineSigner.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/signers/commandline/CommandLineSigner.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** CommandLineSigner.java 25 Oct 2003 00:39:54 -0000 1.8
--- CommandLineSigner.java 28 Oct 2003 23:44:35 -0000 1.9
***************
*** 1,4 ****
--- 1,8 ----
/* $Id$
* $Log$
+ * Revision 1.9 2003/10/28 23:44:35 pelle
+ * The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ * The two SignerStore implementations both use it for the passphrase.
+ *
* Revision 1.8 2003/10/25 00:39:54 pelle
* Fixed SmtpSender it now sends the messages.
***************
*** 290,294 ****
protected CommandLine cmd;
protected Options options;
! protected final static String keystore = System.getProperty("user.home") + "/.keystore";
protected final KeyStore ks;
protected String alias;
--- 294,298 ----
protected CommandLine cmd;
protected Options options;
! public final static String keystore = System.getProperty("user.home") + "/.keystore";
protected final KeyStore ks;
protected String alias;
|
|
From: <pe...@us...> - 2003-10-28 23:44:05
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/configuration
In directory sc8-pr-cvs1:/tmp/cvs-serv8665/src/java/org/neuclear/commons/configuration
Modified Files:
Configuration.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: Configuration.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/configuration/Configuration.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Configuration.java 25 Oct 2003 00:39:27 -0000 1.2
--- Configuration.java 28 Oct 2003 23:43:38 -0000 1.3
***************
*** 9,12 ****
--- 9,13 ----
import javax.xml.parsers.ParserConfigurationException;
+ import java.io.InputStream;
/**
***************
*** 17,21 ****
public class Configuration {
! public static synchronized PicoContainer getContainer(Class context) throws ConfigurationException {
if (pico == null)
pico = buildContainer(context);
--- 18,22 ----
public class Configuration {
! private static synchronized PicoContainer getContainer(String context) throws ConfigurationException {
if (pico == null)
pico = buildContainer(context);
***************
*** 23,30 ****
}
! private static PicoContainer buildContainer(Class context) throws ConfigurationException {
try {
InputSourceRegistrationNanoContainer nc = new DomRegistrationNanoContainer.Default();
! nc.registerComponents(new InputSource(context.getResourceAsStream("neuclear-conf.xml")));
return nc;
} catch (ParserConfigurationException e) {
--- 24,37 ----
}
! public static Object getComponent(Object type, String context) throws ConfigurationException {
! return getContainer(context).getComponent(type);
! }
!
! private static PicoContainer buildContainer(String context) throws ConfigurationException {
try {
InputSourceRegistrationNanoContainer nc = new DomRegistrationNanoContainer.Default();
! InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(context + ".xml");
! nc.registerComponents(new InputSource(in));
! nc.instantiateComponents();
return nc;
} catch (ParserConfigurationException e) {
***************
*** 35,47 ****
e.printStackTrace();
throw new ConfigurationException(e);
- } catch (PicoInitializationException e) {
- throw new ConfigurationException(e);
} catch (NoClassDefFoundError e) {
e.printStackTrace();
throw new ConfigurationException(e);
}
}
private static PicoContainer pico;
}
--- 42,56 ----
e.printStackTrace();
throw new ConfigurationException(e);
} catch (NoClassDefFoundError e) {
e.printStackTrace();
throw new ConfigurationException(e);
+ } catch (PicoInitializationException e) {
+ e.printStackTrace();
+ throw new ConfigurationException(e);
}
}
private static PicoContainer pico;
+ //private static final String CONFIG_FILE_NAME = "neuclear-conf.xml";
}
|
|
From: <pe...@us...> - 2003-10-28 23:43:54
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv8557/src/test/org/neuclear/ledger
Modified Files:
LedgerTest.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: LedgerTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/LedgerTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** LedgerTest.java 20 Sep 2003 23:16:21 -0000 1.1.1.1
--- LedgerTest.java 28 Oct 2003 23:43:15 -0000 1.2
***************
*** 3,14 ****
import junit.framework.TestCase;
! import java.util.Date;
import java.util.Calendar;
import java.util.Random;
- import java.math.BigInteger;
-
- import org.neuclear.ledger.implementations.SimpleLedger;
- import org.picocontainer.PicoContainer;
- import org.picocontainer.defaults.DefaultPicoContainer;
/**
--- 3,10 ----
import junit.framework.TestCase;
! import java.math.BigInteger;
import java.util.Calendar;
+ import java.util.Date;
import java.util.Random;
/**
***************
*** 19,39 ****
* $Id$
* $Log$
* Revision 1.1.1.1 2003/09/20 23:16:21 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
* Older versions can be found /cvsroot/neudist
! *
* Revision 1.15 2003/08/08 23:05:12 pelle
* Updated to use PicoContainer.
* This will be made more elegant as we go along.
! *
* Revision 1.14 2003/08/06 19:16:32 pelle
* Updated various missing items.
! *
* Revision 1.13 2003/08/06 16:41:22 pelle
* Fixed a few implementation bugs with regards to the Held Transactions
! *
* Revision 1.12 2003/08/01 21:59:47 pelle
* More changes to the way helds are managed.
! *
* Revision 1.11 2003/07/30 16:27:55 pelle
* Final fixes for unit tests.
--- 15,39 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/28 23:43:15 pelle
+ * The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ * The two SignerStore implementations both use it for the passphrase.
+ *
* Revision 1.1.1.1 2003/09/20 23:16:21 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
* Older versions can be found /cvsroot/neudist
! * <p/>
* Revision 1.15 2003/08/08 23:05:12 pelle
* Updated to use PicoContainer.
* This will be made more elegant as we go along.
! * <p/>
* Revision 1.14 2003/08/06 19:16:32 pelle
* Updated various missing items.
! * <p/>
* Revision 1.13 2003/08/06 16:41:22 pelle
* Fixed a few implementation bugs with regards to the Held Transactions
! * <p/>
* Revision 1.12 2003/08/01 21:59:47 pelle
* More changes to the way helds are managed.
! * <p/>
* Revision 1.11 2003/07/30 16:27:55 pelle
* Final fixes for unit tests.
***************
*** 42,104 ****
* Note: had to "fix" a unit test to make SimpleLedger pass
* I dont have time to fix it at the moment. I suspect its simple.
! *
* Revision 1.10 2003/07/29 22:57:50 pelle
* New version with refactored support for HeldTransactions.
* Please note that this causes a sql exception when adding held_item rows.
! *
* Revision 1.9 2003/07/28 21:29:15 pelle
* Changed a few things in the LedgerFactory.
* Still not quite there yet.
! *
* Revision 1.8 2003/07/23 17:19:26 pelle
* Ledgers now have a required display name.
! *
* Revision 1.7 2003/07/21 19:43:39 pelle
* Moved the Revisioning tests into the main LedgerTest.
* Fixed the findTransaction method in SQLLedger.
! *
* Revision 1.6 2003/07/21 18:35:15 pelle
* Completed Exception handling refactoring
! *
* Revision 1.5 2003/07/21 17:47:37 pelle
* Held transactions now work in SQL
! *
* Revision 1.4 2003/07/18 20:27:39 pelle
* *** empty log message ***
! *
* Revision 1.3 2003/07/17 22:33:57 pelle
* Fixed various problems. Lets see how we do. I waiting for the autoincrement to work on the entries.
! *
* Revision 1.2 2003/07/16 18:08:49 pelle
* Adding the first parts of sql support.
! *
* Revision 1.1 2003/01/25 19:14:47 pelle
* The ridiculously simple SimpleLedger now passes initial test.
* I've split the Transaction Class into two sub classes and made Transaction abstract.
* The two new Transaction Classes reflect the state of the Transaction and their methods reflect this.
- *
*/
public abstract class LedgerTest extends TestCase {
! protected String account1="Bob";
! protected String account2="Alice";
public LedgerTest(String s) throws LedgerCreationException, LowlevelLedgerException {
super(s);
! ledger=LedgerFactory.getInstance().getLedger("neu://superbux/reserve");
}
public abstract Ledger createLedger();
public void testPostTransaction() throws LedgerException {
! Book bob=getNewBobBook();
! Book alice=getNewAliceBook();
! Date t1=new Date();
! bob.transfer(alice,100,"Loan",t1);
}
private Book getNewBobBook() throws BookExistsException, LowlevelLedgerException {
! return createNewBook(account1);
}
private Book getNewAliceBook() throws BookExistsException, LowlevelLedgerException {
return createNewBook(account2);
--- 42,105 ----
* Note: had to "fix" a unit test to make SimpleLedger pass
* I dont have time to fix it at the moment. I suspect its simple.
! * <p/>
* Revision 1.10 2003/07/29 22:57:50 pelle
* New version with refactored support for HeldTransactions.
* Please note that this causes a sql exception when adding held_item rows.
! * <p/>
* Revision 1.9 2003/07/28 21:29:15 pelle
* Changed a few things in the LedgerFactory.
* Still not quite there yet.
! * <p/>
* Revision 1.8 2003/07/23 17:19:26 pelle
* Ledgers now have a required display name.
! * <p/>
* Revision 1.7 2003/07/21 19:43:39 pelle
* Moved the Revisioning tests into the main LedgerTest.
* Fixed the findTransaction method in SQLLedger.
! * <p/>
* Revision 1.6 2003/07/21 18:35:15 pelle
* Completed Exception handling refactoring
! * <p/>
* Revision 1.5 2003/07/21 17:47:37 pelle
* Held transactions now work in SQL
! * <p/>
* Revision 1.4 2003/07/18 20:27:39 pelle
* *** empty log message ***
! * <p/>
* Revision 1.3 2003/07/17 22:33:57 pelle
* Fixed various problems. Lets see how we do. I waiting for the autoincrement to work on the entries.
! * <p/>
* Revision 1.2 2003/07/16 18:08:49 pelle
* Adding the first parts of sql support.
! * <p/>
* Revision 1.1 2003/01/25 19:14:47 pelle
* The ridiculously simple SimpleLedger now passes initial test.
* I've split the Transaction Class into two sub classes and made Transaction abstract.
* The two new Transaction Classes reflect the state of the Transaction and their methods reflect this.
*/
public abstract class LedgerTest extends TestCase {
! protected String account1 = "Bob";
! protected String account2 = "Alice";
public LedgerTest(String s) throws LedgerCreationException, LowlevelLedgerException {
super(s);
! ledger = LedgerFactory.getInstance().getLedger("neu://superbux/reserve");
}
+
public abstract Ledger createLedger();
public void testPostTransaction() throws LedgerException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! Date t1 = new Date();
! bob.transfer(alice, 100, "Loan", t1);
}
private Book getNewBobBook() throws BookExistsException, LowlevelLedgerException {
! return createNewBook(account1);
}
+
private Book getNewAliceBook() throws BookExistsException, LowlevelLedgerException {
return createNewBook(account2);
***************
*** 106,296 ****
private Book createNewBook(String name) throws BookExistsException, LowlevelLedgerException {
! BigInteger id=new BigInteger(168,new Random());
! String bookID = name+id.toString(36);
! System.out.println("bookid: "+bookID);
! return ledger.createNewBook(bookID,name);
}
! public void testAccountCreate() throws LedgerException {
! Book bob=getNewBobBook();
assertNotNull(bob);
assertTrue(ledger.bookExists(bob.getBookID()));
}
! public void testBalance() throws LedgerException {
! Book alice=getNewAliceBook();
! Book bob=getNewBobBook();
! double aliceBalance=alice.getBalance();
! double bobBalance=bob.getBalance();
! final double amount=105;
! Date t1=new Date();
! alice.transfer(bob,amount,"Repayment",t1);
! assertEquals(aliceBalance-amount,alice.getBalance(),0);
! assertEquals(bobBalance+amount,bob.getBalance(),0);
}
! public void testTimeBalance() throws LedgerException {
! Calendar cal=Calendar.getInstance();
! Date t1=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t2=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t3=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t4=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t5=cal.getTime();
! Book alice=getNewAliceBook();
! Book bob=getNewBobBook();
! final double amount=105;
! double payment=amount/2;
! alice.transfer(bob,payment,"Repayment",t2);
! alice.transfer(bob,payment,"2nd Repayment",t4);
! double aliceBalance=alice.getBalance(t1);
! double bobBalance=bob.getBalance(t1);
! assertEquals(aliceBalance-payment,alice.getBalance(t2),0);
! assertEquals(bobBalance+payment,bob.getBalance(t2),0);
! assertEquals(aliceBalance-payment,alice.getBalance(t3),0);
! assertEquals(bobBalance+payment,bob.getBalance(t3),0);
! assertEquals(aliceBalance-amount,alice.getBalance(t4),0);
! assertEquals(bobBalance+amount,bob.getBalance(t4),0);
! assertEquals(aliceBalance-amount,alice.getBalance(t5),0);
! assertEquals(bobBalance+amount,bob.getBalance(t5),0);
}
! public void testHold() throws LedgerException {
! Calendar cal=Calendar.getInstance();
! Date t1=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t2=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t3=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t4=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t5=cal.getTime();
! Book alice=getNewAliceBook();
! Book bob=getNewBobBook();
! final double amount=105;
// We are holding 105 from t2 to t4
! alice.hold(bob,amount,"Hold",t2,t4);
! double aliceBalance=alice.getBalance(t1);
! double bobBalance=bob.getBalance(t1);
// First lets check it hasnt affected the real balance
! assertEquals(aliceBalance,alice.getBalance(t2),0);
! assertEquals(bobBalance,bob.getBalance(t2),0);
! assertEquals(aliceBalance,alice.getBalance(t3),0);
! assertEquals(bobBalance,bob.getBalance(t3),0);
! assertEquals(aliceBalance,alice.getBalance(t4),0);
! assertEquals(bobBalance,bob.getBalance(t4),0);
! assertEquals(aliceBalance,alice.getBalance(t5),0);
! assertEquals(bobBalance,bob.getBalance(t5),0);
// Then lets check that it has affected the available balance of Alice
// It should affect the following
! assertEquals(aliceBalance-amount,alice.getAvailableBalance(t2),0);
! assertEquals(aliceBalance-amount,alice.getAvailableBalance(t3),0);
! assertEquals(aliceBalance-amount,alice.getAvailableBalance(t4),0);
// Her available balance should be the same as her real balance here
! assertEquals(alice.getBalance(t5),alice.getAvailableBalance(t5),0);
! assertEquals(alice.getBalance(t1),alice.getAvailableBalance(t1),0);
// Her available balance should be the same as the previous balance here
! assertEquals(aliceBalance,alice.getAvailableBalance(t5),0);
// Bob's available balance should be the same as his real balance all along.
! assertEquals(bob.getBalance(t1),bob.getAvailableBalance(t1),0);
if (this instanceof SQLLedgerTest) { // Quick hack. I dont have time to fix the SimpleLedger at the moment
! assertEquals(bob.getBalance(t2),bob.getAvailableBalance(t2),0);
! assertEquals(bob.getBalance(t3),bob.getAvailableBalance(t3),0);
! assertEquals(bob.getBalance(t4),bob.getAvailableBalance(t4),0);
! assertEquals(bob.getBalance(t5),bob.getAvailableBalance(t5),0);
}
}
! public void testReversal() throws LedgerException{
! Book bob=getNewBobBook();
! Book alice=getNewAliceBook();
! double amount=123;
! double balance=bob.getBalance();
! PostedTransaction tran=bob.transfer(alice,amount,"Hello",new Date());
assertNotNull(tran);
! assertEquals(bob.getBalance(),balance-amount,0);
! PostedTransaction reverse=tran.reverse("Reverse it");
assertNotNull(reverse);
! assertEquals(bob.getBalance(),balance,0);
}
! public void testCompleteHeld() throws LedgerException{
! Calendar cal=Calendar.getInstance();
! Date t1=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t2=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t3=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t4=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t5=cal.getTime();
! Book ignacio=createNewBook("neu://verax/testusers/Ignacio");
! Book palacio=createNewBook("neu://verax/testusers/Palacio");
! double amount=123;
! double held=200;
! double balance=ignacio.getBalance(t1);
! PostedHeldTransaction hold=ignacio.hold(palacio,held,"Hello",t2,t4);
assertNotNull(hold);
! assertEquals(ignacio.getBalance(t1),balance,0);
! assertEquals(ignacio.getBalance(t2),balance,0);
! assertEquals(ignacio.getBalance(t3),balance,0);
! assertEquals(ignacio.getBalance(t4),balance,0);
! assertEquals(ignacio.getBalance(t5),balance,0);
! assertEquals(ignacio.getAvailableBalance(t1),balance,0);
! assertEquals(ignacio.getAvailableBalance(t2),balance-held,0);
! assertEquals(ignacio.getAvailableBalance(t3),balance-held,0);
! assertEquals(ignacio.getAvailableBalance(t4),balance-held,0);
! assertEquals(ignacio.getAvailableBalance(t5),balance,0);
! PostedTransaction tran=hold.complete(amount,t3,"Muchas Gracias para escoger El Palacio");
! assertEquals(ignacio.getBalance(t1),balance,0);
! assertEquals(ignacio.getBalance(t2),balance,0);
! assertEquals(ignacio.getBalance(t3),balance-amount,0);
! assertEquals(ignacio.getBalance(t4),balance-amount,0);
! assertEquals(ignacio.getBalance(t5),balance-amount,0);
! assertEquals(ignacio.getAvailableBalance(t1),balance,0);
! assertEquals(ignacio.getAvailableBalance(t2),balance,0);
! assertEquals(ignacio.getAvailableBalance(t3),balance-amount,0);
! assertEquals(ignacio.getAvailableBalance(t4),balance-amount,0);
! assertEquals(ignacio.getAvailableBalance(t5),balance-amount,0);
! assertEquals(ignacio.getBalance(t4),ignacio.getAvailableBalance(t5),0);
try {
! tran=hold.complete(amount,t3,"Muchas Gracias para escoger El Palacio");
assertNull(tran);
! assertTrue("Should have thrown Exception Here",false);
! } catch (TransactionExpiredException e){
! assertTrue("Did throw exception here",true);
}
--- 107,298 ----
private Book createNewBook(String name) throws BookExistsException, LowlevelLedgerException {
! BigInteger id = new BigInteger(168, new Random());
! String bookID = name + id.toString(36);
! System.out.println("bookid: " + bookID);
! return ledger.createNewBook(bookID, name);
}
! public void testAccountCreate() throws LedgerException {
! Book bob = getNewBobBook();
assertNotNull(bob);
assertTrue(ledger.bookExists(bob.getBookID()));
}
!
! public void testBalance() throws LedgerException {
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
! double aliceBalance = alice.getBalance();
! double bobBalance = bob.getBalance();
! final double amount = 105;
! Date t1 = new Date();
! alice.transfer(bob, amount, "Repayment", t1);
! assertEquals(aliceBalance - amount, alice.getBalance(), 0);
! assertEquals(bobBalance + amount, bob.getBalance(), 0);
}
! public void testTimeBalance() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
! final double amount = 105;
! double payment = amount / 2;
! alice.transfer(bob, payment, "Repayment", t2);
! alice.transfer(bob, payment, "2nd Repayment", t4);
! double aliceBalance = alice.getBalance(t1);
! double bobBalance = bob.getBalance(t1);
! assertEquals(aliceBalance - payment, alice.getBalance(t2), 0);
! assertEquals(bobBalance + payment, bob.getBalance(t2), 0);
! assertEquals(aliceBalance - payment, alice.getBalance(t3), 0);
! assertEquals(bobBalance + payment, bob.getBalance(t3), 0);
! assertEquals(aliceBalance - amount, alice.getBalance(t4), 0);
! assertEquals(bobBalance + amount, bob.getBalance(t4), 0);
! assertEquals(aliceBalance - amount, alice.getBalance(t5), 0);
! assertEquals(bobBalance + amount, bob.getBalance(t5), 0);
}
! public void testHold() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book alice = getNewAliceBook();
! Book bob = getNewBobBook();
! final double amount = 105;
// We are holding 105 from t2 to t4
! alice.hold(bob, amount, "Hold", t2, t4);
! double aliceBalance = alice.getBalance(t1);
! double bobBalance = bob.getBalance(t1);
// First lets check it hasnt affected the real balance
! assertEquals(aliceBalance, alice.getBalance(t2), 0);
! assertEquals(bobBalance, bob.getBalance(t2), 0);
! assertEquals(aliceBalance, alice.getBalance(t3), 0);
! assertEquals(bobBalance, bob.getBalance(t3), 0);
! assertEquals(aliceBalance, alice.getBalance(t4), 0);
! assertEquals(bobBalance, bob.getBalance(t4), 0);
! assertEquals(aliceBalance, alice.getBalance(t5), 0);
! assertEquals(bobBalance, bob.getBalance(t5), 0);
// Then lets check that it has affected the available balance of Alice
// It should affect the following
! assertEquals(aliceBalance - amount, alice.getAvailableBalance(t2), 0);
! assertEquals(aliceBalance - amount, alice.getAvailableBalance(t3), 0);
! assertEquals(aliceBalance - amount, alice.getAvailableBalance(t4), 0);
// Her available balance should be the same as her real balance here
! assertEquals(alice.getBalance(t5), alice.getAvailableBalance(t5), 0);
! assertEquals(alice.getBalance(t1), alice.getAvailableBalance(t1), 0);
// Her available balance should be the same as the previous balance here
! assertEquals(aliceBalance, alice.getAvailableBalance(t5), 0);
// Bob's available balance should be the same as his real balance all along.
! assertEquals(bob.getBalance(t1), bob.getAvailableBalance(t1), 0);
if (this instanceof SQLLedgerTest) { // Quick hack. I dont have time to fix the SimpleLedger at the moment
! assertEquals(bob.getBalance(t2), bob.getAvailableBalance(t2), 0);
! assertEquals(bob.getBalance(t3), bob.getAvailableBalance(t3), 0);
! assertEquals(bob.getBalance(t4), bob.getAvailableBalance(t4), 0);
! assertEquals(bob.getBalance(t5), bob.getAvailableBalance(t5), 0);
}
}
! public void testReversal() throws LedgerException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! double balance = bob.getBalance();
! PostedTransaction tran = bob.transfer(alice, amount, "Hello", new Date());
assertNotNull(tran);
! assertEquals(bob.getBalance(), balance - amount, 0);
! PostedTransaction reverse = tran.reverse("Reverse it");
assertNotNull(reverse);
! assertEquals(bob.getBalance(), balance, 0);
}
! public void testCompleteHeld() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! Book palacio = createNewBook("neu://verax/testusers/Palacio");
! double amount = 123;
! double held = 200;
! double balance = ignacio.getBalance(t1);
! PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
! assertEquals(ignacio.getBalance(t1), balance, 0);
! assertEquals(ignacio.getBalance(t2), balance, 0);
! assertEquals(ignacio.getBalance(t3), balance, 0);
! assertEquals(ignacio.getBalance(t4), balance, 0);
! assertEquals(ignacio.getBalance(t5), balance, 0);
! assertEquals(ignacio.getAvailableBalance(t1), balance, 0);
! assertEquals(ignacio.getAvailableBalance(t2), balance - held, 0);
! assertEquals(ignacio.getAvailableBalance(t3), balance - held, 0);
! assertEquals(ignacio.getAvailableBalance(t4), balance - held, 0);
! assertEquals(ignacio.getAvailableBalance(t5), balance, 0);
! PostedTransaction tran = hold.complete(amount, t3, "Muchas Gracias para escoger El Palacio");
! assertEquals(ignacio.getBalance(t1), balance, 0);
! assertEquals(ignacio.getBalance(t2), balance, 0);
! assertEquals(ignacio.getBalance(t3), balance - amount, 0);
! assertEquals(ignacio.getBalance(t4), balance - amount, 0);
! assertEquals(ignacio.getBalance(t5), balance - amount, 0);
! assertEquals(ignacio.getAvailableBalance(t1), balance, 0);
! assertEquals(ignacio.getAvailableBalance(t2), balance, 0);
! assertEquals(ignacio.getAvailableBalance(t3), balance - amount, 0);
! assertEquals(ignacio.getAvailableBalance(t4), balance - amount, 0);
! assertEquals(ignacio.getAvailableBalance(t5), balance - amount, 0);
! assertEquals(ignacio.getBalance(t4), ignacio.getAvailableBalance(t5), 0);
try {
! tran = hold.complete(amount, t3, "Muchas Gracias para escoger El Palacio");
assertNull(tran);
! assertTrue("Should have thrown Exception Here", false);
! } catch (TransactionExpiredException e) {
! assertTrue("Did throw exception here", true);
}
***************
*** 298,350 ****
public void testFindTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob=getNewBobBook();
! Book alice=getNewAliceBook();
! double amount=123;
! PostedTransaction tran=bob.transfer(alice,amount,"Can we find this again",new Date());
assertNotNull(tran);
! PostedTransaction found=ledger.findTransaction(tran.getXid());
assertNotNull(found);
! assertEquals(found.getXid(),tran.getXid());
}
public void testFindHeldTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob=getNewBobBook();
! Book alice=getNewAliceBook();
! double amount=123;
! PostedHeldTransaction tran=bob.hold(alice,amount,"Can we find this again",new Date(),new Date());
assertNotNull(tran);
! PostedHeldTransaction found=ledger.findHeldTransaction(tran.getXid());
assertNotNull(found);
! assertEquals(found.getXid(),tran.getXid());
}
! public void testCancelHeld() throws LedgerException{
! Calendar cal=Calendar.getInstance();
! Date t1=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t2=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t3=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t4=cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR,1);
! Date t5=cal.getTime();
! Book ignacio=createNewBook("neu://verax/testusers/Ignacio");
! Book palacio=createNewBook("neu://verax/testusers/Palacio");
! double amount=123;
! double held=200;
! double balance=ignacio.getBalance(t1);
! PostedHeldTransaction hold=ignacio.hold(palacio,held,"Hello",t2,t4);
assertNotNull(hold);
hold.cancel();
try {
! hold.complete(held,t3,"this shouldnt work");
! assertTrue("Exception wasnt thrown for completing a cancelled transaction",false);
} catch (TransactionExpiredException e) {
;// This should happen so we dont need to do anything
--- 300,353 ----
public void testFindTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! PostedTransaction tran = bob.transfer(alice, amount, "Can we find this again", new Date());
assertNotNull(tran);
! PostedTransaction found = ledger.findTransaction(tran.getXid());
assertNotNull(found);
! assertEquals(found.getXid(), tran.getXid());
}
public void testFindHeldTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException {
! Book bob = getNewBobBook();
! Book alice = getNewAliceBook();
! double amount = 123;
! PostedHeldTransaction tran = bob.hold(alice, amount, "Can we find this again", new Date(), new Date());
assertNotNull(tran);
! PostedHeldTransaction found = ledger.findHeldTransaction(tran.getXid());
assertNotNull(found);
! assertEquals(found.getXid(), tran.getXid());
}
!
! public void testCancelHeld() throws LedgerException {
! Calendar cal = Calendar.getInstance();
! Date t1 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t2 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t3 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t4 = cal.getTime();
! cal.add(Calendar.DAY_OF_YEAR, 1);
! Date t5 = cal.getTime();
! Book ignacio = createNewBook("neu://verax/testusers/Ignacio");
! Book palacio = createNewBook("neu://verax/testusers/Palacio");
! double amount = 123;
! double held = 200;
! double balance = ignacio.getBalance(t1);
! PostedHeldTransaction hold = ignacio.hold(palacio, held, "Hello", t2, t4);
assertNotNull(hold);
hold.cancel();
try {
! hold.complete(held, t3, "this shouldnt work");
! assertTrue("Exception wasnt thrown for completing a cancelled transaction", false);
} catch (TransactionExpiredException e) {
;// This should happen so we dont need to do anything
|
|
From: <pe...@us...> - 2003-10-28 23:43:53
|
Update of /cvsroot/neuclear/neuclear-commons/src/java
In directory sc8-pr-cvs1:/tmp/cvs-serv8665/src/java
Added Files:
neuclear-commons.xml
Removed Files:
neuclear-conf.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
--- NEW FILE: neuclear-commons.xml ---
<components>
<component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/>
</components>
--- neuclear-conf.xml DELETED ---
|
|
From: <pe...@us...> - 2003-10-28 23:43:52
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/configuration
In directory sc8-pr-cvs1:/tmp/cvs-serv8665/src/test/org/neuclear/commons/configuration
Modified Files:
ConfigurationTest.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: ConfigurationTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/configuration/ConfigurationTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ConfigurationTest.java 25 Oct 2003 00:39:27 -0000 1.2
--- ConfigurationTest.java 28 Oct 2003 23:43:38 -0000 1.3
***************
*** 15,19 ****
public void testGetComponent() throws ConfigurationException {
! assertNotNull(Configuration.getContainer(ConnectionSource.class).getComponentInstance(ConnectionSource.class));
}
}
--- 15,19 ----
public void testGetComponent() throws ConfigurationException {
! assertNotNull(Configuration.getComponent(ConnectionSource.class, "neuclear-commons"));
}
}
|
|
From: <pe...@us...> - 2003-10-28 23:43:52
|
Update of /cvsroot/neuclear/neuclear-commons
In directory sc8-pr-cvs1:/tmp/cvs-serv8665
Modified Files:
project.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: project.xml
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/project.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** project.xml 25 Oct 2003 00:39:27 -0000 1.3
--- project.xml 28 Oct 2003 23:43:38 -0000 1.4
***************
*** 74,82 ****
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-2</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-1-SNAPSHOT</version>
</dependency>
<dependency>
--- 74,82 ----
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-1</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-PRESPLIT-1</version>
</dependency>
<dependency>
|
|
From: <pe...@us...> - 2003-10-28 23:43:51
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations
In directory sc8-pr-cvs1:/tmp/cvs-serv8557/src/java/org/neuclear/ledger/implementations
Modified Files:
SQLLedger.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: SQLLedger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/implementations/SQLLedger.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** SQLLedger.java 20 Sep 2003 23:16:20 -0000 1.1.1.1
--- SQLLedger.java 28 Oct 2003 23:43:14 -0000 1.2
***************
*** 7,46 ****
package org.neuclear.ledger.implementations;
import java.sql.*;
import java.util.Date;
import java.util.Iterator;
- import java.io.IOException;
-
- import org.neuclear.ledger.*;
- import org.neuclear.commons.sql.SQLTools;
- import org.neuclear.commons.sql.ConnectionSource;
/**
* @author pelleb
! *
! * To change the template for this generated type comment go to
! * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class SQLLedger extends Ledger {
! /**
! *
! */
/* public SQLLedger(String id) throws SQLException, IOException, UnknownLedgerException {
this(SQLTools.getConnection(),id);
}
*/
! public SQLLedger(ConnectionSource con,String id) throws LowlevelLedgerException, UnknownLedgerException {
! super(id,getLedgerName(con,id));
! this.con=con;
}
! private static String getLedgerName(ConnectionSource con,String id) throws UnknownLedgerException, LowlevelLedgerException {
try {
! PreparedStatement stmt=con.getConnection().prepareStatement("select title from ledger where id=?");
! stmt.setString(1,id);
! ResultSet rs=stmt.executeQuery();
if (rs.next())
return rs.getString(1);
! else throw new UnknownLedgerException(id);
} catch (SQLException e) {
throw new LowlevelLedgerException(e);
--- 7,53 ----
package org.neuclear.ledger.implementations;
+ import org.neuclear.commons.sql.ConnectionSource;
+ import org.neuclear.commons.sql.SQLTools;
+ import org.neuclear.ledger.*;
+
+ import java.io.IOException;
import java.sql.*;
import java.util.Date;
import java.util.Iterator;
/**
* @author pelleb
! * <p/>
! * To change the template for this generated type comment go to
! * Window>Preferences>Java>Code Generation>Code and Comments
*/
public class SQLLedger extends Ledger {
! /**
! * public SQLLedger(String id) throws SQLException, IOException, UnknownLedgerException {
! * this(SQLTools.getConnection(),id);
! * }
! * public SQLLedger(String id) throws SQLException, IOException, UnknownLedgerException {
! * this(SQLTools.getConnection(),id);
! * }
! */
/* public SQLLedger(String id) throws SQLException, IOException, UnknownLedgerException {
this(SQLTools.getConnection(),id);
}
*/
! public SQLLedger(ConnectionSource con, String id) throws LowlevelLedgerException, UnknownLedgerException {
! super(id, getLedgerName(con, id));
! this.con = con;
}
!
! private static String getLedgerName(ConnectionSource con, String id) throws UnknownLedgerException, LowlevelLedgerException {
try {
! PreparedStatement stmt = con.getConnection().prepareStatement("select title from ledger where id=?");
! stmt.setString(1, id);
! ResultSet rs = stmt.executeQuery();
if (rs.next())
return rs.getString(1);
! else
! throw new UnknownLedgerException(id);
} catch (SQLException e) {
throw new LowlevelLedgerException(e);
***************
*** 49,55 ****
}
}
/**
* This decides if new books are automatically created.
! * @return
*/
public boolean allowAutoBookCreation() {
--- 56,64 ----
}
}
+
/**
* This decides if new books are automatically created.
! *
! * @return
*/
public boolean allowAutoBookCreation() {
***************
*** 58,86 ****
public boolean bookExists(String bookID) throws LowlevelLedgerException {
! try {
! PreparedStatement stmt=prepQuery("select id from account where id=?");
! stmt.setString(1,bookID);
! ResultSet rs=stmt.executeQuery();
! return rs.next();
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
! }
}
! public Book createNewBook(String bookID, String title) throws BookExistsException,LowlevelLedgerException {
if (bookExists(bookID))
! throw new BookExistsException(this,bookID);
try {
getConnection().setAutoCommit(false);
! PreparedStatement stmt=prepQuery("insert into account values (?,?,3)");
! stmt.setString(1,bookID);
! stmt.setString(2,title);
stmt.execute();
getConnection().commit();
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
}
! return createBookInstance(bookID,title);
}
--- 67,95 ----
public boolean bookExists(String bookID) throws LowlevelLedgerException {
! try {
! PreparedStatement stmt = prepQuery("select id from account where id=?");
! stmt.setString(1, bookID);
! ResultSet rs = stmt.executeQuery();
! return rs.next();
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
! }
}
! public Book createNewBook(String bookID, String title) throws BookExistsException, LowlevelLedgerException {
if (bookExists(bookID))
! throw new BookExistsException(this, bookID);
try {
getConnection().setAutoCommit(false);
! PreparedStatement stmt = prepQuery("insert into account values (?,?,3)");
! stmt.setString(1, bookID);
! stmt.setString(2, title);
stmt.execute();
getConnection().commit();
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
}
! return createBookInstance(bookID, title);
}
***************
*** 88,101 ****
* @see org.neuclear.ledger.Ledger#performTransaction(org.neuclear.ledger.UnPostedTransaction)
*/
! public PostedTransaction performTransaction(UnPostedTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! String newid;
! if (!transaction.isBalanced()){
! throw new UnBalancedTransactionException(this,transaction);
}
try {
getConnection().setAutoCommit(false);
! long xid=insertTransaction(transaction);
! Iterator items=transaction.getItems();
while (items.hasNext()) {
TransactionItem item = (TransactionItem) items.next();
--- 97,110 ----
* @see org.neuclear.ledger.Ledger#performTransaction(org.neuclear.ledger.UnPostedTransaction)
*/
! public PostedTransaction performTransaction(UnPostedTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! String newid;
! if (!transaction.isBalanced()) {
! throw new UnBalancedTransactionException(this, transaction);
}
try {
getConnection().setAutoCommit(false);
! long xid = insertTransaction(transaction);
! Iterator items = transaction.getItems();
while (items.hasNext()) {
TransactionItem item = (TransactionItem) items.next();
***************
*** 103,118 ****
}
getConnection().commit();
! newid=Long.toString(xid);
} catch (SQLException e) {
try {
getConnection().rollback();
} catch (SQLException e1) {
! throw new LowlevelLedgerException(this,e1);
}
! throw new LowlevelLedgerException(this,e);
}
! return this.createTransaction(transaction,newid);
! }
/**
--- 112,127 ----
}
getConnection().commit();
! newid = Long.toString(xid);
} catch (SQLException e) {
try {
getConnection().rollback();
} catch (SQLException e1) {
! throw new LowlevelLedgerException(this, e1);
}
! throw new LowlevelLedgerException(this, e);
}
! return this.createTransaction(transaction, newid);
! }
/**
***************
*** 120,123 ****
--- 129,133 ----
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
+ *
* @param transaction Transaction to perform
* @return Unique ID
***************
*** 125,136 ****
public PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
String newid;
! if (!transaction.isBalanced()){
! throw new UnBalancedTransactionException(this,transaction);
}
try {
getConnection().setAutoCommit(false);
! long xid=insertHeldTransaction(transaction);
! Iterator items=transaction.getItems();
while (items.hasNext()) {
TransactionItem item = (TransactionItem) items.next();
--- 135,146 ----
public PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
String newid;
! if (!transaction.isBalanced()) {
! throw new UnBalancedTransactionException(this, transaction);
}
try {
getConnection().setAutoCommit(false);
! long xid = insertHeldTransaction(transaction);
! Iterator items = transaction.getItems();
while (items.hasNext()) {
TransactionItem item = (TransactionItem) items.next();
***************
*** 138,199 ****
}
getConnection().commit();
! newid=Long.toString(xid);
} catch (SQLException e) {
try {
getConnection().rollback();
} catch (SQLException e1) {
! throw new LowlevelLedgerException(this,e1);
}
System.err.println(e.getSQLState());
e.printStackTrace(System.err);
! throw new LowlevelLedgerException(this,e);
}
! return this.createHeldTransaction(transaction,newid);
}
/**
* Cancels a Held Transaction.
! * @param hold
! * @throws LowlevelLedgerException
! * @throws UnknownTransactionException
*/
public void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
try {
! PreparedStatement update=prepQuery("update held_transaction set cancelled=1 where id=? and ledgerid=?");
! update.setString(1,hold.getXid());
! update.setString(2,getId());
! int affected=update.executeUpdate();
! if (affected==0)
! throw new UnknownTransactionException(this,hold.getXid());
! if (affected>1) {
getConnection().rollback();
! throw new LowlevelLedgerException(this,"performCancelHold: For some reason multiple rows were updated. Transaction Rolled Back.");
}
getConnection().commit();
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
}
}
! public PostedTransaction performCompleteHold(PostedHeldTransaction hold,double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
try {
! PreparedStatement query=prepQuery("select * from held_transaction where cancelled=0 and transactionid is null and id=? and ledgerid=?");
! query.setString(1,hold.getXid());
! query.setString(2,getId());
! ResultSet rs=query.executeQuery();
if (!rs.next())
! throw new TransactionExpiredException(this,hold);
! PostedTransaction tran=createHeldComplete(hold,amount,time,comment);
! PreparedStatement update=prepQuery("update held_transaction set transactionid=? where id=? and ledgerid=?");
! update.setString(1,tran.getXid());
! update.setString(2,hold.getXid());
! update.setString(3,getId());
! int affected=update.executeUpdate();
! if (affected==0)
! throw new UnknownTransactionException(this,hold.getXid());
! if (affected>1) {
getConnection().rollback();
! throw new LowlevelLedgerException(this,"performCompleteHold: For some reason multiple rows were updated. Transaction Rolled Back.");
}
getConnection().commit();
--- 148,211 ----
}
getConnection().commit();
! newid = Long.toString(xid);
} catch (SQLException e) {
try {
getConnection().rollback();
} catch (SQLException e1) {
! throw new LowlevelLedgerException(this, e1);
}
System.err.println(e.getSQLState());
e.printStackTrace(System.err);
! throw new LowlevelLedgerException(this, e);
}
! return this.createHeldTransaction(transaction, newid);
}
+
/**
* Cancels a Held Transaction.
! *
! * @param hold
! * @throws LowlevelLedgerException
! * @throws UnknownTransactionException
*/
public void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException {
try {
! PreparedStatement update = prepQuery("update held_transaction set cancelled=1 where id=? and ledgerid=?");
! update.setString(1, hold.getXid());
! update.setString(2, getId());
! int affected = update.executeUpdate();
! if (affected == 0)
! throw new UnknownTransactionException(this, hold.getXid());
! if (affected > 1) {
getConnection().rollback();
! throw new LowlevelLedgerException(this, "performCancelHold: For some reason multiple rows were updated. Transaction Rolled Back.");
}
getConnection().commit();
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
}
}
! public PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
try {
! PreparedStatement query = prepQuery("select * from held_transaction where cancelled=0 and transactionid is null and id=? and ledgerid=?");
! query.setString(1, hold.getXid());
! query.setString(2, getId());
! ResultSet rs = query.executeQuery();
if (!rs.next())
! throw new TransactionExpiredException(this, hold);
! PostedTransaction tran = createHeldComplete(hold, amount, time, comment);
! PreparedStatement update = prepQuery("update held_transaction set transactionid=? where id=? and ledgerid=?");
! update.setString(1, tran.getXid());
! update.setString(2, hold.getXid());
! update.setString(3, getId());
! int affected = update.executeUpdate();
! if (affected == 0)
! throw new UnknownTransactionException(this, hold.getXid());
! if (affected > 1) {
getConnection().rollback();
! throw new LowlevelLedgerException(this, "performCompleteHold: For some reason multiple rows were updated. Transaction Rolled Back.");
}
getConnection().commit();
***************
*** 202,402 ****
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
} catch (UnknownTransactionException e) {
! throw new LowlevelLedgerException(this,e);
}
}
! private long insertTransaction(UnPostedTransaction transaction) throws SQLException, LowlevelLedgerException{
PreparedStatement tranInsert;
! tranInsert=prepQuery("insert into transaction (value_date,comment,ledgerid) values (?,?,?)");
! tranInsert.setTimestamp(1,SQLTools.toTimestamp(transaction.getTransactionTime()));
! tranInsert.setString(2,transaction.getComment());
! tranInsert.setString(3,getId());
tranInsert.execute();
! PreparedStatement tranID=prepQuery("select last_insert_id()");
! ResultSet rs=tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
else {
getConnection().rollback();
! throw new LowlevelLedgerException(this,"We couldnt get the id of the transaction. Safer to Rollback.");
}
}
! private long insertHeldTransaction(UnPostedHeldTransaction transaction) throws SQLException, LowlevelLedgerException{
PreparedStatement tranInsert;
! tranInsert=prepQuery("insert into held_transaction (value_date,comment,held_until,ledgerid) values (?,?,?,?)");
! tranInsert.setTimestamp(3,SQLTools.toTimestamp(transaction.getExpiryTime()));
! tranInsert.setTimestamp(1,SQLTools.toTimestamp(transaction.getTransactionTime()));
! tranInsert.setString(2,transaction.getComment());
! tranInsert.setString(4,getId());
tranInsert.execute();
! PreparedStatement tranID=prepQuery("select id from held_transaction where id=last_insert_id()");
! ResultSet rs=tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
else {
getConnection().rollback();
! throw new LowlevelLedgerException(this,"We couldnt get the id of the transaction. Safer to Rollback.");
}
}
! private void insertTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException{
! PreparedStatement itemInsert=prepQuery("insert into entry (transactionid,accountid,amount,ack) values (?,?,?,1)");
! itemInsert.setLong(1,xid);
! itemInsert.setString(2,item.getBook().getBookID());
! itemInsert.setDouble(3,item.getAmount());
itemInsert.execute();
}
! private void insertHeldTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException{
! PreparedStatement itemInsert=prepQuery("insert into held_entry (held_transactionid,accountid,amount,ack) values (?,?,?,1)");
! itemInsert.setLong(1,xid);
! itemInsert.setString(2,item.getBook().getBookID());
! itemInsert.setDouble(3,item.getAmount());
itemInsert.execute();
}
/**
! * Searches for a Transaction based on its Transaction ID
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public PostedTransaction findTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id=Long.parseLong(idstring);
! try {
! PreparedStatement stmt=prepQuery("select value_date,comment from transaction where id=? and ledgerid=?");
! stmt.setLong(1,id);
! stmt.setString(2,getId());
! ResultSet rs=stmt.executeQuery();
! if (!rs.next()) {
! throw new UnknownTransactionException(this,idstring);
! }
! Date started=rs.getTimestamp(1);
! String comment=rs.getString(2);
! UnPostedTransaction transaction=new UnPostedTransaction(this,comment,started);
! stmt=prepQuery("select accountid,amount from entry where transactionid=?");
! stmt.setLong(1,id);
! rs=stmt.executeQuery();
while (rs.next())
! transaction.addItem(getBook(rs.getString(1)),rs.getDouble(2));
! return this.createTransaction(transaction,idstring);
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
! } catch (InvalidTransactionException e) {
! throw new LowlevelLedgerException(this,e);
} catch (UnknownBookException e) {
! throw new LowlevelLedgerException(this,e);
}
! }
/**
! * Searches for a Held Transaction based on its Transaction ID
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id=Long.parseLong(idstring);
! try {
! PreparedStatement stmt=prepQuery("select value_date,held_until,comment from held_transaction where id=? and ledgerid=?");
! stmt.setLong(1,id);
! stmt.setString(2,getId());
! ResultSet rs=stmt.executeQuery();
! if (!rs.next()) {
! throw new UnknownTransactionException(this,idstring);
! }
! Date started=rs.getTimestamp(1);
! Date ended=rs.getTimestamp(2);
! String comment=rs.getString(3);
! UnPostedHeldTransaction transaction=new UnPostedHeldTransaction(this,comment,started,ended);
! stmt=prepQuery("select accountid,amount from held_entry where held_transactionid=?");
! stmt.setLong(1,id);
! rs=stmt.executeQuery();
while (rs.next())
! transaction.addItem(getBook(rs.getString(1)),rs.getDouble(2));
! return this.createHeldTransaction(transaction,idstring);
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
! } catch (InvalidTransactionException e) {
! throw new LowlevelLedgerException(this,e);
} catch (UnknownBookException e) {
! throw new LowlevelLedgerException(this,e);
}
! }
! private PreparedStatement prepQuery(String sql) throws SQLException,LowlevelLedgerException {
! return getConnection().prepareStatement(sql);
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book, java.util.Date)
! */
! public double getBalance(Book book, Date time) throws LowlevelLedgerException {
try {
! PreparedStatement stmt=prepQuery("select sum(e.amount) from entry e,transaction t where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?");
! stmt.setString(1,book.getBookID());
! stmt.setTimestamp(2,new Timestamp(time.getTime()));
! stmt.setString(3,getId());
! ResultSet rs=stmt.executeQuery();
! if (rs.next()){
return rs.getDouble(1);
}
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
}
return 0;
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book)
! */
! public double getBalance(Book book) throws LowlevelLedgerException {
! return getBalance(book,new Date());
! }
! public double getAvailableBalance(Book book, Date time) throws LowlevelLedgerException {
try {
! PreparedStatement stmt=prepQuery("select sum(u.amount) from (" +
! "select sum(e.amount) as amount from entry e,transaction t " +
! "where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=? " +
! "union " +
! "select sum(e.amount) as amount from held_entry e, held_transaction t " +
"where " +
! "e.held_transactionid=t.id and e.accountid=? and t.value_date<= ? " +
! "and e.amount<0 and t.held_until>= ? and t.cancelled=0 and t.transactionid is null and t.ledgerid=?" +
! ") u ");
! Timestamp ts=SQLTools.toTimestamp(time);
! stmt.setString(1,book.getBookID());
! stmt.setTimestamp(2,ts);
! stmt.setString(3,getId());
! stmt.setString(4,book.getBookID());
! stmt.setTimestamp(5,ts);
! stmt.setTimestamp(6,ts);
! stmt.setString(7,getId());
! ResultSet rs=stmt.executeQuery();
! if (rs.next()){
! return rs.getDouble(1);
}
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
}
! return 0;
! }
--- 214,420 ----
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
} catch (UnknownTransactionException e) {
! throw new LowlevelLedgerException(this, e);
}
}
! private long insertTransaction(UnPostedTransaction transaction) throws SQLException, LowlevelLedgerException {
PreparedStatement tranInsert;
! tranInsert = prepQuery("insert into transaction (value_date,comment,ledgerid) values (?,?,?)");
! tranInsert.setTimestamp(1, SQLTools.toTimestamp(transaction.getTransactionTime()));
! tranInsert.setString(2, transaction.getComment());
! tranInsert.setString(3, getId());
tranInsert.execute();
! PreparedStatement tranID = prepQuery("select last_insert_id()");
! ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
else {
getConnection().rollback();
! throw new LowlevelLedgerException(this, "We couldnt get the id of the transaction. Safer to Rollback.");
}
}
! private long insertHeldTransaction(UnPostedHeldTransaction transaction) throws SQLException, LowlevelLedgerException {
PreparedStatement tranInsert;
! tranInsert = prepQuery("insert into held_transaction (value_date,comment,held_until,ledgerid) values (?,?,?,?)");
! tranInsert.setTimestamp(3, SQLTools.toTimestamp(transaction.getExpiryTime()));
! tranInsert.setTimestamp(1, SQLTools.toTimestamp(transaction.getTransactionTime()));
! tranInsert.setString(2, transaction.getComment());
! tranInsert.setString(4, getId());
tranInsert.execute();
! PreparedStatement tranID = prepQuery("select id from held_transaction where id=last_insert_id()");
! ResultSet rs = tranID.executeQuery();
if (rs.next())
return rs.getLong(1);
else {
getConnection().rollback();
! throw new LowlevelLedgerException(this, "We couldnt get the id of the transaction. Safer to Rollback.");
}
}
! private void insertTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException {
! PreparedStatement itemInsert = prepQuery("insert into entry (transactionid,accountid,amount,ack) values (?,?,?,1)");
! itemInsert.setLong(1, xid);
! itemInsert.setString(2, item.getBook().getBookID());
! itemInsert.setDouble(3, item.getAmount());
itemInsert.execute();
}
! private void insertHeldTransactionItem(long xid, TransactionItem item) throws SQLException, LowlevelLedgerException {
! PreparedStatement itemInsert = prepQuery("insert into held_entry (held_transactionid,accountid,amount,ack) values (?,?,?,1)");
! itemInsert.setLong(1, xid);
! itemInsert.setString(2, item.getBook().getBookID());
! itemInsert.setDouble(3, item.getAmount());
itemInsert.execute();
}
/**
! * Searches for a Transaction based on its Transaction ID
! *
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public PostedTransaction findTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id = Long.parseLong(idstring);
! try {
! PreparedStatement stmt = prepQuery("select value_date,comment from transaction where id=? and ledgerid=?");
! stmt.setLong(1, id);
! stmt.setString(2, getId());
! ResultSet rs = stmt.executeQuery();
! if (!rs.next()) {
! throw new UnknownTransactionException(this, idstring);
! }
! Date started = rs.getTimestamp(1);
! String comment = rs.getString(2);
! UnPostedTransaction transaction = new UnPostedTransaction(this, comment, started);
! stmt = prepQuery("select accountid,amount from entry where transactionid=?");
! stmt.setLong(1, id);
! rs = stmt.executeQuery();
while (rs.next())
! transaction.addItem(getBook(rs.getString(1)), rs.getDouble(2));
! return this.createTransaction(transaction, idstring);
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
! } catch (InvalidTransactionException e) {
! throw new LowlevelLedgerException(this, e);
} catch (UnknownBookException e) {
! throw new LowlevelLedgerException(this, e);
}
! }
/**
! * Searches for a Held Transaction based on its Transaction ID
! *
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException {
! long id = Long.parseLong(idstring);
! try {
! PreparedStatement stmt = prepQuery("select value_date,held_until,comment from held_transaction where id=? and ledgerid=?");
! stmt.setLong(1, id);
! stmt.setString(2, getId());
! ResultSet rs = stmt.executeQuery();
! if (!rs.next()) {
! throw new UnknownTransactionException(this, idstring);
! }
! Date started = rs.getTimestamp(1);
! Date ended = rs.getTimestamp(2);
! String comment = rs.getString(3);
! UnPostedHeldTransaction transaction = new UnPostedHeldTransaction(this, comment, started, ended);
! stmt = prepQuery("select accountid,amount from held_entry where held_transactionid=?");
! stmt.setLong(1, id);
! rs = stmt.executeQuery();
while (rs.next())
! transaction.addItem(getBook(rs.getString(1)), rs.getDouble(2));
! return this.createHeldTransaction(transaction, idstring);
! } catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
! } catch (InvalidTransactionException e) {
! throw new LowlevelLedgerException(this, e);
} catch (UnknownBookException e) {
! throw new LowlevelLedgerException(this, e);
}
! }
! private PreparedStatement prepQuery(String sql) throws SQLException, LowlevelLedgerException {
! return getConnection().prepareStatement(sql);
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book, java.util.Date)
! */
! public double getBalance(Book book, Date time) throws LowlevelLedgerException {
try {
! PreparedStatement stmt = prepQuery("select sum(e.amount) from entry e,transaction t where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?");
! stmt.setString(1, book.getBookID());
! stmt.setTimestamp(2, new Timestamp(time.getTime()));
! stmt.setString(3, getId());
! ResultSet rs = stmt.executeQuery();
! if (rs.next()) {
return rs.getDouble(1);
}
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
}
return 0;
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book)
! */
! public double getBalance(Book book) throws LowlevelLedgerException {
! return getBalance(book, new Date());
! }
! public double getAvailableBalance(Book book, Date time) throws LowlevelLedgerException {
! double balance = 0.0;
try {
! PreparedStatement stmt = prepQuery("select sum(u.amount) from (" +
! "select sum( e.amount) as amount from entry e,transaction t " +
! "where e.transactionid=t.id and e.accountid=? and t.value_date<= ? and t.ledgerid=?"
! + "union " +
! "select sum( e.amount) as amount from held_entry e, held_transaction t " +
"where " +
! "e.held_transactionid=t.id and e.accountid=? and t.value_date<= ? " +
! "and e.amount<0 and t.held_until>= ? and t.cancelled=0 and t.transactionid is null and t.ledgerid=?"
! + ") u "
! );
! Timestamp ts = SQLTools.toTimestamp(time);
! stmt.setString(1, book.getBookID());
! stmt.setTimestamp(2, ts);
! stmt.setString(3, getId());
! stmt.setString(4, book.getBookID());
! stmt.setTimestamp(5, ts);
! stmt.setTimestamp(6, ts);
! stmt.setString(7, getId());
! ResultSet rs = stmt.executeQuery();
! // System.out.println("Avaliable Balance at: "+ts.toString());
! while (rs.next()) {
! // System.out.println(rs.getString(3)+": "+rs.getString(2)+" "+rs.getDouble(1)+" "+rs.getTimestamp(4));
! balance = +rs.getDouble(1); // Subselects seem to be causing a problem
}
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
}
! return balance;
! }
***************
*** 404,432 ****
* @see org.neuclear.ledger.Ledger#getAvailableBalance(org.neuclear.ledger.Book)
*/
! public double getAvailableBalance(Book book) throws LowlevelLedgerException {
! return getAvailableBalance(book,new Date());
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#beginLinkedTransaction()
! */
! public void beginLinkedTransaction() {
! // TODO Auto-generated method stub
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#endLinkedTransactions()
! */
! public void endLinkedTransactions() {
! // TODO Auto-generated method stub
! }
public String toString() {
! return "SQL Ledger: "+getName();
}
! private Connection getConnection() throws LowlevelLedgerException {
try {
return con.getConnection();
--- 422,450 ----
* @see org.neuclear.ledger.Ledger#getAvailableBalance(org.neuclear.ledger.Book)
*/
! public double getAvailableBalance(Book book) throws LowlevelLedgerException {
! return getAvailableBalance(book, new Date());
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#beginLinkedTransaction()
! */
! public void beginLinkedTransaction() {
! // TODO Auto-generated method stub
! }
! /* (non-Javadoc)
! * @see org.neuclear.ledger.Ledger#endLinkedTransactions()
! */
! public void endLinkedTransactions() {
! // TODO Auto-generated method stub
! }
public String toString() {
! return "SQL Ledger: " + getName();
}
! private Connection getConnection() throws LowlevelLedgerException {
try {
return con.getConnection();
***************
*** 437,453 ****
}
}
- private ConnectionSource con;
! public Book getBook(String bookID) throws UnknownBookException,LowlevelLedgerException {
try {
! PreparedStatement stmt=prepQuery("select screenname from account where id=?");
! stmt.setString(1,bookID);
! ResultSet rs=stmt.executeQuery();
! if(rs.next())
! return createBookInstance(bookID,rs.getString(1));
} catch (SQLException e) {
! throw new LowlevelLedgerException(this,e);
}
! throw new UnknownBookException(this,bookID);
}
}
--- 455,472 ----
}
}
! private ConnectionSource con;
!
! public Book getBook(String bookID) throws UnknownBookException, LowlevelLedgerException {
try {
! PreparedStatement stmt = prepQuery("select screenname from account where id=?");
! stmt.setString(1, bookID);
! ResultSet rs = stmt.executeQuery();
! if (rs.next())
! return createBookInstance(bookID, rs.getString(1));
} catch (SQLException e) {
! throw new LowlevelLedgerException(this, e);
}
! throw new UnknownBookException(this, bookID);
}
}
|
|
From: <pe...@us...> - 2003-10-28 23:43:47
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java
In directory sc8-pr-cvs1:/tmp/cvs-serv8557/src/java
Added Files:
neuclear-ledger.xml
Removed Files:
neuclear-conf.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
--- NEW FILE: neuclear-ledger.xml ---
<components>
<component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/>
<component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.implementations.SQLLedger">
<param type="java.lang.String">neu://superbux/reserve</param>
</component>
</components>
--- neuclear-conf.xml DELETED ---
|
|
From: <pe...@us...> - 2003-10-28 23:43:44
|
Update of /cvsroot/neuclear/neuclear-ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv8557
Modified Files:
project.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: project.xml
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/project.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** project.xml 25 Oct 2003 00:39:05 -0000 1.2
--- project.xml 28 Oct 2003 23:43:16 -0000 1.3
***************
*** 68,76 ****
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-2</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-1-SNAPSHOT</version>
</dependency>
<dependency>
--- 68,76 ----
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-1</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-PRESPLIT-1</version>
</dependency>
<dependency>
|
|
From: <pe...@us...> - 2003-10-28 23:43:22
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv8557/src/java/org/neuclear/ledger
Modified Files:
Ledger.java LedgerFactory.java UnPostedTransaction.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: Ledger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Ledger.java 25 Oct 2003 00:39:05 -0000 1.3
--- Ledger.java 28 Oct 2003 23:43:14 -0000 1.4
***************
*** 4,7 ****
--- 4,11 ----
* $Id$
* $Log$
+ * Revision 1.4 2003/10/28 23:43:14 pelle
+ * The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ * The two SignerStore implementations both use it for the passphrase.
+ *
* Revision 1.3 2003/10/25 00:39:05 pelle
* Fixed SmtpSender it now sends the messages.
***************
*** 317,321 ****
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
}
}
--- 321,325 ----
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getComponent(Ledger.class, "neuclear-ledger");
}
}
Index: LedgerFactory.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/LedgerFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LedgerFactory.java 25 Oct 2003 00:39:05 -0000 1.2
--- LedgerFactory.java 28 Oct 2003 23:43:15 -0000 1.3
***************
*** 8,11 ****
--- 8,15 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/10/28 23:43:15 pelle
+ * The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ * The two SignerStore implementations both use it for the passphrase.
+ *
* Revision 1.2 2003/10/25 00:39:05 pelle
* Fixed SmtpSender it now sends the messages.
***************
*** 69,73 ****
public final Ledger getLedger(String name) throws LedgerCreationException {
try {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
--- 73,77 ----
public final Ledger getLedger(String name) throws LedgerCreationException {
try {
! return (Ledger) Configuration.getComponent(Ledger.class, "neuclear-ledger");
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
Index: UnPostedTransaction.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/UnPostedTransaction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** UnPostedTransaction.java 1 Oct 2003 17:35:53 -0000 1.2
--- UnPostedTransaction.java 28 Oct 2003 23:43:15 -0000 1.3
***************
*** 8,11 ****
--- 8,15 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/10/28 23:43:15 pelle
+ * The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ * The two SignerStore implementations both use it for the passphrase.
+ *
* Revision 1.2 2003/10/01 17:35:53 pelle
* Made as much as possible immutable for security and reliability reasons.
***************
*** 37,44 ****
*
*/
import java.util.Date;
import java.util.Iterator;
- import java.util.List;
import java.util.LinkedList;
/**
--- 41,49 ----
*
*/
+
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
+ import java.util.List;
/**
***************
*** 46,50 ****
*/
public class UnPostedTransaction extends Transaction {
! /**
* Basic rules for creating Transactions:
* <ul>
--- 51,55 ----
*/
public class UnPostedTransaction extends Transaction {
! /**
* Basic rules for creating Transactions:
* <ul>
***************
*** 53,72 ****
* <li>if there is an expiryTime it must not be before the transactionTime
* </ul>
! * @param ledger
! * @param comment
! * @param transactionTime
*/
! public UnPostedTransaction(Ledger ledger, String comment, Date transactionTime) throws InvalidTransactionException {
! this(ledger,comment,transactionTime,false);
}
! UnPostedTransaction(Ledger ledger, String comment, Date transactionTime, boolean posted) throws InvalidTransactionException {
! super(ledger,transactionTime,comment);
// if (amount<0)
// throw new TransactionException("Negative Transactions are not allowed");
! if (transactionTime==null)
! throw new InvalidTransactionException(ledger,"Transaction must have a Transaction Time");
! balance=0;
! items=new LinkedList();
}
--- 58,79 ----
* <li>if there is an expiryTime it must not be before the transactionTime
* </ul>
! *
! * @param ledger
! * @param comment
! * @param transactionTime
*/
! public UnPostedTransaction(Ledger ledger, String comment, Date transactionTime) throws InvalidTransactionException {
! this(ledger, comment, transactionTime, false);
}
!
! UnPostedTransaction(Ledger ledger, String comment, Date transactionTime, boolean posted) throws InvalidTransactionException {
! super(ledger, transactionTime, comment);
// if (amount<0)
// throw new TransactionException("Negative Transactions are not allowed");
! if (transactionTime == null)
! throw new InvalidTransactionException(ledger, "Transaction must have a Transaction Time");
! balance = 0;
! items = new LinkedList();
}
***************
*** 74,87 ****
* Posts a Transaction permanently to it's ledger.
* Remeber a Transaction must be balanced to be posted.
* @return A Unique Transaction ID
*/
public synchronized PostedTransaction post() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! PostedTransaction postTransaction=null;
if (isBalanced()) {
getLedger().beginLinkedTransaction();
! postTransaction=postTransaction();
getLedger().endLinkedTransactions();
} else
! throw new UnBalancedTransactionException(getLedger(),this);
return postTransaction;
}
--- 81,95 ----
* Posts a Transaction permanently to it's ledger.
* Remeber a Transaction must be balanced to be posted.
+ *
* @return A Unique Transaction ID
*/
public synchronized PostedTransaction post() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException {
! PostedTransaction postTransaction = null;
if (isBalanced()) {
getLedger().beginLinkedTransaction();
! postTransaction = postTransaction();
getLedger().endLinkedTransactions();
} else
! throw new UnBalancedTransactionException(getLedger(), this);
return postTransaction;
}
***************
*** 93,105 ****
/**
* Is the Transaction Balanced
! * @return
*/
public boolean isBalanced() {
! return (getBalance()==0);
}
/**
* Get the balance of the Transaction. This should be 0 for posting.
! * @return
*/
public double getBalance() {
--- 101,115 ----
/**
* Is the Transaction Balanced
! *
! * @return
*/
public boolean isBalanced() {
! return (getBalance() == 0);
}
/**
* Get the balance of the Transaction. This should be 0 for posting.
! *
! * @return
*/
public double getBalance() {
***************
*** 110,117 ****
return items.iterator();
}
! TransactionItem [] getItemArray() {
! TransactionItem itemarray[]=new TransactionItem[items.size()];
for (int i = 0; i < items.size(); i++) {
! itemarray[0] = (org.neuclear.ledger.TransactionItem) items.get(i);
}
--- 120,128 ----
return items.iterator();
}
!
! TransactionItem[] getItemArray() {
! TransactionItem itemarray[] = new TransactionItem[items.size()];
for (int i = 0; i < items.size(); i++) {
! itemarray[i] = (org.neuclear.ledger.TransactionItem) items.get(i);
}
***************
*** 128,142 ****
* <li>Book must be from the same Ledger as the Transaction
* </ul>
! * @param book
! * @param amount
* @return the new balance
*/
! public synchronized double addItem(Book book,double amount) throws InvalidTransactionException {
! if (book==null)
! throw new InvalidTransactionException(getLedger(),"You must supply a valid Book");
if (!book.getLedger().equals(getLedger()))
! throw new InvalidTransactionException(getLedger(),"The book must be part of the same Ledger as the Transaction");
! items.add(new TransactionItem(book,amount));
! balance+=amount;
return balance;
}
--- 139,154 ----
* <li>Book must be from the same Ledger as the Transaction
* </ul>
! *
! * @param book
! * @param amount
* @return the new balance
*/
! public synchronized double addItem(Book book, double amount) throws InvalidTransactionException {
! if (book == null)
! throw new InvalidTransactionException(getLedger(), "You must supply a valid Book");
if (!book.getLedger().equals(getLedger()))
! throw new InvalidTransactionException(getLedger(), "The book must be part of the same Ledger as the Transaction");
! items.add(new TransactionItem(book, amount));
! balance += amount;
return balance;
}
|
|
From: <pe...@us...> - 2003-10-28 23:43:18
|
Update of /cvsroot/neuclear/neuclear-pay
In directory sc8-pr-cvs1:/tmp/cvs-serv8452
Modified Files:
project.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: project.xml
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** project.xml 25 Oct 2003 00:38:43 -0000 1.4
--- project.xml 28 Oct 2003 23:42:47 -0000 1.5
***************
*** 79,83 ****
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-2</version>
</dependency>
<dependency>
--- 79,87 ----
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-1</version>
! </dependency>
! <dependency>
! <id>nanocontainer</id>
! <version>1.0-alpha-PRESPLIT-1</version>
</dependency>
<dependency>
|
|
From: <pe...@us...> - 2003-10-28 23:43:09
|
Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay
In directory sc8-pr-cvs1:/tmp/cvs-serv8452/src/java/org/neuclear/pay
Modified Files:
PaymentProcessor.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: PaymentProcessor.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/pay/PaymentProcessor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PaymentProcessor.java 25 Oct 2003 00:38:43 -0000 1.3
--- PaymentProcessor.java 28 Oct 2003 23:42:47 -0000 1.4
***************
*** 4,8 ****
import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.ledger.*;
- import org.picocontainer.PicoContainer;
import java.util.Date;
--- 4,7 ----
***************
*** 103,108 ****
public static PaymentProcessor getInstance() throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
! PicoContainer pico = Configuration.getContainer(PaymentProcessor.class);
! return (PaymentProcessor) pico.getComponentInstance(PaymentProcessor.class);
}
--- 102,106 ----
public static PaymentProcessor getInstance() throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
! return (PaymentProcessor) Configuration.getComponent(PaymentProcessor.class, "neuclear-pay");
}
|
|
From: <pe...@us...> - 2003-10-28 23:42:51
|
Update of /cvsroot/neuclear/neuclear-pay/src/testdata/payments In directory sc8-pr-cvs1:/tmp/cvs-serv8452/src/testdata/payments Modified Files: payment.xml Log Message: The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase. The two SignerStore implementations both use it for the passphrase. Index: payment.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/testdata/payments/payment.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** payment.xml 25 Oct 2003 00:46:29 -0000 1.1 --- payment.xml 28 Oct 2003 23:42:47 -0000 1.2 *************** *** 1,5 **** ! <xfer:TransferRequest xmlns:xfer="http://neuclear.org/neu/xfer" xmlns:neuid="http://neudist.org/neu/neuid" neuid:name="neu://test@pelle/bob.verax.-u04c15v1iqv1kij85xjp93ka1yrj8osjki4zxsqyaw7mmct50" xfer:recipient="neu://bob@verax" xfer:asset="neu://verax/pay" xfer:amount="20.0" neuid:timestamp="2003-10-24T17:20:33,730EST"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue> ! bBW64ypNvT2Qjhtg5F9+lucWr9A= </ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue> ! P4+aoL+IAZs7cK6Je7+/DW4esjwIdNmSnQx1lTBqBw6WOLNFy9UIQg== </ds:SignatureValue></ds:Signature></xfer:TransferRequest> --- 1,5 ---- ! <xfer:TransferRequest xmlns:xfer="http://neuclear.org/neu/xfer" xmlns:neuid="http://neudist.org/neu/neuid" neuid:name="neu://test@pelle/bob.verax.24i3xrtkk55tqyqbkhpnwrwg9o36apjmathba7k9q6fgrka6l2" xfer:recipient="neu://bob@verax" xfer:asset="neu://superbux/reserve" xfer:amount="20.0" neuid:timestamp="2003-10-27T17:39:48,719EST"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue> ! ev/VHzyZ3flR07oMiccaHQqDYr0= </ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue> ! PL2JWKSeTnZfFURCHmJw27iwORmEho2oMrio8JrVqqwgJKdb6YcBDA== </ds:SignatureValue></ds:Signature></xfer:TransferRequest> |
|
From: <pe...@us...> - 2003-10-28 23:42:51
|
Update of /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/pay/receiver
In directory sc8-pr-cvs1:/tmp/cvs-serv8452/src/test/org/neuclear/pay/receiver
Modified Files:
PaymentReceiverTest.java
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
Index: PaymentReceiverTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/pay/receiver/PaymentReceiverTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PaymentReceiverTest.java 25 Oct 2003 00:46:29 -0000 1.1
--- PaymentReceiverTest.java 28 Oct 2003 23:42:47 -0000 1.2
***************
*** 5,10 ****
--- 5,13 ----
import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.ledger.BookExistsException;
import org.neuclear.ledger.LedgerCreationException;
import org.neuclear.ledger.LowlevelLedgerException;
+ import org.neuclear.ledger.UnknownBookException;
+ import org.neuclear.pay.Account;
import org.neuclear.pay.PaymentProcessor;
import org.neuclear.pay.contracts.TransferContract;
***************
*** 33,36 ****
--- 36,43 ----
$Id$
$Log$
+ Revision 1.2 2003/10/28 23:42:47 pelle
+ The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
+ The two SignerStore implementations both use it for the passphrase.
+
Revision 1.1 2003/10/25 00:46:29 pelle
Added tests to test the PaymentReceiver.
***************
*** 47,51 ****
public PaymentReceiverTest(String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
! //proc=PaymentProcessor.getInstance();
receiver = new PaymentReceiver(proc, "neu://test/pay");
}
--- 54,58 ----
public PaymentReceiverTest(String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
! proc = PaymentProcessor.getInstance();
receiver = new PaymentReceiver(proc, "neu://test/pay");
}
***************
*** 63,72 ****
}
public Object getPreTransactionState(SignedNamedObject obj) throws Exception {
if (obj instanceof TransferContract) {
TransferContract transfer = (TransferContract) obj;
! double fromBalance = proc.getAccount(transfer.getSignatory().getName()).getBalance(transfer.getTimeStamp());
! double toBalance = proc.getAccount(transfer.getRecipient()).getBalance(transfer.getTimeStamp());
return new double[]{fromBalance, toBalance};
--- 70,91 ----
}
+ private Account createNewAccount(String name) throws BookExistsException, LowlevelLedgerException {
+ try {
+ return proc.getAccount(name);
+ } catch (UnknownBookException e) {
+ return proc.createAccount(name, name);
+ }
+
+ }
+
public Object getPreTransactionState(SignedNamedObject obj) throws Exception {
if (obj instanceof TransferContract) {
TransferContract transfer = (TransferContract) obj;
! Account fromAccount = createNewAccount(transfer.getSignatory().getName());
! double fromBalance = (fromAccount != null) ? fromAccount.getBalance(transfer.getTimeStamp()) : 0;
! Account toAccount = createNewAccount(transfer.getRecipient());
! double toBalance = (toAccount != null) ? toAccount.getBalance(transfer.getTimeStamp()) : 0;
! ;
return new double[]{fromBalance, toBalance};
***************
*** 79,84 ****
TransferContract transfer = (TransferContract) obj;
final double prebalances[] = (double[]) state;
! double fromBalance = proc.getAccount(transfer.getSignatory().getName()).getBalance(transfer.getTimeStamp());
! double toBalance = proc.getAccount(transfer.getRecipient()).getBalance(transfer.getTimeStamp());
return (fromBalance == prebalances[0] - transfer.getAmount()) &&
--- 98,106 ----
TransferContract transfer = (TransferContract) obj;
final double prebalances[] = (double[]) state;
! Account fromAccount = createNewAccount(transfer.getSignatory().getName());
! Account toAccount = createNewAccount(transfer.getRecipient());
! double fromBalance = (fromAccount != null) ? fromAccount.getBalance(transfer.getTimeStamp()) : 0;
! double toBalance = (toAccount != null) ? toAccount.getBalance(transfer.getTimeStamp()) : 0;
! ;
return (fromBalance == prebalances[0] - transfer.getAmount()) &&
|
|
From: <pe...@us...> - 2003-10-28 23:42:51
|
Update of /cvsroot/neuclear/neuclear-pay/src/java
In directory sc8-pr-cvs1:/tmp/cvs-serv8452/src/java
Added Files:
neuclear-pay.xml
Removed Files:
neuclear-conf.xml
Log Message:
The PassPhraseDialogue now works. It simply presents itself as a simple modal dialog box asking for a passphrase.
The two SignerStore implementations both use it for the passphrase.
--- NEW FILE: neuclear-pay.xml ---
<components>
<component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/>
<component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.implementations.SQLLedger">
<param type="java.lang.String">neu://superbux/reserve</param>
</component>
<component class="org.neuclear.pay.PaymentProcessor">
<param type="java.lang.String">SuperBux</param>
<param type="java.lang.String">neu://superbux/reserve</param>
</component>
</components>
--- neuclear-conf.xml DELETED ---
|
|
From: <pe...@us...> - 2003-10-27 23:49:01
|
Update of /cvsroot/neuclear/neuclear-bet
In directory sc8-pr-cvs1:/tmp/cvs-serv20480
Modified Files:
project.xml
Log Message:
Configuration should now work again. There current snapshots of NanoContainer are changing to rapidly and do not seem to
have a working XMLRegistration system. So I have created a snapshot of NanoContainer from before they started doing major changes.
If you use the Configuration class directly, the interface has changed to a getComponent which takes the class as well as a context name.
This context name is the name minus the (.xml) extension of the configuration file. eg context "neuclear-pay" loads the configuration
from "neuclear-pay.xml" using the class loader.
Working on getting PaymentReceiverTest working. To do that we need somesort of Signing Pico Component. I have taken the old
SignerStore interface and redesigned it a bit. Now you pass it the name that needs to sign it and a byte array. It then returns the
signed version. This allows all matters of different models and we dont need to worry about PrivateKeys floating around.
Index: project.xml
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** project.xml 25 Oct 2003 00:38:20 -0000 1.4
--- project.xml 27 Oct 2003 23:48:17 -0000 1.5
***************
*** 87,95 ****
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-2</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-1-SNAPSHOT</version>
</dependency>
<dependency>
--- 87,95 ----
<dependency>
<id>picocontainer</id>
! <version>1.0-beta-1</version>
</dependency>
<dependency>
<id>nanocontainer</id>
! <version>1.0-alpha-PRESPLIT-1</version>
</dependency>
<dependency>
|
|
From: <pe...@us...> - 2003-10-27 23:49:01
|
Update of /cvsroot/neuclear/neuclear-bet/src/java
In directory sc8-pr-cvs1:/tmp/cvs-serv20480/src/java
Added Files:
neuclear-bet.xml
Removed Files:
neuclear-conf.xml
Log Message:
Configuration should now work again. There current snapshots of NanoContainer are changing to rapidly and do not seem to
have a working XMLRegistration system. So I have created a snapshot of NanoContainer from before they started doing major changes.
If you use the Configuration class directly, the interface has changed to a getComponent which takes the class as well as a context name.
This context name is the name minus the (.xml) extension of the configuration file. eg context "neuclear-pay" loads the configuration
from "neuclear-pay.xml" using the class loader.
Working on getting PaymentReceiverTest working. To do that we need somesort of Signing Pico Component. I have taken the old
SignerStore interface and redesigned it a bit. Now you pass it the name that needs to sign it and a byte array. It then returns the
signed version. This allows all matters of different models and we dont need to worry about PrivateKeys floating around.
--- NEW FILE: neuclear-bet.xml ---
<components>
<component type="org.neuclear.sql.ConnectionSource" class="org.neuclear.sql.DefaultConnectionSource"/>
<component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.implementations.SQLLedger">
<param type="java.lang.String">neu://superbux/reserve</param>
</component>
<component class="org.neuclear.pay.PaymentProcessor">
<param type="java.lang.String">SuperBux</param>
<param type="java.lang.String">neu://superbux/reserve</param>
</component>
<component type="org.neuclear.bet.totalizers.Totalizer" class="org.neuclear.bet.totalizers.dumb.DumbTotalizer">
<param type="java.lang.Double">0.25</param>
</component>
<component class="org.neuclear.bet.BetProcessor">
<param type="java.lang.String">FrogRacing</param>
<param type="java.lang.String">neu://frograce/parimutual</param>
</component>
</components>
--- neuclear-conf.xml DELETED ---
|
|
From: <pe...@us...> - 2003-10-27 23:49:01
|
Update of /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet
In directory sc8-pr-cvs1:/tmp/cvs-serv20480/src/java/org/neuclear/bet
Modified Files:
BetProcessor.java
Log Message:
Configuration should now work again. There current snapshots of NanoContainer are changing to rapidly and do not seem to
have a working XMLRegistration system. So I have created a snapshot of NanoContainer from before they started doing major changes.
If you use the Configuration class directly, the interface has changed to a getComponent which takes the class as well as a context name.
This context name is the name minus the (.xml) extension of the configuration file. eg context "neuclear-pay" loads the configuration
from "neuclear-pay.xml" using the class loader.
Working on getting PaymentReceiverTest working. To do that we need somesort of Signing Pico Component. I have taken the old
SignerStore interface and redesigned it a bit. Now you pass it the name that needs to sign it and a byte array. It then returns the
signed version. This allows all matters of different models and we dont need to worry about PrivateKeys floating around.
Index: BetProcessor.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/java/org/neuclear/bet/BetProcessor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BetProcessor.java 25 Oct 2003 00:38:20 -0000 1.2
--- BetProcessor.java 27 Oct 2003 23:48:17 -0000 1.3
***************
*** 89,93 ****
public static BetProcessor getInstance() throws ConfigurationException {
! return (BetProcessor) Configuration.getContainer(BetProcessor.class).getComponentInstance(BetProcessor.class);
}
--- 89,93 ----
public static BetProcessor getInstance() throws ConfigurationException {
! return (BetProcessor) Configuration.getComponent(BetProcessor.class, "neuclear-bet");
}
|
|
From: <pe...@us...> - 2003-10-25 11:30:02
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id
In directory sc8-pr-cvs1:/tmp/cvs-serv15459/src/java/org/neuclear/id
Modified Files:
NSTools.java
Log Message:
Replaced the dependency for the Apache Regex library with JDK1.4's Regex implementation.
Changed the valid format of NeuClear ID's to include neu://bob@hello/ formatted ids.
These ids are not identical to neu://hello/bob however in both cases neu://hello has to sign the Identity document.
Index: NSTools.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/id/NSTools.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** NSTools.java 21 Oct 2003 22:31:13 -0000 1.7
--- NSTools.java 22 Oct 2003 22:12:33 -0000 1.8
***************
*** 2,5 ****
--- 2,10 ----
* $Id$
* $Log$
+ * Revision 1.8 2003/10/22 22:12:33 pelle
+ * Replaced the dependency for the Apache Regex library with JDK1.4's Regex implementation.
+ * Changed the valid format of NeuClear ID's to include neu://bob@hello/ formatted ids.
+ * These ids are not identical to neu://hello/bob however in both cases neu://hello has to sign the Identity document.
+ *
* Revision 1.7 2003/10/21 22:31:13 pelle
* Renamed NeudistException to NeuClearException and moved it to org.neuclear.commons where it makes more sense.
***************
*** 113,128 ****
package org.neuclear.id;
- import org.apache.regexp.RE;
- import org.apache.regexp.RESyntaxException;
import org.dom4j.DocumentHelper;
import org.dom4j.Namespace;
import org.neuclear.id.resolver.NSResolver;
import org.neudist.crypto.CryptoTools;
- import org.neuclear.commons.NeuClearException;
import org.neudist.utils.Utility;
import java.util.Random;
public final class NSTools {
private NSTools() {
};
--- 118,140 ----
package org.neuclear.id;
import org.dom4j.DocumentHelper;
import org.dom4j.Namespace;
+ import org.neuclear.commons.NeuClearException;
import org.neuclear.id.resolver.NSResolver;
import org.neudist.crypto.CryptoTools;
import org.neudist.utils.Utility;
import java.util.Random;
+ import java.util.regex.Matcher;
+ import java.util.regex.Pattern;
public final class NSTools {
+ private static final String VALID_TOKEN = "[\\w.]+";
+ private static final String VALID_ID = "^(neu:\\/)?" +
+ "(\\/(" + VALID_TOKEN + "@" + VALID_TOKEN + ")?" +
+ "((\\/)|" + VALID_TOKEN + ")*)$";
+
+ private static final Pattern VALID = Pattern.compile(VALID_ID);
+
private NSTools() {
};
***************
*** 130,133 ****
--- 142,146 ----
/**
* Takes a valid NEU Name and Creates a URI
+ *
* @param name Valid NEU Name
* @return Valid URI
***************
*** 145,169 ****
* Name must follow the follwing rules:<br>
* Available Characters: <pre>a..zA..Z0..9_/.-</pre> <br>
! *
* Name starts with either URI prefix <tt>neu://</tt>
* or <tt>/</tt>
* @param name to test
* @return boolean
*/
! public static boolean isValidName(String name) throws NeuClearException {
! try {
! if (Utility.isEmpty(name))
! return false;
! RE re = new RE("^(neu:\\/)?((\\/)|(\\/[a-zA-Z0-9_\\-\\.]+)*)$");
! return (re.match(name));
! } catch (RESyntaxException e) {
! e.printStackTrace();
! Utility.rethrowException(e);
return false;
! }
}
/**
* Returns the URI of the parent Identity for a given NEU Name
* @param name a valid NEU Name
* @return Parent URI or null if name is the root
--- 158,178 ----
* Name must follow the follwing rules:<br>
* Available Characters: <pre>a..zA..Z0..9_/.-</pre> <br>
! * <p/>
* Name starts with either URI prefix <tt>neu://</tt>
* or <tt>/</tt>
+ *
* @param name to test
* @return boolean
*/
! public static boolean isValidName(String name) {
! if (Utility.isEmpty(name))
return false;
! Matcher matcher = VALID.matcher(name);
! return (matcher.matches());
}
/**
* Returns the URI of the parent Identity for a given NEU Name
+ *
* @param name a valid NEU Name
* @return Parent URI or null if name is the root
|
|
From: <pe...@us...> - 2003-10-25 10:38:11
|
Update of /cvsroot/neuclear/neuclear-id
In directory sc8-pr-cvs1:/tmp/cvs-serv15459
Modified Files:
project.xml
Log Message:
Replaced the dependency for the Apache Regex library with JDK1.4's Regex implementation.
Changed the valid format of NeuClear ID's to include neu://bob@hello/ formatted ids.
These ids are not identical to neu://hello/bob however in both cases neu://hello has to sign the Identity document.
Index: project.xml
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/project.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** project.xml 24 Sep 2003 23:56:47 -0000 1.6
--- project.xml 22 Oct 2003 22:12:34 -0000 1.7
***************
*** 106,117 ****
<version>3.8.1</version>
</dependency>
- <dependency>
- <id>regexp</id>
- <name>regexp</name>
- <version>1.2</version>
- <properties>
- <war.bundle.jar>true</war.bundle.jar>
- </properties>
- </dependency>
<dependency>
<id>servletapi</id>
--- 106,109 ----
|
|
From: <pe...@us...> - 2003-10-25 08:27:45
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id
In directory sc8-pr-cvs1:/tmp/cvs-serv15459/src/test/org/neuclear/id
Modified Files:
NSToolsTest.java
Log Message:
Replaced the dependency for the Apache Regex library with JDK1.4's Regex implementation.
Changed the valid format of NeuClear ID's to include neu://bob@hello/ formatted ids.
These ids are not identical to neu://hello/bob however in both cases neu://hello has to sign the Identity document.
Index: NSToolsTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/NSToolsTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** NSToolsTest.java 21 Oct 2003 22:31:14 -0000 1.5
--- NSToolsTest.java 22 Oct 2003 22:12:33 -0000 1.6
***************
*** 2,5 ****
--- 2,10 ----
$Id$
$Log$
+ Revision 1.6 2003/10/22 22:12:33 pelle
+ Replaced the dependency for the Apache Regex library with JDK1.4's Regex implementation.
+ Changed the valid format of NeuClear ID's to include neu://bob@hello/ formatted ids.
+ These ids are not identical to neu://hello/bob however in both cases neu://hello has to sign the Identity document.
+
Revision 1.5 2003/10/21 22:31:14 pelle
Renamed NeudistException to NeuClearException and moved it to org.neuclear.commons where it makes more sense.
***************
*** 77,88 ****
package org.neuclear.id;
- import junit.framework.Test;
import junit.framework.TestCase;
- import junit.framework.TestSuite;
import org.neuclear.commons.NeuClearException;
/**
- *
* @author Pelle Braendgaard
*/
--- 82,90 ----
***************
*** 108,112 ****
assertValidName("neu://help/abcdefg232Avc");
assertValidName("/help/abcdefg232Avc");
! //assertInvalidName("neu:/");// TODO Doesnt pass as invalid. Ignore short term, fix soon.
assertInvalidName("neu");
assertInvalidName("");
--- 110,124 ----
assertValidName("neu://help/abcdefg232Avc");
assertValidName("/help/abcdefg232Avc");
!
! assertValidName("neu://pelle@help");
! assertValidName("neu://pelle@help/abcdefg232Avc");
!
! assertValidName("neu://pelle@neuclear.org");
! assertValidName("neu://pelle@neuclear.org/abcdefg232Avc");
!
! assertInvalidName("neu:/");
! assertInvalidName("neu://test/pelle@help");
! assertInvalidName("neu://test/pelle@help/abcdefg232Avc");
!
assertInvalidName("neu");
assertInvalidName("");
|
|
From: <pe...@us...> - 2003-10-25 03:40:43
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv8013/src/java/org/neuclear/ledger
Modified Files:
Ledger.java LedgerFactory.java
Log Message:
Fixed SmtpSender it now sends the messages.
Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
Index: Ledger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Ledger.java 1 Oct 2003 17:35:53 -0000 1.2
--- Ledger.java 25 Oct 2003 00:39:05 -0000 1.3
***************
*** 1,6 ****
--- 1,13 ----
package org.neuclear.ledger;
+
/**
* $Id$
* $Log$
+ * Revision 1.3 2003/10/25 00:39:05 pelle
+ * Fixed SmtpSender it now sends the messages.
+ * Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
+ * is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
+ * Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
+ *
* Revision 1.2 2003/10/01 17:35:53 pelle
* Made as much as possible immutable for security and reliability reasons.
***************
*** 70,78 ****
*/
- import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.commons.configuration.Configuration;
import java.util.Date;
import java.util.Iterator;
/**
* This is the abstract Ledger class that implementators of the NeuClear Ledger need to implement.
--- 77,86 ----
*/
import org.neuclear.commons.configuration.Configuration;
+ import org.neuclear.commons.configuration.ConfigurationException;
import java.util.Date;
import java.util.Iterator;
+
/**
* This is the abstract Ledger class that implementators of the NeuClear Ledger need to implement.
***************
*** 82,105 ****
/**
* The unique id of the ledger
! * @param id
*/
! public Ledger(String id,String name) {
! this.name=name;
! this.id=id;
}
/**
* Default implementation allows for new Books to be created on the fly. If you need control over this. Over ride.
! * @param bookID
! * @return
*/
! public abstract Book getBook(String bookID) throws UnknownBookException,LowlevelLedgerException;
/**
* Used by implementations to securely create Book Instances
! * @param bookID
* @return Valid Book instance
*/
! protected Book createBookInstance(String bookID,String name) {
! return new Book(bookID,name,this);
}
--- 90,117 ----
/**
* The unique id of the ledger
! *
! * @param id
*/
! public Ledger(String id, String name) {
! this.name = name;
! this.id = id;
}
+
/**
* Default implementation allows for new Books to be created on the fly. If you need control over this. Over ride.
! *
! * @param bookID
! * @return
*/
! public abstract Book getBook(String bookID) throws UnknownBookException, LowlevelLedgerException;
/**
* Used by implementations to securely create Book Instances
! *
! * @param bookID
* @return Valid Book instance
*/
! protected Book createBookInstance(String bookID, String name) {
! return new Book(bookID, name, this);
}
***************
*** 109,113 ****
public Book createNewBook(String bookID) throws BookExistsException, LowlevelLedgerException {
! return createNewBook(bookID,"Unnamed Account");
}
--- 121,125 ----
public Book createNewBook(String bookID) throws BookExistsException, LowlevelLedgerException {
! return createNewBook(bookID, "Unnamed Account");
}
***************
*** 117,130 ****
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
/**
* The basic interface for creating Transactions in the database.
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
--- 129,145 ----
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
+ *
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
+
/**
* The basic interface for creating Transactions in the database.
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
+ *
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
***************
*** 132,139 ****
/**
* Searches for a Transaction based on its Transaction ID
* @param id A valid ID
* @return The Transaction object
*/
! public abstract PostedTransaction findTransaction(String id) throws LowlevelLedgerException, UnknownTransactionException, InvalidTransactionException, UnknownBookException;
/**
--- 147,155 ----
/**
* Searches for a Transaction based on its Transaction ID
+ *
* @param id A valid ID
* @return The Transaction object
*/
! public abstract PostedTransaction findTransaction(String id) throws LowlevelLedgerException, UnknownTransactionException, InvalidTransactionException, UnknownBookException;
/**
***************
*** 152,161 ****
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! *
* </pre>
! * @param balancedate
* @return the balance as a double
*/
public abstract double getBalance(Book book, Date balancedate) throws LowlevelLedgerException;
public abstract double getBalance(Book book) throws LowlevelLedgerException;
--- 168,179 ----
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! * <p/>
* </pre>
! *
! * @param balancedate
* @return the balance as a double
*/
public abstract double getBalance(Book book, Date balancedate) throws LowlevelLedgerException;
+
public abstract double getBalance(Book book) throws LowlevelLedgerException;
***************
*** 174,184 ****
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! *
* </pre>
! * @param balancedate
* @return the balance as a double
*/
! public abstract double getAvailableBalance(Book book, Date balancedate) throws LowlevelLedgerException;
! public abstract double getAvailableBalance(Book book) throws LowlevelLedgerException;
/**
--- 192,204 ----
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! * <p/>
* </pre>
! *
! * @param balancedate
* @return the balance as a double
*/
! public abstract double getAvailableBalance(Book book, Date balancedate) throws LowlevelLedgerException;
!
! public abstract double getAvailableBalance(Book book) throws LowlevelLedgerException;
/**
***************
*** 187,190 ****
--- 207,211 ----
*/
public abstract void beginLinkedTransaction();
+
/**
* Use this to indicate to the underlying system that we want to end a database transaction.
***************
*** 211,264 ****
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedTransaction createTransaction(UnPostedTransaction transaction,String xid) throws InvalidTransactionException {
! return new PostedTransaction(transaction,xid);
}
/**
* Ledger Implementations use this to create Transactions.
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedHeldTransaction createHeldTransaction(UnPostedHeldTransaction transaction,String xid) throws InvalidTransactionException {
! return new PostedHeldTransaction(transaction,xid);
}
! protected final PostedTransaction createHeldComplete(PostedHeldTransaction hold,double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
//TODO Rework these Exception
! if (hold.getTransactionTime().after(hold.getExpiryTime()))
! throw new TransactionExpiredException(this,hold);
! if (amount<0)
! throw new InvalidTransactionException(this,"The amount must be positive");
try {
beginLinkedTransaction();
//PostedTransaction rev=hold.reverse(comment); // We dont need to reverse this
! UnPostedTransaction tran=new UnPostedTransaction(this,comment,time);
! Iterator iter=hold.getItems();
! while (iter.hasNext()){
! TransactionItem item=(TransactionItem)iter.next();
! if (item.getAmount()>=0)
! tran.addItem(item.getBook(),amount);
else
! tran.addItem(item.getBook(),-amount);
}
endLinkedTransactions();
return tran.post();
} catch (UnBalancedTransactionException e) {
! throw new LowlevelLedgerException(this,e);
}
}
public String toString() {
return name;
}
public String getName() {
return name;
}
public String getId() {
return id;
--- 232,291 ----
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
+ *
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedTransaction createTransaction(UnPostedTransaction transaction, String xid) throws InvalidTransactionException {
! return new PostedTransaction(transaction, xid);
}
+
/**
* Ledger Implementations use this to create Transactions.
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
+ *
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedHeldTransaction createHeldTransaction(UnPostedHeldTransaction transaction, String xid) throws InvalidTransactionException {
! return new PostedHeldTransaction(transaction, xid);
}
! protected final PostedTransaction createHeldComplete(PostedHeldTransaction hold, double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
//TODO Rework these Exception
! if (hold.getTransactionTime().after(hold.getExpiryTime()))
! throw new TransactionExpiredException(this, hold);
! if (amount < 0)
! throw new InvalidTransactionException(this, "The amount must be positive");
try {
beginLinkedTransaction();
//PostedTransaction rev=hold.reverse(comment); // We dont need to reverse this
! UnPostedTransaction tran = new UnPostedTransaction(this, comment, time);
! Iterator iter = hold.getItems();
! while (iter.hasNext()) {
! TransactionItem item = (TransactionItem) iter.next();
! if (item.getAmount() >= 0)
! tran.addItem(item.getBook(), amount);
else
! tran.addItem(item.getBook(), -amount);
}
endLinkedTransactions();
return tran.post();
} catch (UnBalancedTransactionException e) {
! throw new LowlevelLedgerException(this, e);
}
}
+
public String toString() {
return name;
}
+
public String getName() {
return name;
}
+
public String getId() {
return id;
***************
*** 269,290 ****
/**
! * Searches for a Held Transaction based on its Transaction ID
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public abstract PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException;
/**
* Cancels a Held Transaction.
! * @param hold
* @throws org.neuclear.ledger.LowlevelLedgerException
* @throws org.neuclear.ledger.UnknownTransactionException
*/
public abstract void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException;
! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold,double amount, Date time, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException;
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getContainer().getComponent(Ledger.class);
}
}
--- 296,321 ----
/**
! * Searches for a Held Transaction based on its Transaction ID
! *
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public abstract PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException;
/**
* Cancels a Held Transaction.
! *
! * @param hold
* @throws org.neuclear.ledger.LowlevelLedgerException
+ *
* @throws org.neuclear.ledger.UnknownTransactionException
+ *
*/
public abstract void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException;
! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, Date time, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException;
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
}
}
Index: LedgerFactory.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/LedgerFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** LedgerFactory.java 20 Sep 2003 23:16:17 -0000 1.1.1.1
--- LedgerFactory.java 25 Oct 2003 00:39:05 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
package org.neuclear.ledger;
+
/**
* (C) 2003 Antilles Software Ventures SA
***************
*** 7,10 ****
--- 8,17 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/25 00:39:05 pelle
+ * Fixed SmtpSender it now sends the messages.
+ * Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
+ * is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
+ * Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
+ *
* Revision 1.1.1.1 2003/09/20 23:16:17 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 35,52 ****
*/
- import org.neuclear.ledger.implementations.SimpleLedger;
- import org.neuclear.ledger.implementations.SQLLedger;
- import org.neuclear.commons.sql.SQLTools;
- import org.neuclear.commons.sql.DefaultConnectionSource;
- import org.neuclear.commons.sql.ConnectionSource;
import org.neuclear.commons.configuration.Configuration;
import org.neuclear.commons.configuration.ConfigurationException;
! import org.picocontainer.defaults.*;
! import org.picocontainer.PicoIntrospectionException;
! import org.picocontainer.PicoInitializationException;
! import org.picocontainer.PicoContainer;
- import java.util.Map;
import java.util.HashMap;
/**
--- 42,52 ----
*/
import org.neuclear.commons.configuration.Configuration;
import org.neuclear.commons.configuration.ConfigurationException;
! import org.neuclear.ledger.implementations.SQLLedger;
! import org.picocontainer.defaults.DefaultPicoContainer;
import java.util.HashMap;
+ import java.util.Map;
/**
***************
*** 57,72 ****
*/
public class LedgerFactory {
! protected LedgerFactory() throws LowlevelLedgerException{
! ledgerMap=new HashMap();
}
/**
* This attempts to find a ledger in the map. If not it creates a new one and returns it.
* @param name Unique Ledger Name
* @return Ledger
*/
! public final Ledger getLedger(String name) throws LedgerCreationException{
try {
! return (Ledger)Configuration.getContainer().getComponent(Ledger.class);
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
--- 57,73 ----
*/
public class LedgerFactory {
! protected LedgerFactory() throws LowlevelLedgerException {
! ledgerMap = new HashMap();
}
/**
* This attempts to find a ledger in the map. If not it creates a new one and returns it.
+ *
* @param name Unique Ledger Name
* @return Ledger
*/
! public final Ledger getLedger(String name) throws LedgerCreationException {
try {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
***************
*** 76,84 ****
/**
* Gets a Singleton instance of the LedgerFactory.
* @return the Singleton Instance
*/
public synchronized static LedgerFactory getInstance() throws LowlevelLedgerException {
! if (instance==null){
! instance=new LedgerFactory();
}
return instance;
--- 77,86 ----
/**
* Gets a Singleton instance of the LedgerFactory.
+ *
* @return the Singleton Instance
*/
public synchronized static LedgerFactory getInstance() throws LowlevelLedgerException {
! if (instance == null) {
! instance = new LedgerFactory();
}
return instance;
***************
*** 98,101 ****
private static Map ledgerMap;
private DefaultPicoContainer pico;
! private static Class DEFAULT_IMPLEMENTATION=SQLLedger.class;
}
--- 100,103 ----
private static Map ledgerMap;
private DefaultPicoContainer pico;
! private static Class DEFAULT_IMPLEMENTATION = SQLLedger.class;
}
|
|
From: <pe...@us...> - 2003-10-25 00:51:48
|
Update of /cvsroot/neuclear/neuclear-pay/src/testdata/payments In directory sc8-pr-cvs1:/tmp/cvs-serv9768/src/testdata/payments Added Files: payment.xml Log Message: Added tests to test the PaymentReceiver. CreateTestPayments is a command line utility to create signed payment requests --- NEW FILE: payment.xml --- <xfer:TransferRequest xmlns:xfer="http://neuclear.org/neu/xfer" xmlns:neuid="http://neudist.org/neu/neuid" neuid:name="neu://test@pelle/bob.verax.-u04c15v1iqv1kij85xjp93ka1yrj8osjki4zxsqyaw7mmct50" xfer:recipient="neu://bob@verax" xfer:asset="neu://verax/pay" xfer:amount="20.0" neuid:timestamp="2003-10-24T17:20:33,730EST"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#dsa-sha1"/><ds:Reference URI=""><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue> bBW64ypNvT2Qjhtg5F9+lucWr9A= </ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue> P4+aoL+IAZs7cK6Je7+/DW4esjwIdNmSnQx1lTBqBw6WOLNFy9UIQg== </ds:SignatureValue></ds:Signature></xfer:TransferRequest> |