@GET @Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS) @Produces(APPLICATION_JSON) public Response getEmails( @PathParam(ID_PARAM_NAME) final String id, @javax.ws.rs.core.Context final HttpServletRequest request) { final UUID accountId = UUID.fromString(id); final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request)); final List<AccountEmailJson> emailsJson = new ArrayList<AccountEmailJson>(); for (final AccountEmail email : emails) { emailsJson.add(new AccountEmailJson(email.getAccountId().toString(), email.getEmail())); } return Response.status(Status.OK).entity(emailsJson).build(); }
@DELETE @Path("/{accountId:" + UUID_PATTERN + "}/" + EMAILS + "/{email}") @Produces(APPLICATION_JSON) public Response removeEmail( @PathParam(ID_PARAM_NAME) final String id, @PathParam("email") final String email, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) { final UUID accountId = UUID.fromString(id); final List<AccountEmail> emails = accountUserApi.getEmails(accountId, context.createContext(request)); for (AccountEmail cur : emails) { if (cur.getEmail().equals(email)) { final AccountEmailJson accountEmailJson = new AccountEmailJson(accountId.toString(), email); final AccountEmail accountEmail = accountEmailJson.toAccountEmail(cur.getId()); accountUserApi.removeEmail( accountId, accountEmail, context.createContext(createdBy, reason, comment, request)); } } return Response.status(Status.OK).build(); }