コード例 #1
0
 public Account getAccount(String id) {
   id = ApiFunctions.safeTrim(id);
   if (ApiFunctions.isEmpty(id)) {
     throw new ApiException("A non-empty account id must be specified.");
   } else {
     return (Account) _accountMap.get(id.toLowerCase());
   }
 }
コード例 #2
0
  private void validateAccount(Account account, StringBuffer problems) {
    boolean appendComma = problems.length() > 0;
    // validate the account id exists and is a known account id
    String id = ApiFunctions.safeTrim(account.getId());
    if (ApiFunctions.isEmpty(id)) {
      if (appendComma) {
        problems.append(",");
      }
      problems.append(" account with empty id encountered");
      appendComma = true;
    } else {
      ArdaisaccountAccessBean ardaisAccount = null;
      try {
        ardaisAccount = new ArdaisaccountAccessBean(new ArdaisaccountKey(id));
      } catch (Exception e) {
        if (appendComma) {
          problems.append(",");
        }
        problems.append(" account with unknown id (" + id + ") encountered");
        appendComma = true;
      }
    }

    // validate that the bartender command line exists and has the correct insertion points
    String bartenderCommandLine = account.getBartenderCommandLine();
    if (ApiFunctions.isEmpty(bartenderCommandLine)) {
      if (appendComma) {
        problems.append(",");
      }
      problems.append(" account with empty bartenderCommandLine encountered.");
      appendComma = true;
    } else {
      if (bartenderCommandLine.indexOf(Constants.LABEL_PRINTING_INSERTION_STRING_LABEL_PRINTER)
          <= 0) {
        if (appendComma) {
          problems.append(",");
        }
        problems.append(
            " account with bartenderCommandLine having no printer insertion string encountered.");
        appendComma = true;
      }
      if (bartenderCommandLine.indexOf(Constants.LABEL_PRINTING_INSERTION_STRING_LABEL_TEMPLATE)
          <= 0) {
        if (appendComma) {
          problems.append(",");
        }
        problems.append(
            " account with bartenderCommandLine having no template insertion string encountered.");
        appendComma = true;
      }
    }

    // validate the results form definitions in the account
    validateAccountResultsFormDefinitions(account, problems);

    // validate the label template definitions in the account
    validateAccountLabelTemplateDefinitions(account, problems);

    // validate the label printers in the account
    validateAccountLabelPrinters(account, problems);
  }