Package org.apache.accumulo.core.util

Examples of org.apache.accumulo.core.util.BadArgumentException


          }
        } else {
          shellState.getReader().printString("Not tracing\n");
        }
      } else
        throw new BadArgumentException("Argument must be 'on' or 'off'", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
    } else if (cl.getArgs().length == 0) {
      shellState.getReader().printString(Trace.isTracing() ? "on\n" : "off\n");
    } else {
      Shell.printException(new IllegalArgumentException("Expected 0 or 1 argument. There were " + cl.getArgs().length + "."));
      printHelp();
View Full Code Here


    if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
      try {
        shellState.getConnector().securityOperations().grantSystemPermission(user, SystemPermission.valueOf(permission[1]));
        Shell.log.debug("Granted " + user + " the " + permission[1] + " permission");
      } catch (IllegalArgumentException e) {
        throw new BadArgumentException("No such system permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      }
    } else if (permission[0].equalsIgnoreCase("Table")) {
      if (cl.hasOption(tableOpt.getOpt())) {
        String tableName = cl.getOptionValue(tableOpt.getOpt());
        try {
          shellState.getConnector().securityOperations().grantTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
          Shell.log.debug("Granted " + user + " the " + permission[1] + " permission on table " + tableName);
        } catch (IllegalArgumentException e) {
          throw new BadArgumentException("No such table permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
        }
      } else if (cl.hasOption(tablePatternOpt.getOpt())) {
        for (String tableName : shellState.getConnector().tableOperations().list()) {
          if (tableName.matches(cl.getOptionValue(tablePatternOpt.getOpt()))) {
            try {
              shellState.getConnector().securityOperations().grantTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
              Shell.log.debug("Granted " + user + " the " + permission[1] + " permission on table " + tableName);
            } catch (IllegalArgumentException e) {
              throw new BadArgumentException("No such table permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
            }
          }
        }
      } else {
        throw new BadArgumentException("You must provide a table name", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      }
    } else {
      throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
    }
    return 0;
  }
View Full Code Here

       
        EscapeTokenizer colToks = new EscapeTokenizer(col, ":");
        Iterator<String> tokIter = colToks.iterator();
        Text cf = null, cq = null;
        if (colToks.count() < 1 || colToks.count() > 2)
          throw new BadArgumentException("column must be in the format cf[:cq]", fullCommand, fullCommand.indexOf(col));
        cf = new Text(tokIter.next());
        if (colToks.count() == 2)
          cq = new Text(tokIter.next());
       
        aggregators.add(new PerColumnIteratorConfig(cf, cq, className));
View Full Code Here

    if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
      try {
        shellState.getConnector().securityOperations().revokeSystemPermission(user, SystemPermission.valueOf(permission[1]));
        Shell.log.debug("Revoked from " + user + " the " + permission[1] + " permission");
      } catch (IllegalArgumentException e) {
        throw new BadArgumentException("No such system permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      }
    } else if (cl.hasOption(tableOpt.getOpt()) && permission[0].equalsIgnoreCase("Table")) {
      String tableName = cl.getOptionValue(tableOpt.getOpt());
      try {
        shellState.getConnector().securityOperations().revokeTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
        Shell.log.debug("Revoked from " + user + " the " + permission[1] + " permission on table " + tableName);
      } catch (IllegalArgumentException e) {
        throw new BadArgumentException("No such table permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      }
    } else {
      throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
    }
    return 0;
  }
View Full Code Here

   
    if (cl.hasOption(deleteOpt.getOpt())) {
      // delete property from table
      String property = cl.getOptionValue(deleteOpt.getOpt());
      if (property.contains("="))
        throw new BadArgumentException("Invalid '=' operator in delete operation.", fullCommand, fullCommand.indexOf('='));
      if (tableName != null) {
        if (!Property.isValidTablePropertyKey(property))
          Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
       
        shellState.getConnector().tableOperations().removeProperty(tableName, property);
        Shell.log.debug("Successfully deleted table configuration option.");
      } else {
        if (!Property.isValidZooPropertyKey(property))
          Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
        shellState.getConnector().instanceOperations().removeProperty(property);
        Shell.log.debug("Successfully deleted system configuration option");
      }
    } else if (cl.hasOption(setOpt.getOpt())) {
      // set property on table
      String property = cl.getOptionValue(setOpt.getOpt()), value = null;
      if (!property.contains("="))
        throw new BadArgumentException("Missing '=' operator in set operation.", fullCommand, fullCommand.indexOf(property));
     
      String pair[] = property.split("=", 2);
      property = pair[0];
      value = pair[1];
     
      if (tableName != null) {
        if (!Property.isValidTablePropertyKey(property))
          throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property));
       
        if (property.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey()))
          new ColumnVisibility(value); // validate that it is a valid expression
         
        shellState.getConnector().tableOperations().setProperty(tableName, property, value);
        Shell.log.debug("Successfully set table configuration option.");
      } else {
        if (!Property.isValidZooPropertyKey(property))
          throw new BadArgumentException("Property cannot be modified in zookeeper", fullCommand, fullCommand.indexOf(property));
       
        shellState.getConnector().instanceOperations().setProperty(property, value);
        Shell.log.debug("Successfully set system configuration option");
      }
    } else {
View Full Code Here

    if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
      try {
        shellState.getConnector().securityOperations().grantSystemPermission(user, SystemPermission.valueOf(permission[1]));
        Shell.log.debug("Granted " + user + " the " + permission[1] + " permission");
      } catch (IllegalArgumentException e) {
        throw new BadArgumentException("No such system permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      }
    } else if (permission[0].equalsIgnoreCase("Table")) {
      super.execute(fullCommand, cl, shellState);
    } else {
      throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
    }
    return 0;
  }
View Full Code Here

        if (ch == 'x') {
          hexChars = "";
        } else if (ch == ' ' || ch == '\'' || ch == '"' || ch == '\\') {
          token[tokenLength++] = inputBytes[i];
        } else {
          throw new BadArgumentException("can only escape single quotes, double quotes, the space character, the backslash, and hex input", input, i);
        }
      }
      // in a hex escape sequence
      else if (hexChars != null) {
        final int digit = Character.digit(ch, 16);
        if (digit < 0) {
          throw new BadArgumentException("expected hex character", input, i);
        }
        hexChars += ch;
        if (hexChars.length() == 2) {
          byte b;
          try {
            b = (byte) (0xff & Short.parseShort(hexChars, 16));
            if (!Character.isValidCodePoint(0xff & b))
              throw new NumberFormatException();
          } catch (NumberFormatException e) {
            throw new BadArgumentException("unsupported non-ascii character", input, i);
          }
          token[tokenLength++] = b;
          hexChars = null;
        }
      }
      // in a quote, either end the quote, start escape, or continue a token
      else if (inQuote) {
        if (ch == inQuoteChar) {
          inQuote = false;
          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
          tokenLength = 0;
        } else if (ch == '\\') {
          inEscapeSequence = true;
        } else {
          token[tokenLength++] = inputBytes[i];
        }
      }
      // not in a quote, either enter a quote, end a token, start escape, or continue a token
      else {
        if (ch == '\'' || ch == '"') {
          if (tokenLength > 0) {
            tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
            tokenLength = 0;
          }
          inQuote = true;
          inQuoteChar = ch;
        } else if (ch == ' ' && tokenLength > 0) {
          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
          tokenLength = 0;
        } else if (ch == '\\') {
          inEscapeSequence = true;
        } else if (ch != ' ') {
          token[tokenLength++] = inputBytes[i];
        }
      }
    }
    if (inQuote) {
      throw new BadArgumentException("missing terminating quote", input, input.length());
    } else if (inEscapeSequence || hexChars != null) {
      throw new BadArgumentException("escape sequence not complete", input, input.length());
    }
    if (tokenLength > 0) {
      tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
    }
  }
View Full Code Here

        ++exitCode;
        printException(e);
      }
    } else {
      ++exitCode;
      printException(new BadArgumentException("Unrecognized empty command", command, -1));
    }
    reader.flushConsole();
  }
View Full Code Here

        ++exitCode;
        printException(e);
      }
    } else {
      ++exitCode;
      printException(new BadArgumentException("Unrecognized empty command", command, -1));
    }
    reader.flushConsole();
  }
View Full Code Here

   
    Node parse(byte[] expression) {
      if (expression.length > 0) {
        Node node = parse_(expression);
        if (node == null) {
          throw new BadArgumentException("operator or missing parens", new String(expression, Constants.UTF8), index - 1);
        }
        if (parens != 0) {
          throw new BadArgumentException("parenthesis mis-match", new String(expression, Constants.UTF8), index - 1);
        }
        return node;
      }
      return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.util.BadArgumentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.