Package org.restlet.data

Examples of org.restlet.data.Response


    }

    private Representation getRepresentation() {
        checkNotNull(client, request);
        answerHandler.setAcceptedMediaTypes(request);
        final Response response = client.handle(request);
        final Status status = response.getStatus();
        if (status.isSuccess()) {
            return response.getEntity();
        } else {
            return handleFail(status);
        }
    }
View Full Code Here


        if (LOG.isDebugEnabled()) {
            LOG.debug("Client sends a request (method: " + request.getMethod() + ", uri: " + resourceUri + ")");
        }

        Response response = client.handle(request);
        if (throwException) {
            if (response instanceof Response) {
                Integer respCode = response.getStatus().getCode();
                if (respCode > 207) {
                    throw populateRestletProducerException(exchange, response, respCode);
                }
            }
        }
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Client sends a request (method: " + request.getMethod()
                    + ", uri: " + resourceUri + ")");
        }
       
        Response response = client.handle(request);
        binding.populateExchangeFromRestletResponse(exchange, response);
    }
View Full Code Here

    xstream.omitField(Status.class, "truncated");
   
    String URL = BASE_URL+"friendships/create/"+friendId+".xml";
    Request request = new Request(Method.GET, URL);   
    auth(request);
    Response response = client.handle(request);
   
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
      UserStatus s = (UserStatus)xstream.unmarshal(
          new DomReader(response.getEntityAsDom().getDocument()));
      System.out.println(s.getScreen_name()+"-"+s.getStatus().getText());
      return s;
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

    String URL = BASE_URL+"friendships/destroy/"+friendId+".xml";
    Request request = new Request(Method.GET, URL);
    //request.setEntity(status.getTextURLEncoded());
   
    auth(request);
    Response response = client.handle(request);
   
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
      User s = (User)xstream.unmarshal(new DomReader(response.getEntityAsDom().getDocument()));
      System.out.println(s.getScreen_name());
      return s;
    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

  public Collection<Status> getFriendsLatest20Updates() {
    String URL = BASE_URL+"statuses/friends_timeline.xml";
    Request request = new Request(Method.GET, URL);
    auth(request);   
    Response response = client.handle(request);
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
      StatusList s = (StatusList) xstream.unmarshal(
          new DomReader(response.getEntityAsDom().getDocument()));
      System.out.println(s.getStatuses().size());
      for(Status it : s.getStatuses()){
        System.out.println(it);
      }
      return s.getStatuses();
View Full Code Here

    String URL = BASE_URL+"statuses/update.xml?status="+status.getTextURLEncoded();
    Request request = new Request(Method.POST, URL);       
    //request.setEntity(status.getTextURLEncoded());
   
    auth(request);
    Response response = client.handle(request);
   
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
      Status s = (Status)xstream.unmarshal(new DomReader(response.getEntityAsDom().getDocument()));
      if(response.getStatus().equals(org.restlet.data.Status.SUCCESS_OK)){
        //TwipsePlugin.getDefault().getStatusList().add(s);
        //TwipsePlugin.getDefault().getStatusList().notifyObservers();       
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

  }
 

  public boolean isAuthenticated(){
    Request request = new Request(Method.GET, BASE_URL+"/account/verify_credentials");
    Response response = client.handle(request);
    try {
      return response.getEntity().getText().equalsIgnoreCase("Authorized");
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return false;
View Full Code Here

    auth(request);
    Date date = new Date(new Date().getTime()-this.getRefreshTime()*1000);
    //System.out.println(date);
    request.getConditions().setModifiedSince(date);
   
    Response response = client.handle(request);
    try {
      if(response.getStatus().equals(org.restlet.data.Status.REDIRECTION_NOT_MODIFIED)){
        //System.out.println("No updates");
        return null;
      }

      StatusList s = (StatusList) xstream.unmarshal(
          new DomReader(response.getEntityAsDom().getDocument()));
     
      for(Status it:s.getStatuses()){
        System.out.println(it);
      }
      return s.getStatuses();
View Full Code Here

  }
  public boolean authenticate(String screenName, String password) {
    String URL = BASE_URL+"statuses/friends_timeline.xml";
    Request request = new Request(Method.GET, URL);
    auth(request);   
    Response response = client.handle(request);
    System.out.println(response.getStatus());
    return response.getStatus().equals(org.restlet.data.Status.SUCCESS_OK);
  }
View Full Code Here

TOP

Related Classes of org.restlet.data.Response

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.