org.opengroupware.jogi.connect.xmlrpc
Class XmlRpcAccountManager

java.lang.Object
  extended byorg.opengroupware.jogi.connect.xmlrpc.XmlRpcAccountManager
All Implemented Interfaces:
AccountManager, java.util.Observer

public class XmlRpcAccountManager
extends java.lang.Object
implements AccountManager, java.util.Observer

Author:
Werner Schuster (murphee) Andreas Rath (teddius)

Field Summary
protected  java.util.Map cached_accounts_
          This stores all the accounts that have ever been loaded or generated.
static java.lang.String OGO_CALL_ACCOUNT_DELETE
           
static java.lang.String OGO_CALL_ACCOUNT_DELETE_BY_LOGIN
           
static java.lang.String OGO_CALL_ACCOUNT_DELETE_BY_NUMBER
           
static java.lang.String OGO_CALL_ACCOUNT_FETCH
           
static java.lang.String OGO_CALL_ACCOUNT_FETCH_IDS
           
static java.lang.String OGO_CALL_ACCOUNT_GET_BY_ID
           
static java.lang.String OGO_CALL_ACCOUNT_GET_BY_LOGIN
           
static java.lang.String OGO_CALL_ACCOUNT_GET_BY_NUMBER
           
static java.lang.String OGO_CALL_ACCOUNT_GET_LOGIN_ACCOUNT
           
static java.lang.String OGO_CALL_ACCOUNT_INSERT
           
static java.lang.String OGO_CALL_ACCOUNT_PASSWORD_FOR_LOGIN
           
static java.lang.String OGO_CALL_ACCOUNT_UPDATE
           
protected  OpenGroupWare openGroupware_
           
 
Constructor Summary
XmlRpcAccountManager(XmlRpcCaller caller)
           
XmlRpcAccountManager(XmlRpcCaller caller, OpenGroupWare ogo)
           
 
Method Summary
 void commitUpdate()
           
protected  XmlRpcAccount createNewAccount(java.util.Map content)
          Creates a new XmlRpcAccount from a Map.
 void delete(Account account)
           
 void deleteByLogin(java.lang.String login)
           
 void deleteByNumber(java.lang.String number)
          Deletes an account by a number.
 java.util.Iterator fetch(FetchSpecification spec)
          Fetches all Accounts that match the FetchSpecification.
 java.util.Iterator fetchIds(FetchSpecification spec)
           
 java.util.List getAllTemplateUserLogins()
           
 Account getById(java.lang.String id)
          This method returns the Account associated by this id.
 Account getByLogin(java.lang.String login)
          Returns the Account with the provided login name.
 Account getByNumber(java.lang.String account_number)
           
protected  XmlRpcAccount getCachedAccount(java.lang.Object obj)
          This method takes the return value of an XML-RPC call and looks up the object which represents this id in the cache.
 Account getLoginAccount()
           
 java.util.List getTeamsForLogin(java.lang.String login)
           
 Account insert(java.lang.String login)
          Creates a new Account and inserts in on the server.
 java.lang.String passwordForLogin(java.lang.String login)
          Returns the Password for a specific Account.
protected  XmlRpcAccount receiveAccount(java.lang.Object accTemp)
          This takes the return value of an XML-RPC call, and if that is an Account it either updates the cached version of it or creates a new one.
 void update(java.util.Observable o, java.lang.Object arg)
          Updates an object and synchronizes it with the OpengroupWare server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OGO_CALL_ACCOUNT_UPDATE

public static final java.lang.String OGO_CALL_ACCOUNT_UPDATE
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_DELETE

public static final java.lang.String OGO_CALL_ACCOUNT_DELETE
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_INSERT

public static final java.lang.String OGO_CALL_ACCOUNT_INSERT
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_GET_LOGIN_ACCOUNT

public static final java.lang.String OGO_CALL_ACCOUNT_GET_LOGIN_ACCOUNT
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_GET_BY_LOGIN

public static final java.lang.String OGO_CALL_ACCOUNT_GET_BY_LOGIN
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_DELETE_BY_LOGIN

public static final java.lang.String OGO_CALL_ACCOUNT_DELETE_BY_LOGIN
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_DELETE_BY_NUMBER

public static final java.lang.String OGO_CALL_ACCOUNT_DELETE_BY_NUMBER
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_PASSWORD_FOR_LOGIN

public static final java.lang.String OGO_CALL_ACCOUNT_PASSWORD_FOR_LOGIN
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_FETCH

public static final java.lang.String OGO_CALL_ACCOUNT_FETCH
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_FETCH_IDS

public static final java.lang.String OGO_CALL_ACCOUNT_FETCH_IDS
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_GET_BY_ID

public static final java.lang.String OGO_CALL_ACCOUNT_GET_BY_ID
See Also:
Constant Field Values

OGO_CALL_ACCOUNT_GET_BY_NUMBER

public static final java.lang.String OGO_CALL_ACCOUNT_GET_BY_NUMBER
See Also:
Constant Field Values

cached_accounts_

protected java.util.Map cached_accounts_
This stores all the accounts that have ever been loaded or generated. The key used to store them is their id, as this should be unique (hopefully...). This is vitally important, to ensure that only one instance of an specific Account exists. Otherwise, any fetch* method would/could return new instances of Accounts that might already have instance here, which would lead to inconsistancies (eg. one instance representing an older state of a new one) as well as it would be impossible to check for equality using the "==" operator.


openGroupware_

protected OpenGroupWare openGroupware_
Constructor Detail

XmlRpcAccountManager

public XmlRpcAccountManager(XmlRpcCaller caller,
                            OpenGroupWare ogo)

XmlRpcAccountManager

public XmlRpcAccountManager(XmlRpcCaller caller)
Method Detail

getByNumber

public Account getByNumber(java.lang.String account_number)
                    throws OgoException,
                           ConnectionException
Throws:
OgoException
ConnectionException

fetchIds

public java.util.Iterator fetchIds(FetchSpecification spec)
                            throws OgoException,
                                   ConnectionException
Specified by:
fetchIds in interface AccountManager
Parameters:
spec - a FetchSpecification object holding the query
Returns:
an Iterator for accessing the returned Account objects OR null if something went wrong;
Throws:
OgoException
ConnectionException

getById

public Account getById(java.lang.String id)
                throws OgoException,
                       ConnectionException
This method returns the Account associated by this id. For example if you want to receive the Account with the OpengroupWare id
skyrix://skyrix.com/sx_skyrix/122282
you must supply the numeric part as argument to the method call. In the example above the correct argument to receive the account would be 122282

Specified by:
getById in interface AccountManager
Parameters:
id - The numeric Part of the OpengroupWare id.
Returns:
An Account Object for this id
Throws:
OgoException
ConnectionException

deleteByNumber

public void deleteByNumber(java.lang.String number)
                    throws OgoException,
                           ConnectionException
Deletes an account by a number. Because a number is unique in the OpenGroupware database deleting by number is safe.

Throws:
OgoException
ConnectionException

deleteByLogin

public void deleteByLogin(java.lang.String login)
                   throws OgoException,
                          ConnectionException
Specified by:
deleteByLogin in interface AccountManager
Throws:
OgoException
ConnectionException

delete

public void delete(Account account)
            throws OgoException,
                   ConnectionException
Specified by:
delete in interface AccountManager
Throws:
OgoException
ConnectionException

passwordForLogin

public java.lang.String passwordForLogin(java.lang.String login)
                                  throws OgoException,
                                         ConnectionException
Description copied from interface: AccountManager
Returns the Password for a specific Account. This only works for the root user.

Specified by:
passwordForLogin in interface AccountManager
Parameters:
login -
Returns:
the encrypted password, refer to the OpenGroupware.org documentation for details.
Throws:
OgoException
ConnectionException

getTeamsForLogin

public java.util.List getTeamsForLogin(java.lang.String login)
                                throws OgoException,
                                       ConnectionException
Throws:
OgoException
ConnectionException

getByLogin

public Account getByLogin(java.lang.String login)
                   throws OgoException,
                          ConnectionException
Description copied from interface: AccountManager
Returns the Account with the provided login name.

Specified by:
getByLogin in interface AccountManager
Returns:
the Account or null if no account by that name was found.
Throws:
OgoException
ConnectionException

fetch

public java.util.Iterator fetch(FetchSpecification spec)
                         throws OgoException,
                                ConnectionException
Description copied from interface: AccountManager
Fetches all Accounts that match the FetchSpecification.

Specified by:
fetch in interface AccountManager
Parameters:
spec - An FetchSpecification for selecting Accounts.
Returns:
an Iterator giving access to the resulting Accounts or null if no matching accounts were found.
Throws:
OgoException
ConnectionException

insert

public Account insert(java.lang.String login)
               throws OgoException,
                      ConnectionException
Description copied from interface: AccountManager
Creates a new Account and inserts in on the server. This is the only way to create an Account object.

Specified by:
insert in interface AccountManager
Parameters:
login - the login name for the new Account, please refer to the OpenGroupware.org documentation for the constraints imposed on these names.
Returns:
the newly created Account
Throws:
OgoException
ConnectionException

commitUpdate

public void commitUpdate()
                  throws OgoException,
                         ConnectionException
Throws:
OgoException
ConnectionException

getAllTemplateUserLogins

public java.util.List getAllTemplateUserLogins()
                                        throws OgoException,
                                               ConnectionException
Throws:
OgoException
ConnectionException

getLoginAccount

public Account getLoginAccount()
                        throws OgoException,
                               ConnectionException
Specified by:
getLoginAccount in interface AccountManager
Returns:
the Account of the user that is used to log on to the server or null if something goes wrong;
Throws:
OgoException
ConnectionException

receiveAccount

protected XmlRpcAccount receiveAccount(java.lang.Object accTemp)
                                throws OgoException,
                                       ConnectionException
This takes the return value of an XML-RPC call, and if that is an Account it either updates the cached version of it or creates a new one.

Parameters:
accTemp - The object returned by an XML-RPC call.
Returns:
An updated copy of an XmlRpcAccount.
Throws:
OgoException
ConnectionException

getCachedAccount

protected XmlRpcAccount getCachedAccount(java.lang.Object obj)
This method takes the return value of an XML-RPC call and looks up the object which represents this id in the cache. If the object exists in the cache the cached Object will be returned. If the object is not in the cache null will be returned.

Parameters:
obj - The result of an XML-RPC Call.
Returns:
An instance of an XmlRpcAccount object or null if no object exists in the cache.

createNewAccount

protected XmlRpcAccount createNewAccount(java.util.Map content)
                                  throws OgoException,
                                         ConnectionException
Creates a new XmlRpcAccount from a Map.

Parameters:
content - The Map containing the data from which a new XmlRpcAccount should be created.
Returns:
A newly created XmlRpcAccount with its values initalized from the Map.
Throws:
OgoException
ConnectionException

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Updates an object and synchronizes it with the OpengroupWare server

Specified by:
update in interface java.util.Observer
Parameters:
o - An observable.
arg - The object which should be updated.


Copyright © 2003 ogojogi Project, All Rights Reserved.