Package br.com.caelum.restfulie

Examples of br.com.caelum.restfulie.RestfulieException


      if(location == null || location.equals(""))
        return getRequest().getURI();
      else
        return new URI(location);
    } catch (URISyntaxException e) {
      throw new RestfulieException("Invalid URI received as a response", e);
    }
  }
View Full Code Here


    }

    final Map<String, String> headers = details.getHeaders();

    if (!headers.containsKey("Content-type")) {
      throw new RestfulieException(
          "You should set a content type prior to sending some payload.");
    }

//    ContentProducer cp = new ContentProducer() {
//      public void writeTo(OutputStream outstream) throws IOException {
//        Writer writer = new OutputStreamWriter(outstream, "UTF-8");
//        String type = headers.get("Content-type");
//        handlerFor(type).marshal(payload, writer);
//        writer.flush();
//      }
//    };
    StringWriter writer = new StringWriter();
    String type = headers.get("Content-type");
    try {
      handlerFor(type).marshal(payload, writer, client);
      writer.flush();
     
      HttpEntityEnclosingRequestBase verb = (HttpEntityEnclosingRequestBase) verbFor(method, uri);
      add(verb, headers);
      String string = writer.getBuffer().toString();
      verb.setEntity(new StringEntity(string));
      return execute(details, verb);
    } catch (IOException e) {
      throw new RestfulieException("Unable to marshal entity.", e);
    }

  }
View Full Code Here

    } else if(method.equals("OPTIONS")) {
      return new HttpOptions(uri);
    } else if(method.equals("HEAD")) {
      return new HttpHead(uri);
    }
    throw new RestfulieException("You can not " + method + " to " + uri + ", there is no such verb in the apache http API.");
  }
View Full Code Here

        lastExecuted.discard();
      }
      HttpResponse response = http.execute(method, getContext());
      return responseFor(response, details);
    } catch (ClientProtocolException e) {
      throw new RestfulieException(
          "Unable to execute " + method.getURI(), e);
    } catch (IOException e) {
      throw new RestfulieException(
          "Unable to execute " + method.getURI(), e);
    }
  }
View Full Code Here

   */
  public Request at(String uri) {
    try {
      return at(new URI(uri));
    } catch (URISyntaxException e) {
      throw new RestfulieException("Unable to build an URI for this request.", e);
    }
  }
View Full Code Here

   */
  public Request at(String uri) {
    try {
      return at(new URI(uri));
    } catch (URISyntaxException e) {
      throw new RestfulieException("Unable to build an URI for this request.", e);
    }
  }
View Full Code Here

    }

    final Map<String, String> headers = details.getHeaders();

    if (!headers.containsKey("Content-type")) {
      throw new RestfulieException(
          "You should set a content type prior to sending some payload.");
    }

//    ContentProducer cp = new ContentProducer() {
//      public void writeTo(OutputStream outstream) throws IOException {
//        Writer writer = new OutputStreamWriter(outstream, "UTF-8");
//        String type = headers.get("Content-type");
//        handlerFor(type).marshal(payload, writer);
//        writer.flush();
//      }
//    };
    StringWriter writer = new StringWriter();
    String type = headers.get("Content-type");
    try {
      handlerFor(type).marshal(payload, writer, client);
      writer.flush();
     
      HttpEntityEnclosingRequestBase verb = (HttpEntityEnclosingRequestBase) verbFor(method, uri);
      add(verb, headers);
      verb.setEntity(new StringEntity(writer.getBuffer().toString()));
      return execute(details, verb);
    } catch (IOException e) {
      throw new RestfulieException("Unable to marshal entity.", e);
    }

  }
View Full Code Here

    } else if(method.equals("OPTIONS")) {
      return new HttpOptions(uri);
    } else if(method.equals("HEAD")) {
      return new HttpHead(uri);
    }
    throw new RestfulieException("You can not " + method + " to " + uri + ", there is no such verb in the apache http API.");
  }
View Full Code Here

        lastExecuted.discard();
      }
      HttpResponse response = http.execute(method, getContext());
      return responseFor(response, details);
    } catch (ClientProtocolException e) {
      throw new RestfulieException(
          "Unable to execute " + method.getURI(), e);
    } catch (IOException e) {
      throw new RestfulieException(
          "Unable to execute " + method.getURI(), e);
    }
  }
View Full Code Here

   */
  public Request at(String uri) {
    try {
      return at(new URI(uri));
    } catch (URISyntaxException e) {
      throw new RestfulieException("Unable to build an URI for this request.", e);
    }
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.restfulie.RestfulieException

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.