jondonym.console
Class Controller

java.lang.Object
  extended by jondonym.console.Controller

public class Controller
extends java.lang.Object

TODO documentation TODO forwarding server support TODO memory and performance tuning TODO some more functionality tests

Author:
Rolf Wendolsky

Nested Class Summary
private static class Controller.AutoSwitchedMixCascadeContainer
           
static class Controller.ForcePremiumIfAccountAvailableAttribute
           
private static class Controller.MixCascadeUpdater
           
private static class Controller.RunnableStarter
           
 
Field Summary
private static java.lang.String[] DEFAULT_INFOSERVICE_HOSTNAMES
           
private static java.lang.String[] DEFAULT_INFOSERVICE_NAMES
           
private static int[][] DEFAULT_INFOSERVICE_PORT_NUMBERS
           
static int LOG_DETAIL_LEVEL_HIGH
           
static int LOG_DETAIL_LEVEL_HIGHEST
           
static int LOG_DETAIL_LEVEL_LOWER
           
static int LOG_DETAIL_LEVEL_LOWEST
           
private static boolean m_bShuttingDown
           
private static int m_iInitLogLevel
           
private static java.lang.String MESSAGES
           
private static Controller.MixCascadeUpdater ms_cascadeUpdater
           
private static Configuration ms_configuration
           
private static PayAccount ms_currentlyCreatedAccount
           
private static java.lang.String ms_currentPIID
           
private static InfoServiceUpdater ms_isUpdater
           
private static AnonProxy ms_jondonymProxy
           
private static Log ms_logger
           
private static PaymentInstanceUpdater ms_paymentUpdater
           
private static PerformanceInfoUpdater ms_perfUpdater
           
private static Controller.AutoSwitchedMixCascadeContainer ms_serviceContainer
           
private static java.net.ServerSocket ms_socketListener
           
private static Controller.RunnableStarter ms_starter
           
private static java.lang.Thread ms_starterThread
           
private static java.lang.String MSG_DEFAULT_TRUST_MODEL
           
private static java.lang.String MSG_NO_CHARGED_ACCOUNT
           
private static java.lang.String PI_JONDOS
           
private static java.lang.Object SYNC_STARTER
           
private static long TIMEOUT_RECHARGE
           
private static java.lang.String VERSION
           
private static java.lang.String XML_ATTR_LOG_DETAIL
           
private static java.lang.String XML_ATTR_LOG_LEVEL
           
private static java.lang.String XML_ROOT_NODE
           
 
Constructor Summary
Controller()
           
 
Method Summary
static boolean activateCoupon(java.lang.String a_code)
          Call this method always before validation of the coupon code with "null" as argument.
private static boolean activateCouponCode(java.lang.String a_code, PayAccount a_account, boolean a_bPreCheckOnly)
           
private static void checkActiveAccount(PayAccount a_account)
           
private static PayAccount createAccount()
           
static java.lang.String exportAccounts(java.lang.String a_password)
           
static java.lang.String getActivePaymentInstanceID()
           
static java.util.Vector getAvailableCascades()
           
static MixCascade getCurrentCascade()
           
static long getCurrentCredit()
          Returns the current credit in bytes.
private static long getCurrentCredit(long a_time)
           
static java.util.Locale getLocale()
           
static int getLogDetail()
           
static int getLogDetailCount()
           
static java.lang.String getLogDetailName(int a_detail)
           
static int getLogLevel()
           
static int getLogLevelCount()
          Returns the number of log levels.
static java.lang.String getLogLevelName(int a_level)
           
private static boolean importAccounts_internal(java.lang.String a_accountData, IMiscPasswordReader a_pwReader)
           
static boolean importAccounts(java.lang.String a_accountData)
          Optionally import without the possibility to enter a password.
static boolean importAccounts(java.lang.String a_accountData, IMiscPasswordReader a_pwReader)
           
static void init(org.apache.log4j.Logger a_logger, Configuration a_configuration)
           
static boolean isCascadeAutoSwitched()
           
static boolean isConnected()
           
static boolean isRunning()
           
static void saveConfiguration()
          Tells the program to save the configuration.
static void setActivePaymentInstanceID(java.lang.String a_piid)
           
static void setCascadeAutoSwitched(boolean a_bAutoSwitch)
           
static void setLocale(java.util.Locale a_locale)
           
static boolean setLogDetail(int a_logDetail)
           
static void setLogLevel(int a_level)
           
static boolean shouldRecharge()
          Returns whether the user should recharge.
static boolean start()
           
protected static boolean start(MixCascade a_cascade)
           
static void stop()
           
static void switchCascade()
           
static void switchCascade(MixCascade a_cascade)
           
static boolean validateCoupon(java.lang.String a_code)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_DETAIL_LEVEL_LOWEST

public static final int LOG_DETAIL_LEVEL_LOWEST
See Also:
Constant Field Values

LOG_DETAIL_LEVEL_LOWER

public static final int LOG_DETAIL_LEVEL_LOWER
See Also:
Constant Field Values

LOG_DETAIL_LEVEL_HIGH

public static final int LOG_DETAIL_LEVEL_HIGH
See Also:
Constant Field Values

LOG_DETAIL_LEVEL_HIGHEST

public static final int LOG_DETAIL_LEVEL_HIGHEST
See Also:
Constant Field Values

VERSION

private static final java.lang.String VERSION
See Also:
Constant Field Values

XML_ROOT_NODE

private static final java.lang.String XML_ROOT_NODE
See Also:
Constant Field Values

MESSAGES

private static final java.lang.String MESSAGES
See Also:
Constant Field Values

XML_ATTR_LOG_DETAIL

private static final java.lang.String XML_ATTR_LOG_DETAIL
See Also:
Constant Field Values

XML_ATTR_LOG_LEVEL

private static final java.lang.String XML_ATTR_LOG_LEVEL
See Also:
Constant Field Values

PI_JONDOS

private static final java.lang.String PI_JONDOS
See Also:
Constant Field Values

TIMEOUT_RECHARGE

private static final long TIMEOUT_RECHARGE
See Also:
Constant Field Values

MSG_NO_CHARGED_ACCOUNT

private static final java.lang.String MSG_NO_CHARGED_ACCOUNT

MSG_DEFAULT_TRUST_MODEL

private static final java.lang.String MSG_DEFAULT_TRUST_MODEL

ms_isUpdater

private static InfoServiceUpdater ms_isUpdater

ms_cascadeUpdater

private static Controller.MixCascadeUpdater ms_cascadeUpdater

ms_paymentUpdater

private static PaymentInstanceUpdater ms_paymentUpdater

ms_perfUpdater

private static PerformanceInfoUpdater ms_perfUpdater

ms_socketListener

private static java.net.ServerSocket ms_socketListener

ms_jondonymProxy

private static AnonProxy ms_jondonymProxy

ms_serviceContainer

private static Controller.AutoSwitchedMixCascadeContainer ms_serviceContainer

ms_currentPIID

private static java.lang.String ms_currentPIID

ms_configuration

private static Configuration ms_configuration

ms_logger

private static Log ms_logger

ms_currentlyCreatedAccount

private static PayAccount ms_currentlyCreatedAccount

m_iInitLogLevel

private static int m_iInitLogLevel

ms_starterThread

private static java.lang.Thread ms_starterThread

ms_starter

private static Controller.RunnableStarter ms_starter

SYNC_STARTER

private static final java.lang.Object SYNC_STARTER

m_bShuttingDown

private static boolean m_bShuttingDown

DEFAULT_INFOSERVICE_NAMES

private static final java.lang.String[] DEFAULT_INFOSERVICE_NAMES

DEFAULT_INFOSERVICE_HOSTNAMES

private static final java.lang.String[] DEFAULT_INFOSERVICE_HOSTNAMES

DEFAULT_INFOSERVICE_PORT_NUMBERS

private static final int[][] DEFAULT_INFOSERVICE_PORT_NUMBERS
Constructor Detail

Controller

public Controller()
Method Detail

init

public static void init(org.apache.log4j.Logger a_logger,
                        Configuration a_configuration)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getLogLevelCount

public static int getLogLevelCount()
Returns the number of log levels. Each log level is represented by an integer value from 0 to getLogLevelCount() - 1.

Returns:

getLogLevelName

public static java.lang.String getLogLevelName(int a_level)

getLogLevel

public static int getLogLevel()

setLogLevel

public static void setLogLevel(int a_level)

getLogDetailName

public static java.lang.String getLogDetailName(int a_detail)

setLocale

public static void setLocale(java.util.Locale a_locale)

getLocale

public static java.util.Locale getLocale()

getLogDetail

public static int getLogDetail()

getLogDetailCount

public static int getLogDetailCount()

setLogDetail

public static boolean setLogDetail(int a_logDetail)

stop

public static void stop()

switchCascade

public static void switchCascade()

switchCascade

public static void switchCascade(MixCascade a_cascade)

setCascadeAutoSwitched

public static void setCascadeAutoSwitched(boolean a_bAutoSwitch)

isCascadeAutoSwitched

public static boolean isCascadeAutoSwitched()

getAvailableCascades

public static java.util.Vector getAvailableCascades()

getCurrentCascade

public static MixCascade getCurrentCascade()

isRunning

public static boolean isRunning()

isConnected

public static boolean isConnected()

getActivePaymentInstanceID

public static java.lang.String getActivePaymentInstanceID()

setActivePaymentInstanceID

public static void setActivePaymentInstanceID(java.lang.String a_piid)

createAccount

private static PayAccount createAccount()
                                 throws java.lang.Exception
Throws:
java.lang.Exception

activateCouponCode

private static boolean activateCouponCode(java.lang.String a_code,
                                          PayAccount a_account,
                                          boolean a_bPreCheckOnly)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

validateCoupon

public static boolean validateCoupon(java.lang.String a_code)
                              throws java.lang.Exception
Parameters:
a_code -
Returns:
Throws:
java.lang.Exception - if the account could not be created

shouldRecharge

public static boolean shouldRecharge()
Returns whether the user should recharge.

Returns:
whether the user should recharge

getCurrentCredit

public static long getCurrentCredit()
Returns the current credit in bytes.

Returns:

getCurrentCredit

private static long getCurrentCredit(long a_time)

activateCoupon

public static boolean activateCoupon(java.lang.String a_code)
                              throws java.lang.Exception
Call this method always before validation of the coupon code with "null" as argument. Then execute validateCoupon until the user gives up or the coupon code works. Then you may call this method again. If it succeeds, no further validation is needed, as the account has been activated successfully.

Parameters:
a_code -
Returns:
Throws:
java.lang.Exception

checkActiveAccount

private static void checkActiveAccount(PayAccount a_account)

saveConfiguration

public static void saveConfiguration()
                              throws java.lang.Exception
Tells the program to save the configuration. Note that a configuration is automatically loaded, but might not be saved unless this method is called from outside this class.

Throws:
java.lang.Exception - if an error occurs while saving the configuration

exportAccounts

public static java.lang.String exportAccounts(java.lang.String a_password)

importAccounts

public static boolean importAccounts(java.lang.String a_accountData)
Optionally import without the possibility to enter a password.

Parameters:
a_accountData -
Returns:

importAccounts

public static boolean importAccounts(java.lang.String a_accountData,
                                     IMiscPasswordReader a_pwReader)

importAccounts_internal

private static boolean importAccounts_internal(java.lang.String a_accountData,
                                               IMiscPasswordReader a_pwReader)

start

public static boolean start()

start

protected static boolean start(MixCascade a_cascade)