java.lang.Object
com.aoindustries.aoserv.master.AccountHandler
The
AccountHandler handles all the accesses to the Account tables.- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name name, String contractVersion, int defaultServer, Account.Name parent, boolean canAddBackupServers, boolean canAddBusinesses, boolean canSeePrices, boolean billParent) Creates a newAccount.static intaddAccountHost(DatabaseConnection conn, InvalidateList invalidateList, Account.Name account, int host) Creates a newAccountHost.static intaddAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, int host) Creates a newAccountHost.static voidaddAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name user, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip, boolean enableEmailSupport) Creates a newAdministrator.static intaddDisableLog(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String disableReason) Creates a newDistroLog.static intaddNoticeLog(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String billingContact, String emailAddress, String type, int transaction) Adds a notice log.static intaddProfile(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String name, boolean isPrivate, String phone, String fax, String address1, String address2, String city, String state, String country, String zip, boolean sendInvoice, String billingContact, Set<Email> billingEmail, Profile.EmailFormat billingEmailFormat, String technicalContact, Set<Email> technicalEmail, Profile.EmailFormat technicalEmailFormat) Creates a newProfile.static booleancanAccessAccount(DatabaseAccess db, RequestSource source, Account.Name account) static booleancanAccessDisableLog(DatabaseConnection conn, RequestSource source, int disableLog, boolean enabling) static booleancanAccountAccessHost(DatabaseConnection conn, Account.Name account, int host) static booleancanAccountHost_column(DatabaseConnection conn, RequestSource source, int host, String column) static voidcancelAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String cancelReason) static booleancanSeePrices(DatabaseConnection conn, Account.Name account) static booleancanSeePrices(DatabaseConnection conn, RequestSource source) static booleancanSwitchUser(DatabaseAccess db, User.Name authenticatedAs, User.Name connectAs) static voidcheckAccessAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name account) static voidcheckAccessDisableLog(DatabaseConnection conn, RequestSource source, String action, int disableLog, boolean enabling) static voidcheckAccountAccessHost(DatabaseConnection conn, RequestSource source, String action, Account.Name account, int host) static voidcheckAddAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name parent, int host) static voidcheckPermission(DatabaseConnection conn, RequestSource source, String action, Permission.Name permission) static StringconvertUsState(DatabaseConnection conn, String state) static voiddisableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, Account.Name account) static voiddisableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, User.Name administrator) static voidenableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account) static voidenableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) static Account.NamegenerateAccountName(DatabaseConnection conn, Account.Name template) static StringGenerates a random, unused support code.static Map<Account.Name, List<String>> Gets the list of both technical and billing contacts for all not-canceled account.Account.static Account.NamegetAccountForDisableLog(DatabaseConnection conn, int disableLog) static Account.NamegetAccountFromEmailAddresses(DatabaseConnection conn, List<String> addresses) Gets the best estimate of an account for a list of email addresses ornullif can't determine.static AdministratorgetAdministrator(DatabaseAccess db, User.Name user) static List<Account.Name> getAllowedAccounts(DatabaseAccess db, RequestSource source) static List<Account.Name> getChildAccounts(DatabaseConnection conn, Account.Name account) static intgetDepthInAccountTree(DatabaseConnection conn, Account.Name account) Gets the depth of the account in the account tree.static User.NamegetDisabledByForDisableLog(DatabaseConnection conn, int disableLog) static intgetDisableLogForAccount(DatabaseConnection conn, Account.Name account) static intgetDisableLogForAdministrator(DatabaseAccess db, User.Name administrator) static IntListgetHostsForAccount(DatabaseConnection conn, Account.Name account) static List<Account.Name> getPackagesForAccount(DatabaseConnection conn, Account.Name account) static Account.NamegetParentAccount(DatabaseConnection conn, Account.Name account) static Account.NamegetTechnicalEmail(DatabaseConnection conn, Account.Name account) static booleanhasPermission(DatabaseConnection conn, RequestSource source, Permission.Name permission) static voidinvalidateTable(Table.TableId tableId) static booleanisAccountBillParent(DatabaseConnection conn, Account.Name account) static booleanisAccountCanceled(DatabaseConnection conn, Account.Name account) static booleanisAccountDisabled(DatabaseConnection conn, Account.Name account) static booleanisAccountNameAvailable(DatabaseConnection conn, Account.Name name) static booleanisAccountOrParent(DatabaseConnection conn, Account.Name parentAccounting, Account.Name account) static booleanisAdministrator(DatabaseAccess db, User.Name user) static booleanisAdministratorDisabled(DatabaseAccess db, User.Name administrator) static booleanisAdministratorPasswordSet(DatabaseConnection conn, RequestSource source, User.Name administrator) static voidremoveAccountHost(DatabaseConnection conn, InvalidateList invalidateList, int accountHost) Removes aAccountHost.static voidremoveAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) Removes aAccountHost.static voidremoveAdministrator(DatabaseConnection conn, InvalidateList invalidateList, User.Name administrator) static voidremoveAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) static voidremoveDisableLog(DatabaseConnection conn, InvalidateList invalidateList, int disableLog) static voidsetAccountName(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, Account.Name name) static voidsetAdministratorPassword(DatabaseAccess db, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) static voidsetAdministratorPassword(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) static voidsetAdministratorProfile(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip) Sets an administrators profile.static voidsetDefaultAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) Sets the default Host for an Account.
-
Method Details
-
canAccessAccount
public static boolean canAccessAccount(DatabaseAccess db, RequestSource source, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
canAccessDisableLog
public static boolean canAccessDisableLog(DatabaseConnection conn, RequestSource source, int disableLog, boolean enabling) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
cancelAccount
public static void cancelAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String cancelReason) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
canAccountHost_column
public static boolean canAccountHost_column(DatabaseConnection conn, RequestSource source, int host, String column) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
checkAccessAccount
public static void checkAccessAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
checkAccessDisableLog
public static void checkAccessDisableLog(DatabaseConnection conn, RequestSource source, String action, int disableLog, boolean enabling) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
checkAddAccount
public static void checkAddAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name parent, int host) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
hasPermission
public static boolean hasPermission(DatabaseConnection conn, RequestSource source, Permission.Name permission) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
checkPermission
public static void checkPermission(DatabaseConnection conn, RequestSource source, String action, Permission.Name permission) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getAllowedAccounts
public static List<Account.Name> getAllowedAccounts(DatabaseAccess db, RequestSource source) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getAccountForDisableLog
public static Account.Name getAccountForDisableLog(DatabaseConnection conn, int disableLog) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
addAccount
public static void addAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name name, String contractVersion, int defaultServer, Account.Name parent, boolean canAddBackupServers, boolean canAddBusinesses, boolean canSeePrices, boolean billParent) throws IOException, SQLException Creates a newAccount.- Throws:
IOExceptionSQLException
-
addAdministrator
public static void addAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name user, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip, boolean enableEmailSupport) throws IOException, SQLException Creates a newAdministrator.- Throws:
IOExceptionSQLException
-
convertUsState
public static String convertUsState(DatabaseConnection conn, String state) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
addProfile
public static int addProfile(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String name, boolean isPrivate, String phone, String fax, String address1, String address2, String city, String state, String country, String zip, boolean sendInvoice, String billingContact, Set<Email> billingEmail, Profile.EmailFormat billingEmailFormat, String technicalContact, Set<Email> technicalEmail, Profile.EmailFormat technicalEmailFormat) throws IOException, SQLException Creates a newProfile.- Throws:
IOExceptionSQLException
-
addAccountHost
public static int addAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, int host) throws IOException, SQLException Creates a newAccountHost.- Throws:
IOExceptionSQLException
-
addAccountHost
public static int addAccountHost(DatabaseConnection conn, InvalidateList invalidateList, Account.Name account, int host) throws IOException, SQLException Creates a newAccountHost.- Throws:
IOExceptionSQLException
-
addDisableLog
public static int addDisableLog(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String disableReason) throws IOException, SQLException Creates a newDistroLog.- Throws:
IOExceptionSQLException
-
addNoticeLog
public static int addNoticeLog(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String billingContact, String emailAddress, String type, int transaction) throws IOException, SQLException Adds a notice log.- Throws:
IOExceptionSQLException
-
disableAccount
public static void disableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
disableAdministrator
public static void disableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
enableAccount
public static void enableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
enableAdministrator
public static void enableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
generateSupportCode
Generates a random, unused support code.- Throws:
IOExceptionSQLException
-
generateAccountName
public static Account.Name generateAccountName(DatabaseConnection conn, Account.Name template) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getDepthInAccountTree
public static int getDepthInAccountTree(DatabaseConnection conn, Account.Name account) throws IOException, SQLException Gets the depth of the account in the account tree. root_accounting is at depth 1.- Returns:
- the depth between 1 and Account.MAXIMUM_ACCOUNT_TREE_DEPTH, inclusive.
- Throws:
IOExceptionSQLException
-
getDisabledByForDisableLog
public static User.Name getDisabledByForDisableLog(DatabaseConnection conn, int disableLog) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getDisableLogForAccount
public static int getDisableLogForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getDisableLogForAdministrator
public static int getDisableLogForAdministrator(DatabaseAccess db, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getPackagesForAccount
public static List<Account.Name> getPackagesForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getHostsForAccount
public static IntList getHostsForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getRootAccount
- Throws:
IOException
-
isAccountNameAvailable
public static boolean isAccountNameAvailable(DatabaseConnection conn, Account.Name name) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAdministratorPasswordSet
public static boolean isAdministratorPasswordSet(DatabaseConnection conn, RequestSource source, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
removeAdministrator
public static void removeAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
removeAdministrator
public static void removeAdministrator(DatabaseConnection conn, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
removeAccountHost
public static void removeAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Removes aAccountHost.- Throws:
IOExceptionSQLException
-
removeAccountHost
public static void removeAccountHost(DatabaseConnection conn, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Removes aAccountHost.- Throws:
IOExceptionSQLException
-
removeDisableLog
public static void removeDisableLog(DatabaseConnection conn, InvalidateList invalidateList, int disableLog) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
setAccountName
public static void setAccountName(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, Account.Name name) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
setAdministratorPassword
public static void setAdministratorPassword(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) throws IOException, SQLException - Parameters:
password- Is destroyed before this method returns. If the original password is needed, pass a clone to this method.- Throws:
IOExceptionSQLException
-
setAdministratorPassword
public static void setAdministratorPassword(DatabaseAccess db, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) throws IOException, SQLException - Parameters:
password- Is destroyed before this method returns. If the original password is needed, pass a clone to this method.- Throws:
IOExceptionSQLException
-
setAdministratorProfile
public static void setAdministratorProfile(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator, String name, String title, Date birthday, boolean isPrivate, String workPhone, String homePhone, String cellPhone, String fax, String email, String address1, String address2, String city, String state, String country, String zip) throws IOException, SQLException Sets an administrators profile.- Throws:
IOExceptionSQLException
-
setDefaultAccountHost
public static void setDefaultAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Sets the default Host for an Account.- Throws:
IOExceptionSQLException
-
getAdministrator
public static Administrator getAdministrator(DatabaseAccess db, User.Name user) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
invalidateTable
-
getParentAccount
public static Account.Name getParentAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getChildAccounts
public static List<Account.Name> getChildAccounts(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getTechnicalEmail
public static Set<Email> getTechnicalEmail(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAdministrator
public static boolean isAdministrator(DatabaseAccess db, User.Name user) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAdministratorDisabled
public static boolean isAdministratorDisabled(DatabaseAccess db, User.Name administrator) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAccountDisabled
public static boolean isAccountDisabled(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAccountCanceled
public static boolean isAccountCanceled(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAccountBillParent
public static boolean isAccountBillParent(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
canSeePrices
public static boolean canSeePrices(DatabaseConnection conn, RequestSource source) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
canSeePrices
public static boolean canSeePrices(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
isAccountOrParent
public static boolean isAccountOrParent(DatabaseConnection conn, Account.Name parentAccounting, Account.Name account) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
canSwitchUser
public static boolean canSwitchUser(DatabaseAccess db, User.Name authenticatedAs, User.Name connectAs) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
getAccountContacts
public static Map<Account.Name,List<String>> getAccountContacts(DatabaseConnection conn) throws IOException, SQLException Gets the list of both technical and billing contacts for all not-canceled account.Account.- Returns:
- a
HashMapofArrayList - Throws:
IOExceptionSQLException
-
getAccountFromEmailAddresses
public static Account.Name getAccountFromEmailAddresses(DatabaseConnection conn, List<String> addresses) throws IOException, SQLException Gets the best estimate of an account for a list of email addresses ornullif can't determine. The algorithm takes these steps.- Look for exact matches in billing and technical contacts, with a weight of 10.
- Look for matches in
email.Domain, with a weight of 5 - Look for matches in
web.VirtualHostNamewith a weight of 1 - Look for matches in
dns.Zonewith a weight of 1 - Add up the weights per account
- Find the highest weight
- Follow the bill_parents up to top billing level
- Throws:
IOExceptionSQLException
-
canAccountAccessHost
public static boolean canAccountAccessHost(DatabaseConnection conn, Account.Name account, int host) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
checkAccountAccessHost
public static void checkAccountAccessHost(DatabaseConnection conn, RequestSource source, String action, Account.Name account, int host) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
