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 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) Creates a newAccount
.static int
addAccountHost
(DatabaseConnection conn, InvalidateList invalidateList, Account.Name account, int host) Creates a newAccountHost
.static int
addAccountHost
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, int host) Creates a newAccountHost
.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) Creates a newAdministrator
.static int
addDisableLog
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String disableReason) Creates a newDistroLog
.static int
addNoticeLog
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String billingContact, String emailAddress, String type, int transaction) Adds a notice log.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) Creates a newProfile
.static boolean
canAccessAccount
(DatabaseAccess db, RequestSource source, Account.Name account) static boolean
canAccessDisableLog
(DatabaseConnection conn, RequestSource source, int disableLog, boolean enabling) static boolean
canAccountAccessHost
(DatabaseConnection conn, Account.Name account, int host) static boolean
canAccountHost_column
(DatabaseConnection conn, RequestSource source, int host, String column) static void
cancelAccount
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String cancelReason) static boolean
canSeePrices
(DatabaseConnection conn, Account.Name account) static boolean
canSeePrices
(DatabaseConnection conn, RequestSource source) static boolean
canSwitchUser
(DatabaseAccess db, User.Name authenticatedAs, User.Name connectAs) static void
checkAccessAccount
(DatabaseConnection conn, RequestSource source, String action, Account.Name account) static void
checkAccessDisableLog
(DatabaseConnection conn, RequestSource source, String action, int disableLog, boolean enabling) static void
checkAccountAccessHost
(DatabaseConnection conn, RequestSource source, String action, Account.Name account, int host) static void
checkAddAccount
(DatabaseConnection conn, RequestSource source, String action, Account.Name parent, int host) static void
checkPermission
(DatabaseConnection conn, RequestSource source, String action, Permission.Name permission) static String
convertUsState
(DatabaseConnection conn, String state) static void
disableAccount
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, Account.Name account) static void
disableAdministrator
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, User.Name administrator) static void
enableAccount
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account) static void
enableAdministrator
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) static Account.Name
generateAccountName
(DatabaseConnection conn, Account.Name template) static String
Generates 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.Name
getAccountForDisableLog
(DatabaseConnection conn, int disableLog) static Account.Name
getAccountFromEmailAddresses
(DatabaseConnection conn, List<String> addresses) Gets the best estimate of an account for a list of email addresses ornull
if can't determine.static Administrator
getAdministrator
(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 int
getDepthInAccountTree
(DatabaseConnection conn, Account.Name account) Gets the depth of the account in the account tree.static User.Name
getDisabledByForDisableLog
(DatabaseConnection conn, int disableLog) static int
getDisableLogForAccount
(DatabaseConnection conn, Account.Name account) static int
getDisableLogForAdministrator
(DatabaseAccess db, User.Name administrator) static IntList
getHostsForAccount
(DatabaseConnection conn, Account.Name account) static List
<Account.Name> getPackagesForAccount
(DatabaseConnection conn, Account.Name account) static Account.Name
getParentAccount
(DatabaseConnection conn, Account.Name account) static Account.Name
getTechnicalEmail
(DatabaseConnection conn, Account.Name account) static boolean
hasPermission
(DatabaseConnection conn, RequestSource source, Permission.Name permission) static void
invalidateTable
(Table.TableId tableId) static boolean
isAccountBillParent
(DatabaseConnection conn, Account.Name account) static boolean
isAccountCanceled
(DatabaseConnection conn, Account.Name account) static boolean
isAccountDisabled
(DatabaseConnection conn, Account.Name account) static boolean
isAccountNameAvailable
(DatabaseConnection conn, Account.Name name) static boolean
isAccountOrParent
(DatabaseConnection conn, Account.Name parentAccounting, Account.Name account) static boolean
isAdministrator
(DatabaseAccess db, User.Name user) static boolean
isAdministratorDisabled
(DatabaseAccess db, User.Name administrator) static boolean
isAdministratorPasswordSet
(DatabaseConnection conn, RequestSource source, User.Name administrator) static void
removeAccountHost
(DatabaseConnection conn, InvalidateList invalidateList, int accountHost) Removes aAccountHost
.static void
removeAccountHost
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) Removes aAccountHost
.static void
removeAdministrator
(DatabaseConnection conn, InvalidateList invalidateList, User.Name administrator) static void
removeAdministrator
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) static void
removeDisableLog
(DatabaseConnection conn, InvalidateList invalidateList, int disableLog) static void
setAccountName
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, Account.Name name) static void
setAdministratorPassword
(DatabaseAccess db, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) static void
setAdministratorPassword
(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator, UnprotectedPassword password) 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) Sets an administrators profile.static void
setDefaultAccountHost
(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:
IOException
SQLException
-
canAccessDisableLog
public static boolean canAccessDisableLog(DatabaseConnection conn, RequestSource source, int disableLog, boolean enabling) throws IOException, SQLException - Throws:
IOException
SQLException
-
cancelAccount
public static void cancelAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String cancelReason) throws IOException, SQLException - Throws:
IOException
SQLException
-
canAccountHost_column
public static boolean canAccountHost_column(DatabaseConnection conn, RequestSource source, int host, String column) throws IOException, SQLException - Throws:
IOException
SQLException
-
checkAccessAccount
public static void checkAccessAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
checkAccessDisableLog
public static void checkAccessDisableLog(DatabaseConnection conn, RequestSource source, String action, int disableLog, boolean enabling) throws IOException, SQLException - Throws:
IOException
SQLException
-
checkAddAccount
public static void checkAddAccount(DatabaseConnection conn, RequestSource source, String action, Account.Name parent, int host) throws IOException, SQLException - Throws:
IOException
SQLException
-
hasPermission
public static boolean hasPermission(DatabaseConnection conn, RequestSource source, Permission.Name permission) throws IOException, SQLException - Throws:
IOException
SQLException
-
checkPermission
public static void checkPermission(DatabaseConnection conn, RequestSource source, String action, Permission.Name permission) throws IOException, SQLException - Throws:
IOException
SQLException
-
getAllowedAccounts
public static List<Account.Name> getAllowedAccounts(DatabaseAccess db, RequestSource source) throws IOException, SQLException - Throws:
IOException
SQLException
-
getAccountForDisableLog
public static Account.Name getAccountForDisableLog(DatabaseConnection conn, int disableLog) throws IOException, SQLException - Throws:
IOException
SQLException
-
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:
IOException
SQLException
-
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:
IOException
SQLException
-
convertUsState
public static String convertUsState(DatabaseConnection conn, String state) throws IOException, SQLException - Throws:
IOException
SQLException
-
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:
IOException
SQLException
-
addAccountHost
public static int addAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, int host) throws IOException, SQLException Creates a newAccountHost
.- Throws:
IOException
SQLException
-
addAccountHost
public static int addAccountHost(DatabaseConnection conn, InvalidateList invalidateList, Account.Name account, int host) throws IOException, SQLException Creates a newAccountHost
.- Throws:
IOException
SQLException
-
addDisableLog
public static int addDisableLog(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, String disableReason) throws IOException, SQLException Creates a newDistroLog
.- Throws:
IOException
SQLException
-
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:
IOException
SQLException
-
disableAccount
public static void disableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
disableAdministrator
public static void disableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int disableLog, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
enableAccount
public static void enableAccount(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
enableAdministrator
public static void enableAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
generateSupportCode
Generates a random, unused support code.- Throws:
IOException
SQLException
-
generateAccountName
public static Account.Name generateAccountName(DatabaseConnection conn, Account.Name template) throws IOException, SQLException - Throws:
IOException
SQLException
-
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:
IOException
SQLException
-
getDisabledByForDisableLog
public static User.Name getDisabledByForDisableLog(DatabaseConnection conn, int disableLog) throws IOException, SQLException - Throws:
IOException
SQLException
-
getDisableLogForAccount
public static int getDisableLogForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
getDisableLogForAdministrator
public static int getDisableLogForAdministrator(DatabaseAccess db, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
getPackagesForAccount
public static List<Account.Name> getPackagesForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
getHostsForAccount
public static IntList getHostsForAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
getRootAccount
- Throws:
IOException
-
isAccountNameAvailable
public static boolean isAccountNameAvailable(DatabaseConnection conn, Account.Name name) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAdministratorPasswordSet
public static boolean isAdministratorPasswordSet(DatabaseConnection conn, RequestSource source, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
removeAdministrator
public static void removeAdministrator(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
removeAdministrator
public static void removeAdministrator(DatabaseConnection conn, InvalidateList invalidateList, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
removeAccountHost
public static void removeAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Removes aAccountHost
.- Throws:
IOException
SQLException
-
removeAccountHost
public static void removeAccountHost(DatabaseConnection conn, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Removes aAccountHost
.- Throws:
IOException
SQLException
-
removeDisableLog
public static void removeDisableLog(DatabaseConnection conn, InvalidateList invalidateList, int disableLog) throws IOException, SQLException - Throws:
IOException
SQLException
-
setAccountName
public static void setAccountName(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, Account.Name account, Account.Name name) throws IOException, SQLException - Throws:
IOException
SQLException
-
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:
IOException
SQLException
-
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:
IOException
SQLException
-
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:
IOException
SQLException
-
setDefaultAccountHost
public static void setDefaultAccountHost(DatabaseConnection conn, RequestSource source, InvalidateList invalidateList, int accountHost) throws IOException, SQLException Sets the default Host for an Account.- Throws:
IOException
SQLException
-
getAdministrator
public static Administrator getAdministrator(DatabaseAccess db, User.Name user) throws IOException, SQLException - Throws:
IOException
SQLException
-
invalidateTable
-
getParentAccount
public static Account.Name getParentAccount(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
getChildAccounts
public static List<Account.Name> getChildAccounts(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
getTechnicalEmail
public static Set<Email> getTechnicalEmail(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAdministrator
public static boolean isAdministrator(DatabaseAccess db, User.Name user) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAdministratorDisabled
public static boolean isAdministratorDisabled(DatabaseAccess db, User.Name administrator) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAccountDisabled
public static boolean isAccountDisabled(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAccountCanceled
public static boolean isAccountCanceled(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAccountBillParent
public static boolean isAccountBillParent(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
canSeePrices
public static boolean canSeePrices(DatabaseConnection conn, RequestSource source) throws IOException, SQLException - Throws:
IOException
SQLException
-
canSeePrices
public static boolean canSeePrices(DatabaseConnection conn, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
isAccountOrParent
public static boolean isAccountOrParent(DatabaseConnection conn, Account.Name parentAccounting, Account.Name account) throws IOException, SQLException - Throws:
IOException
SQLException
-
canSwitchUser
public static boolean canSwitchUser(DatabaseAccess db, User.Name authenticatedAs, User.Name connectAs) throws IOException, SQLException - Throws:
IOException
SQLException
-
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
HashMap
ofArrayList
- Throws:
IOException
SQLException
-
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 ornull
if 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.VirtualHostName
with a weight of 1 - Look for matches in
dns.Zone
with a weight of 1 - Add up the weights per account
- Find the highest weight
- Follow the bill_parents up to top billing level
- Throws:
IOException
SQLException
-
canAccountAccessHost
public static boolean canAccountAccessHost(DatabaseConnection conn, Account.Name account, int host) throws IOException, SQLException - Throws:
IOException
SQLException
-
checkAccountAccessHost
public static void checkAccountAccessHost(DatabaseConnection conn, RequestSource source, String action, Account.Name account, int host) throws IOException, SQLException - Throws:
IOException
SQLException
-