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: Pelle B. <pe...@us...> - 2004-03-22 20:18:43
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11636/src/java Modified Files: neuclear-ledger.xml Log Message: Added simple ledger for unit testing and in memory use Index: neuclear-ledger.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/neuclear-ledger.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** neuclear-ledger.xml 28 Oct 2003 23:43:15 -0000 1.1 --- neuclear-ledger.xml 22 Mar 2004 20:08:24 -0000 1.2 *************** *** 1,5 **** <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> --- 1,5 ---- <components> <component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/> ! <component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.sql.SQLLedger"> <param type="java.lang.String">neu://superbux/reserve</param> </component> |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:29
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11520/src/java Modified Files: neuclear-ledger.xml Log Message: Added simple ledger for unit testing and in memory use Index: neuclear-ledger.xml =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger-sql/src/java/neuclear-ledger.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** neuclear-ledger.xml 22 Mar 2004 19:49:52 -0000 1.1.1.1 --- neuclear-ledger.xml 22 Mar 2004 20:08:09 -0000 1.2 *************** *** 1,5 **** <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> --- 1,5 ---- <components> <component type="org.neuclear.commons.sql.ConnectionSource" class="org.neuclear.commons.sql.DefaultConnectionSource"/> ! <component type="org.neuclear.ledger.Ledger" class="org.neuclear.ledger.sql.SQLLedger"> <param type="java.lang.String">neu://superbux/reserve</param> </component> |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:29
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/test/org/neuclear/ledger/sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11520/src/test/org/neuclear/ledger/sql Added Files: SQLLedgerTest.java Log Message: Added simple ledger for unit testing and in memory use --- NEW FILE: SQLLedgerTest.java --- package org.neuclear.ledger.sql; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.sql.DefaultConnectionSource; import org.neuclear.commons.sql.statements.SimpleStatementFactory; import org.neuclear.ledger.AbstractLedgerTest; import org.neuclear.ledger.Ledger; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.UnknownLedgerException; import javax.naming.NamingException; import java.io.IOException; import java.sql.SQLException; /** * Created by IntelliJ IDEA. * User: pelleb * Date: Jul 16, 2003 * Time: 12:58:30 PM * To change this template use Options | File Templates. */ public final class SQLLedgerTest extends AbstractLedgerTest { public SQLLedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); } public final Ledger createLedger() throws UnknownLedgerException, LowlevelLedgerException { return new SQLLedger(new SimpleStatementFactory(new DefaultConnectionSource()), "test"); } } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:29
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/test/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11520/src/test/org/neuclear/ledger Removed Files: SQLLedgerTest.java Log Message: Added simple ledger for unit testing and in memory use --- SQLLedgerTest.java DELETED --- |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:29
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11520/src/java/org/neuclear/ledger/sql Added Files: SQLLedger.java Log Message: Added simple ledger for unit testing and in memory use --- NEW FILE: SQLLedger.java --- /* * Created on Jul 14, 2003 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package org.neuclear.ledger.sql; import org.bouncycastle.crypto.Digest; import org.bouncycastle.crypto.digests.SHA1Digest; import org.neuclear.commons.crypto.CryptoTools; import org.neuclear.commons.sql.SQLTools; import org.neuclear.commons.sql.entities.EntityModel; import org.neuclear.commons.sql.entities.Schema; import org.neuclear.commons.sql.statements.StatementFactory; import org.neuclear.id.NSTools; import org.neuclear.ledger.*; import org.neuclear.ledger.browser.BookBrowser; import org.neuclear.ledger.browser.LedgerBrowser; import org.neuclear.ledger.browser.QueryBookBrowser; import javax.transaction.UserTransaction; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; 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 final class SQLLedger extends Ledger implements LedgerBrowser { /** * 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(final StatementFactory fact, final String id) throws LowlevelLedgerException, UnknownLedgerException { super(id, "sql ledger"); this.fact = fact; create(fact); createLedger(id); } public void createLedger(String name) throws LowlevelLedgerException { try { final PreparedStatement query = prepQuery("select * from ledger where id= ?"); query.setString(1, name); ResultSet rs = query.executeQuery(); if (!rs.next()) { final PreparedStatement stmt = prepQuery("insert into ledger (id,title,created) values (?,?,now())"); stmt.setString(1, name); stmt.setString(2, name); stmt.execute(); } } catch (SQLException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } } public static synchronized void create(StatementFactory fact) { createSchema().create(fact); } public static Schema createSchema() { Schema schema = new Schema("mysql"); EntityModel ledgerModel = schema.addEntityModel("ledger"); ledgerModel.addTitle(); // ledgerModel.addComment(); ledgerModel.addTimeStamp(); EntityModel bookModel = schema.addEntityModel("book"); bookModel.addTitle(); bookModel.addTimeStamp(); EntityModel xactModel = schema.addEntityModel("transaction"); xactModel.addComment(); xactModel.addValueTime(); xactModel.addReference(ledgerModel); EntityModel entryModel = schema.addEntityModel("entry", false); entryModel.addMoney(); entryModel.addReference(bookModel); entryModel.addReference(xactModel); EntityModel hxactModel = schema.addEntityModel("held_transaction"); hxactModel.addComment(); hxactModel.addValueTime(); hxactModel.addTimeStamp("held_until"); hxactModel.addReference(ledgerModel); hxactModel.addReference(xactModel); hxactModel.addBoolean("cancelled"); EntityModel hentryModel = schema.addEntityModel("held_entry", false); hentryModel.addMoney(); hentryModel.addReference(bookModel); hentryModel.addReference(hxactModel); return schema; } private static String getLedgerName(final StatementFactory fact, final String id) throws UnknownLedgerException, LowlevelLedgerException { try { final PreparedStatement stmt = fact.prepareStatement("select title from ledger where id=?"); stmt.setString(1, id); final ResultSet rs = stmt.executeQuery(); if (rs.next()) return rs.getString(1); else throw new UnknownLedgerException(id); } catch (SQLException e) { throw new LowlevelLedgerException(e); } } /** * This decides if new books are automatically created. * * @return */ public final boolean allowAutoBookCreation() { return false; } public final boolean bookExists(final String bookID) throws LowlevelLedgerException { try { final PreparedStatement stmt = prepQuery("select id from book where id=?"); stmt.setString(1, bookID); final ResultSet rs = stmt.executeQuery(); return rs.next(); } catch (SQLException e) { throw new LowlevelLedgerException(this, e); } } public final Book createNewBook(final String bookID, final String title) throws BookExistsException, LowlevelLedgerException { if (bookExists(bookID)) throw new BookExistsException(this, bookID); try { final PreparedStatement stmt = prepQuery("insert into book values (?,?,now())"); stmt.setString(1, bookID); stmt.setString(2, title); stmt.execute(); return createBookInstance(bookID, title); } catch (SQLException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } } /* (non-Javadoc) * @see org.neuclear.ledger.Ledger#performTransaction(org.neuclear.ledger.UnPostedTransaction) */ public final PostedTransaction performTransaction(final UnPostedTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!transaction.isBalanced()) { throw new UnBalancedTransactionException(this, transaction); } try { final String xid = insertTransaction(transaction); final Iterator items = transaction.getItems(); while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); insertTransactionItem(xid, item); } return this.createTransaction(transaction, xid); } catch (SQLException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } } /** * 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 transaction Transaction to perform * @return Unique ID */ public final PostedHeldTransaction performHeldTransaction(final UnPostedHeldTransaction transaction) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { if (!transaction.isBalanced()) { throw new UnBalancedTransactionException(this, transaction); } try { final String xid = insertHeldTransaction(transaction); final Iterator items = transaction.getItems(); while (items.hasNext()) { final TransactionItem item = (TransactionItem) items.next(); insertHeldTransactionItem(xid, item); } return this.createHeldTransaction(transaction, xid); } catch (SQLException e) { rollbackUT(); System.err.println(e.getSQLState()); e.printStackTrace(System.err); throw new LowlevelLedgerException(this, e); } } /** * Cancels a Held Transaction. * * @param hold * @throws LowlevelLedgerException * @throws UnknownTransactionException */ public final void performCancelHold(final PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException { try { final PreparedStatement update = prepQuery("update held_transaction set cancelled=1 where id=? and ledgerid=?"); update.setString(1, hold.getXid()); update.setString(2, getId()); final int affected = update.executeUpdate(); if (affected == 0) { rollbackUT(); throw new UnknownTransactionException(this, hold.getXid()); } if (affected > 1) { rollbackUT(); throw new LowlevelLedgerException(this, "performCancelHold: For some reason multiple rows were updated. Transaction Rolled Back."); } } catch (SQLException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } } public final PostedTransaction performCompleteHold(final PostedHeldTransaction hold, final double amount, final Date time, final String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException { try { final 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()); final ResultSet rs = query.executeQuery(); if (!rs.next()) throw new TransactionExpiredException(this, hold); final PostedTransaction tran = createHeldComplete(hold, amount, time, comment); final 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()); final int affected = update.executeUpdate(); if (affected == 0) { rollbackUT(); throw new UnknownTransactionException(this, hold.getXid()); } if (affected > 1) { rollbackUT(); throw new LowlevelLedgerException(this, "performCompleteHold: For some reason multiple rows were updated. Transaction Rolled Back."); } return tran; } catch (SQLException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } catch (UnknownTransactionException e) { rollbackUT(); throw new LowlevelLedgerException(this, e); } } private String createTransactionID() { final Digest dig = new SHA1Digest(); final StringBuffer buffy = new StringBuffer(getId()); buffy.append('!'); buffy.append(System.currentTimeMillis()); buffy.append(CryptoTools.createRandomID()); return buffy.toString(); } private String insertTransaction(final UnPostedTransaction transaction) throws SQLException, LowlevelLedgerException { final PreparedStatement tranInsert = prepQuery("insert into transaction (id,valuetime,comment,ledgerid) values (?,?,?,?)"); final String xid = createTransactionID(); tranInsert.setString(1, xid); tranInsert.setTimestamp(2, SQLTools.toTimestamp(transaction.getTransactionTime())); tranInsert.setString(3, transaction.getComment()); tranInsert.setString(4, getId()); tranInsert.execute(); return xid; } private String insertHeldTransaction(final UnPostedHeldTransaction transaction) throws SQLException, LowlevelLedgerException { final String xid = createTransactionID(); final PreparedStatement tranInsert = prepQuery("insert into held_transaction (id,valuetime,comment,held_until,ledgerid,cancelled) values (?,?,?,?,?,0)"); tranInsert.setString(1, xid); tranInsert.setTimestamp(2, SQLTools.toTimestamp(transaction.getTransactionTime())); tranInsert.setString(3, transaction.getComment()); tranInsert.setTimestamp(4, SQLTools.toTimestamp(transaction.getExpiryTime())); tranInsert.setString(5, getId()); tranInsert.execute(); return xid; } private void insertTransactionItem(final String xid, final TransactionItem item) throws SQLException, LowlevelLedgerException { final PreparedStatement itemInsert = prepQuery("insert into entry (transactionid,bookid,amount) values (?,?,?)"); itemInsert.setString(1, xid); itemInsert.setString(2, item.getBook().getBookID()); itemInsert.setDouble(3, item.getAmount()); itemInsert.execute(); } private void insertHeldTransactionItem(final String xid, final TransactionItem item) throws SQLException, LowlevelLedgerException { final PreparedStatement itemInsert = prepQuery("insert into held_entry (held_transactionid,bookid,amount) values (?,?,?)"); itemInsert.setString(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 xid A valid ID * @return The Transaction object */ public final PostedTransaction findTransaction(final String xid) throws LowlevelLedgerException, UnknownTransactionException { try { PreparedStatement stmt = prepQuery("select valuetime,comment from transaction where id=? and ledgerid=?"); stmt.setString(1, xid); stmt.setString(2, getId()); ResultSet rs = stmt.executeQuery(); if (!rs.next()) { throw new UnknownTransactionException(this, xid); } final Date started = rs.getTimestamp(1); final String comment = rs.getString(2); final UnPostedTransaction transaction = new UnPostedTransaction(this, comment, started); stmt = prepQuery("select bookid,amount from entry where transactionid=?"); stmt.setString(1, xid); rs = stmt.executeQuery(); while (rs.next()) transaction.addItem(getBook(rs.getString(1)), rs.getDouble(2)); return this.createTransaction(transaction, xid); } 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 xid A valid ID * @return The Transaction object */ public final PostedHeldTransaction findHeldTransaction(final String xid) throws LowlevelLedgerException, UnknownTransactionException { try { PreparedStatement stmt = prepQuery("select valuetime,held_until,comment from held_transaction where id=? and ledgerid=?"); stmt.setString(1, xid); stmt.setString(2, getId()); ResultSet rs = stmt.executeQuery(); if (!rs.next()) { throw new UnknownTransactionException(this, xid); } final Date started = rs.getTimestamp(1); final Date ended = rs.getTimestamp(2); final String comment = rs.getString(3); final UnPostedHeldTransaction transaction = new UnPostedHeldTransaction(this, comment, started, ended); stmt = prepQuery("select bookid,amount from held_entry where held_transactionid=?"); stmt.setString(1, xid); rs = stmt.executeQuery(); while (rs.next()) transaction.addItem(getBook(rs.getString(1)), rs.getDouble(2)); return this.createHeldTransaction(transaction, xid); } 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(final String sql) throws SQLException, LowlevelLedgerException { return fact.prepareStatement(sql); } /* (non-Javadoc) * @see org.neuclear.ledger.Ledger#getBalance(org.neuclear.ledger.Book, java.util.Date) */ public final double getBalance(final Book book, final Date time) throws LowlevelLedgerException { try { final PreparedStatement stmt = prepQuery("select sum(e.amount) from entry e,transaction t where e.transactionid=t.id and e.bookid=? and t.valuetime<= ? and t.ledgerid=?"); stmt.setString(1, book.getBookID()); stmt.setTimestamp(2, new Timestamp(time.getTime() + 1)); stmt.setString(3, getId()); final 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 final double getBalance(final Book book) throws LowlevelLedgerException { return getBalance(book, new Date()); } public final double getAvailableBalance(final Book book, final Date time) throws LowlevelLedgerException { double balance = 0.0; try { final 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.bookid=? and t.valuetime<= ? 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.bookid=? and t.valuetime<= ? " + "and e.amount<0 and t.held_until>= ? and t.cancelled=0 and t.transactionid is null and t.ledgerid=?" + ") u "); final Timestamp ts = new Timestamp(time.getTime() + 1); 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()); final 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; } /* (non-Javadoc) * @see org.neuclear.ledger.Ledger#getAvailableBalance(org.neuclear.ledger.Book) */ public final double getAvailableBalance(final Book book) throws LowlevelLedgerException { return getAvailableBalance(book, new Date()); } public final String toString() { return "SQL Ledger: " + getName(); } public final Book getBook(final String bookID) throws UnknownBookException, LowlevelLedgerException { try { final PreparedStatement stmt = prepQuery("select title from book where id=?"); stmt.setString(1, bookID); final 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); } /** * Rolls back a JTA UserTransaction on the ledger. Not to be confused with a Ledger Transaction. * * @param ut * @throws LowlevelLedgerException */ public void rollbackUT(UserTransaction ut) throws LowlevelLedgerException { super.rollbackUT(ut); } public BookBrowser browse(Book book) throws LowlevelLedgerException { try { return new QueryBookBrowser(book, fact); } catch (SQLException e) { throw new LowlevelLedgerException(this, e); } } public BookBrowser browseFrom(Book book, Timestamp from) throws LowlevelLedgerException { try { return new QueryBookBrowser(book, fact, from); } catch (SQLException e) { throw new LowlevelLedgerException(this, e); } } public BookBrowser browseRange(Book book, Timestamp from, Timestamp until) throws LowlevelLedgerException { try { return new QueryBookBrowser(book, fact, from, until); } catch (SQLException e) { throw new LowlevelLedgerException(this, e); } } private final StatementFactory fact; } |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:18:28
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/implementations In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11520/src/java/org/neuclear/ledger/implementations Removed Files: SQLLedger.java Log Message: Added simple ledger for unit testing and in memory use --- SQLLedger.java DELETED --- |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:16:04
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11024/src/java/org/neuclear/ledger/simple Log Message: Directory /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/simple added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:13:54
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/test/org/neuclear/ledger/sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10603/src/test/org/neuclear/ledger/sql Log Message: Directory /cvsroot/neuclear/neuclear-ledger-sql/src/test/org/neuclear/ledger/sql added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-22 20:08:44
|
Update of /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/sql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9422/src/java/org/neuclear/ledger/sql Log Message: Directory /cvsroot/neuclear/neuclear-ledger-sql/src/java/org/neuclear/ledger/sql added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-22 19:55:02
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12182/src/java/org/neuclear/ledger/sample Log Message: Directory /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/sample added to the repository |
|
From: Pelle B. <pe...@us...> - 2004-03-22 19:49:31
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9416/src/java/org/neuclear/ledger Modified Files: Ledger.java Added Files: InsufficientFundsException.java Log Message: Added a verified transfer to neuclear-ledger. Added InsufficientFundsException to be thrown if transfer isnt verified. HeldTransfers also are now verified. --- NEW FILE: InsufficientFundsException.java --- package org.neuclear.ledger; /** * Created by IntelliJ IDEA. * User: pelleb * Date: Mar 22, 2004 * Time: 11:40:22 AM * To change this template use File | Settings | File Templates. */ public class InsufficientFundsException extends InvalidTransactionException { public InsufficientFundsException(final Ledger ledger, final String book, final double amount) { super(ledger, " Insufficient funds in account: " + book + " to cover the amount: " + amount); this.amount = amount; this.book = book; } public double getAmount() { return amount; } public String getBook() { return book; } private final double amount; private final String book; } Index: Ledger.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Ledger.java 21 Mar 2004 00:48:36 -0000 1.10 --- Ledger.java 22 Mar 2004 17:33:02 -0000 1.11 *************** *** 4,7 **** --- 4,12 ---- * $Id$ * $Log$ + * Revision 1.11 2004/03/22 17:33:02 pelle + * Added a verified transfer to neuclear-ledger. + * Added InsufficientFundsException to be thrown if transfer isnt verified. + * HeldTransfers also are now verified. + * * Revision 1.10 2004/03/21 00:48:36 pelle * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. *************** *** 132,151 **** * 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 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; /** --- 137,187 ---- * The basic interface for creating Transactions in the database. * The implementing class takes this transacion information and stores it with an automatically generated uniqueid. ! * * @param trans Transaction to perform ! * @return The reference to the transaction */ public abstract PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException; /** + * Similar to a transaction but guarantees that there wont be any negative balances left after the transaction. + * + * @param trans Transaction to perform + * @return The reference to the transaction + */ + public abstract PostedTransaction performVerifiedTransfer(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 transaction guarantees to not leave a negative balance in any account. * * @param trans Transaction to perform */ ! public abstract PostedHeldTransaction performHeldTransfer(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException; ! ! /** ! * 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; ! ! /** ! * Completes a held transaction. Which means: ! * cancelling the hold and performing the transfer with the given updated amount and comment. ! * ! * @param hold HeldTransaction to complete ! * @param amount The updatd amount. It must be <= than the amount of the hold ! * @param comment ! * @return ! * @throws InvalidTransactionException ! * @throws LowlevelLedgerException ! * @throws TransactionExpiredException ! */ ! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException; /** *************** *** 220,235 **** 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, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException; public final PostedTransaction transfer(String req, String id, String from, String to, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException { --- 256,259 ---- *************** *** 244,255 **** } ! public final PostedHeldTransaction hold(String req, String id, String from, String to, Date expiry, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException { UnPostedHeldTransaction tran = new UnPostedHeldTransaction(req, id, comment, expiry); tran.addItem(from, -amount); tran.addItem(to, amount); ! return performHeldTransaction(tran); } ! public final PostedHeldTransaction hold(String from, String to, Date expiry, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException { return hold(CryptoTools.createRandomID(), CryptoTools.createRandomID(), from, to, expiry, amount, comment); } --- 268,290 ---- } ! public final PostedTransaction verifiedTransfer(String req, String id, String from, String to, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException, InsufficientFundsException { ! UnPostedTransaction tran = new UnPostedTransaction(req, id, comment); ! tran.addItem(from, -amount); ! tran.addItem(to, amount); ! return performVerifiedTransfer(tran); ! } ! ! public final PostedTransaction verifiedTransfer(String from, String to, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException, InsufficientFundsException { ! return verifiedTransfer(CryptoTools.createRandomID(), CryptoTools.createRandomID(), from, to, amount, comment); ! } ! ! public final PostedHeldTransaction hold(String req, String id, String from, String to, Date expiry, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException, InsufficientFundsException { UnPostedHeldTransaction tran = new UnPostedHeldTransaction(req, id, comment, expiry); tran.addItem(from, -amount); tran.addItem(to, amount); ! return performHeldTransfer(tran); } ! public final PostedHeldTransaction hold(String from, String to, Date expiry, double amount, String comment) throws InvalidTransactionException, LowlevelLedgerException, UnBalancedTransactionException, InsufficientFundsException { return hold(CryptoTools.createRandomID(), CryptoTools.createRandomID(), from, to, expiry, amount, comment); } |
|
From: <bug...@ve...> - 2004-03-22 17:30:38
|
Message:
The following issue has been closed.
Resolver: Pelle Braendgaard
Date: Mon, 22 Mar 2004 9:29 AM
Now verifies the balance and throws InssuficientFundsException appropriately.
---------------------------------------------------------------------
View the issue:
http://jira.neuclear.org//browse/GL-21
Here is an overview of the issue:
---------------------------------------------------------------------
Key: GL-21
Summary: Verify balances for held transactions
Type: Improvement
Status: Closed
Priority: Major
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NeuClear Ledger
Fix Fors:
r_0_4
Versions:
r_0_4
Assignee: Pelle Braendgaard
Reporter: Pelle Braendgaard
Created: Mon, 22 Mar 2004 8:48 AM
Updated: Mon, 22 Mar 2004 9:29 AM
Description:
We need to verify that a held transaction never leaves an account with a negative available balance.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.neuclear.org//secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|
|
From: <bug...@ve...> - 2004-03-22 17:21:36
|
Message:
The following issue has been closed.
Resolver: Pelle Braendgaard
Date: Mon, 22 Mar 2004 9:21 AM
Done. Throws InsufficientFundsException if available balance is too low.
---------------------------------------------------------------------
View the issue:
http://jira.neuclear.org//browse/GL-20
Here is an overview of the issue:
---------------------------------------------------------------------
Key: GL-20
Summary: Add VerifiedTransfer
Type: New Feature
Status: Closed
Priority: Major
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NeuClear Ledger
Fix Fors:
r_0_4
Versions:
r_0_4
Assignee: Pelle Braendgaard
Reporter: Pelle Braendgaard
Created: Mon, 22 Mar 2004 8:45 AM
Updated: Mon, 22 Mar 2004 9:21 AM
Description:
To not force users to worry about the underlying database platform and transaction handling. We need a way of performing a verified transfer, which guarantees that the accounts wont be left with a negative balance.
Prior this was an application level feature and not handled by the underlying ledger.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.neuclear.org//secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|
|
From: <bug...@ve...> - 2004-03-22 16:50:47
|
Message: Work on this issue has been started by Pelle Braendgaard (mailto:pe...@ve...) --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-21 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-21 Summary: Verify balances for held transactions Type: Improvement Status: In Progress Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 8:48 AM Updated: Mon, 22 Mar 2004 8:48 AM Description: We need to verify that a held transaction never leaves an account with a negative available balance. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: <bug...@ve...> - 2004-03-22 16:50:47
|
Message: Work on this issue has been started by Pelle Braendgaard (mailto:pe...@ve...) --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-20 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-20 Summary: Add VerifiedTransfer Type: New Feature Status: In Progress Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 8:45 AM Updated: Mon, 22 Mar 2004 8:49 AM Description: To not force users to worry about the underlying database platform and transaction handling. We need a way of performing a verified transfer, which guarantees that the accounts wont be left with a negative balance. Prior this was an application level feature and not handled by the underlying ledger. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: <bug...@ve...> - 2004-03-22 16:48:38
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-21 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-21 Summary: Verify balances for held transactions Type: Improvement Status: Open Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 8:48 AM Updated: Mon, 22 Mar 2004 8:48 AM Description: We need to verify that a held transaction never leaves an account with a negative available balance. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: <bug...@ve...> - 2004-03-22 16:46:37
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://jira.neuclear.org//browse/GL-20 Here is an overview of the issue: --------------------------------------------------------------------- Key: GL-20 Summary: Add VerifiedTransfer Type: New Feature Status: Open Priority: Major Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: NeuClear Ledger Versions: r_0_4 Assignee: Pelle Braendgaard Reporter: Pelle Braendgaard Created: Mon, 22 Mar 2004 8:45 AM Updated: Mon, 22 Mar 2004 8:45 AM Description: To not force users to worry about the underlying database platform and transaction handling. We need a way of performing a verified transfer, which guarantees that the accounts wont be left with a negative balance. Prior this was an application level feature and not handled by the underlying ledger. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://jira.neuclear.org//secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
|
From: <bug...@ve...> - 2004-03-22 16:43:40
|
Message:
The following issue has been closed.
Resolver: Pelle Braendgaard
Date: Mon, 22 Mar 2004 8:42 AM
completes and cancels now work and pass all unit tests.
---------------------------------------------------------------------
View the issue:
http://jira.neuclear.org//browse/GL-18
Here is an overview of the issue:
---------------------------------------------------------------------
Key: GL-18
Summary: CancelHeld and CompleteHeld not working in Prevalent Ledger
Type: Bug
Status: Closed
Priority: Major
Resolution: FIXED
Original Estimate: Unknown
Time Spent: Unknown
Remaining: Unknown
Project: NeuClear Ledger
Components:
Prevalent Ledger
Fix Fors:
r_0_4
Versions:
r_0_4
Assignee: Pelle Braendgaard
Reporter: Pelle Braendgaard
Created: Sat, 20 Mar 2004 4:22 PM
Updated: Mon, 22 Mar 2004 8:42 AM
Description:
Cancel doesnt seem to do anything.
Complete is incomplete.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://jira.neuclear.org//secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:54
|
Update of /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3012/src/test/org/neuclear/id Modified Files: IdentityTests.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: IdentityTests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-id/src/test/org/neuclear/id/IdentityTests.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IdentityTests.java 20 Mar 2004 17:19:55 -0000 1.7 --- IdentityTests.java 21 Mar 2004 00:48:51 -0000 1.8 *************** *** 54,64 **** public void testAnonymous() throws NoSuchAlgorithmException { - <<<<<<< IdentityTests.java KeyPair kp = CryptoTools.createTinyDSAKeyPair(); Identity id = new Identity(kp.getPublic()); - ======= - KeyPair kp = CryptoTools.createTinyRSAKeyPair(); - Identity id = new Identity(kp.getPublic()); - >>>>>>> 1.6 assertNotNull(id); assertNotNull(id.getName()); --- 54,59 ---- *************** *** 69,73 **** } - <<<<<<< IdentityTests.java public void testEmbedded() throws NoSuchAlgorithmException, XMLSecurityException, CryptoException, NameResolutionException, InvalidNamedObjectException { KeyPair kp = CryptoTools.createTinyDSAKeyPair(); --- 64,67 ---- *************** *** 81,109 **** assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(kp.getPublic().getEncoded())), obj.getName().substring(5, 37)); assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(obj.getEncoded().getBytes())), obj.getName().substring(obj.getName().length() - 32)); - ======= - public void testEmbedded - () throws NoSuchAlgorithmException, XMLSecurityException, CryptoException, NameResolutionException, InvalidNamedObjectException - { - KeyPair kp = CryptoTools.createTinyRSAKeyPair(); - Document doc = DocumentHelper.createDocument(); - Element elem = doc.addElement("TestElement"); - XMLSignature sig = new XMLSignature(kp, elem); - assertEquals(kp.getPublic(), sig.getSignersKey()); - SignedNamedObject obj = VerifyingReader.getInstance().read(elem); - System.out.println("Name: " + obj.getName()); - assertEquals("sha1:", obj.getName().substring(0, 5)); - assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(kp.getPublic().getEncoded())), obj.getName().substring(5, 37)); - assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(obj.getEncoded().getBytes())), obj.getName().substring(obj.getName().length() - 32)); - >>>>>>> 1.6 ! Identity id = obj.getSignatory(); ! assertNotNull(id); ! assertNotNull(id.getName()); ! assertEquals("sha1:", id.getName().substring(0, 5)); ! assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(kp.getPublic().getEncoded())), id.getName().substring(5)); ! assertEquals(kp.getPublic(), id.getPublicKey()); - } } --- 75,88 ---- assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(kp.getPublic().getEncoded())), obj.getName().substring(5, 37)); assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(obj.getEncoded().getBytes())), obj.getName().substring(obj.getName().length() - 32)); ! Identity id = obj.getSignatory(); ! assertNotNull(id); ! assertNotNull(id.getName()); ! assertEquals("sha1:", id.getName().substring(0, 5)); ! assertEquals(CryptoTools.encodeBase32(CryptoTools.digest(kp.getPublic().getEncoded())), id.getName().substring(5)); ! assertEquals(kp.getPublic(), id.getPublicKey()); } + } |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:48
|
Update of /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/asset/receiver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2965/src/test/org/neuclear/asset/receiver Modified Files: PaymentReceiverTest.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: PaymentReceiverTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/asset/receiver/PaymentReceiverTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PaymentReceiverTest.java 2 Mar 2004 18:58:35 -0000 1.16 --- PaymentReceiverTest.java 21 Mar 2004 00:48:45 -0000 1.17 *************** *** 5,25 **** import org.neuclear.asset.contracts.AssetGlobals; import org.neuclear.asset.controllers.currency.CurrencyController; import org.neuclear.asset.orders.TransferGlobals; import org.neuclear.asset.orders.TransferOrder; - import org.neuclear.asset.orders.Amount; import org.neuclear.asset.orders.builders.TransferOrderBuilder; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.TestCaseSigner; - import org.neuclear.commons.sql.DefaultConnectionSource; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; - import org.neuclear.commons.time.TimeTools; import org.neuclear.id.Identity; import org.neuclear.id.SignedNamedObject; import org.neuclear.id.resolver.NSResolver; - import org.neuclear.ledger.BookExistsException; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.UnknownLedgerException; - import org.neuclear.ledger.implementations.SQLLedger; - import org.neuclear.id.receiver.Receiver; import org.neuclear.tests.AbstractSigningTest; import org.neuclear.xml.XMLException; --- 5,20 ---- import org.neuclear.asset.contracts.AssetGlobals; import org.neuclear.asset.controllers.currency.CurrencyController; + import org.neuclear.asset.orders.Amount; import org.neuclear.asset.orders.TransferGlobals; import org.neuclear.asset.orders.TransferOrder; import org.neuclear.asset.orders.builders.TransferOrderBuilder; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.crypto.signers.TestCaseSigner; import org.neuclear.id.Identity; import org.neuclear.id.SignedNamedObject; + import org.neuclear.id.receiver.Receiver; import org.neuclear.id.resolver.NSResolver; import org.neuclear.ledger.LowlevelLedgerException; import org.neuclear.ledger.UnknownLedgerException; import org.neuclear.tests.AbstractSigningTest; import org.neuclear.xml.XMLException; *************** *** 51,54 **** --- 46,52 ---- $Id$ $Log$ + Revision 1.17 2004/03/21 00:48:45 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.16 2004/03/02 18:58:35 pelle Further cleanups in neuclear-id. Moved everything under id. *************** *** 179,183 **** */ public final class PaymentReceiverTest extends AbstractSigningTest { ! public PaymentReceiverTest(final String string) throws NeuClearException, GeneralSecurityException, UnknownLedgerException, LowlevelLedgerException, BookExistsException, IOException, InvalidTransferException, XMLException, SQLException, NamingException { super(string); AssetGlobals.registerReaders(); --- 177,181 ---- */ public final class PaymentReceiverTest extends AbstractSigningTest { ! public PaymentReceiverTest(final String string) throws NeuClearException, GeneralSecurityException, UnknownLedgerException, LowlevelLedgerException, IOException, InvalidTransferException, XMLException, SQLException, NamingException { super(string); AssetGlobals.registerReaders(); *************** *** 185,197 **** asset = (Asset) NSResolver.resolveIdentity(assetName); ! proc = new CurrencyController( ! new SQLLedger( ! new SimpleStatementFactory(new DefaultConnectionSource()), ! assetName ! ), new TestCaseSigner(), ! assetName ! ); ! receiver=proc; } --- 183,190 ---- asset = (Asset) NSResolver.resolveIdentity(assetName); ! proc = new CurrencyController(null, new TestCaseSigner(), ! assetName); ! receiver = proc; } *************** *** 224,229 **** if (obj instanceof TransferOrder) { final TransferOrder transfer = (TransferOrder) obj; ! final double fromBalance = proc.getBalance(transfer.getSignatory(), transfer.getTimeStamp()); ! final double toBalance = proc.getBalance(transfer.getRecipient(), transfer.getTimeStamp()); return new double[]{fromBalance, toBalance}; --- 217,222 ---- if (obj instanceof TransferOrder) { final TransferOrder transfer = (TransferOrder) obj; ! final double fromBalance = proc.getBalance(transfer.getSignatory()); ! final double toBalance = proc.getBalance(transfer.getRecipient()); return new double[]{fromBalance, toBalance}; *************** *** 236,241 **** if (obj instanceof TransferOrder) { final TransferOrder transfer = (TransferOrder) obj; ! final double fromBalance = proc.getBalance(transfer.getSignatory(), transfer.getTimeStamp()); ! final double toBalance = proc.getBalance(transfer.getRecipient(), transfer.getTimeStamp()); final double prebalances[] = (double[]) state; --- 229,234 ---- if (obj instanceof TransferOrder) { final TransferOrder transfer = (TransferOrder) obj; ! final double fromBalance = proc.getBalance(transfer.getSignatory()); ! final double toBalance = proc.getBalance(transfer.getRecipient()); final double prebalances[] = (double[]) state; *************** *** 248,252 **** public final SignedNamedObject createPayments(final Identity from, final Identity to, final double amount) throws InvalidTransferException, XMLException, NeuClearException, IOException, UnsupportedEncodingException { final TransferOrderBuilder transfer = new TransferOrderBuilder(asset, to, new Amount(amount), "Test One"); ! return transfer.convert(from.getName(),getSigner()); } --- 241,245 ---- public final SignedNamedObject createPayments(final Identity from, final Identity to, final double amount) throws InvalidTransferException, XMLException, NeuClearException, IOException, UnsupportedEncodingException { final TransferOrderBuilder transfer = new TransferOrderBuilder(asset, to, new Amount(amount), "Test One"); ! return transfer.convert(from.getName(), getSigner()); } |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:48
|
Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/servlet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2965/src/java/org/neuclear/asset/servlet Modified Files: AssetControllerServlet.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: AssetControllerServlet.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/servlet/AssetControllerServlet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AssetControllerServlet.java 2 Mar 2004 18:58:34 -0000 1.2 --- AssetControllerServlet.java 21 Mar 2004 00:48:45 -0000 1.3 *************** *** 1,15 **** package org.neuclear.asset.servlet; import org.neuclear.asset.contracts.Asset; import org.neuclear.asset.contracts.AssetGlobals; import org.neuclear.asset.controllers.currency.CurrencyController; import org.neuclear.asset.orders.TransferGlobals; - import org.neuclear.asset.AssetController; import org.neuclear.commons.servlets.ServletTools; - import org.neuclear.commons.sql.JNDIConnectionSource; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; - import org.neuclear.id.resolver.NSResolver; - import org.neuclear.ledger.implementations.SQLLedger; import org.neuclear.id.receiver.ReceiverServlet; import javax.servlet.ServletConfig; --- 1,12 ---- package org.neuclear.asset.servlet; + import org.neuclear.asset.AssetController; import org.neuclear.asset.contracts.Asset; import org.neuclear.asset.contracts.AssetGlobals; import org.neuclear.asset.controllers.currency.CurrencyController; import org.neuclear.asset.orders.TransferGlobals; import org.neuclear.commons.servlets.ServletTools; import org.neuclear.id.receiver.ReceiverServlet; + import org.neuclear.id.resolver.NSResolver; import javax.servlet.ServletConfig; *************** *** 36,39 **** --- 33,39 ---- $Id$ $Log$ + Revision 1.3 2004/03/21 00:48:45 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.2 2004/03/02 18:58:34 pelle Further cleanups in neuclear-id. Moved everything under id. *************** *** 107,128 **** public final void init(final ServletConfig config) throws ServletException { super.init(config); ! datasource = ServletTools.getInitParam("datasource",config); AssetGlobals.registerReaders(); TransferGlobals.registerReaders(); try { asset = (Asset) NSResolver.resolveIdentity(getServiceid()); ! final AssetController receiver = new CurrencyController( ! new SQLLedger( ! new SimpleStatementFactory(new JNDIConnectionSource(datasource)), ! getServiceid() ! ), ! getSigner(), ! getServiceid() ! ! ); setReceiver(receiver); } catch (Exception e) { ! ctx.log("AssetControllerServer: "+e.getLocalizedMessage()); throw new ServletException(e); } --- 107,122 ---- public final void init(final ServletConfig config) throws ServletException { super.init(config); ! datasource = ServletTools.getInitParam("datasource", config); AssetGlobals.registerReaders(); TransferGlobals.registerReaders(); try { asset = (Asset) NSResolver.resolveIdentity(getServiceid()); ! final AssetController receiver = new CurrencyController(null, ! getSigner(), ! getServiceid()); setReceiver(receiver); } catch (Exception e) { ! ctx.log("AssetControllerServer: " + e.getLocalizedMessage()); throw new ServletException(e); } |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:48
|
Update of /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/asset/controllers/currency In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2965/src/test/org/neuclear/asset/controllers/currency Modified Files: CurrencyTests.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: CurrencyTests.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/test/org/neuclear/asset/controllers/currency/CurrencyTests.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CurrencyTests.java 5 Jan 2004 23:47:10 -0000 1.5 --- CurrencyTests.java 21 Mar 2004 00:48:45 -0000 1.6 *************** *** 2,18 **** import junit.framework.TestCase; - import org.neuclear.asset.*; - import org.neuclear.asset.controllers.currency.CurrencyController; - import org.neuclear.exchange.orders.ExchangeOrderReceipt; - import org.neuclear.asset.orders.TransferReceipt; import org.neuclear.commons.configuration.ConfigurationException; ! import org.neuclear.ledger.*; import java.io.IOException; - import java.math.BigInteger; import java.sql.SQLException; - import java.util.Calendar; - import java.util.Date; - import java.util.Random; /** --- 2,11 ---- import junit.framework.TestCase; import org.neuclear.commons.configuration.ConfigurationException; ! import org.neuclear.ledger.LedgerCreationException; ! import org.neuclear.ledger.LowlevelLedgerException; import java.io.IOException; import java.sql.SQLException; /** *************** *** 22,26 **** */ public final class CurrencyTests extends TestCase { ! public CurrencyTests(final String s) throws SQLException, IOException, LowlevelLedgerException, BookExistsException, LedgerCreationException, ConfigurationException { super(s); // proc = CurrencyController.getInstance(); --- 15,19 ---- */ public final class CurrencyTests extends TestCase { ! public CurrencyTests(final String s) throws SQLException, IOException, LowlevelLedgerException, LedgerCreationException, ConfigurationException { super(s); // proc = CurrencyController.getInstance(); |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:47
|
Update of /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/controllers/currency In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2965/src/java/org/neuclear/asset/controllers/currency Modified Files: CurrencyController.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: CurrencyController.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-pay/src/java/org/neuclear/asset/controllers/currency/CurrencyController.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CurrencyController.java 13 Jan 2004 15:11:17 -0000 1.14 --- CurrencyController.java 21 Mar 2004 00:48:44 -0000 1.15 *************** *** 10,16 **** import org.neuclear.commons.time.TimeTools; import org.neuclear.exchange.orders.*; - import org.neuclear.exchange.orders.builders.CancelExchangeReceiptBuilder; - import org.neuclear.exchange.orders.builders.ExchangeOrderReceiptBuilder; - import org.neuclear.exchange.orders.builders.ExchangeCompletedReceiptBuilder; import org.neuclear.id.Identity; import org.neuclear.id.resolver.NSResolver; --- 10,13 ---- *************** *** 18,22 **** import java.sql.Timestamp; - import java.util.Date; import java.util.Iterator; --- 15,18 ---- *************** *** 31,47 **** // this(LedgerFactory.getInstance().getLedger(ledgername),title,reserve); // } ! public CurrencyController(final Ledger ledger, final Signer signer,final String assetname) throws LowlevelLedgerException, BookExistsException, NeuClearException { super(); this.ledger = ledger; ! this.signer=signer; asset = (Asset) NSResolver.resolveIdentity(assetname); ! ! Book tmpIssuer = null; ! try { ! tmpIssuer = ledger.getBook(asset.getName()); ! } catch (UnknownBookException e) { ! tmpIssuer = ledger.createNewBook(asset.getName()); ! } ! issuerBook = tmpIssuer; } --- 27,36 ---- // this(LedgerFactory.getInstance().getLedger(ledgername),title,reserve); // } ! public CurrencyController(final Ledger ledger, final Signer signer, final String assetname) throws LowlevelLedgerException, NeuClearException { super(); this.ledger = ledger; ! this.signer = signer; asset = (Asset) NSResolver.resolveIdentity(assetname); ! issuerBook = asset.getName(); } *************** *** 53,64 **** try { - final Book from = getBook(req.getSignatory()); - final Book to = getBook(req.getRecipient()); ! final Timestamp valuetime =TimeTools.now(); ! final PostedTransaction posted = from.transfer(to, req.getAmount().getAmount(), req.getComment(), valuetime); ! return (TransferReceipt) new TransferReceiptBuilder(req, valuetime).convert(asset.getName(),signer); ! } catch (UnknownBookException e) { ! throw new InvalidTransferException(e.getSubMessage()); } catch (LowlevelLedgerException e) { throw new LowLevelPaymentException(e); --- 42,49 ---- try { ! final Timestamp valuetime = TimeTools.now(); ! final PostedTransaction posted = ledger.transfer("id", req.getName(), req.getSignatory().getName(), req.getRecipient().getName(), req.getAmount().getAmount(), req.getComment()); ! return (TransferReceipt) new TransferReceiptBuilder(req, valuetime).convert(asset.getName(), signer); } catch (LowlevelLedgerException e) { throw new LowLevelPaymentException(e); *************** *** 76,83 **** } - private Book getBook(final Identity id) throws UnknownBookException, LowlevelLedgerException { - return ledger.getBook(id.getName()); - } - /** * Returns balance for a given Identity. --- 61,64 ---- *************** *** 88,108 **** * @throws LowLevelPaymentException */ ! public double getBalance(final Identity id, final Date time) throws LowLevelPaymentException { try { ! return getBook(id).getBalance(time); } catch (LowlevelLedgerException e) { throw new LowLevelPaymentException(e); - } catch (UnknownBookException e) { - return 0.0;// If an account isnt listed its balance is always 0 } } public final ExchangeOrderReceipt process(final ExchangeOrder req) throws InvalidTransferException, LowLevelPaymentException, TransferDeniedException, NeuClearException { try { ! final Book from = getBook(req.getSignatory()); ! final Book to = getBook(req.getAgent()); ! final Timestamp valuetime = TimeTools.now(); ! ! final PostedHeldTransaction posted = from.hold(to, req.getAmount().getAmount(), req.getComment(), valuetime,req.getExpiry()); return (ExchangeOrderReceipt) new ExchangeOrderReceiptBuilder(req, valuetime).convert(asset.getName(),signer); --- 69,85 ---- * @throws LowLevelPaymentException */ ! public double getBalance(final Identity id) throws LowLevelPaymentException { try { ! return ledger.getBalance(id.getName()); } catch (LowlevelLedgerException e) { throw new LowLevelPaymentException(e); } } + public final ExchangeOrderReceipt process(final ExchangeOrder req) throws InvalidTransferException, LowLevelPaymentException, TransferDeniedException, NeuClearException { + /* try { ! final PostedHeldTransaction posted = ledger.hold(to, req.getAmount().getAmount(), req.getComment(), valuetime,req.getExpiry()); return (ExchangeOrderReceipt) new ExchangeOrderReceiptBuilder(req, valuetime).convert(asset.getName(),signer); *************** *** 118,124 **** --- 95,104 ---- throw new InvalidTransferException("postive amount"); } + */ + return null; } public final ExchangeCompletedReceipt process(final ExchangeCompletionOrder complete) throws LowLevelPaymentException, InvalidTransferException, TransferDeniedException, NeuClearException { + /* try { // *************** *** 145,151 **** --- 125,133 ---- throw new LowLevelPaymentException(e); } + */ return null; } public final CancelExchangeReceipt process(final CancelExchangeOrder cancel) throws InvalidTransferException, LowLevelPaymentException, TransferDeniedException, NeuClearException { + /* try { final PostedHeldTransaction heldTran = ledger.findHeldTransaction(cancel.getReceipt().getOrder().getDigest()); *************** *** 159,164 **** --- 141,148 ---- throw new LowLevelPaymentException(e); } + */ return null; } + /** * Little tool to return the amount of a ledger transaction. *************** *** 190,194 **** while (iter.hasNext()) { final TransactionItem item = (TransactionItem) iter.next(); ! if (item.getAmount() >= 0 && item.getBook().getBookID().equals(id.getName())) return true; } --- 174,178 ---- while (iter.hasNext()) { final TransactionItem item = (TransactionItem) iter.next(); ! if (item.getAmount() >= 0 && item.getBook().equals(id.getName())) return true; } *************** *** 198,202 **** private final Ledger ledger; private final Asset asset; ! private final Book issuerBook; private final Signer signer; } --- 182,186 ---- private final Ledger ledger; private final Asset asset; ! private final String issuerBook; private final Signer signer; } |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:40
|
Update of /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2857/src/test/org/neuclear/ledger Modified Files: LedgerTest.java SQLLedgerTest.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: LedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/LedgerTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LedgerTest.java 2 Jan 2004 23:18:35 -0000 1.10 --- LedgerTest.java 21 Mar 2004 00:48:36 -0000 1.11 *************** *** 3,21 **** import junit.framework.TestCase; import org.neuclear.commons.NeuClearException; - import org.neuclear.commons.sql.DefaultConnectionSource; - import org.neuclear.commons.sql.DefaultXAConnectionSource; - import org.neuclear.commons.sql.TestCaseConnectionSource; - import org.neuclear.commons.sql.TestCaseXAConnectionSource; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; - import org.neuclear.ledger.implementations.SQLLedger; import javax.naming.NamingException; - import javax.transaction.UserTransaction; import java.io.IOException; - import java.math.BigInteger; import java.sql.SQLException; - import java.util.Calendar; import java.util.Date; - import java.util.Random; /** --- 3,11 ---- *************** *** 26,39 **** * $Id$ * $Log$ * Revision 1.10 2004/01/02 23:18:35 pelle * Added StatementFactory pattern and refactored the ledger to use it. ! * * Revision 1.9 2003/12/31 00:39:05 pelle * Added Drivers for handling different Database dialects in the entity model. * Added BookBrowser pattern to ledger, simplifying the statement writing process. ! * * Revision 1.8 2003/12/26 22:50:52 pelle * Mainly fixes to SQLLedger to support the schema generated by the new EntityModel ! * * Revision 1.7 2003/12/24 00:24:33 pelle * Created a kind of poor man's version of ofbiz.org's EntityEngine. It doesnt use xml to configure it, but code. --- 16,32 ---- * $Id$ * $Log$ + * Revision 1.11 2004/03/21 00:48:36 pelle + * The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + * * Revision 1.10 2004/01/02 23:18:35 pelle * Added StatementFactory pattern and refactored the ledger to use it. ! * <p/> * Revision 1.9 2003/12/31 00:39:05 pelle * Added Drivers for handling different Database dialects in the entity model. * Added BookBrowser pattern to ledger, simplifying the statement writing process. ! * <p/> * Revision 1.8 2003/12/26 22:50:52 pelle * Mainly fixes to SQLLedger to support the schema generated by the new EntityModel ! * <p/> * Revision 1.7 2003/12/24 00:24:33 pelle * Created a kind of poor man's version of ofbiz.org's EntityEngine. It doesnt use xml to configure it, but code. *************** *** 42,49 **** * need that myself right now. * SQLLedger now uses this to create its tables. It is not fully working yet, but will be shortly. ! * * Revision 1.6 2003/12/03 23:21:43 pelle * Got rid of ofbiz support. Way over the top for our use. ! * * Revision 1.5 2003/11/21 04:43:21 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. --- 35,42 ---- * need that myself right now. * SQLLedger now uses this to create its tables. It is not fully working yet, but will be shortly. ! * <p/> * Revision 1.6 2003/12/03 23:21:43 pelle * Got rid of ofbiz support. Way over the top for our use. ! * <p/> * Revision 1.5 2003/11/21 04:43:21 pelle * EncryptedFileStore now works. It uses the PBECipher with DES3 afair. *************** *** 106,110 **** * 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 --- 99,103 ---- * Revision 1.7 2003/07/21 19:43:39 pelle * Moved the Revisioning tests into the main LedgerTest. ! * Fixed the getTransactionTime method in SQLLedger. * <p/> * Revision 1.6 2003/07/21 18:35:15 pelle *************** *** 129,433 **** */ public abstract class LedgerTest extends TestCase { ! protected final String account1 = "neu://test/bob"; ! protected final String account2 = "nru://test/alice"; public LedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); ! ledger = new SQLLedger(new SimpleStatementFactory(new TestCaseXAConnectionSource()), "neu://test/bux"); ! ! } ! ! public abstract Ledger createLedger(); ! ! public final void testPostTransaction() throws LedgerException { ! final Book bob = getNewBobBook(); ! final Book alice = getNewAliceBook(); ! final Date t1 = new Date(); ! UserTransaction ut = ledger.beginUT(); ! bob.transfer(alice, 100, "Loan", t1); ! ledger.commitUT(ut); ! } ! ! private Book getNewBobBook() throws BookExistsException, LowlevelLedgerException { ! return createNewBook(account1); ! } ! ! private Book getNewAliceBook() throws BookExistsException, LowlevelLedgerException { ! return createNewBook(account2); ! } ! ! private Book createNewBook(final String name) throws BookExistsException, LowlevelLedgerException { ! final BigInteger id = new BigInteger(168, new Random()); ! final String bookID = name + id.toString(36); ! System.out.println("bookid: " + bookID); ! return ledger.createNewBook(bookID, name); } ! public final void testAccountCreate() throws LedgerException { ! UserTransaction ut = ledger.beginUT(); ! final Book bob = getNewBobBook(); ! assertNotNull(bob); ! assertTrue(ledger.bookExists(bob.getBookID())); ! ledger.commitUT(ut); } ! public final void testBalance() throws LedgerException { ! final Book alice = getNewAliceBook(); ! final Book bob = getNewBobBook(); ! final double aliceBalance = alice.getBalance(); ! final double bobBalance = bob.getBalance(); ! final double amount = 105; ! final Date t1 = new Date(); ! UserTransaction ut = ledger.beginUT(); ! ! alice.transfer(bob, amount, "Repayment", t1); ! assertEquals(aliceBalance - amount, alice.getBalance(), 0); ! assertEquals(bobBalance + amount, bob.getBalance(), 0); ! ledger.commitUT(ut); } ! public final void testTimeBalance() throws LedgerException { ! final Calendar cal = Calendar.getInstance(); ! final Date t1 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t2 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t3 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t4 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t5 = cal.getTime(); ! UserTransaction ut = ledger.beginUT(); ! ! final Book alice = getNewAliceBook(); ! final Book bob = getNewBobBook(); ! ! final double amount = 105; ! final double payment = amount / 2; ! ! alice.transfer(bob, payment, "Repayment", t2); ! alice.transfer(bob, payment, "2nd Repayment", t4); ! ! final double aliceBalance = alice.getBalance(t1); ! final 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); ! ledger.commitUT(ut); } ! public final void testHold() throws LedgerException { ! final Calendar cal = Calendar.getInstance(); ! final Date t1 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t2 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t3 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t4 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t5 = cal.getTime(); ! UserTransaction ut = ledger.beginUT(); ! ! final Book alice = getNewAliceBook(); ! final Book bob = getNewBobBook(); ! ! ! final double amount = 105; ! ! // We are holding 105 from t2 to t4 ! alice.hold(bob, amount, "Hold", t2, t4); ! ! final double aliceBalance = alice.getBalance(t1); ! final 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); ! ! // Her available balance should be the same as her real balance here ! assertEquals(alice.getBalance(t4), alice.getAvailableBalance(t4), 0); ! 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); } ! ledger.commitUT(ut); ! } ! public final void testReversal() throws LedgerException { ! UserTransaction ut = ledger.beginUT(); ! final Book bob = getNewBobBook(); ! final Book alice = getNewAliceBook(); ! ! final double amount = 123; ! final double balance = bob.getBalance(); ! ! final PostedTransaction tran = bob.transfer(alice, amount, "Hello", new Date()); ! assertNotNull(tran); ! assertEquals(bob.getBalance(), balance - amount, 0); ! final PostedTransaction reverse = tran.reverse("Reverse it"); ! assertNotNull(reverse); ! assertEquals(bob.getBalance(), balance, 0); ! ledger.commitUT(ut); ! } ! public final void testCompleteHeld() throws LedgerException { ! final Calendar cal = Calendar.getInstance(); ! final Date t1 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t2 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t3 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t4 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t5 = cal.getTime(); ! ! UserTransaction ut = ledger.beginUT(); ! ! final Book ignacio = createNewBook("neu://verax/testusers/Ignacio"); ! final Book palacio = createNewBook("neu://verax/testusers/Palacio"); ! final double amount = 123; ! final double held = 200; ! final double balance = ignacio.getBalance(t1); ! final 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 , 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); ! } ! ledger.commitUT(ut); ! } ! public final void testFindTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException { ! UserTransaction ut = ledger.beginUT(); ! final Book bob = getNewBobBook(); ! final Book alice = getNewAliceBook(); ! final double amount = 123; ! final PostedTransaction tran = bob.transfer(alice, amount, "Can we find this again", new Date()); ! assertNotNull(tran); ! final PostedTransaction found = ledger.findTransaction(tran.getXid()); ! assertNotNull(found); ! assertEquals(found.getXid(), tran.getXid()); ! ledger.commitUT(ut); ! } - public final void testFindHeldTransaction() throws LowlevelLedgerException, BookExistsException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, UnknownBookException { - UserTransaction ut = ledger.beginUT(); - final Book bob = getNewBobBook(); - final Book alice = getNewAliceBook(); ! final double amount = 123; ! final PostedHeldTransaction tran = bob.hold(alice, amount, "Can we find this again", new Date(), new Date()); ! assertNotNull(tran); ! final PostedHeldTransaction found = ledger.findHeldTransaction(tran.getXid()); ! assertNotNull(found); ! assertEquals(found.getXid(), tran.getXid()); ! ledger.commitUT(ut); } ! public final void testCancelHeld() throws LedgerException { ! UserTransaction ut = ledger.beginUT(); ! final Calendar cal = Calendar.getInstance(); ! final Date t1 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t2 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t3 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t4 = cal.getTime(); ! cal.add(Calendar.DAY_OF_YEAR, 1); ! final Date t5 = cal.getTime(); ! ! final Book ignacio = createNewBook("neu://verax/testusers/Ignacio"); ! final Book palacio = createNewBook("neu://verax/testusers/Palacio"); ! final double amount = 123; ! final double held = 200; ! final double balance = ignacio.getBalance(t1); ! final 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 ! } - ledger.commitUT(ut); } ! final Ledger ledger; } --- 122,266 ---- */ public abstract class LedgerTest extends TestCase { ! static final String BOB = "bob"; ! static final String ALICE = "alice"; public LedgerTest(final String s) throws LowlevelLedgerException, UnknownLedgerException, SQLException, NamingException, IOException, NeuClearException { super(s); ! // ledger=createLedger(); } ! // protected void finalize() throws Throwable { ! // ledger.close(); ! // } ! // ! /** ! * Sets up the fixture, for example, open a network connection. ! * This method is called before a test is executed. ! */ ! protected void setUp() throws Exception { ! ledger = createLedger(); } ! /** ! * Tears down the fixture, for example, close a network connection. ! * This method is called after a test is executed. ! */ ! protected void tearDown() throws Exception { ! ledger.close(); } ! public abstract Ledger createLedger() throws LowlevelLedgerException; ! public final void testTransfer() throws LedgerException { ! final double aliceBalance = ledger.getBalance(ALICE); ! final double bobBalance = ledger.getBalance(BOB); ! final double amount = 100; ! ledger.transfer(ALICE, BOB, amount, "LOAN"); ! assertEquals("ALICE BALANCE", aliceBalance - amount, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE", bobBalance + amount, ledger.getBalance(BOB), 0); + ledger.transfer(BOB, ALICE, amount, "Repayment"); + assertEquals("REPAY ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); + assertEquals("REPAY BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); + ledger.transfer(BOB, ALICE, 5, "Interest"); + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } ! public final void testMultiTransfer() throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException { ! final double bobBalance = ledger.getBalance(BOB); ! int cumulative = 0; ! for (int i = 0; i < 100; i++) { ! ledger.transfer("req" + i + System.currentTimeMillis(), "x" + i + System.currentTimeMillis(), "Issuer", "bob", i, "fund it"); ! cumulative += i; ! assertEquals("BOB BALANCE", bobBalance + cumulative, ledger.getBalance(BOB), 0); } ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } ! public final void testBalance() throws LedgerException { ! System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } ! public final void testHoldAndExpireTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException { ! final double aliceBalance = ledger.getBalance(ALICE); ! final double bobBalance = ledger.getBalance(BOB); ! final double amount = 100; ! System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); ! ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); ! assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); ! try { ! Thread.currentThread().sleep(5000); ! } catch (InterruptedException e) { ! ; ! } ! assertEquals("ALICE BALANCE EXPIRED", aliceBalance, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE EXPIRED", bobBalance, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE EXPIRED", aliceBalance, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE EXPIRED", bobBalance, ledger.getAvailableBalance(BOB), 0); ! System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); ! } ! public final void testHoldAndCancelTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException { ! final double aliceBalance = ledger.getBalance(ALICE); ! final double bobBalance = ledger.getBalance(BOB); ! final double amount = 100; ! PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); ! assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); ! ledger.performCancelHold(tran); ! assertEquals("ALICE BALANCE CANCELLED", aliceBalance, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE CANCELLED", bobBalance, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE CANCELLED", aliceBalance, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE CANCELLED", bobBalance, ledger.getAvailableBalance(BOB), 0); ! System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); ! System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } ! public final void testHoldAndCompleteTransfer() throws LowlevelLedgerException, UnBalancedTransactionException, InvalidTransactionException, UnknownTransactionException, TransactionExpiredException { ! final double aliceBalance = ledger.getBalance(ALICE); ! final double bobBalance = ledger.getBalance(BOB); ! final double amount = 100; ! PostedHeldTransaction tran = ledger.hold(ALICE, BOB, new Date(System.currentTimeMillis() + 5000), amount, "LOAN"); ! assertEquals("ALICE BALANCE", aliceBalance, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE", bobBalance, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE", bobBalance, ledger.getAvailableBalance(BOB), 0); ! ledger.performCompleteHold(tran, 100, "done"); ! assertEquals("ALICE BALANCE CANCELLED", aliceBalance - amount, ledger.getBalance(ALICE), 0); ! assertEquals("BOB BALANCE CANCELLED", bobBalance + amount, ledger.getBalance(BOB), 0); ! assertEquals("ALICE Available BALANCE CANCELLED", aliceBalance - amount, ledger.getAvailableBalance(ALICE), 0); ! assertEquals("BOB Available BALANCE CANCELLED", bobBalance + amount, ledger.getAvailableBalance(BOB), 0); + System.out.println("Alice's Balance: " + ledger.getBalance(ALICE)); + System.out.println("Bob's Balance: " + ledger.getBalance(BOB)); } ! protected Ledger ledger; } Index: SQLLedgerTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/test/org/neuclear/ledger/SQLLedgerTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SQLLedgerTest.java 26 Dec 2003 22:50:52 -0000 1.5 --- SQLLedgerTest.java 21 Mar 2004 00:48:36 -0000 1.6 *************** *** 2,8 **** import org.neuclear.commons.NeuClearException; - import org.neuclear.commons.sql.SQLTools; - import org.neuclear.commons.sql.DefaultConnectionSource; - import org.neuclear.ledger.implementations.SQLLedger; import javax.naming.NamingException; --- 2,5 ---- |
|
From: Pelle B. <pe...@us...> - 2004-03-21 00:58:40
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2857/src/java/org/neuclear/ledger/browser Modified Files: BookBrowser.java LedgerBrowser.java LedgerConfiguration.java QueryBookBrowser.java Log Message: The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. Index: QueryBookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/QueryBookBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryBookBrowser.java 2 Jan 2004 23:18:34 -0000 1.1 --- QueryBookBrowser.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 1,11 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; - import org.neuclear.ledger.LowlevelLedgerException; - import org.neuclear.commons.Utility; import org.neuclear.commons.sql.statements.StatementFactory; ! import java.sql.*; ! import java.security.Principal; /* --- 1,12 ---- package org.neuclear.ledger.browser; import org.neuclear.commons.sql.statements.StatementFactory; + import org.neuclear.ledger.Ledger; + import org.neuclear.ledger.LowlevelLedgerException; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; /* *************** *** 29,32 **** --- 30,36 ---- $Id$ $Log$ + Revision 1.2 2004/03/21 00:48:35 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.1 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. *************** *** 44,84 **** */ public class QueryBookBrowser extends BookBrowser { ! public QueryBookBrowser(Book book,StatementFactory fact) throws SQLException { ! this(book,executeQuery(fact,book)); } ! public QueryBookBrowser(Book book,StatementFactory fact,Timestamp from, Timestamp until) throws SQLException { ! this(book,executeRangeQuery(fact,book,from,until)); } ! public QueryBookBrowser(Book book,StatementFactory fact,Timestamp from) throws SQLException { ! this(book,executeFromQuery(fact,book,from)); } ! private QueryBookBrowser(Book book,ResultSet rs) throws SQLException { super(book); ! this.rs=rs; ! next=rs.next(); } ! private static ResultSet executeRangeQuery(StatementFactory fact,Book book,Timestamp from, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(RANGE_QUERY); ! stmt.setTimestamp(3,from); ! stmt.setTimestamp(4,until); ! return executeQuery(stmt,book); } ! private static ResultSet executeFromQuery(StatementFactory fact,Book book,Timestamp from) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(FROM_QUERY); ! stmt.setTimestamp(3,from); ! return executeQuery(stmt,book); } ! private static ResultSet executeUntilQuery(StatementFactory fact,Book book, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(UNTIL_QUERY); ! stmt.setTimestamp(3,until); ! return executeQuery(stmt,book); } ! private static ResultSet executeQuery(StatementFactory fact,Book book) throws SQLException { ! return executeQuery(fact.prepareStatement(FULL_QUERY),book); } ! private static ResultSet executeQuery(PreparedStatement stmt,Book book) throws SQLException { ! stmt.setString(1,book.getBookID()); ! stmt.setString(2,book.getLedger().getId()); return stmt.executeQuery(); --- 48,96 ---- */ public class QueryBookBrowser extends BookBrowser { ! public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact) throws SQLException { ! this(ledger, book, executeQuery(fact, ledger.getId(), book)); } ! ! public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact, Timestamp from, Timestamp until) throws SQLException { ! this(ledger, book, executeRangeQuery(fact, ledger.getId(), book, from, until)); } ! ! public QueryBookBrowser(Ledger ledger, String book, StatementFactory fact, Timestamp from) throws SQLException { ! this(ledger, book, executeFromQuery(fact, ledger.getId(), book, from)); } ! ! private QueryBookBrowser(Ledger ledger, String book, ResultSet rs) throws SQLException { super(book); ! this.rs = rs; ! next = rs.next(); ! this.ledger = ledger; } ! private static ResultSet executeRangeQuery(StatementFactory fact, String ledgerid, String book, Timestamp from, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(RANGE_QUERY); ! stmt.setTimestamp(3, from); ! stmt.setTimestamp(4, until); ! return executeQuery(stmt, ledgerid, book); } ! ! private static ResultSet executeFromQuery(StatementFactory fact, String ledgerid, String book, Timestamp from) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(FROM_QUERY); ! stmt.setTimestamp(3, from); ! return executeQuery(stmt, ledgerid, book); } ! ! private static ResultSet executeUntilQuery(StatementFactory fact, String ledgerid, String book, Timestamp until) throws SQLException { final PreparedStatement stmt = fact.prepareStatement(UNTIL_QUERY); ! stmt.setTimestamp(3, until); ! return executeQuery(stmt, ledgerid, book); } ! ! private static ResultSet executeQuery(StatementFactory fact, String ledgerid, String book) throws SQLException { ! return executeQuery(fact.prepareStatement(FULL_QUERY), ledgerid, book); } ! ! private static ResultSet executeQuery(PreparedStatement stmt, String ledgerid, String book) throws SQLException { ! stmt.setString(1, book); ! stmt.setString(2, ledgerid); return stmt.executeQuery(); *************** *** 89,99 **** if (!rs.next()) return false; ! setRow(rs.getString(1),rs.getString(3),rs.getString(4),rs.getTimestamp(2),rs.getBigDecimal(5)); return true; } catch (SQLException e) { ! throw new LowlevelLedgerException(getBook().getLedger(),e); } } private final ResultSet rs; private boolean next; private static final String BASE_QUERY = "select t.id,t.valuetime, r.bookid,t.comment,s.amount from entry s,entry r, transaction t where s.transactionid=t.id and r.transactionid=t.id and r.id<>s.id\nand s.bookid = ? and t.ledgerid=?"; --- 101,113 ---- if (!rs.next()) return false; ! setRow(rs.getString(1), rs.getString(3), rs.getString(4), rs.getTimestamp(2), rs.getBigDecimal(5)); return true; } catch (SQLException e) { ! throw new LowlevelLedgerException(ledger, e); } } + private final ResultSet rs; + private final Ledger ledger; private boolean next; private static final String BASE_QUERY = "select t.id,t.valuetime, r.bookid,t.comment,s.amount from entry s,entry r, transaction t where s.transactionid=t.id and r.transactionid=t.id and r.id<>s.id\nand s.bookid = ? and t.ledgerid=?"; *************** *** 102,109 **** private static final String ORDERBY = " order by t.valuetime,t.id"; ! private static final String FULL_QUERY = BASE_QUERY+ORDERBY; ! private static final String RANGE_QUERY = BASE_QUERY+FROM_CLAUSE+UNTIL_CLAUSE+ORDERBY; ! private static final String FROM_QUERY = BASE_QUERY+FROM_CLAUSE+ORDERBY; ! private static final String UNTIL_QUERY = BASE_QUERY+UNTIL_CLAUSE+ORDERBY; } --- 116,123 ---- private static final String ORDERBY = " order by t.valuetime,t.id"; ! private static final String FULL_QUERY = BASE_QUERY + ORDERBY; ! private static final String RANGE_QUERY = BASE_QUERY + FROM_CLAUSE + UNTIL_CLAUSE + ORDERBY; ! private static final String FROM_QUERY = BASE_QUERY + FROM_CLAUSE + ORDERBY; ! private static final String UNTIL_QUERY = BASE_QUERY + UNTIL_CLAUSE + ORDERBY; } Index: BookBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/BookBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BookBrowser.java 2 Jan 2004 23:18:34 -0000 1.1 --- BookBrowser.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 1,10 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; import org.neuclear.ledger.LowlevelLedgerException; - import java.util.Iterator; - import java.sql.Timestamp; import java.math.BigDecimal; /* --- 1,8 ---- package org.neuclear.ledger.browser; import org.neuclear.ledger.LowlevelLedgerException; import java.math.BigDecimal; + import java.sql.Timestamp; /* *************** *** 28,31 **** --- 26,32 ---- $Id$ $Log$ + Revision 1.2 2004/03/21 00:48:35 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.1 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. *************** *** 43,48 **** */ public abstract class BookBrowser { ! public BookBrowser(Book book){ ! this.book=book; } --- 44,49 ---- */ public abstract class BookBrowser { ! public BookBrowser(String book) { ! this.book = book; } *************** *** 50,61 **** ! protected final void setRow(String xid,String counterparty,String comment,Timestamp valuetime, BigDecimal amount) { ! this.xid=xid; ! this.counterparty=counterparty; ! this.comment=comment; ! this.valuetime=valuetime; ! this.amount=amount; } ! public Book getBook() { return book; } --- 51,63 ---- ! protected final void setRow(String xid, String counterparty, String comment, Timestamp valuetime, BigDecimal amount) { ! this.xid = xid; ! this.counterparty = counterparty; ! this.comment = comment; ! this.valuetime = valuetime; ! this.amount = amount; } ! ! public String getBook() { return book; } *************** *** 81,85 **** } ! private final Book book; private String xid; --- 83,87 ---- } ! private final String book; private String xid; Index: LedgerConfiguration.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/LedgerConfiguration.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LedgerConfiguration.java 2 Jan 2004 23:18:34 -0000 1.1 --- LedgerConfiguration.java 21 Mar 2004 00:48:35 -0000 1.2 *************** *** 2,14 **** import org.neuclear.commons.configuration.Configuration; - import org.neuclear.commons.sql.statements.StatementFactory; - import org.neuclear.commons.sql.statements.SimpleStatementFactory; import org.neuclear.commons.sql.ConnectionSource; - import org.neuclear.commons.sql.DefaultXAConnectionSource; import org.neuclear.commons.sql.TestCaseXAConnectionSource; ! import org.neuclear.ledger.implementations.SQLLedger; ! import org.neuclear.ledger.Ledger; ! import org.picocontainer.Parameter; ! import org.picocontainer.defaults.ConstantParameter; /* --- 2,9 ---- import org.neuclear.commons.configuration.Configuration; import org.neuclear.commons.sql.ConnectionSource; import org.neuclear.commons.sql.TestCaseXAConnectionSource; ! import org.neuclear.commons.sql.statements.SimpleStatementFactory; ! import org.neuclear.commons.sql.statements.StatementFactory; /* *************** *** 32,35 **** --- 27,33 ---- $Id$ $Log$ + Revision 1.2 2004/03/21 00:48:35 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.1 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. *************** *** 44,50 **** public class LedgerConfiguration implements Configuration { public void configure(org.picocontainer.MutablePicoContainer pico) { ! pico.registerComponentImplementation(ConnectionSource.class,TestCaseXAConnectionSource.class); ! pico.registerComponentImplementation(StatementFactory.class,SimpleStatementFactory.class); ! pico.registerComponentImplementation(Ledger.class,SQLLedger.class,new Parameter[] {new ConstantParameter("neu://test/bux")}); } --- 42,48 ---- public class LedgerConfiguration implements Configuration { public void configure(org.picocontainer.MutablePicoContainer pico) { ! pico.registerComponentImplementation(ConnectionSource.class, TestCaseXAConnectionSource.class); ! pico.registerComponentImplementation(StatementFactory.class, SimpleStatementFactory.class); ! // pico.registerComponentImplementation(Ledger.class,SQLLedger.class,new Parameter[] {new ConstantParameter("neu://test/bux")}); } Index: LedgerBrowser.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/browser/LedgerBrowser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LedgerBrowser.java 2 Jan 2004 23:18:34 -0000 1.2 --- LedgerBrowser.java 21 Mar 2004 00:48:35 -0000 1.3 *************** *** 1,8 **** package org.neuclear.ledger.browser; - import org.neuclear.ledger.Book; import org.neuclear.ledger.LowlevelLedgerException; - import java.util.Iterator; import java.sql.Timestamp; --- 1,6 ---- *************** *** 27,30 **** --- 25,31 ---- $Id$ $Log$ + Revision 1.3 2004/03/21 00:48:35 pelle + The problem with Enveloped signatures has now been fixed. It was a problem in the way transforms work. I have bandaided it, but in the future if better support for transforms need to be made, we need to rethink it a bit. Perhaps using the new crypto channel's in neuclear-commons. + Revision 1.2 2004/01/02 23:18:34 pelle Added StatementFactory pattern and refactored the ledger to use it. *************** *** 42,48 **** */ public interface LedgerBrowser { ! public BookBrowser browse(Book book) throws LowlevelLedgerException; ! public BookBrowser browseFrom(Book book,Timestamp from) throws LowlevelLedgerException; // public BookBrowser browseUntil(Book book,Timestamp until); ! public BookBrowser browseRange(Book book,Timestamp from, Timestamp until) throws LowlevelLedgerException; } --- 43,50 ---- */ public interface LedgerBrowser { ! public BookBrowser browse(String book) throws LowlevelLedgerException; ! ! public BookBrowser browseFrom(String book, Timestamp from) throws LowlevelLedgerException; // public BookBrowser browseUntil(Book book,Timestamp until); ! public BookBrowser browseRange(String book, Timestamp from, Timestamp until) throws LowlevelLedgerException; } |