コード例 #1
0
  public static void validateColumnOrSuperColumn(
      String keyspace, String cfName, ColumnOrSuperColumn cosc) throws InvalidRequestException {
    if (cosc.column != null) {
      validateTtl(cosc.column);
      ThriftValidation.validateColumnPath(
          keyspace,
          new ColumnPath(cfName).setSuper_column((ByteBuffer) null).setColumn(cosc.column.name));
    }

    if (cosc.super_column != null) {
      for (Column c : cosc.super_column.columns) {
        validateTtl(c);
        ThriftValidation.validateColumnPath(
            keyspace,
            new ColumnPath(cfName).setSuper_column(cosc.super_column.name).setColumn(c.name));
      }
    }

    if (cosc.column == null && cosc.super_column == null)
      throw new InvalidRequestException(
          "ColumnOrSuperColumn must have one or both of Column or SuperColumn");
  }
コード例 #2
0
 public static void validateColumn(String keyspace, ColumnParent column_parent, Column column)
     throws InvalidRequestException {
   validateTtl(column);
   validateColumns(keyspace, column_parent, Arrays.asList(column.name));
   try {
     AbstractType validator =
         DatabaseDescriptor.getValueValidator(keyspace, column_parent.column_family, column.name);
     if (validator != null) validator.validate(column.value);
   } catch (MarshalException me) {
     throw new InvalidRequestException(
         String.format(
             "[%s][%s][%s] = [%s] failed validation (%s)",
             keyspace,
             column_parent.getColumn_family(),
             FBUtilities.bytesToHex(column.name),
             FBUtilities.bytesToHex(column.value),
             me.getMessage()));
   }
 }