Examples of BadArgumentException


Examples of ORG.oclc.oai.server.verb.BadArgumentException

        }
        Crosswalks crosswalks = abstractCatalog.getCrosswalks();
  try {
      if (identifier == null || identifier.length() == 0) {
                if (debug) System.out.println("Bad argument");
    throw new BadArgumentException();
      }
      else if (!crosswalks.containsValue("oai_dc")) {
                if (debug) System.out.println("crosswalk not present: oai_dc");
    throw new CannotDisseminateFormatException("oai_dc");
      } else {
View Full Code Here

Examples of ORG.oclc.oai.server.verb.BadArgumentException

        }
  try {
      if (metadataPrefix == null || metadataPrefix.length() == 0
    || identifier == null || identifier.length() == 0) {
                if (debug) System.out.println("Bad argument");
    throw new BadArgumentException();
      }
      else if (!crosswalks.containsValue(metadataPrefix)) {
                if (debug) System.out.println("crosswalk not present: " + metadataPrefix);
    throw new CannotDisseminateFormatException(metadataPrefix);
      } else {
View Full Code Here

Examples of ORG.oclc.oai.server.verb.BadArgumentException

  if (debug) {
      System.out.println("AbstractCatalog.toFinestFrom: from=" + from);
      System.out.println("                            target=" + VALID_GRANULARITIES[supportedGranularityOffset]);
  }
  if (from.length() > VALID_GRANULARITIES[supportedGranularityOffset].length()) {
      throw new BadArgumentException();
  }
  if (from.length() != VALID_GRANULARITIES[supportedGranularityOffset].length()) {
      StringBuffer sb = new StringBuffer(from);
      if (sb.charAt(sb.length()-1) == 'Z')
    sb.setLength(sb.length()-1);
     
      sb.append(FROM_GRANULARITIES[supportedGranularityOffset].substring(sb.length()));
      from = sb.toString();
  }

  if (!isValidGranularity(from)) {
      throw new BadArgumentException();
  }

  return from;
    }
View Full Code Here

Examples of ORG.oclc.oai.server.verb.BadArgumentException

     */
    public String toFinestUntil(String until)
  throws BadArgumentException {
  if (until.length() == VALID_GRANULARITIES[supportedGranularityOffset].length()) {
      if (!isValidGranularity(until))
    throw new BadArgumentException();
      return until;
  }
  if (until.length() > VALID_GRANULARITIES[supportedGranularityOffset].length()) {
      throw new BadArgumentException();
  }
 
  StringBuffer sb = new StringBuffer(until);
  if (sb.charAt(sb.length()-1) == 'Z')
      sb.setLength(sb.length()-1);

  if (sb.length() < VALID_GRANULARITIES[0].length()) {
      while (sb.length() < 4) sb.append("9");
      switch (sb.length()) {
      case 4: // YYYY
    sb.append("-");
      case 5: // YYYY-
    sb.append("12");
      case 7: // YYYY-MM
    sb.append("-");
      case 8: // YYYY-MM-
    sb.append("31");
    break;
   
      case 6: // YYYY-M
      case 9: // YYYY-MM-D
    throw new BadArgumentException();
      }
  }

  until = sb.toString();
  if (until.length() == VALID_GRANULARITIES[supportedGranularityOffset].length()) {
      if (!isValidGranularity(until))
    throw new BadArgumentException();
      return until;
  }
 
  if (sb.length() < VALID_GRANULARITIES[1].length()) {
      switch (sb.length()) {
      case 10: // YYYY-MM-DD
    sb.append("T");
      case 11: // YYYY-MM-DDT
    sb.append("23");
      case 13: // YYYY-MM-DDThh
    sb.append(":");
      case 14: // YYYY-MM-DDThh:
    sb.append("59");
//       case 16: // YYYY-MM-DDThh:mm
//     sb.append("Z");
//     break;
   
//       case 12: // YYYY-MM-DDTh
//       case 15: // YYYY-MM-DDThh:m
//     throw new BadGranularityException();
//       }
//   }

//   until = sb.toString();
//   if (until.length() == VALID_GRANULARITIES[supportedGranularityOffset].length()) {
//       if (!isValidGranularity(until))
//     throw new BadGranularityException();
//       return until;
//   }

//   if (sb.charAt(sb.length()-1) == 'Z')
//       sb.setLength(sb.length()-1); // remove the trailing 'Z'
 
//   if (sb.length() < VALID_GRANULARITIES[2].length()) {
//       switch (sb.length()) {
      case 16: // YYYY-MM-DDThh:mm
    sb.append(":");
      case 17: // YYYY-MM-DDThh:mm:
    sb.append("59");
      case 19: // YYYY-MM-DDThh:mm:ss
    sb.append("Z");
    break;
   
      case 18: // YYYY-MM-DDThh:mm:s
    throw new BadArgumentException();
      }
  }

//   until = sb.toString();
//   if (until.length() == VALID_GRANULARITIES[supportedGranularityOffset].length()) {
//       if (!isValidGranularity(until))
//     throw new BadGranularityException();
//       return until;
//   }

//   if (sb.charAt(sb.length()-1) == 'Z')
//       sb.setLength(sb.length()-1); // remove the trailing 'Z'
 
//   switch (sb.length()) {
//   case 19: // YYYY-MM-DDThh:mm:ss
//       sb.append(".");
//   case 20: // YYYY-MM-DDThh:mm:ss.
//       sb.append("0");
//   case 21: // YYYY-MM-DDThh:mm:ss.s
//       sb.append("Z");
//       break;
//   }

  until = sb.toString();
  if (!isValidGranularity(until))
      throw new BadArgumentException();
  return until;
    }
View Full Code Here

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

        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

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

   
    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

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

    }
   
    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, Constants.UTF8), start);
        return new Node(start, end);
      }
      if (expr == null)
        throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), start);
      return expr;
    }
View Full Code Here

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

        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, Constants.UTF8), index - 1);
            } else {
              result = new Node(NodeType.AND);
            }
            result.add(expr);
            expr = null;
            termStart = index;
            termComplete = false;
            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, Constants.UTF8), index - 1);
            } else {
              result = new Node(NodeType.OR);
            }
            result.add(expr);
            expr = null;
            termStart = index;
            termComplete = false;
            break;
          }
          case '(': {
            parens++;
            if (termStart != index - 1 || expr != null)
              throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
            expr = parse_(expression);
            termStart = index;
            termComplete = false;
            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, Constants.UTF8), 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;
          }
          case '"': {
            if (termStart != index - 1)
              throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
           
            while (index < expression.length && expression[index] != '"') {
              if (expression[index] == '\\') {
                index++;
                if (expression[index] != '\\' && expression[index] != '"')
                  throw new BadArgumentException("invalid escaping within quotes", new String(expression, Constants.UTF8), index - 1);
              }
              index++;
            }
           
            if (index == expression.length)
              throw new BadArgumentException("unclosed quote", new String(expression, Constants.UTF8), termStart);
           
            if (termStart + 1 == index)
              throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), termStart);
           
            index++;
           
            termComplete = true;
           
            break;
          }
          default: {
            if (termComplete)
              throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
           
            byte c = expression[index - 1];
            if (!Authorizations.isValidAuthChar(c))
              throw new BadArgumentException("bad character (" + c + ")", new String(expression, Constants.UTF8), 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, Constants.UTF8), index);
      return result;
    }
View Full Code Here

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

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

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

   
    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
TOP
Copyright © 2018 www.massapi.com. 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.