19 package org.sleuthkit.autopsy.centralrepository.datamodel;
 
   21 import java.sql.ResultSet;
 
   22 import java.sql.SQLException;
 
   23 import java.util.ArrayList;
 
   24 import java.util.Collection;
 
   25 import java.util.Collections;
 
   26 import java.util.List;
 
   27 import java.util.Objects;
 
   28 import org.apache.commons.lang.StringUtils;
 
   60             this.accountTypeId = acctTypeID;
 
   82             hash = 29 * hash + Objects.hashCode(this.
acctType);
 
   95             if (getClass() != obj.getClass()) {
 
  149         hash = 43 * hash + (int) (this.accountId ^ (this.accountId >>> 32));
 
  150         hash = 43 * hash + (this.accountType != null ? this.accountType.
hashCode() : 0);
 
  151         hash = 43 * hash + (this.typeSpecificIdentifier != null ? this.typeSpecificIdentifier.hashCode() : 0);
 
  163         if (getClass() != obj.getClass()) {
 
  167         if (this.accountId != other.
getId()) {
 
  170         if (!Objects.equals(
this.typeSpecificIdentifier, other.
getIdentifier())) {
 
  181         Collection<CentralRepoAccount> accountsList = 
new ArrayList<>();
 
  193                         rs.getInt(
"account_id"),
 
  195                         rs.getString(
"account_unique_identifier"));
 
  197                 accountsList.add(account);
 
  201         Collection<CentralRepoAccount> getAccountsList() {
 
  202             return Collections.unmodifiableCollection(accountsList);
 
  207             = 
"SELECT accounts.id as account_id,  " 
  208             + 
" accounts.account_type_id as account_type_id, accounts.account_unique_identifier as account_unique_identifier," 
  209             + 
" account_types.id as account_type_id, " 
  210             + 
" account_types.type_name as type_name, account_types.display_name as display_name, account_types.correlation_type_id as correlation_type_id  " 
  212             + 
" JOIN account_types as account_types on accounts.account_type_id = account_types.id ";
 
  229                 + 
" WHERE LOWER(accounts.account_unique_identifier) LIKE LOWER(?)";
 
  231         List<Object> params = 
new ArrayList<>();
 
  232         params.add(
"%" + accountIdentifierSubstring + 
"%");
 
  237         return queryCallback.getAccountsList();
 
  255                 + 
" WHERE LOWER(accounts.account_unique_identifier) = LOWER(?)";
 
  257         List<Object> params = 
new ArrayList<>();
 
  258         params.add(normalizedAccountIdentifier);
 
  263         return queryCallback.getAccountsList();
 
  275     public static Collection<CentralRepoAccount> 
getAllAccounts() throws CentralRepoException {
 
  279         List<Object> params = 
new ArrayList<>(); 
 
  284         return queryCallback.getAccountsList();
 
  297         if (StringUtils.isEmpty(accountIdentifier)) {
 
  298             throw new InvalidAccountIDException(
"Account id is null or empty.");
 
  301         String normalizedAccountIdentifier;
 
  308                 normalizedAccountIdentifier = accountIdentifier.toLowerCase().trim();
 
  311             throw new InvalidAccountIDException(
"Failed to normalize the account idenitier " + accountIdentifier, ex);
 
  313         return normalizedAccountIdentifier;
 
  327         if (StringUtils.isBlank(accountIdentifier)) {
 
  328             throw new InvalidAccountIDException(
"Account identifier is null or empty.");
 
  331         String normalizedAccountIdentifier;
 
  339                 normalizedAccountIdentifier = accountIdentifier.toLowerCase();
 
  342             throw new InvalidAccountIDException(String.format(
"Account id normaization failed, invalid account identifier %s", accountIdentifier), ex);
 
  345         return normalizedAccountIdentifier;
 
static String normalizeAccountIdentifier(CentralRepoAccountType crAccountType, String accountIdentifier)
static Collection< CentralRepoAccount > getAllAccounts()
void executeQuery(String sql, List< Object > params, CentralRepositoryDbQueryCallback queryCallback)
final String typeSpecificIdentifier
boolean equals(Object obj)
boolean equals(Object obj)
static final String ACCOUNTS_QUERY_CLAUSE
static final Account.Type PHONE
static String normalizeAccountIdentifier(String accountIdentifier)
static Collection< CentralRepoAccount > getAccountsWithIdentifier(String accountIdentifier)
static Collection< CentralRepoAccount > getAccountsWithIdentifierLike(String accountIdentifierSubstring)
final Account.Type acctType
int getCorrelationTypeId()
final int correlationTypeId
CentralRepoAccountType getAccountType()
void process(ResultSet rs)
static CentralRepository getInstance()
static final Account.Type EMAIL
final CentralRepoAccountType accountType
Account.Type getAcctType()