Package dovetaildb.apiservice

Examples of dovetaildb.apiservice.ApiException


  protected Object handle(String url, boolean insertOrUpdate, HttpServletRequest request, HttpServletResponse response) {
    ParsedRequest req = new ParsedRequest(url, insertOrUpdate, request, response);
    if (req.db == null) req.db = "_metadata";
    RequestAcceptor acceptor = repo.getRequestAcceptor("_metadata");
    if (! acceptor.accept(req) ) {
      throw new ApiException("PermissionDenied","Permission denied");
//      if (! req.response.isCommitted()) {
//        try {
//          req.response.sendError(HttpServletResponse.SC_FORBIDDEN);
//          return;
//        } catch (IOException e) {
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

      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

        case DbServiceUtil.OP_HASH_BETWEEN_IE:
          isExclusive2 = true;
          term1 = sencode(query.get(1));
          term2 = sencode(query.get(2));
        default:
          throw new ApiException("QueryFormatError", "Unknown query operator: \""+query.get(0)+"\"");
        }
        queryNode = index.getRange(prefix, term1, term2, isExclusive1, isExclusive2, revNum);
      }
    }
    return new QueryNodeTemplate(queryNode, vars);
View Full Code Here

    case CopyOfDbServiceUtilDelme.OP_HASH_BETWEEN_IE:
      isExclusive2 = true;
      term1 = encoder.encode(fieldName, query.get(2));
      term2 = encoder.encode(fieldName, query.get(3));
    default:
      throw new ApiException("QueryFormatError", "Unknown query operator: \""+query.get(0)+"\"");
    }
    return index.fetchRange(term1, term2, isExclusive1, isExclusive2, revNum);
  }
View Full Code Here

    case CopyOfDbServiceUtilDelme.OP_HASH_BETWEEN_IE:
      isExclusive2 = true;
      term1 = encoder.encode(fieldName, query.get(2));
      term2 = encoder.encode(fieldName, query.get(3));
    default:
      throw new ApiException("QueryFormatError", "Unknown query operator: \""+query.get(0)+"\"");
    }
    return index.fetchRange(term1, term2, isExclusive1, isExclusive2, revNum);
  }
View Full Code Here

    case CopyOfDbServiceUtilDelme.OP_HASH_BETWEEN_IE:
      isExclusive2 = true;
      term1 = encoder.encode(fieldName, query.get(2));
      term2 = encoder.encode(fieldName, query.get(3));
    default:
      throw new ApiException("QueryFormatError", "Unknown query operator: \""+query.get(0)+"\"");
    }
    return index.fetchRange(term1, term2, isExclusive1, isExclusive2, revNum);
  }
View Full Code Here

    @Override
    public ScriptFunction getFunction(String fnname, int numParameters) {
      Object functionObject = scope.get(fnname, scope);
      if (functionObject == null) return null;
      if (!(functionObject instanceof Function))
        throw new ApiException("InvalidFunction","The object named \""+fnname+"\" is not a function.");
      Function function = (Function)functionObject;
      return new RhinoScriptFunction(function, numParameters, scope);
    }
View Full Code Here

    this.globals = globals;
    return new NativeScriptEnv();
  }

  public Object evaluateExpression(String code, Map<String, Object> globals) {
    throw new ApiException("LanguageFeatureNotSupported", "Cannot evaluate a Java expression at runtime");
  }
View Full Code Here

    @Override
    public Object call(Object[] parameters) {
      try {
        return method.invoke(instance, parameters);
      } catch (IllegalArgumentException e) {
        throw new ApiException("InvalidFunction", e.getMessage());
      } catch (IllegalAccessException e) {
        throw new ApiException("InvalidFunction", e.getMessage());
      } catch (InvocationTargetException e) {
        throw new ApiException("InvalidFunction", e.getMessage());
      }
    }
View Full Code Here

TOP

Related Classes of dovetaildb.apiservice.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.