Package edu.wpi.cs.wpisuitetng.network.models

Examples of edu.wpi.cs.wpisuitetng.network.models.ResponseModel


  public void responseSuccess(IRequest iReq) {
    // cast observable to request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    if (response.getStatusCode() == 200) {
      // parse the response       
      Defect[] defects = Defect.fromJSONArray(response.getBody());

      // notify the controller
      controller.receivedData(defects);
    }
    else {
View Full Code Here


  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    // check the response code of the request
    if (response.getStatusCode() != 200) {
      controller.errorRetrievingDefect("Received " + iReq.getResponse().getStatusCode() + " error from server: " + iReq.getResponse().getStatusMessage());
      return;
    }

    // parse the defect received from the core
    Defect[] defects = Defect.fromJSONArray(response.getBody());
    if (defects.length > 0 && defects[0] != null) {
      controller.showDefect(defects[0]);
    }
    else {
      controller.errorRetrievingDefect("No defects received.");
View Full Code Here

  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    // check the response code of the request
    if (response.getStatusCode() != 200) {
      controller.requestFailed();
      return;
    }

    // parse the list of defects received from the core
    Defect[] defects = Defect.fromJSONArray(response.getBody());

    // make sure that there is actually a defect in the body     
    if (defects.length > 0 && defects[0] != null) {
      controller.receivedResponse(defects[0]);
    }
View Full Code Here

          reader.close();
        }
      }
     
      // create Response
      ResponseModel response = new Response(responseCode, responseMessage, responseHeaders, responseBody);
     
      // set the Request's response to the newly created response
      request.setResponse(response);
    } catch (IOException e) {
      exceptionRecv = e;
View Full Code Here

*/
public class MyRequestObserver implements RequestObserver {
  @Override
  public void responseSuccess(IRequest iReq) {
      // get the response from the request
      ResponseModel response = iReq.getResponse();

      // print the body
      System.out.println("Received response: " + response.getBody());

  }
View Full Code Here

  private class Handler implements Container {
    private RequestModel lastReceived;
    private ResponseModel cannedResponse;
   
    public Handler() {
      cannedResponse = new ResponseModel();
      cannedResponse.setStatusCode(200);
      cannedResponse.setStatusMessage("OK");
      cannedResponse.setBody("");
    }
View Full Code Here

   * @see edu.wpi.cs.wpisuitetng.network.RequestObserver#responseSuccess(edu.wpi.cs.wpisuitetng.network.models.IRequest)
   */
  @Override
  public void responseSuccess(IRequest iReq) {
    // Get the response to the given request
    final ResponseModel response = iReq.getResponse();
   
    // Parse the message out of the response body
    final PostBoardMessage message = PostBoardMessage.fromJson(response.getBody());
   
    // Pass the messages back to the controller
    controller.addMessageToModel(message);
  }
View Full Code Here

  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();

    // print the body
    System.out.println("Received response: " + response.getBody()); //TODO change this to logger
    if (response.getStatusCode() == 200) {
      // parse the defect from the body
      final Defect defect = Defect.fromJSON(response.getBody());

      // make sure the defect isn't null
      if (defect != null) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
View Full Code Here

  public void responseSuccess(IRequest iReq) {
    // cast observable to a Request
    Request request = (Request) iReq;

    // get the response from the request
    ResponseModel response = request.getResponse();


    // print the body
    System.out.println("Received response: " + response.getBody()); //TODO change this to logger

    if (response.getStatusCode() == 201) {
      // parse the defect from the body
      final Defect defect = Defect.fromJSON(response.getBody());

      // make sure the defect isn't null
      if (defect != null) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
View Full Code Here

   */
  @Test(expected = IllegalStateException.class)
  public void testSetResponseIllegalStateException() {
    Request r = new Request(config, null, HttpMethod.GET);
    r.running = true;
    r.setResponse(new ResponseModel());
  }
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.network.models.ResponseModel

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.