Package dovetaildb.api

Examples of dovetaildb.api.ApiException


        switch(opHash) {
        case DbServiceUtil.OP_HASH_AS:
        case DbServiceUtil.OP_HASH_OR:
        case DbServiceUtil.OP_HASH_AND:
        case DbServiceUtil.OP_HASH_NOT:
          throw new ApiException("QueryFormatError", "Invalid narrowing operator: "+list.get(0));
        default:
          ranges.add(parseRange(prefix, opHash, list));
        }
      } else if (list.size() > 1) {
        throw new RuntimeException("malformed list structure in query: "+pattern);
View Full Code Here


        break;
      case DbServiceUtil.OP_HASH_OR:
      case DbServiceUtil.OP_HASH_AND:
        Object subQueryObject = query.get(1);
        if (!(subQueryObject instanceof List)) {
          throw new ApiException("QueryFormatError", "\""+query.get(0)+"\" operator must have a list in the first position, instead found: "+subQueryObject);
        }
        List<Object> subQueries = (List<Object>)query.get(1);
        int numQueries = subQueries.size();
        clauses = new ArrayList<QueryNode>(numQueries);
        for(int i=0; i<numQueries; i++) {
View Full Code Here

    char firstChar = ' ';
    try {
      firstChar = (char)reader.read();
    } catch(IOException e) {}
    if (firstChar != '/') {
      throw new ApiException("InvalidRequestUrl", "Url request is invalid");
    }
    db = reader.readUntil('/');
    String actionString = reader.readUntil('/');
    action = cannonicalActionStrings.get(actionString);
    if (action == null) {
      throw new ApiException("UnsupportedAction", "Unsupported action: \""+actionString+"\"");
    }
    this.request = request;
    this.response = response;
    parseUsingMap(parameterMap);
  }
View Full Code Here

//    return null;
//  }
 
  public static String chkGet(Map<String,String> map, String key) {
    String val = map.get(key);
    if (val == null) throw new ApiException("MissingParameter", "A parameter named \""+key+"\" is required in this call");
    return val;
  }
View Full Code Here

      case query:
        String queryString = chkGet(map,"query");
        try {
          query = Util.jsonDecode(queryString);
        } catch(Util.JsonParseRuntimeException e) {
          throw new ApiException("InvalidQuery", "Query is not JSON decodable: "+ e.getMessage());
        }
        options = (String)map.get("options");
        break;
      case put:
        String entryString = chkGet(map,"entry");
        try {
          entry = Util.jsonDecode(entryString);
        } catch(Util.JsonParseRuntimeException e) {
          throw new ApiException("InvalidEntry", "Entry is not JSON decodable: "+ e.getMessage());
        }
        break;
      case remove:
        id = chkGet(map,"id");
        break;
View Full Code Here

      try {
        try {
          Object ret = parser.parse(this);
          int ch = read();
          if (ch != -1 && ch != '/') {
            throw new ApiException("InvalidRequestUrl", "Url request is invalid");
          }
          return ret;
        } catch (ParseException e) {
          throw new ApiException("InvalidRequestUrl", "Url request is invalid");
        }
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }
View Full Code Here

          Object first = list.get(0);
          if (first != null && first instanceof String && isOperationLead((String)first)) {
            handleOperation(prefix, suffix, (String)first, list);
          }
        } else if (list.size() > 1) {
          throw new ApiException("QueryFormatError", "malformed list structure; only 1 element is allowed here: "+pattern);
        } else {
          prefix = new CompoundBytes(prefix, HEADER_BYTE_LISTOPEN);
          handleList(prefix, suffix, list);
        }
      } else {
View Full Code Here

    Map<String, String> params = new HashMap<String,String>();
    try {
      for(Map.Entry entry: (Set<Map.Entry>)request.getParameterMap().entrySet()) {
        String key = (String) entry.getKey();
        String[] vals = (String[])entry.getValue();
        if (vals.length > 1) throw new ApiException("DuplicateParamter","Parameter \""+key+"\" was duplicated");
        params.put(key, vals[0]);
      }
      req = new ParsedRequest(url, insertOrUpdate, request, response, params);
      ret = handle(req, params, response);
      boolean wasDirty = isDirty.getAndSet(false);
View Full Code Here

    ApiService api = repo.newSession(req.getDb(), req);
    if (Util.logger.isLoggable(Level.FINEST)) {
      Util.logger.log(Level.FINEST, "ApiService given: "+api);
    }
    if (api == null) {
      throw new ApiException("PermissionDenied","Permission denied");
    }
    try {
      switch(req.getAction()) {
      case call:
        List<Object> args = (List<Object>)Util.jsonDecode(req.getArguments());
View Full Code Here

  public static JSONObject toJsonError(Exception e) {
    Throwable cause = e.getCause();
    if (cause == null) cause = e;
    JSONObject error = new JSONObject();
    if (e instanceof ApiException) {
      ApiException apiException = (ApiException)e;
      error.put("name", apiException.exName);
      error.put("message", apiException.getMessage());
      if (apiException.stackTrace != null)
        error.put("stacktrace", apiException.stackTrace);
    } else {
      error.put("name", e.getClass().toString());
      error.put("message", e.toString());
View Full Code Here

TOP

Related Classes of dovetaildb.api.ApiException

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.