0% found this document useful (0 votes)
68 views

Infobip Assignment - Java URL Shortener Eng

The document describes requirements for building a URL shortening service with the following key capabilities: 1. Users can create accounts and register long URLs to be shortened. 2. When a client accesses a shortened URL, they are redirected to the original long URL. 3. Users can view statistics on the number of times each shortened URL was accessed. The service should be implemented as a Java application using the Spring framework. It must provide REST APIs and run standalone without external dependencies beyond what is defined in the project configuration.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Infobip Assignment - Java URL Shortener Eng

The document describes requirements for building a URL shortening service with the following key capabilities: 1. Users can create accounts and register long URLs to be shortened. 2. When a client accesses a shortened URL, they are redirected to the original long URL. 3. Users can view statistics on the number of times each shortened URL was accessed. The service should be implemented as a Java application using the Spring framework. It must provide REST APIs and run standalone without external dependencies beyond what is defined in the project configuration.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

We power your mobile world

URL shortener

Author: Dragan Benčić ([email protected])

Assignment: Write an HTTP service which is used to shorten URLs, with following functionalities:
• Registration of a web address (API)
• Redirect of clients call according to the shortened URL-u
• Statistic of API calls (API)

Description:
1. Basic Architecture
The service must have two parts: configuration part and user part.

1.1 Configuration part:


Configuration part is called over REST with JSON parameters and it has following functionalities:

a) Account creation
b) Registration of URL-s in the „Shortener“ service
c) Statistics retrieval

1.1.1 Account creation

HTTP method POST


URI /account
Request type application/json
Request Body JSON with following parameters:
• AccountId (String, mandatory)
Example: { AccountId : 'myAccountId'}
Response Type application/json
Response Two types of response: successful and non-successful.
Non-successful registration is when the account (AccountID) already
exists. The parameters are:
• success: true | false
• description: Status description
• password: It is returned only for successfully created accounts.
Automatically generated password is an 8 alphanumeric string
Example {success: 'true', description: 'Your account is opened',
password: 'xC345Fc0'}

1.1.2 URLs Registration

HTTP method POST


URI /register
Request type application/json
Request Headers Set Authorization header and perform user authentication
JSON with following parameters:
• URL (mandatory, URL that needs to be shortened)
Request Body
• redirectType : 301 | 302 (optional, default 302)

Infobip d.o.o. za informatičke usluge | OIB: 29756659895 www.infobip.com


Registrirana adresa: Istarska 43/A, 52215 Vodnjan, Hrvatska
Društvo je upisano u registar Trgovačkog suda u Rijeci, Središnja služba Pazin, br. 130004106
Zagrebačka banka d.d. | Žiro račun:2360000-1101891544 | IBAN: HR7123600001101891544 Page 1
Početni kapital uplaćen u cijelosti: 2.141.000,00 HRK. | Članovi uprave: Silvio Kutić , Izabel Jelenić,
Roberto Kutić.
Telefon: +385 (0) 52 638 772 | Faks: +385 (0) 52 210 979 | E-mail: [email protected]
We power your mobile world

Example: {
URL: 'http://stackoverflow.com/questions/1567929/website-safe-data-
access-architecture-question?rq=1',
redirectType : 301
}
Response Type application/json
Response parameters in case of a successful registration:
• shortUrl (shortened URL)
Response
Example: { shortUrl: 'http://short.com/xYswlE'}

1.1.3 Statistics get

HTTP method GET


URI /statistic/{AccountId}
Request Headers Set Authorization header and perform user authentication
Response Type application/json
The server responds with JSON object (key:value map) where the key is
the registered URL, and the value is the number of calls to that URL.
Example:
{
Response 'http://myweb.com/something1/somethingelse1/: 10,
'http:// myweb.com/something2/somethingelse2/: 4,
'http:// myweb.com/something3/somethingelse3/: 91,
}

1.2 Redirect
Redirect the client on the configurated address with the configurated HTTP status

2. General requirements
• Use Java programming language
• Make sure that the response HTTP statuses meet the REST standards (statuses
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
• The service needs to be written as an 'executable' or 'deployable' package.
• The application must not need any other dependency other than the ones in POM file (must
run out-of-the-box).
• In accordance with the previous requirement, it is not allowed to use databases other than the
embedded ones.
• Any framework can be used (Spring preferred)
• Make a help page (URI: /help) containing instructions of installation/run and usage
• Provide the source code with all the dependencies, preferably as a maven project.

Infobip d.o.o. za informatičke usluge | OIB: 29756659895 www.infobip.com


Registrirana adresa: Istarska 43/A, 52215 Vodnjan, Hrvatska
Društvo je upisano u registar Trgovačkog suda u Rijeci, Središnja služba Pazin, br. 130004106
Zagrebačka banka d.d. | Žiro račun:2360000-1101891544 | IBAN: HR7123600001101891544 Page 2
Početni kapital uplaćen u cijelosti: 2.141.000,00 HRK. | Članovi uprave: Silvio Kutić , Izabel Jelenić,
Roberto Kutić.
Telefon: +385 (0) 52 638 772 | Faks: +385 (0) 52 210 979 | E-mail: [email protected]

You might also like