|
From: <pe...@us...> - 2003-10-25 03:40:43
|
Update of /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger
In directory sc8-pr-cvs1:/tmp/cvs-serv8013/src/java/org/neuclear/ledger
Modified Files:
Ledger.java LedgerFactory.java
Log Message:
Fixed SmtpSender it now sends the messages.
Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
Index: Ledger.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/Ledger.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Ledger.java 1 Oct 2003 17:35:53 -0000 1.2
--- Ledger.java 25 Oct 2003 00:39:05 -0000 1.3
***************
*** 1,6 ****
--- 1,13 ----
package org.neuclear.ledger;
+
/**
* $Id$
* $Log$
+ * Revision 1.3 2003/10/25 00:39:05 pelle
+ * Fixed SmtpSender it now sends the messages.
+ * Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
+ * is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
+ * Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
+ *
* Revision 1.2 2003/10/01 17:35:53 pelle
* Made as much as possible immutable for security and reliability reasons.
***************
*** 70,78 ****
*/
- import org.neuclear.commons.configuration.ConfigurationException;
import org.neuclear.commons.configuration.Configuration;
import java.util.Date;
import java.util.Iterator;
/**
* This is the abstract Ledger class that implementators of the NeuClear Ledger need to implement.
--- 77,86 ----
*/
import org.neuclear.commons.configuration.Configuration;
+ import org.neuclear.commons.configuration.ConfigurationException;
import java.util.Date;
import java.util.Iterator;
+
/**
* This is the abstract Ledger class that implementators of the NeuClear Ledger need to implement.
***************
*** 82,105 ****
/**
* The unique id of the ledger
! * @param id
*/
! public Ledger(String id,String name) {
! this.name=name;
! this.id=id;
}
/**
* Default implementation allows for new Books to be created on the fly. If you need control over this. Over ride.
! * @param bookID
! * @return
*/
! public abstract Book getBook(String bookID) throws UnknownBookException,LowlevelLedgerException;
/**
* Used by implementations to securely create Book Instances
! * @param bookID
* @return Valid Book instance
*/
! protected Book createBookInstance(String bookID,String name) {
! return new Book(bookID,name,this);
}
--- 90,117 ----
/**
* The unique id of the ledger
! *
! * @param id
*/
! public Ledger(String id, String name) {
! this.name = name;
! this.id = id;
}
+
/**
* Default implementation allows for new Books to be created on the fly. If you need control over this. Over ride.
! *
! * @param bookID
! * @return
*/
! public abstract Book getBook(String bookID) throws UnknownBookException, LowlevelLedgerException;
/**
* Used by implementations to securely create Book Instances
! *
! * @param bookID
* @return Valid Book instance
*/
! protected Book createBookInstance(String bookID, String name) {
! return new Book(bookID, name, this);
}
***************
*** 109,113 ****
public Book createNewBook(String bookID) throws BookExistsException, LowlevelLedgerException {
! return createNewBook(bookID,"Unnamed Account");
}
--- 121,125 ----
public Book createNewBook(String bookID) throws BookExistsException, LowlevelLedgerException {
! return createNewBook(bookID, "Unnamed Account");
}
***************
*** 117,130 ****
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
/**
* The basic interface for creating Transactions in the database.
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
--- 129,145 ----
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
+ *
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedTransaction performTransaction(UnPostedTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
+
/**
* The basic interface for creating Transactions in the database.
* The implementing class takes this transacion information and stores it with an automatically generated uniqueid.
* This id is returned as an identifier of the transaction.
+ *
* @param trans Transaction to perform
! * @return Unique ID
*/
public abstract PostedHeldTransaction performHeldTransaction(UnPostedHeldTransaction trans) throws UnBalancedTransactionException, LowlevelLedgerException, InvalidTransactionException;
***************
*** 132,139 ****
/**
* Searches for a Transaction based on its Transaction ID
* @param id A valid ID
* @return The Transaction object
*/
! public abstract PostedTransaction findTransaction(String id) throws LowlevelLedgerException, UnknownTransactionException, InvalidTransactionException, UnknownBookException;
/**
--- 147,155 ----
/**
* Searches for a Transaction based on its Transaction ID
+ *
* @param id A valid ID
* @return The Transaction object
*/
! public abstract PostedTransaction findTransaction(String id) throws LowlevelLedgerException, UnknownTransactionException, InvalidTransactionException, UnknownBookException;
/**
***************
*** 152,161 ****
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! *
* </pre>
! * @param balancedate
* @return the balance as a double
*/
public abstract double getBalance(Book book, Date balancedate) throws LowlevelLedgerException;
public abstract double getBalance(Book book) throws LowlevelLedgerException;
--- 168,179 ----
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! * <p/>
* </pre>
! *
! * @param balancedate
* @return the balance as a double
*/
public abstract double getBalance(Book book, Date balancedate) throws LowlevelLedgerException;
+
public abstract double getBalance(Book book) throws LowlevelLedgerException;
***************
*** 174,184 ****
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! *
* </pre>
! * @param balancedate
* @return the balance as a double
*/
! public abstract double getAvailableBalance(Book book, Date balancedate) throws LowlevelLedgerException;
! public abstract double getAvailableBalance(Book book) throws LowlevelLedgerException;
/**
--- 192,204 ----
* where transactiondate <= sysdate and end_date is null and debit= 'neu://bob'
* ) d
! * <p/>
* </pre>
! *
! * @param balancedate
* @return the balance as a double
*/
! public abstract double getAvailableBalance(Book book, Date balancedate) throws LowlevelLedgerException;
!
! public abstract double getAvailableBalance(Book book) throws LowlevelLedgerException;
/**
***************
*** 187,190 ****
--- 207,211 ----
*/
public abstract void beginLinkedTransaction();
+
/**
* Use this to indicate to the underlying system that we want to end a database transaction.
***************
*** 211,264 ****
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedTransaction createTransaction(UnPostedTransaction transaction,String xid) throws InvalidTransactionException {
! return new PostedTransaction(transaction,xid);
}
/**
* Ledger Implementations use this to create Transactions.
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedHeldTransaction createHeldTransaction(UnPostedHeldTransaction transaction,String xid) throws InvalidTransactionException {
! return new PostedHeldTransaction(transaction,xid);
}
! protected final PostedTransaction createHeldComplete(PostedHeldTransaction hold,double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
//TODO Rework these Exception
! if (hold.getTransactionTime().after(hold.getExpiryTime()))
! throw new TransactionExpiredException(this,hold);
! if (amount<0)
! throw new InvalidTransactionException(this,"The amount must be positive");
try {
beginLinkedTransaction();
//PostedTransaction rev=hold.reverse(comment); // We dont need to reverse this
! UnPostedTransaction tran=new UnPostedTransaction(this,comment,time);
! Iterator iter=hold.getItems();
! while (iter.hasNext()){
! TransactionItem item=(TransactionItem)iter.next();
! if (item.getAmount()>=0)
! tran.addItem(item.getBook(),amount);
else
! tran.addItem(item.getBook(),-amount);
}
endLinkedTransactions();
return tran.post();
} catch (UnBalancedTransactionException e) {
! throw new LowlevelLedgerException(this,e);
}
}
public String toString() {
return name;
}
public String getName() {
return name;
}
public String getId() {
return id;
--- 232,291 ----
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
+ *
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedTransaction createTransaction(UnPostedTransaction transaction, String xid) throws InvalidTransactionException {
! return new PostedTransaction(transaction, xid);
}
+
/**
* Ledger Implementations use this to create Transactions.
* The reason for this kind of round the way contructions is that we dont want dodgy Implementations to cause security problems for
* other implementations.
+ *
* @param transaction An Unposted Transaction containing the Transaction details
! * @param xid Unique Transaction ID
* @return PostedTransaction
*/
! protected final PostedHeldTransaction createHeldTransaction(UnPostedHeldTransaction transaction, String xid) throws InvalidTransactionException {
! return new PostedHeldTransaction(transaction, xid);
}
! protected final PostedTransaction createHeldComplete(PostedHeldTransaction hold, double amount, Date time, String comment) throws TransactionExpiredException, InvalidTransactionException, LowlevelLedgerException {
//TODO Rework these Exception
! if (hold.getTransactionTime().after(hold.getExpiryTime()))
! throw new TransactionExpiredException(this, hold);
! if (amount < 0)
! throw new InvalidTransactionException(this, "The amount must be positive");
try {
beginLinkedTransaction();
//PostedTransaction rev=hold.reverse(comment); // We dont need to reverse this
! UnPostedTransaction tran = new UnPostedTransaction(this, comment, time);
! Iterator iter = hold.getItems();
! while (iter.hasNext()) {
! TransactionItem item = (TransactionItem) iter.next();
! if (item.getAmount() >= 0)
! tran.addItem(item.getBook(), amount);
else
! tran.addItem(item.getBook(), -amount);
}
endLinkedTransactions();
return tran.post();
} catch (UnBalancedTransactionException e) {
! throw new LowlevelLedgerException(this, e);
}
}
+
public String toString() {
return name;
}
+
public String getName() {
return name;
}
+
public String getId() {
return id;
***************
*** 269,290 ****
/**
! * Searches for a Held Transaction based on its Transaction ID
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public abstract PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException;
/**
* Cancels a Held Transaction.
! * @param hold
* @throws org.neuclear.ledger.LowlevelLedgerException
* @throws org.neuclear.ledger.UnknownTransactionException
*/
public abstract void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException;
! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold,double amount, Date time, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException;
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getContainer().getComponent(Ledger.class);
}
}
--- 296,321 ----
/**
! * Searches for a Held Transaction based on its Transaction ID
! *
! * @param idstring A valid ID
! * @return The Transaction object
! */
! public abstract PostedHeldTransaction findHeldTransaction(String idstring) throws LowlevelLedgerException, UnknownTransactionException;
/**
* Cancels a Held Transaction.
! *
! * @param hold
* @throws org.neuclear.ledger.LowlevelLedgerException
+ *
* @throws org.neuclear.ledger.UnknownTransactionException
+ *
*/
public abstract void performCancelHold(PostedHeldTransaction hold) throws LowlevelLedgerException, UnknownTransactionException;
! public abstract PostedTransaction performCompleteHold(PostedHeldTransaction hold, double amount, Date time, String comment) throws InvalidTransactionException, LowlevelLedgerException, TransactionExpiredException;
public static Ledger getInstance() throws ConfigurationException {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
}
}
Index: LedgerFactory.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-ledger/src/java/org/neuclear/ledger/LedgerFactory.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** LedgerFactory.java 20 Sep 2003 23:16:17 -0000 1.1.1.1
--- LedgerFactory.java 25 Oct 2003 00:39:05 -0000 1.2
***************
*** 1,3 ****
--- 1,4 ----
package org.neuclear.ledger;
+
/**
* (C) 2003 Antilles Software Ventures SA
***************
*** 7,10 ****
--- 8,17 ----
* $Id$
* $Log$
+ * Revision 1.2 2003/10/25 00:39:05 pelle
+ * Fixed SmtpSender it now sends the messages.
+ * Refactored CommandLineSigner. Now it simply signs files read from command line. However new class IdentityCreator
+ * is subclassed and creates new Identities. You can subclass CommandLineSigner to create your own variants.
+ * Several problems with configuration. Trying to solve at the moment. Updated PicoContainer to beta-2
+ *
* Revision 1.1.1.1 2003/09/20 23:16:17 pelle
* First revision of neuclear-ledger in /cvsroot/neuclear
***************
*** 35,52 ****
*/
- import org.neuclear.ledger.implementations.SimpleLedger;
- import org.neuclear.ledger.implementations.SQLLedger;
- import org.neuclear.commons.sql.SQLTools;
- import org.neuclear.commons.sql.DefaultConnectionSource;
- import org.neuclear.commons.sql.ConnectionSource;
import org.neuclear.commons.configuration.Configuration;
import org.neuclear.commons.configuration.ConfigurationException;
! import org.picocontainer.defaults.*;
! import org.picocontainer.PicoIntrospectionException;
! import org.picocontainer.PicoInitializationException;
! import org.picocontainer.PicoContainer;
- import java.util.Map;
import java.util.HashMap;
/**
--- 42,52 ----
*/
import org.neuclear.commons.configuration.Configuration;
import org.neuclear.commons.configuration.ConfigurationException;
! import org.neuclear.ledger.implementations.SQLLedger;
! import org.picocontainer.defaults.DefaultPicoContainer;
import java.util.HashMap;
+ import java.util.Map;
/**
***************
*** 57,72 ****
*/
public class LedgerFactory {
! protected LedgerFactory() throws LowlevelLedgerException{
! ledgerMap=new HashMap();
}
/**
* This attempts to find a ledger in the map. If not it creates a new one and returns it.
* @param name Unique Ledger Name
* @return Ledger
*/
! public final Ledger getLedger(String name) throws LedgerCreationException{
try {
! return (Ledger)Configuration.getContainer().getComponent(Ledger.class);
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
--- 57,73 ----
*/
public class LedgerFactory {
! protected LedgerFactory() throws LowlevelLedgerException {
! ledgerMap = new HashMap();
}
/**
* This attempts to find a ledger in the map. If not it creates a new one and returns it.
+ *
* @param name Unique Ledger Name
* @return Ledger
*/
! public final Ledger getLedger(String name) throws LedgerCreationException {
try {
! return (Ledger) Configuration.getContainer(Ledger.class).getComponentInstance(Ledger.class);
} catch (ConfigurationException e) {
throw new LedgerCreationException(e);
***************
*** 76,84 ****
/**
* Gets a Singleton instance of the LedgerFactory.
* @return the Singleton Instance
*/
public synchronized static LedgerFactory getInstance() throws LowlevelLedgerException {
! if (instance==null){
! instance=new LedgerFactory();
}
return instance;
--- 77,86 ----
/**
* Gets a Singleton instance of the LedgerFactory.
+ *
* @return the Singleton Instance
*/
public synchronized static LedgerFactory getInstance() throws LowlevelLedgerException {
! if (instance == null) {
! instance = new LedgerFactory();
}
return instance;
***************
*** 98,101 ****
private static Map ledgerMap;
private DefaultPicoContainer pico;
! private static Class DEFAULT_IMPLEMENTATION=SQLLedger.class;
}
--- 100,103 ----
private static Map ledgerMap;
private DefaultPicoContainer pico;
! private static Class DEFAULT_IMPLEMENTATION = SQLLedger.class;
}
|