FolderId folderId = new FolderId(WellKnownFolderName.Calendar, new Mailbox("organizer@company.com"))
@Override public Mailbox authenticate(String username, String password) { Mailbox mailbox = new Mailbox(username); logger.debug("Authenticated " + mailbox.getId()); return mailbox; }
@Override public AccountStatus getAccountStatus(String username) { Mailbox mailbox = new Mailbox(username); logger.debug("Validating " + mailbox.getId()); return AccountStatus.ACTIVE; }
/** * 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(); }
//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);
/** * 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(); }
/** * 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(); }
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);
/** * 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(); }
@PathParam("domain") final String domain) final Mailbox mailbox = new Mailbox(user, domain);
/** * Delete label * * @param account * @param labelId * @return */ @DELETE @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public Response deleteLabel( @PathParam("user") String user, @PathParam("domain") String domain, @PathParam("id") Integer labelId) { 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); } return Response.noContent().build(); }
/** * 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(); }
@QueryParam("metadata") @DefaultValue("false") boolean getMetadata) Mailbox mailbox = new Mailbox(user, domain); byte[] response;
final String requestJSONContent) Mailbox mailbox = new Mailbox(user, domain); List<UUID> messageIds = null;
@QueryParam("count") @DefaultValue("50") int count) Mailbox mailbox = new Mailbox(user, domain); byte[] response;
/** * Redirect to original message blob URI * * @param account * @param messageId * @return */ @GET @Path("url") public Response getMessageUrl( @PathParam("user") final String user, @PathParam("domain") final String domain, @PathParam("messageid") final UUID messageId) { Mailbox mailbox = new Mailbox(user, domain); URI uri = null; 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); } return Response.temporaryRedirect(uri).build(); }
@PathParam("messageid") final UUID messageId) Mailbox mailbox = new Mailbox(user, domain);
@QueryParam("removemarker") Set<Marker> removeMarkers) Mailbox mailbox = new Mailbox(user, domain);
throws IOException Mailbox mailbox = new Mailbox(user, domain); InputStream rawIn = null; InputStream partIn = null;
throws IOException Mailbox mailbox = new Mailbox(user, domain); InputStream rawIn = null; InputStream partIn = null;