Skip to content
Pedro Felix edited this page Apr 11, 2016 · 4 revisions

Introduction

This document describes the requirements for the second phase of the Software Laboratory project.

Requirements

Command request structure

On phase 1, the command request structure was composed by three components: method, path and parameters

{method} {path} {parameters}

For phase 2, this structure is added with a new optional component, called headers, placed after the path and before the parameters

{method} {path} {headers} {parameters}

The headers component is composed by a sequence of name-value pairs, where each pair is separated by the '|' character. The name is separated from the value by the ':' character. An example is

accept:text/plain|accept-language:en-gb

Multiple visualisation formats

All the GET method commands must support the accept header, defining the format for the outputted representation:

  • text/plain- plain text, similar to what was used in the first phase.
  • text/html - Hypertext Markup Language (HTML).

An usage example is GET /movies accept:text/html

If the accept header is absent, then the text/html format should be used.

The GET methods must also support the file-name header, defining the file system location for the outputted representation. If this header is absent, then the representation is written into the standard output.

Interactive operation

If the application is called with empty arguments, then it should enter into an interactive mode. In this mode, the application repeatedly reads a line from the standard input and executes the corresponding command. This repetition is stopped by the execution of a command with EXIT method.

Collections

A collection represents a sequence of movies ('Oscar 2016 Winners') or series ('Star Wars'). The same movie can be in more than one collection.

The application should support the following additional commands

  • POST /collections - creates a new collection and returns its identifier, given the following parameters

    • name - the tag unique name;
    • description - the tag description;
  • GET /collections - returns the list of collections, using the insertion order.

  • GET /collections/{cid} - returns the details for the cid collection, namely all the movies in that collection.

  • POST /collections/{cid}/movies/ - adds a movie to the cid collection, given

    • mid - the movie unique identifier.
  • DELETE /collections/{cid}/movies/{mid} - removes the movie mid from the collections cid.

Paging

All the GET commands that return a sequence of items (e.g. GET /movies and GET /collections) should support paging, i.e., the ability to return a subsequence of the original sequence. This paging is defined by two parameters (name-value pairs in the parameters set):

  • top - length of the subsequence to return.
  • skip - start position of the subsequence to return.

Both these parameters are optional. For instance the command GET /movies accept:text/html skip=6&top=3 returns the movies subsequence starting at the seventh movie and ending on the ninth movie, using the HTML format,

Sorting

The GET /movies command should support multiple sorting criteria, defined by the parameter sortBy and the following values:

  • addedData - sorted by the date the movie was added to the catalog.
  • addedDateDesc - sorted descending by the date the movie was added to the catalog.
  • year - sorted by the year the movie was released.
  • yearDesc - sorted descending by the year the movie was released.
  • title - sorted by the movie title.
  • titleDesc - sorted descending by the movie title.
  • rating - sorted by the movie rating.
  • ratingDesc - sorted descending by the movie rating.

The sortBy parameter is optional.

Additional commands

  • OPTION / - presents a list of available commands and their characteristics.

  • EXIT / - ends the application.

Delivery date

The phase 2 must be delivered until 30 April (end of week 8), via the creation of a 0.2.0 tag on the GitHub repository.

Clone this wiki locally