Warning
This page is located in archive.

Project

Assignment

Design and develop a web service for aircraft company which allows the clients to plan and order flights. In the project you will design the RESTful Airline Service, you will connect this service to other existing services. Part of the application is also a thick client implemented as a web page allowing the user to access the Airline Service. The client *must* be able to demonstrate all the functionality.

Realizujte projekt letecké společnosti pro plánování a rezervaci letů. Výsledný produkt musí být součástí již existující architektury a napojený na již existující služby, ale bylo dosaženo celkové kompaktnosti a efektivity systému. Hlavním požadavkem na realizaci produktu je implementace RESTful Airline Service, která spravuje dostupné datové zdroje: Destination (seznam destinací, kam společnost létá), Flight (seznam plánovaných, zrušených i uskutečněných letů) a Reservation (rezervace určitého počtu míst ve zvoleném letu). Další částí celého systému je zprostředkování plateb rezervací skrze centrální banku a tisk elektronických letenek. Součástí implementace musí být i tlustý klient implementovaný jako webová stránka prohlížeče zprostředkovávající přístup ke vzdálené Airline službě.

REST - Airline Service

You will design a service providing the following REST resources

  • Flight
  • Destination
  • Reservation

The first three resources will provide the CRUD (Create Read Update Delete) opearations. The last source will support only the Create operation (using the POST method).

Server part

 Server part diagram

Destination Resource

The resource is defined as follows:

  • URI: /destination (GET, POST), /destination/{id} (GET, PUT, DELETE)
  • Methods:
    • List of all destinations - GET (URI: /destination). Konkrétní destinace: GET( URI: /destination/{id})
    • Create destination - POST (URI: /destination)
    • Modify destination - PUT (URI: /destination/{id})
    • Delete destination - DELETE (URI: /destination/{id})
  • Destination attributes:
    • id - identificator (Long)
    • name - destination name (unikátní)
    • url - destination url (př. /destination/1)
    • lat - latitude (float)
    • lon - longitude (float)
  • format: both XML and JSON
  • All methods will return JSON/XML with attributes defined above and source URL

Methods POST, PUT and DELETE will be secured. The methods may be called only by users with the “admin” user role.

Flight Resource

Flight resource provides a list of flights and allows the user to modify the flights.

  • URI: /flight (GET, POST), /flight/{id} (GET, PUT, DELETE)
  • Methods:
    • List of all flights - GET (URI list of flights: /flight, URI one flight: /flight/{id})
    • Create a flight - POST (URI: /flight)
    • Change flight info - PUT (URI: /flight/{id})
    • Delete a flight - DELETE (URI: /flight/{id})
  • Attributes:
    • id - identificator (Long)
    • name - flight name (unikátní)
    • dateOfdeparture - date and time of departure (format iso8601 YYYY-MM-DDThh:mm:ssTZD)
    • distance - distance in km
    • seats - number of seats in the aircraft
    • price - proce of the flight
    • from - from destination - id of the flight is sent when the destination is created only
    • to - final destination - id of the flight is sent when the destination is created only
    • url - url of the resource (př. /flight/1)
  • format: XML, JSON
  • All methods will return JSON/XML with attributes defined above and source URL

The security of this resource is the same like for the destination. The POST, PUT and DELETE operations are secured. Caution! It is necessary to connect the resurces between the flights and destination resources (using URL address of destinations).

Filtering, pagination, sorting

Use the “X-Filter” header to filter the flights in the FROM, TO manner.

example:

 X-Filter: dateOfDepartureFrom=2013-02-27T02:04:46+01:00,dateOfDepartureTo=2013-02-27T03:04:46+01:00
 

Date is in format ISO8601

It will be also possible to order the values.

Example:

 X-Order: dateOfDeparture:asc    nebo     X-Order: name:desc

It does not make sence to send all data at once, therefore pagination is used. Pagination will be created using the X-Base and X-Offset headers. Base is the number of requested records, offset is the beginning of the records. If the client requests 10 records starting from the 20tieth record, he adds the following headers to the request:

X-Base: 10 X-Offset: 20

If the request doesn't contain these headers, server sends all data. For the client to know the number of records he can get the server sends the X-Count-records header together with the data: X-Count-records: 18

Reservation

The clients create reservations for flights. New reservation starts with the state new. Once the reservation is paid (the client presses the pay button), the reservation goes to the paid state. The user can cancel the reservation using the PUT method - the state is changed to cancel. Only reservation in the state “new” can be canceled.

When the reservation is created, random password is sent to the client. When the client wishes to modify the reservation, he needs to input the password.

It is necessary to consider number of seats in the aircraft and allow the users to reserve their places accordingly. Don't forget to connect the flights with destinations.

  • URI: /reservation (GET, POST), /reservation/{reservationId} (GET, PUT, DELETE)
  • Methods:
    • List - GET (URI list of reservations: /reservation, URI one reservation: /reservation/{id})
    • Create - POST (URI: /reservation)
    • Update - PUT (URI: /reservation/{id})
    • Delete - DELETE (URI: /reservation/{id})
  • Attributes:
    • id - identificator (Long)
    • flight - flight id
    • created - date and time of reservation creation
    • password - randomly generated password
    • seats - number of the seats of the reservation
    • state - reservation state (new, canceled, paid)
    • url - url address of the resource
  • format: XML, JSON
  • All methods will return JSON/XML with attributes defined above and source URL

Securing the source is a bit more complicated. The list of the reservations (GET method) may see only the user with the role “admin” or “manager”. The same applies to the DELETE operation for a given resource. To get one reservation /reservation/{id} the user has to know the password (send the “X-Password” header). The same applies to the PUT method.

Single entry point

At the address / the server will return both the thick client (by using the content-type: text/html) and the list of resources used by the service while using the header content-type: application/json or application/xml

Client

The client will be realised using HTML, JavaScript or any other suitable technology. It does not have to be nice or complicated. However, the client has to implement all the functionality provided by the server - sorting, filtering, pagination.

Third parties

Google API

Before the new destination is created, get the coordinates of the destination using the [https://developers.google.com/maps/documentation/geocoding/|The Google Geocoding API]]. Store the coordinates to the destination.

Flight distance API

When creating the new flight use the service which computes the distance between two points at the map Rome2Rio. The service may find other modes of transport than air travel. We are interested in the length of the final route. Use the distance to compute the price of the ticket. 100 km = 1000 CZK.

WebSockets: Number of connected clients

Implement visualisation of number of currently connected clients in the client part using Websockets.

JAX-WS Printing Service

Printing Service is a service for automatic generation of e-tickets. It accepts the object of the reservation as a parameter. The reservation has to be paid.

  • Use the JAX-WS bottom-up method to design a service which returns simple text file as a response to the request for printing.
  • Use the JAX-WS top-down method to design a service which sends the tickets to the email. The service gets an email address as an input and does not return anything. When an email is received, the service generates a JMS message and sends it to the channel. The message contains a generated file and a mail to which the file should be sent.
  • On the same channel there is a JMS consumer listener which processes the received messages. Processing means printing the output to the console.

Requirements Summary

Airline Service a Client

Implement a RESTful service and using an API allow the users to manage these resources:

  • Destination
  • Flight
  • Reservation

The service has to fulfil the following:

  • Single entry point - access to the / resource returns the list of the available resources. Each resource returns links to other resources.
  • Only authorised person can manage the list of the flights.
  • The reservation may be created and canceled, not changed. The access to the reservation is protected by the password, which is generated when the reservation is created. The administrator may access all reservations.
  • The list of flights may be ordered by departure date, the parameter is handed over using the HTTP header. Both ASC and DESC are supported
  • The list of the flights may be filtered using from-to, the filter is handed over using a HTTP header.
  • The list of the flights may be paginated using the HTTP headers.
  • The list of destinations may be sorted automatically according the name of the destination, supports both ASC and DESC, the parameter is passed using the HTTP header.
  • Only the unpaid reservation may be deleted. When invoking deleting of the paid reservation the service returns HTTP error 400.
  • The reservation may be paid (the POST method to the resource /reservation/reservation-id/payment). The payment is invoked by pressing the payment button at the client. The parameter is the number of the card (any number).
  • The whole airline service supports the content negotiation, either JSON or XML is returned based on the HTTP header used.
  • The resource / returns the client in XHTML
  • The client displays the distance of the destinations.
  • The current number of clients connected to the server is displayed in each client window.
  • The paid reservation allows the user to print the e-ticket

Grading

The following is the grading criteria. You need to get at least 25 points to pass.

Checkpoint 1 max 17 points
RESTful management of resources for Airline Service 6b
HTML / Javascript client 6b
Single entry point for Airline Service, lists of resources 1b
Filtering and sorting using headers 4b
Checkpoint 2 max 12 points
Flight, Destination: authorisation BASIC for resource management 3b
Reservation: authorisation BASIC (GET and DELETE, admin/manager can do anything) 2b
Reservation: authorisation X-Password (PUT and GET, who knows the password can do anything) 2b
Google Geocoding API for getting the coordinates 1b
Rome2Rio for getting the flight distance 1b
PrintService design using the bottom-up approach 3b
Checkpoint 3 max 21 points
WebSockets: Number of parallel clients is displayed in the client 3b
PrintService design using the top-down approach 3b
JMS producer - generates the request for email 3b
JMS consumer - processes the request for email 3b
File sending using the PrintService 3b
Code quality 6b
courses/a4m36aos/cviceni/semestral_work.txt · Last modified: 2015/12/10 08:56 by kopriste