Package org.restlet.data

Examples of org.restlet.data.Request


    return this.refreshTime;
  }

  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(
View Full Code Here


    return null;
  }

  public void postStatusUpdate(org.eclipse.twipse.model.Status status) {
    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);
   
View Full Code Here

    return request;
  }
 

  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
View Full Code Here

  }
  public Collection<Status> getFriendsUpdatesSinceLatestRefresh() {
    String URL = BASE_URL+"statuses/friends_timeline.xml";
   
   
    Request request = new Request(Method.GET, URL);       
    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");
View Full Code Here

    }
    return null;
  }
  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

    xstream.omitField(Status.class, "description");
   
   
    String URL = BASE_URL+"statuses/friends/"+getScreenName()+".xml";
    System.out.println(URL);
    Request request = new Request(Method.GET, URL);
    auth(request);
    Map<User,Status> usersMap = new HashMap<User,Status>();
    Response response = client.handle(request);
    try {
      //System.out.println(response.getStatus()+response.getEntity().getText());
View Full Code Here

  {
    String httpUrlBase =
        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
            + "/StateModelDefs/MasterSlave";
    Reference resourceRef = new Reference(httpUrlBase);
    Request request = new Request(Method.GET, resourceRef);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
    result.write(sw);
    ObjectMapper mapper = new ObjectMapper();
    ZNRecord zn = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);

    Map<String, String> paraMap = new HashMap<String, String>();

    paraMap.put(JsonParameters.MANAGEMENT_COMMAND,
                ClusterSetup.addStateModelDef);

    ZNRecord r = new ZNRecord("Test");
    r.merge(zn);
    StateModelDefinition newStateModel = new StateModelDefinition(r);

    httpUrlBase =
        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/StateModelDefs";
    resourceRef = new Reference(httpUrlBase);
    request = new Request(Method.POST, resourceRef);
    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
                          + ClusterRepresentationUtil.ObjectToJson(paraMap) + "&"
                          + JsonParameters.NEW_STATE_MODEL_DEF + "="
                          + ClusterRepresentationUtil.ZNRecordToJson(r),
                      MediaType.APPLICATION_ALL);
    client = new Client(Protocol.HTTP);
View Full Code Here

                                           Map<String, String> jsonParameters,
                                           boolean hasException) throws IOException
  {
    Reference resourceRef = new Reference(url);

    Request request = new Request(Method.POST, resourceRef);
    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
                          + ClusterRepresentationUtil.ObjectToJson(jsonParameters),
                      MediaType.APPLICATION_ALL);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);
    Representation result = response.getEntity();
View Full Code Here

    paraMap.put(JsonParameters.CLUSTER_NAME, clusterName);
    paraMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.addCluster);

    Reference resourceRef = new Reference(httpUrlBase);

    Request request = new Request(Method.POST, resourceRef);

    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
        + ClusterRepresentationUtil.ObjectToJson(paraMap), MediaType.APPLICATION_ALL);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);

    Representation result = response.getEntity();
View Full Code Here

                                           Map<String, String> extraForm,
                                           boolean hasException) throws IOException
  {
    Reference resourceRef = new Reference(url);

    Request request = new Request(Method.POST, resourceRef);
    String entity =
        JsonParameters.JSON_PARAMETERS + "="
            + ClusterRepresentationUtil.ObjectToJson(jsonParameters);
    for (String key : extraForm.keySet())
    {
      entity = entity + "&" + (key + "=" + extraForm.get(key));
    }
    request.setEntity(entity, MediaType.APPLICATION_ALL);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
    result.write(sw);
View Full Code Here

TOP

Related Classes of org.restlet.data.Request

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.