Examples of ResponseBean


Examples of org.onebusaway.api.model.ResponseBean

    _action.setId("1");
    _action.setTime(new Date(now));

    _action.show();
   
    ResponseBean model = _action.getModel();
    FeedMessage feed = (FeedMessage) model.getData();
    assertEquals(now / 1000, feed.getHeader().getTimestamp());
    assertEquals(2, feed.getEntityCount());

    {
      FeedEntity entity = feed.getEntity(0);
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

    long t = System.currentTimeMillis();

    DefaultHttpHeaders headers = action.index();
    assertEquals(200, headers.getStatus());

    ResponseBean response = action.getModel();
    assertEquals(200, response.getCode());
    assertEquals(2, response.getVersion());

    @SuppressWarnings("unchecked")
    EntryWithReferencesBean<TimeBean> entry = (EntryWithReferencesBean<TimeBean>) response.getData();
    TimeBean time = entry.getEntry();
   
    assertNotNull(time);

    long delta = Math.abs(time.getTime() - t);
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

    _action.setId("1");
    _action.setTime(new Date(now));

    _action.show();
   
    ResponseBean model = _action.getModel();
    FeedMessage feed = (FeedMessage) model.getData();
    assertEquals(now / 1000, feed.getHeader().getTimestamp());
    assertEquals(2, feed.getEntityCount());

    {
      FeedEntity entity = feed.getEntity(0);
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

    _action.setId("1");
    _action.setTime(new Date(now));

    _action.show();

    ResponseBean model = _action.getModel();
    FeedMessage feed = (FeedMessage) model.getData();
    assertEquals(now / 1000, feed.getHeader().getTimestamp());
    assertEquals(2, feed.getEntityCount());

    {
      FeedEntity entity = feed.getEntity(0);
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

  }

  @Override
  public String fromObject(Object obj, String resultCode, Writer stream)
      throws IOException {
    ResponseBean response = (ResponseBean) obj;
    if (response.getData() != null && response.getData() instanceof Message) {
      Message message = (Message) response.getData();
      /**
       * Instead of writing to the output Writer, we write directly to the
       * HttpServletResponse output stream. That way, we can avoid any weirdness
       * with encoding the serialized protobuf to a String.
       */
      HttpServletResponse res = ServletActionContext.getResponse();
      message.writeTo(res.getOutputStream());
    } else {
      stream.write(response.getText());
    }
    return null;
  }
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

   *
   ****/

  private Class<?> getEntityType(Object obj) {
    if (obj instanceof ResponseBean) {
      ResponseBean response = (ResponseBean) obj;
      if (response.getData() == null)
        return response.getClass();
      return getEntityType(response.getData());
    } else if (obj instanceof EntryWithReferencesBean) {
      EntryWithReferencesBean<?> entry = (EntryWithReferencesBean<?>) obj;
      return entry.getEntry().getClass();
    } else if (obj instanceof ListWithReferencesBean) {
      ListWithReferencesBean<?> list = (ListWithReferencesBean<?>) obj;
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

  }

  @SuppressWarnings("unchecked")
  private List<?> getEntityValues(Object obj) {
    if (obj instanceof ResponseBean) {
      ResponseBean response = (ResponseBean) obj;
      if (response.getData() == null)
        return Arrays.asList(response);
      return getEntityValues(response.getData());
    } else if (obj instanceof EntryWithReferencesBean) {
      EntryWithReferencesBean<?> entry = (EntryWithReferencesBean<?>) obj;
      return Arrays.asList(entry.getEntry());
    } else if (obj instanceof ListWithReferencesBean) {
      ListWithReferencesBean<?> list = (ListWithReferencesBean<?>) obj;
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

    return _keyService.getPermission(keys[0], "api");
  }

  private String unauthorized(ActionInvocation invocation, String reason) throws IOException {
    ActionProxy proxy = invocation.getProxy();
    ResponseBean response = new ResponseBean(1, ResponseCodes.RESPONSE_UNAUTHORIZED, reason, null);
    DefaultHttpHeaders methodResult = new DefaultHttpHeaders().withStatus(response.getCode());
    return _handlerSelector.handleResult(proxy.getConfig(), methodResult, response);
  }
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

  /*****************************************************************************
   * Response Bean Generation Methods
   ****************************************************************************/

  protected DefaultHttpHeaders setOkResponse(Object data) {
    _response = new ResponseBean(getReturnVersion(), ResponseCodes.RESPONSE_OK,
        "OK", data);
    return new DefaultHttpHeaders();
  }
View Full Code Here

Examples of org.onebusaway.api.model.ResponseBean

  }

  protected DefaultHttpHeaders setValidationErrorsResponse() {
    ValidationErrorBean bean = new ValidationErrorBean(new ArrayList<String>(
        getActionErrors()), getFieldErrors());
    _response = new ResponseBean(getReturnVersion(),
        ResponseCodes.RESPONSE_INVALID_ARGUMENT, "validation error", bean);
    return new DefaultHttpHeaders().withStatus(_response.getCode());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.