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.
@ProducesMediaTypeJSON
@ConsumesMediaTypeJSON
@POST
Public String addContactContact 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;
@ProducesMediaTypeJSON
@ConsumesMediaTypeTEXTPLAIN
@GET
This is not exact syntax and it is only for explanation only
Public ArrayList searchContactsString 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
