/**
     * Build the AccountSQLCall object
     *
     * @return a AccountSQLCall
     */
    public AccountSQLCall build() {
      final List<SQLParam> sqlParams = new ArrayList<SQLParam>();

      // Update the password attribute, if defined and value is present
      if (resourcePassword != null) {
        setSqlValue(UNENCRYPT_PWD, resourcePassword);
        setSqlValue(PWD_DATE, currentDate);
      } else if (password != null) {
        setSqlValue(UNENCRYPT_PWD, password);
        setSqlValue(PWD_DATE, currentDate);
      }

      // Check required columns
      Assertions.nullCheck(sqlParamsMap.get(USER_NAME), Name.NAME);
      Assertions.nullCheck(sqlParamsMap.get(OWNER), OWNER);
      if (create) {
        Assertions.nullCheck(sqlParamsMap.get(UNENCRYPT_PWD), OperationalAttributes.PASSWORD_NAME);
      }

      final String fn = (create) ? CREATE_FNC : UPDATE_FNC;
      log.ok("getUserCallSQL: {0}", fn);
      StringBuilder body = new StringBuilder();
      boolean first = true;
      for (CallParam par : CALL_PARAMS) {
        final String columnName = par.name;
        final String parameterExpress = par.expression;

        SQLParam val = getSqlParam(columnName);
        String nullParam = getNullParam(columnName);
        if (nullParam == null && val == null) {
          continue; // skip all non setup values
        }
        if (!first) body.append(", ");
        if (val != null) {
          // exact value has advantage
          body.append(MessageFormat.format(parameterExpress, Q));
          sqlParams.add(val);
        } else if (nullParam != null) {
          body.append(MessageFormat.format(parameterExpress, nullParam));
        } else {
          throw new IllegalStateException();
        }
        first = false;
      }

      final String sql = createCallSQL(fn, body);

      log.ok("getUserCallSQL done");
      return new AccountSQLCall(sql, sqlParams);
    }
Example #2
0
 /**
  * Returns the OperationOptionInfo for the given name.
  *
  * @param name The name to find.
  * @return the OperationOptionInfo for the given name or null if not found.
  */
 public OperationOptionInfo findOperationOptionInfo(String name) {
   Assertions.nullCheck(name, "name");
   for (OperationOptionInfo info : _declaredOperationOptions) {
     if (info.getName().equals(name)) {
       return info;
     }
   }
   return null;
 }
Example #3
0
 /**
  * Returns the ObjectClassInfo for the given type.
  *
  * @param type The type to find.
  * @return the ObjectClassInfo for the given type or null if not found.
  */
 public ObjectClassInfo findObjectClassInfo(String type) {
   Assertions.nullCheck(type, "type");
   for (ObjectClassInfo info : _declaredObjectClasses) {
     if (info.is(type)) {
       return info;
     }
   }
   return null;
 }