Package com.almende.eve.rpc.jsonrpc

Examples of com.almende.eve.rpc.jsonrpc.JSONRPCException


        ObjectNode json = mapper.readValue(resp, ObjectNode.class);

        // check for errors
        if (json.has("error")) {
            ObjectNode error = (ObjectNode) json.get("error");
            throw new JSONRPCException(error);
        }

        // get items from the response
        ArrayNode items = null;
        if (json.has("items")) {
View Full Code Here



        // check for errors
        if (response.has("error")) {
            ObjectNode error = (ObjectNode) response.get("error");
            throw new JSONRPCException(error);
        }

        // get items from the response
        ArrayNode items = null;
        if (response.has("calendars")) {
View Full Code Here

        // check for errors
        if (event.has("error")) {
            ObjectNode error = (ObjectNode) event.get("error");
            Integer code = error.has("code") ? error.get("code").asInt() : null;
            if (code != null && (code.equals(404) || code.equals(410))) {
                throw new JSONRPCException(CODE.NOT_FOUND);
            }

            throw new JSONRPCException(error);
        }

        // check if canceled. If so, return null
        // TODO: be able to retrieve canceled events?
        if (event.has("status") && event.get("status").asText().equals("cancelled")) {
            throw new JSONRPCException(CODE.NOT_FOUND);
        }

        return event;
    }
View Full Code Here

        toEveEvent(event);

        // check for errors
        if (createdEvent.has("error")) {
            ObjectNode error = (ObjectNode) createdEvent.get("error");
            throw new JSONRPCException(error);
        }

        return createdEvent;
    }
View Full Code Here

        ObjectNode updatedEvent = mapper.readValue(resp, ObjectNode.class);

        // check for errors
        if (updatedEvent.has("error")) {
            ObjectNode error = (ObjectNode) updatedEvent.get("error");
            throw new JSONRPCException(error);
        }

        // convert from Google to Eve event
        toEveEvent(event);
View Full Code Here

            // check error code
            if (node.has("error")) {
                ObjectNode error = (ObjectNode) node.get("error");
                Integer code = error.has("code") ? error.get("code").asInt() : null;
                if (code != null && (code.equals(404) || code.equals(410))) {
                    throw new JSONRPCException(CODE.NOT_FOUND);
                }

                throw new JSONRPCException(error);
            } else {
                throw new Exception(resp);
            }
        }
    }
View Full Code Here

            else {
              // remote agent
              JSONRequest request = JSONRPC.createRequest(method, args);
              JSONResponse response = send(senderId, receiverUrl, request);
             
              JSONRPCException err = response.getError();
              if (err != null) {
                throw err;
              }
              else if (response.getResult() != null &&
                  !method.getReturnType().equals(Void.TYPE)) {
View Full Code Here

           
            final SyncCallback<JSONResponse> callback = new SyncCallback<JSONResponse>();
            try {
              sender.send(request, receiverUrl, callback, null);
            } catch (final IOException e1) {
              throw new JSONRPCException(CODE.REMOTE_EXCEPTION,
                  "", e1);
            }
           
            JSONResponse response;
            try {
              response = callback.get();
            } catch (final Exception e) {
              throw new JSONRPCException(CODE.REMOTE_EXCEPTION,
                  "", e);
            }
            final JSONRPCException err = response.getError();
            if (err != null) {
              throw err;
            } else if (response.getResult() != null
                && !method.getReturnType().equals(Void.TYPE)) {
              return TypeUtil.inject(response.getResult(),
View Full Code Here

    // invoke the other agent via the state, allowing the state
    // to route the request internally or externally
    String id = UUID.randomUUID().toString();
    JSONRequest request = new JSONRequest(id, method, jsonParams);
    JSONResponse response = getAgentFactory().send(getId(), url, request);
    JSONRPCException err = response.getError();
    if (err != null) {
      throw err;
    }
    if (type != null && type != void.class) {
      return response.getResult(type);
View Full Code Here

    send(request, url, callback, null);
    JSONResponse response;
    try {
      response = callback.get();
    } catch (final Exception e) {
      throw new JSONRPCException(CODE.REMOTE_EXCEPTION, "", e);
    }
    final JSONRPCException err = response.getError();
    if (err != null) {
      throw err;
    }
    return response;
  }
View Full Code Here

TOP

Related Classes of com.almende.eve.rpc.jsonrpc.JSONRPCException

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.