##Preparation:
- Install Maven and make sure it's added to the PATH (https://maven.apache.org/install.html)
- Install Tomcat (https://tomcat.apache.org/tomcat-7.0-doc/setup.html)
- Install PostgreSQL (http://www.postgresql.org/download/)
- Using pgAdmin, create a database called 'Multicert' and then create a table with the following code:
CREATE TABLE customers
(
id serial PRIMARY KEY NOT NULL,
name text NOT NULL,
nif character(9) NOT NULL UNIQUE,
address text,
telephone text
)You might want to change the openDatabaseConnection() function in CustomerInterface.java to change the user and password for your database.
##Instructions:
- Pull the code from the repository.
- Use the command line to navigate to project root folder.
- Run the following commands :
mvn package
mvn tomcat:run
- Hopefully, you will have the webservice up and running on http://localhost:8080 .
##Available services
Get all customers in the database. Usage:
GET http://localhost:8080/Multicert/rest/customerservice/getallcustomersGet a customer by NIF. Usage (nif must have 9 digits, no more, no less):
GET http://localhost:8080/Multicert/rest/customerservice/getcustomerbynif?nif=<NIFnumber>Get a customer by name. Usage (case insensitive, will look for similar names):
GET http://localhost:8080/Multicert/rest/customerservice/getcustomerbyname?name=<name>Add a customer to the database. Usage (needs JSON with the new customer data):
POST http://localhost:8080/Multicert/rest/customerservice/addcustomer
{"name":"Martins","nif":"123456789","address":"Multicert","telephone":"912345678"}Deletes a customer from database. Usage (if customer doesn't exist, will return ACCEPTED deleting nothing):
POST http://localhost:8080/Multicert/rest/customerservice/deletecustomer?nif=<NIFnumber>