Package com.elasticinbox.rest

Examples of com.elasticinbox.rest.BadRequestException


    Mailbox mailbox = new Mailbox(user, domain);

    try {
      labelDAO.delete(mailbox, labelId);
    } catch (IllegalLabelException ile) {
      throw new BadRequestException(ile.getMessage());
    } catch (Exception e) {
      logger.error("Deleting label failed", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here


      in = new FileInputStream(file);
      messageDAO.put(mailbox, messageId, message, in);
      in.close();
    } catch (MimeParserException mpe) {
      logger.error("Unable to parse message: ", mpe);
      throw new BadRequestException("Parsing error. Invalid MIME message.");
    } catch (OverQuotaException oqe) {
      throw new WebApplicationException(Response
          .status(Status.NOT_ACCEPTABLE).entity(oqe.getMessage())
          .type("text/plain").build());
    } catch (IOException ioe) {
View Full Code Here

    try {
      messageIds = JSONUtils.toUUIDList(requestJSONContent);
    } catch (IllegalStateException jpe) {
      logger.info("Malformed JSON request: {}", jpe.getMessage());
      throw new BadRequestException("Malformed JSON request");
    }

    if (messageIds == null || messageIds.isEmpty()) {
      throw new BadRequestException("Malformed JSON request");
    }

    try {
      // Deduplicate message IDs
      List<UUID> depdupeMessageIds =
            new ArrayList<UUID>(new LinkedHashSet<UUID>(messageIds));

      // Prepare modification
      MessageModification modification = new MessageModification.Builder()
          .addLabels(addLabels).removeLabels(removeLabels)
          .addMarkers(addMarkers).removeMarkers(removeMarkers)
          .build();

      messageDAO.modify(mailbox, depdupeMessageIds, modification);
    } catch (IllegalLabelException ile) {
      throw new BadRequestException(ile.getMessage());
    } catch (Exception e) {
      logger.error("Message modifications failed: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

    try {
      messageIds = JSONUtils.toUUIDList(requestJSONContent);
    } catch (IllegalStateException jpe) {
      logger.info("Malformed JSON request: {}", jpe.getMessage());
      throw new BadRequestException("Malformed JSON request");
    }

    if (messageIds == null || messageIds.isEmpty()) {
      throw new BadRequestException("Malformed JSON request");
    }

    try {
      // Deduplicate message IDs
      List<UUID> depdupeMessageIds =
View Full Code Here

    Mailbox mailbox = new Mailbox(user, domain);

    try {
      accountDAO.add(mailbox);
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (IOException e) {
      logger.error("Account initialization failed: {}", mailbox.getId());
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

      // get message as JSON
      response = JSONUtils.fromObject(result);

    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.warn("Internal Server Error: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

      } else {
        response = Response.ok(blobDS.getUncompressedInputStream(),
            MediaType.TEXT_PLAIN).build();
      }
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.warn("Internal Server Error: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

    try {
      Message message = messageDAO.getParsed(mailbox, messageId);
      uri = message.getLocation();
      Assert.notNull(uri, "No source message");
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.warn("Internal Server Error: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
View Full Code Here

      mimeParser.parse(rawIn);
      part = mimeParser.getMessage().getPart(partId);
      partIn = mimeParser.getInputStreamByPartId(partId);
      rawIn.close();
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.warn("Internal Server Error: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    } finally {
      if (rawIn != null) rawIn.close();
View Full Code Here

      mimeParser.parse(rawIn);
      part = mimeParser.getMessage().getPartByContentId(contentId);
      partIn = mimeParser.getInputStreamByContentId(contentId);
      rawIn.close();
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.info("Internal Server Error: ", e);
      throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    } finally {
      if (rawIn != null) rawIn.close();
View Full Code Here

TOP

Related Classes of com.elasticinbox.rest.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.