Question: You are asked to create a contacts management application where users of your application can search for contacts and display the contacts that match the

You are asked to create a contacts management application where users of your application can search for contacts and display the contacts that match the search criteria. The contact entity consists of First Name, Last Name, Email, Phone, Address, City, State, Zipcode and all of them are Strings.
You are asked to create a RESTFul service that has two methods, addContact, searchContact and their definition is given below.
@Produces(MediaType.JSON)
@Consumes(MediaType.JSON)
@POST
Public String addContact(Contact contact){
//Add the contact to an Arraylist and return Success.
StringBuffer sb = new StringBuffer();
//return a JSON string {Status : Success} for success
// and fail if the add customer fails
return JSON String Success;
}
@Produces(MediaType.JSON)
@Consumes(MediaType.TEXT_PLAIN)
@GET
//This is not exact syntax and it is only for explanation only
Public ArrayList searchContacts(String fname, String lname){
//Search the contact list, iterate through the contacts List and if a contacts First Name contains passed first name and Last Name contains Last name, then select that Contact as a match and add it to a list to be returned to client. Search should be case insensitive.
//The returned ArrayList contain the contacts whose First Name and Last Name contains passed values.
Return new ArrayList();
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!