Package com.google.walkaround.util.server.servlet

Examples of com.google.walkaround.util.server.servlet.BadRequestException


    int to;
    try {
      from = fromStr != null ? Integer.parseInt(fromStr) : 1;
      to = toStr != null ? Integer.parseInt(toStr) : (from + MAX_SIZE);
    } catch (NumberFormatException e) {
      throw new BadRequestException("Range not numeric: " + req.getQueryString(), e);
    }
    if (1 > from || from > to) {
      throw new BadRequestException("Invalid range: [" + from + ", " + to + ")");
    }
    if (to > from + MAX_SIZE) {
      throw new BadRequestException(
          "Range too large (max " + MAX_SIZE + "): [" + from + ", " + to + ")");
    }
    assert from <= to && to <= from + MAX_SIZE;
    return Pair.of(from, to);
  }
View Full Code Here


    } catch (PermanentFailure e) {
      throw new IOException(e);
    }

    if (result.isRejected()) {
      throw new BadRequestException(result.exception);
    }

    ServerMutateResponse response = new ServerMutateResponseGsonImpl();
    response.setResultingVersion(result.getResultingRevision());
    response.setBroadcastData(jsonBroadcastData(objectId, result.getBroadcastData()));
View Full Code Here

  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    try {
      xsrfHelper.verify(XSRF_ACTION, requireParameter(req, "token"));
    } catch (XsrfTokenExpiredException e) {
      throw new BadRequestException(e);
    } catch (InvalidSecurityTokenException e) {
      throw new BadRequestException(e);
    }
    String action = requireParameter(req, "action");
    if ("newwave".equals(action)) {
      SlobId newWaveId = waveletCreator.newConvWithGeneratedId(null, null, false);
      // TODO(ohler): Send 303, not 302.  See
      // http://en.wikipedia.org/wiki/Post/Redirect/Get .
      resp.sendRedirect(Searcher.makeWaveLink(newWaveId));
    } else {
      throw new BadRequestException("Unknown action: " + action);
    }
  }
View Full Code Here

    String visiblePart = helper.verifyAndGetVisiblePart(makeHiddenPart(action), token);
    long tokenTime;
    try {
      tokenTime = Long.parseLong(visiblePart);
    } catch (NumberFormatException e) {
      throw new BadRequestException(e);
    }

    if (tokenTime + expiryMs < System.currentTimeMillis()) {
      throw new XsrfTokenExpiredException("Token expired: " + action + ", " + userId
          + ", " + token);
View Full Code Here

    SignedObjectSessionGsonImpl signedSession;
    try {
      signedSession = GsonProto.fromGson(
          new SignedObjectSessionGsonImpl(), rawSessionString);
    } catch (MessageException e) {
      throw new BadRequestException("Failed to parse signed session", e);
    }
    xsrfHelper.verify(makeAction(signedSession.getSession()), signedSession.getSignature());
    return objectSessionFromProto(signedSession.getSession());
  }
View Full Code Here

  @Provides @RequestScoped
  ObjectSession provideVerifiedSession(ObjectSessionHelper helper, HttpServletRequest req) {
    try {
      return helper.getVerifiedSession(req);
    } catch (InvalidSecurityTokenException e) {
      throw new BadRequestException(e);
    } catch (XsrfTokenExpiredException e) {
      throw new BadRequestException(e);
    }
  }
View Full Code Here

  @Override
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    log.info(this + ": doPost()");
    if (req.getHeader("X-AppEngine-QueueName") == null) {
      throw new BadRequestException();
    }
    String storeType = requireParameter(req, STORE_TYPE_PARAM);
    SlobId slobId = new SlobId(requireParameter(req, SLOB_ID_PARAM));
    storeSelector.get(storeType).getPostCommitActionScheduler().taskInvoked(slobId);
  }
View Full Code Here

    ServerMutateRequest mutateRequest;
    try {
      mutateRequest = GsonProto.fromGson(new ServerMutateRequestGsonImpl(),
          requestString);
    } catch (MessageException e) {
      throw new BadRequestException("Failed to parse request: " + requestString, e);
    }
    ObjectSession session = ObjectSessionHelper.objectSessionFromProto(mutateRequest.getSession());
    ServerMutateResponse result =
        storeSelector.get(session.getStoreType()).getLocalMutationProcessor()
        .mutateObject(mutateRequest);
View Full Code Here

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    log.warning("Admin page requested by " + user.getEmail());
    if (!userService.isUserAdmin()) {
      log.severe("Admin page requested by non-admin user!");
      throw new BadRequestException();
    }
    resp.setContentType("text/html");
    Admin.write(resp.getWriter(), new GxpContext(getLocale(req)),
        analyticsAccount, EMPTY_CONTENT);
  }
View Full Code Here

          }
        } finally {
          tx.rollback();
        }
      } catch (NumberFormatException e) {
        throw new BadRequestException(e);
      } catch (PermanentFailure e) {
        throw new IOException(e);
      } catch (RetryableFailure e) {
        throw new IOException(e);
      }
View Full Code Here

TOP

Related Classes of com.google.walkaround.util.server.servlet.BadRequestException

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.