Esempio n. 1
0
 public static boolean exists(String acctID, String strID)
     throws DBException // if error occurs while testing existance
     {
   if ((acctID != null) && (strID != null)) {
     AccountString.Key strKey = new AccountString.Key(acctID, strID);
     return strKey.exists();
   }
   return false;
 }
Esempio n. 2
0
 /* get string */
 public static AccountString getAccountString(Account account, String strID) throws DBException {
   if ((account != null) && (strID != null)) {
     String acctID = account.getAccountID();
     AccountString.Key key = new AccountString.Key(acctID, strID);
     if (key.exists()) {
       AccountString str = key.getDBRecord(true);
       str.setAccount(account);
       return str;
     } else {
       // AccountString does not exist
       return null;
     }
   } else {
     return null; // just say it doesn't exist
   }
 }
Esempio n. 3
0
  // Note: does NOT return null
  public static AccountString getAccountString(Account account, String strID, boolean create)
      throws DBException {

    /* account-id specified? */
    if (account == null) {
      throw new DBNotFoundException("Account not specified.");
    }
    String acctID = account.getAccountID();

    /* string-id specified? */
    if ((strID == null) || strID.equals("")) {
      throw new DBNotFoundException("String-ID not specified for account: " + acctID);
    }

    /* get/create */
    AccountString str = null;
    AccountString.Key strKey = new AccountString.Key(acctID, strID);
    if (!strKey.exists()) {
      if (create) {
        str = strKey.getDBRecord();
        str.setAccount(account);
        str.setCreationDefaultValues();
        return str; // not yet saved!
      } else {
        throw new DBNotFoundException("String-ID does not exists: " + strKey);
      }
    } else if (create) {
      // we've been asked to create the AccountString, and it already exists
      throw new DBAlreadyExistsException("String-ID already exists '" + strKey + "'");
    } else {
      str = AccountString.getAccountString(account, strID);
      if (str == null) {
        throw new DBException("Unable to read existing String-ID: " + strKey);
      }
      return str;
    }
  }