Skip to content

Commit

Permalink
Updated the ContactRESTService.retrieveContactsByEmail
Browse files Browse the repository at this point in the history
  • Loading branch information
hugofirth committed Oct 29, 2014
1 parent 8936ad6 commit 9cd7d12
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ public Response retrieveAllContacts() {
/**
* <p>Search for and return a Contact identified by email address.<p/>
*
* <p>Path annotation includes very simple regex to differentiate between email addresses and Ids.
* <strong>DO NOT</strong> attempt to use this regex to validate email addresses.</p>
*
*
* @param email The string parameter value provided as a Contact's email
* @return A Response containing a single Contact
*/
@GET
@Path("/{email: ^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$ }")
@Path("/{email:^.+@.+$}")
public Response retrieveContactsByEmail(@PathParam("email") String email) {
Contact contact;
try {
Expand All @@ -111,7 +115,7 @@ public Response retrieveContactsByEmail(@PathParam("email") String email) {
* @return A Response containing a single Contact
*/
@GET
@Path("/{id:[0-9][0-9]*}")
@Path("/{id:[0-9]+}")
public Response retrieveContactById(@PathParam("id") long id) {
Contact contact = service.findById(id);
if (contact == null) {
Expand Down

0 comments on commit 9cd7d12

Please sign in to comment.