/** * 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(); }