FolderId folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("organizer@company.com"))
/** * Build Mailbox object from email * * @param email */ public Mailbox(String email) { isEmailAddress(email, "Mailbox ID should be valid RFC5322 email address"); // use email as mailbox id this.id = email.toLowerCase(); //TODO: add support for mailbox aliasing }
ItemView iview = new ItemView(1); Mailbox mb = new Mailbox(); mb.setAddress("mymailbox@mycompany.com"); FolderId folderId = new FolderId(WellKnownFolderName.Inbox, mb); FindItemsResults<Item> findResults = service.findItems(folderId, iview);
@Override public Message getParsed(final Mailbox mailbox, final UUID messageId) { return MessagePersistence.fetch(mailbox.getId(), messageId, true); }
@Override public String getIdentifier() throws IOException { logger.debug("POP3: Get identifier"); return mailbox.toString(); }
@Override public List<UUID> getMessageIds(final Mailbox mailbox, final int labelId, final UUID start, final int count, final boolean reverse) { return LabelIndexPersistence.get(mailbox.getId(), labelId, start, count, reverse); }
/** * Delete message * * @param account * @param messageId * @return */ @DELETE @Produces(MediaType.APPLICATION_JSON) public Response deleteMessage( @PathParam("user") final String user, @PathParam("domain") final String domain, @PathParam("messageid") UUID messageId) { Mailbox mailbox = new Mailbox(user, domain); try { messageDAO.delete(mailbox, messageId); } catch (Exception e) { logger.warn("Internal Server Error: ", e); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } return Response.noContent().build(); }
public MessageAggregator(final Mailbox mailbox, final List<UUID> messageIds) { // get message headers messages = MessagePersistence.fetch(mailbox.getId(), messageIds, false); invalidMessageIds = new HashSet<UUID>(messageIds); invalidMessageIds.removeAll(this.getValidMessageIds()); }
//Create a inclusive view FolderView fv = new FolderView(100); fv.setTraversal(FolderTraversal.Deep); //Find ID of parent calendar FolderId sharedFolderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("email.address@of-thing-sharing-calendar")); //Find children of that calendar FindFoldersResults findResults = service.findFolders(sharedFolderId, fv);
/** * Initialize new account * * @param account * @return */ @POST @Produces(MediaType.APPLICATION_JSON) public Response add( @PathParam("user") final String user, @PathParam("domain") final String domain) { 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); } URI messageUri = uriInfo.getAbsolutePathBuilder().path("mailbox").build(); return Response.created(messageUri).entity(JSONResponse.OK).build(); }
@Override public String getBlobName(BlobNameBuilder builder) { Assert.notNull(builder.messageId, "message id cannot be null"); Assert.notNull(builder.mailbox, "mailbox cannot be null"); return builder.messageId.toString() + ":" + builder.mailbox.getId(); }
/** * Scrub mailbox and recalculate counters * * @param account * @return */ @POST @Path("counters") @Produces(MediaType.APPLICATION_JSON) public Response scrubCounters( @PathParam("user") final String user, @PathParam("domain") final String domain) { Mailbox mailbox = new Mailbox(user, domain); LabelMap calculatedCounters = messageDAO.scrub(mailbox, false); labelDAO.setCounters(mailbox, calculatedCounters); return Response.noContent().build(); }
@Override public Map<UUID, Message> getMessageIdsWithMetadata(final Mailbox mailbox, final int labelId, final UUID start, final int count, boolean reverse, boolean includeBody) { List<UUID> messageIds = getMessageIds(mailbox, labelId, start, count, reverse); return MessagePersistence.fetch(mailbox.getId(), messageIds, includeBody); }
/** * Scrub mailbox, rebuild indexes and recalculate counters * * @param account * @return */ @POST @Path("indexes") @Produces(MediaType.APPLICATION_JSON) public Response scrubIndexes( @PathParam("user") final String user, @PathParam("domain") final String domain) { Mailbox mailbox = new Mailbox(user, domain); LabelMap calculatedCounters = messageDAO.scrub(mailbox, true); labelDAO.setCounters(mailbox, calculatedCounters); return Response.noContent().build(); }
@Override public Map<Integer, String> getAll(final Mailbox mailbox) { return AccountPersistence.getLabels(mailbox.getId()).getNameMap(); }
/** * Purge deleted messages older than given date * * @param account * @param age * @return */ @PUT @Path("purge") @Produces(MediaType.APPLICATION_JSON) public Response purge( @PathParam("user") final String user, @PathParam("domain") final String domain, @QueryParam("age") Date age) { Mailbox mailbox = new Mailbox(user, domain); // set date to now if not given (purges all messages) if (age == null) age = new Date(); try { messageDAO.purge(mailbox, age); } catch (Exception e) { logger.error("Failed to purge messages:", e); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } return Response.noContent().build(); }