Package edu.wpi.cs.wpisuitetng.network

Examples of edu.wpi.cs.wpisuitetng.network.Request


  /**
   * Sends a request for all of the defects
   */
  public void refreshData() {   
    final RequestObserver requestObserver = new RetrieveAllDefectsRequestObserver(this);
    Request request;
    request = Network.getInstance().makeRequest("defecttracker/defect", HttpMethod.GET);
    request.addObserver(requestObserver);
    request.send();
  }
View Full Code Here


  }

  @Override
  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());
View Full Code Here

  }

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

        JOptionPane.showMessageDialog(parentView, "The defect ID you entered is not valid.", "Invalid Defect ID", JOptionPane.WARNING_MESSAGE);
        return;
      }

      // Generate the request
      Request request;
      request = Network.getInstance().makeRequest("defecttracker/defect/" + id, HttpMethod.GET);
      request.addObserver(new LookupRequestObserver(this));
      request.send();
    }
  }
View Full Code Here

      // make sure the user actually clicked on a row
      if (row > -1) {
        String defectId = (String) resultsTable.getValueAt(row, 0);

        // Create and send a request for the defect with the given ID
        Request request;
        request = Network.getInstance().makeRequest("defecttracker/defect/" + defectId, HttpMethod.GET);
        request.addObserver(new RetrieveDefectRequestObserver(this));
        request.send();
      }
    }
  }
View Full Code Here

  }

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

   * Save the view's Defect model to the server (asynchronous).
   */
  public void save() {
    final DefectPanel panel = (DefectPanel) view.getDefectPanel();
    final RequestObserver requestObserver = (panel.getEditMode() == Mode.CREATE) ? new CreateDefectRequestObserver(view) : new UpdateDefectRequestObserver(view);
    Request request;
    panel.getParent().setInputEnabled(false);
    request = Network.getInstance().makeRequest("defecttracker/defect", (panel.getEditMode() == Mode.CREATE) ? HttpMethod.PUT : HttpMethod.POST);
    request.setBody(panel.getEditedModel().toJSON());
    request.addObserver(requestObserver);
    request.send();
  }
View Full Code Here

   */
  public void saveComment() {
    final String commentText = view.getCommentField().getText();
    if (commentText.length() > 0) {
      final RequestObserver requestObserver = new SaveCommentObserver(this);
      final Request request = Network.getInstance().makeRequest(
          "defecttracker/comment", HttpMethod.PUT);
      final Comment comment = new Comment(model.getId(), model.getCreator(), view.getCommentField().getText());
      view.getCommentField().setText("");
      request.setBody(comment.toJSON());
      request.addObserver(requestObserver);
      request.send();
    }
  }
View Full Code Here

    // The first Request's body
    String body1 = "The request body of the manually configured Request";

    // Make a new POST Request.
    Request manualRequest = new Request(config, "subpath", HttpMethod.POST)// construct the Request

    // Configure the request
    manualRequest.setBody(body1)// set the request body to send to the server
    manualRequest.addObserver(requestObserver)// Add the requestObserver to the request's set of Observers

    // Send the request!
    manualRequest.send();

    // This should print first.
    System.out.println("This was printed after sending the manually created Request!");





    /* ~~~ Below shows how to send a request using the Network. ~~~ */

    // Set the default network configuration. This step will likely already have been completed by Janeway, so you don't have to do it.
    Network.getInstance().setDefaultNetworkConfiguration(config);

    // The first Request's body
    String body2 = "The request body of the Request created by Network";

    // Make a new POST Request with the default network configuration.
    Request networkRequest = Network.getInstance().makeRequest("subpath", HttpMethod.POST);

    // Configure the request
    networkRequest.setBody(body2)// set the request body to send to the server
    networkRequest.addObserver(requestObserver)// Add the requestObserver to the request's set of Observers

    // Send the request!
    networkRequest.send();

    // This should print first.
    System.out.println("This was printed after sending the Request created using Network!");
  }
View Full Code Here

    if (message.length() > 0) {
      // Clear the text field
      view.getTxtNewMessage().setText("");
     
      // Send a request to the core to save this message
      final Request request = Network.getInstance().makeRequest("postboard/postboardmessage", HttpMethod.PUT); // PUT == create
      request.setBody(new PostBoardMessage(message).toJSON()); // put the new message in the body of the request
      request.addObserver(new AddMessageRequestObserver(this)); // add an observer to process the response
      request.send(); // send the request
    }
  }
View Full Code Here

TOP

Related Classes of edu.wpi.cs.wpisuitetng.network.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.