Package org.apache.accumulo.core.util

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


      if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
        try {
          shellState.connector.securityOperations().revokeSystemPermission(user, SystemPermission.valueOf(permission[1]));
          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.connector.securityOperations().revokeTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
          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.getArgs()[0].equalsIgnoreCase("on"))
          Shell.setDebugging(true);
        else if (cl.getArgs()[0].equalsIgnoreCase("off"))
          Shell.setDebugging(false);
        else
          throw new BadArgumentException("Argument must be 'on' or 'off'", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
      } else if (cl.getArgs().length == 0) {
        shellState.reader.printString(Shell.isDebuggingEnabled() ? "on\n" : "off\n");
      } else {
        printException(new IllegalArgumentException("Expected 0 or 1 argument. There were " + cl.getArgs().length + "."));
        printHelp();
View Full Code Here

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

        if (ch == 'x')
          hexChars = "";
        else if (ch == ' ' || ch == '\'' || ch == '"' || ch == '\\')
          sb.append(ch);
        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) {
        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(b))
              throw new NumberFormatException();
          } catch (NumberFormatException e) {
            throw new BadArgumentException("unsupported non-ascii character", input, i);
          }
          sb.append((char) 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(sb.toString());
          sb = new StringBuilder();
        } else if (ch == '\\')
          inEscapeSequence = true;
        else
          sb.append(ch);
      }
      // not in a quote, either enter a quote, end a token, start escape, or continue a token
      else {
        if (ch == '\'' || ch == '"') {
          if (sb.length() > 0) {
            tokens.add(sb.toString());
            sb = new StringBuilder();
          }
          inQuote = true;
          inQuoteChar = ch;
        } else if (ch == ' ' && sb.length() > 0) {
          tokens.add(sb.toString());
          sb = new StringBuilder();
        } else if (ch == '\\')
          inEscapeSequence = true;
        else if (ch != ' ')
          sb.append(ch);
      }
    }
    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 (sb.length() > 0)
      tokens.add(sb.toString());
  }
View Full Code Here

      if (cl.getArgs()[0].equalsIgnoreCase("on"))
        Shell.setDebugging(true);
      else if (cl.getArgs()[0].equalsIgnoreCase("off"))
        Shell.setDebugging(false);
      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(Shell.isDebuggingEnabled() ? "on\n" : "off\n");
    } else {
      Shell.printException(new IllegalArgumentException("Expected 0 or 1 argument. There were " + cl.getArgs().length + "."));
      printHelp();
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), index - 1);
        }
        if (parens != 0) {
          throw new BadArgumentException("parenthesis mis-match", new String(expression), index - 1);
        }
        return node;
      }
      return null;
    }
View Full Code Here

    }
   
    Node processTerm(int start, int end, Node expr, byte[] expression) {
      if (start != end) {
        if (expr != null)
          throw new BadArgumentException("expression needs | or &", new String(expression), start);
        return new Node(start, end);
      }
      if (expr == null)
        throw new BadArgumentException("empty term", new String(expression), start);
      return expr;
    }
View Full Code Here

        switch (expression[index++]) {
          case '&': {
            expr = processTerm(termStart, index - 1, expr, expression);
            if (result != null) {
              if (!result.type.equals(NodeType.AND))
                throw new BadArgumentException("cannot mix & and |", new String(expression), index - 1);
            } else {
              result = new Node(NodeType.AND);
            }
            result.add(expr);
            expr = null;
            termStart = index;
            break;
          }
          case '|': {
            expr = processTerm(termStart, index - 1, expr, expression);
            if (result != null) {
              if (!result.type.equals(NodeType.OR))
                throw new BadArgumentException("cannot mix | and &", new String(expression), index - 1);
            } else {
              result = new Node(NodeType.OR);
            }
            result.add(expr);
            expr = null;
            termStart = index;
            break;
          }
          case '(': {
            parens++;
            if (termStart != index - 1 || expr != null)
              throw new BadArgumentException("expression needs & or |", new String(expression), index - 1);
            expr = parse_(expression);
            termStart = index;
            break;
          }
          case ')': {
            parens--;
            Node child = processTerm(termStart, index - 1, expr, expression);
            if (child == null && result == null)
              throw new BadArgumentException("empty expression not allowed", new String(expression), index);
            if (result == null)
              return child;
            if (result.type == child.type)
              for (Node c : child.children)
                result.add(c);
            else
              result.add(child);
            result.end = index - 1;
            return result;
          }
          default: {
            byte c = expression[index - 1];
            if (!Authorizations.isValidAuthChar(c))
              throw new BadArgumentException("bad character (" + c + ")", new String(expression), index - 1);
          }
        }
      }
      Node child = processTerm(termStart, index, expr, expression);
      if (result != null)
        result.add(child);
      else
        result = child;
      if (result.type != NodeType.TERM)
        if (result.children.size() < 2)
          throw new BadArgumentException("missing term", new String(expression), index);
      return result;
    }
View Full Code Here

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

public class DropUserCommand extends Command {
  @Override
  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException {
    String user = cl.getArgs()[0];
    if (shellState.getConnector().whoami().equals(user))
      throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user));
    shellState.getConnector().securityOperations().dropUser(user);
    Shell.log.debug("Deleted user " + user);
    return 0;
  }
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.