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: "+operation.get(0));
      default:
        ranges.add(parseRange(prefix, opHash, operation));
      }
    }
View Full Code Here


    return env;
  }

  private DbRecord getDbRec(String name) {
    DbRecord rec = repo.get(name);
    if (rec == null) throw new ApiException("UnknownDb", "There is no database named \""+name+"\"");
    return rec;
  }
View Full Code Here

  }
 
  public void respond(HttpServletResponse response) {
    for(String header : headers) {
      int colonPos = header.indexOf(":");
      if (colonPos == -1) throw new ApiException("InvalidHttpHeader", "Header must contain a colon character");
      response.addHeader(header.substring(0, colonPos), header.substring(colonPos+1));
    }
    try {
      response.getWriter().write(content);
    } catch (IOException e) {
View Full Code Here

      if (engine == null) {
        ArrayList<String> availableNames = new ArrayList<String>();
        for(ScriptEngineFactory factory : manager.getEngineFactories()) {
          availableNames.add(StandardDbRepository.getScriptEngineFactoryName(factory));
        }
        throw new ApiException("UnknownScriptEngine", "\""+name+"\" is not a known script engine; available engines are: "+availableNames);
      }
    }
    return engine;
  }
View Full Code Here

      if (e.getColumnNumber() != -1) {
        desc += ", column "+e.getColumnNumber();
      }
      Throwable cause = e.getCause();
      if (cause != null && cause instanceof Exception) {
        throw new ApiException("ScriptException", desc, (Exception)cause);
      } else {
        throw new ApiException("ScriptException", desc, e);
      }
    }
  }
View Full Code Here

            Object target = engine.get(objectName);
            if (target != null) {
              try {
                return invocable.invokeMethod(target, functionName, args);
              } catch (NoSuchMethodException e) {
                throw new ApiException("UnknownFunction", "Method \""+functionName+"\" not defined on object \""+objectName+"\"");
              }
            }
          } else {
            try {
              return ((Invocable)engine).invokeFunction(functionName, args);
            } catch (NoSuchMethodException e) {}
          }
        } catch (ScriptException e) {
          throw new ApiException("ScriptException", e);
        }
      }
    }
    throw new ApiException("UnknownFunction", "Function not defined: \""+functionName+"\"");
  }
View Full Code Here

      return TYPE_CHAR_LIST;
    } else if (val instanceof Boolean) {
      if (((Boolean)val).booleanValue()) return TYPE_CHAR_TRUE;
      else return TYPE_CHAR_FALSE;
    } else {
      throw new ApiException("UnencodableValue","Result of type \""+val.getClass().getName()+"\" cannot be encoded in JSON (must be a String, Number, Boolean, HashMap, or ArrayList)");
    }
  }
View Full Code Here

      return HEADER_BYTE_L;
    } else if (val instanceof Boolean) {
      if (((Boolean)val).booleanValue()) return HEADER_BYTE_T;
      else return HEADER_BYTE_F;
    } else {
      throw new ApiException("UnencodableValue","Result of type \""+val.getClass().getName()+"\" cannot be encoded in JSON (must be a String, Number, Boolean, HashMap, or ArrayList)");
    }
  }
View Full Code Here

      if (list.size() > 0 && list.get(0) != null &&
          list.get(0) instanceof String &&
          SYMBOLS.contains(list.get(0).hashCode())) {
        return applyQueryToBagIndex(prefix, list, index, revNum);
      } else if (list.size() > 1) {
        throw new ApiException("QueryFormatError", "malformed list structure in query: "+pattern);
      } else {
        prefix = new CompoundBytes(prefix, HEADER_BYTE_LISTOPEN);
        if (list.isEmpty()) {
          queryNode = index.getTerm(prefix, revNum);
        } else {
View Full Code Here

      isExclusive2 = true;
      term1 = sencode(query.get(1));
      term2 = sencode(query.get(2));
      break;
    default:
      throw new ApiException("QueryFormatError", "Unknown query operator: \""+query.get(0)+"\"");
    }
    return new Range(prefix, term1, term2, !isExclusive1, !isExclusive2);
  }
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.