JUGTAAS - RESTFUL
OVVERO,
COME SCOMODARE UN CLOUD RESTFUL
PER UN LAVORO DA PAGINETTA PHP…
byTiziano Lattisi
RICETTA
• Servizio in cloud di RedHat (OpenShift)
• Versionamento (git su GitHub e OpenShift)
• Tomcat
• Jax-ws (Jersey)
• Json (Jackson)
• AngularJS
OPENSHIFT DI REDHAT
• Gratuito fino a tre applicazioni con tre "small
gears" ciascuna
• Repository git
• SSH
• https://www.openshift.com
RICHARDSON MATURITY
MODEL
• RMM estende l’approccio REST introducendo :
• Risorse
• Verbi HTTP
• Hypermedia link
REST (RICAPITOLIAMO)
• separazione client / server
• stateless: nessun contesto client memorizzato sul server (Representational
StateTransfer)
• cacheable: i client possono fare cache delle risposte
• layered: posso metterci in mezzo load balancing, cache, etc
• code on demand (opzionale): es. il server può passare codice js
• uniform interface: identificazione risorse, manipolazione attraverso la
rappresentazione, messaggi auto-descrittivi, hateoas
HTTP COMETRASPORTO
• HTTP semplicemente come tunnel
• Nessun altro meccanismo tipico del web
• URI rappresentano servizi (come soap, xml-rpc)
• Architetture SOA (services oriented architecture)
POST /eventsService HTTP/1.1

{“request”: “get”, ”event-id”: 3}
HTTP/1.1 200 OK

{“title”: “...”, “description”: “...”, “status”: “pending”}
POST /eventsService HTTP/1.1

{“request”: “confirm”, ”event-id”: 3}
HTTP/1.1 200 OK

{“title”: “...”, “description”: “...”, “status”: “confirmed”}
RISORSE
• URI rappresentano risorse
• I “metodi” vengono chiamati sulle risorse
• Architettura ROA (resources oriented
architecture)
POST /events/3 HTTP/1.1

{“request”: “options”}
HTTP/1.1 200 OK

{“options”: [

{“id”: 123, “date”: “2015-03-19”, “hour”: “18:00”},

{“id”: 124, “date”: “2015-03-19”, “hour”: “19:00”}

]}
POST /options/123 HTTP/1.1

{“request”: “confirm”, “participant”: “Tiziano”}
HTTP/1.1 200 OK

{“id”: 123, “participant”: “Tiziano”, “status”: “confirmed”}
HTTPVERBS
• I verbi HTTP per il controllo del ciclo di vita della
risorsa (CRUD)
• Utilizzo dei codici di risposta HTTP
• Rispetto dei comportamenti safe e idempotent dei
verbi HTTP
• Safe: la chiamata non comporta modificazioni
sul server
• Idempotent: chiamate successive alla prima
non comportano modificazioni sul server
(almeno per quanto il client possa percepire)
SAFE AND IDEMPOTENT
safe idempotent verb ex. codes
Select v v GET 200 OK
Insert x x POST 201 Created
Update/Insert x v PUT 204 No content
Partial update x x PATCH 204 No content
Delete x v DELETE 200 OK
Client errors: 4xx (400 Bad request, 401 Unauthorized, 404 Not found,…)
Server errors: 5xx
GET /events/3 HTTP/1.1
HTTP/1.1 200 OK

{“id”: 3, “title”: “...”, “description”: “...”, “status”:
“confirmed”}
POST /events HTTP/1.1

{“title”: “...”, “description”: “...”}
HTTP/1.1 201 CREATED

{“id”: 4, “title”: “...”, “description”: “...”, “status”:
“pending”}
HYPERMEDIA CONTROLS
• HATEOAS (hypermedia as the engine of
application state)
• La risorsa espone dei link che indicano come
proseguire nell’interazione con la risorsa stessa
GET /events?filterBy=confirmed&startIndex=4&size=4 HTTP/1.1
HTTP/1.1 200 OK

{

“events”: {

“0”: “/services/events/1”,

“1”: “/services/events/12”

},

"_links": {

“self”: “/events?filterBy=confirmed&startIndex=4&size=4”,

“prev”: “/events?filterBy=confirmed&startIndex=0&size=4”,

“next”: “/events?filterBy=confirmed&startIndex=8&size=4”,

}

}
GET /events/1 HTTP/1.1
HTTP/1.1 200 OK

{

“title”: “A new talk”,

“description”: “An interesting talk”

“events”: {

“0”: “/services/events/1”,

“1”: “/services/events/12”

},

"_links": {

“self”: “/events/1”,

“confirm”: “/events/1/confirm”,

“post-resource”: “/resources/1”,

}

}
FLUSSO GIT
master
develop
v. 1.0 v. 2.0
master
v. 1.0 v. 2.0
GITHUB
OpenShift
build & deploy handle
VEDIAMO UN PO’ DI COSE
• API: services-jugtaas.rhcloud.com/docs/swagger-ui/?url=../api/services.json
• ConfigurazioneTomcat OpenShift da git:
• https://github.com/jugtaas/services/blob/develop/.openshift/config/server.xml
• https://github.com/jugtaas/services/blob/develop/src/main/webapp/WEB-INF/web.xml
• Backports ZoeXF:
• https://github.com/jugtaas/services/blob/develop/src/main/java/org/jugtaas/services/
zoefxports/rest/AbstractResource.java
• https://github.com/jugtaas/services/blob/develop/src/main/java/org/jugtaas/services/
zoefxports/db/Manager.java
NOTE
• Abbiamo usato json, che non ha hypermedia support (json-ld
oppure hal); non abbiamo usato xhtml/atom per AngularJs
• PUT (idempotent) o POST (!idempotent)?
• Risorse composite (buona idea per la cache):

/events/3/speakers
• Autenticazione/autorizzazione su ogni richiesta
• Backport da ZoeFX per manager jpa e hateoas
RISORSE
• Roy Fielding (tesi di dottorato, idea originale di REST): http://
www.ics.uci.edu/%7Efielding/pubs/dissertation/rest_arch_style.htm
• Martin Fowler (articolo RMM): http://martinfowler.com/articles/
richardsonMaturityModel.html
• http://www.w3.org/TR/json-ld/
• http://stateless.co/hal_specification.html
• https://github.com/jugtaas/services
E ora passiamo al client…

More Related Content

PDF
WebSocket
KEY
Jugando con websockets en nodeJS
PDF
Netty - anfix tech&beers
ODP
IT Operations for Web Developers
PDF
Umleitung: a tiny mochiweb/CouchDB app
KEY
Internals - Exploring the webOS Browser and JavaScript
PDF
Debugging webOS applications
PDF
RabbitMQ + CouchDB = Awesome
WebSocket
Jugando con websockets en nodeJS
Netty - anfix tech&beers
IT Operations for Web Developers
Umleitung: a tiny mochiweb/CouchDB app
Internals - Exploring the webOS Browser and JavaScript
Debugging webOS applications
RabbitMQ + CouchDB = Awesome

What's hot (20)

PDF
T3DD12 Caching with Varnish
 
PPTX
Campus days 2014 owin
PDF
Undertow 맛보기
PPTX
Web sockets in Java
PPT
WebSockets and Java
KEY
Router と WebSocket
PPTX
Nomad + Flatcar: a harmonious marriage of lightweights
PDF
CouchDB for Web Applications - Erlang Factory London 2009
PPTX
Nancy - A Lightweight .NET Web Framework
PDF
Introducing TokuMX: The Performance Engine for MongoDB (NYC.rb 2013-12-10)
PDF
Cf camp 2019 cfconfig - a new way to manage your cold-fusion engine config
ODP
Remove web calls and scale your site like crazy !
PDF
Rapid API development on MongoDB
ODP
Making dynamic sites scale like static sites
PPTX
Websockets and SockJS, Real time chatting
PDF
WebSockets with Spring 4
PPTX
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
KEY
Server side scripting smack down - Node.js vs PHP
PDF
Securing Prometheus exporters using HashiCorp Vault
PDF
Scaling WordPress
T3DD12 Caching with Varnish
 
Campus days 2014 owin
Undertow 맛보기
Web sockets in Java
WebSockets and Java
Router と WebSocket
Nomad + Flatcar: a harmonious marriage of lightweights
CouchDB for Web Applications - Erlang Factory London 2009
Nancy - A Lightweight .NET Web Framework
Introducing TokuMX: The Performance Engine for MongoDB (NYC.rb 2013-12-10)
Cf camp 2019 cfconfig - a new way to manage your cold-fusion engine config
Remove web calls and scale your site like crazy !
Rapid API development on MongoDB
Making dynamic sites scale like static sites
Websockets and SockJS, Real time chatting
WebSockets with Spring 4
Magento Meetup Wrocław 6. "Docker for Mac - possible solutions to performance...
Server side scripting smack down - Node.js vs PHP
Securing Prometheus exporters using HashiCorp Vault
Scaling WordPress
Ad

Viewers also liked (11)

PDF
Del plugin non si butta via niente - Angularjsday 2014 Ancona @apasella
PPTX
AngularJs, Bootstrap e Cordova: il connubio per app mobile cross-platform
PPTX
L’evoluzione dei linguaggi di scripting lato browser: Il caso dart - Luca Ala...
PDF
Data binding libera tutti!
PDF
ModulAngular
PPTX
Design pattern architetturali Model View Controller, MVP e MVVM
PPTX
Mvc e di spring e angular js
PDF
Presentazione tirocinio
PDF
Thesis
PDF
Angularjs
PDF
AngularJS-Intro
Del plugin non si butta via niente - Angularjsday 2014 Ancona @apasella
AngularJs, Bootstrap e Cordova: il connubio per app mobile cross-platform
L’evoluzione dei linguaggi di scripting lato browser: Il caso dart - Luca Ala...
Data binding libera tutti!
ModulAngular
Design pattern architetturali Model View Controller, MVP e MVVM
Mvc e di spring e angular js
Presentazione tirocinio
Thesis
Angularjs
AngularJS-Intro
Ad

Similar to JugTAAS ReSTful (20)

PPT
Synapseindia dot net development web applications with ajax
PPT
RESTful services
PDF
Resting with OroCRM Webinar
PDF
Web services tutorial
PDF
Nodejs and WebSockets
PDF
Ws rest
PDF
Play Framework: async I/O with Java and Scala
KEY
Message in a Bottle
PDF
Web Services PHP Tutorial
PDF
Web Services Tutorial
PDF
Building Client-Side Attacks with HTML5 Features
PPTX
Vulnerabilities on Various Data Processing Levels
PPT
jkljklj
PPS
RIA and Ajax
PPTX
Asynchronous Web Programming with HTML5 WebSockets and Java
PDF
Make your gui shine with ajax solr
PDF
08 ajax
PPTX
4th Lecture: JSP and such
PPTX
Vulnerabilities in data processing levels
PDF
Infrastructure as Code: Manage your Architecture with Git
Synapseindia dot net development web applications with ajax
RESTful services
Resting with OroCRM Webinar
Web services tutorial
Nodejs and WebSockets
Ws rest
Play Framework: async I/O with Java and Scala
Message in a Bottle
Web Services PHP Tutorial
Web Services Tutorial
Building Client-Side Attacks with HTML5 Features
Vulnerabilities on Various Data Processing Levels
jkljklj
RIA and Ajax
Asynchronous Web Programming with HTML5 WebSockets and Java
Make your gui shine with ajax solr
08 ajax
4th Lecture: JSP and such
Vulnerabilities in data processing levels
Infrastructure as Code: Manage your Architecture with Git

More from Tiziano Lattisi (6)

PDF
ZoeFX: un framework MVC per JavaFX
PDF
Groovy e Domain Specific Languages
PDF
JavaFX2: una panoramica
PDF
VCS - DVCS - GIT-FLOW
PDF
JPA2 - a brief intro
PPT
PyPaPi Qt Java Framework
ZoeFX: un framework MVC per JavaFX
Groovy e Domain Specific Languages
JavaFX2: una panoramica
VCS - DVCS - GIT-FLOW
JPA2 - a brief intro
PyPaPi Qt Java Framework

Recently uploaded (20)

PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PDF
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
PPTX
Folder Lock 10.1.9 Crack With Serial Key
PDF
Website Design & Development_ Professional Web Design Services.pdf
PDF
IT Consulting Services to Secure Future Growth
PDF
Lumion Pro Crack New latest version Download 2025
PDF
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
PDF
AI-Powered Fuzz Testing: The Future of QA
PDF
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PDF
Engineering Document Management System (EDMS)
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
PPTX
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
PDF
infoteam HELLAS company profile 2025 presentation
DOCX
Industrial Bio-Lynx: Advanced Biometric Solution for Workforce Management
PDF
Crypto Loss And Recovery Guide By Expert Recovery Agency.
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PDF
Workplace Software and Skills - OpenStax
PDF
What Makes a Great Data Visualization Consulting Service.pdf
Internet Download Manager IDM Crack powerful download accelerator New Version...
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
Folder Lock 10.1.9 Crack With Serial Key
Website Design & Development_ Professional Web Design Services.pdf
IT Consulting Services to Secure Future Growth
Lumion Pro Crack New latest version Download 2025
Sun and Bloombase Spitfire StoreSafe End-to-end Storage Security Solution
AI-Powered Fuzz Testing: The Future of QA
Streamlining Project Management in Microsoft Project, Planner, and Teams with...
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
Engineering Document Management System (EDMS)
Understanding the Need for Systemic Change in Open Source Through Intersectio...
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
infoteam HELLAS company profile 2025 presentation
Industrial Bio-Lynx: Advanced Biometric Solution for Workforce Management
Crypto Loss And Recovery Guide By Expert Recovery Agency.
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
Top 10 Project Management Software for Small Teams in 2025.pdf
Workplace Software and Skills - OpenStax
What Makes a Great Data Visualization Consulting Service.pdf

JugTAAS ReSTful

  • 1. JUGTAAS - RESTFUL OVVERO, COME SCOMODARE UN CLOUD RESTFUL PER UN LAVORO DA PAGINETTA PHP… byTiziano Lattisi
  • 2. RICETTA • Servizio in cloud di RedHat (OpenShift) • Versionamento (git su GitHub e OpenShift) • Tomcat • Jax-ws (Jersey) • Json (Jackson) • AngularJS
  • 3. OPENSHIFT DI REDHAT • Gratuito fino a tre applicazioni con tre "small gears" ciascuna • Repository git • SSH • https://www.openshift.com
  • 4. RICHARDSON MATURITY MODEL • RMM estende l’approccio REST introducendo : • Risorse • Verbi HTTP • Hypermedia link
  • 5. REST (RICAPITOLIAMO) • separazione client / server • stateless: nessun contesto client memorizzato sul server (Representational StateTransfer) • cacheable: i client possono fare cache delle risposte • layered: posso metterci in mezzo load balancing, cache, etc • code on demand (opzionale): es. il server può passare codice js • uniform interface: identificazione risorse, manipolazione attraverso la rappresentazione, messaggi auto-descrittivi, hateoas
  • 6. HTTP COMETRASPORTO • HTTP semplicemente come tunnel • Nessun altro meccanismo tipico del web • URI rappresentano servizi (come soap, xml-rpc) • Architetture SOA (services oriented architecture)
  • 7. POST /eventsService HTTP/1.1
 {“request”: “get”, ”event-id”: 3} HTTP/1.1 200 OK
 {“title”: “...”, “description”: “...”, “status”: “pending”} POST /eventsService HTTP/1.1
 {“request”: “confirm”, ”event-id”: 3} HTTP/1.1 200 OK
 {“title”: “...”, “description”: “...”, “status”: “confirmed”}
  • 8. RISORSE • URI rappresentano risorse • I “metodi” vengono chiamati sulle risorse • Architettura ROA (resources oriented architecture)
  • 9. POST /events/3 HTTP/1.1
 {“request”: “options”} HTTP/1.1 200 OK
 {“options”: [
 {“id”: 123, “date”: “2015-03-19”, “hour”: “18:00”},
 {“id”: 124, “date”: “2015-03-19”, “hour”: “19:00”}
 ]} POST /options/123 HTTP/1.1
 {“request”: “confirm”, “participant”: “Tiziano”} HTTP/1.1 200 OK
 {“id”: 123, “participant”: “Tiziano”, “status”: “confirmed”}
  • 10. HTTPVERBS • I verbi HTTP per il controllo del ciclo di vita della risorsa (CRUD) • Utilizzo dei codici di risposta HTTP • Rispetto dei comportamenti safe e idempotent dei verbi HTTP
  • 11. • Safe: la chiamata non comporta modificazioni sul server • Idempotent: chiamate successive alla prima non comportano modificazioni sul server (almeno per quanto il client possa percepire)
  • 12. SAFE AND IDEMPOTENT safe idempotent verb ex. codes Select v v GET 200 OK Insert x x POST 201 Created Update/Insert x v PUT 204 No content Partial update x x PATCH 204 No content Delete x v DELETE 200 OK Client errors: 4xx (400 Bad request, 401 Unauthorized, 404 Not found,…) Server errors: 5xx
  • 13. GET /events/3 HTTP/1.1 HTTP/1.1 200 OK
 {“id”: 3, “title”: “...”, “description”: “...”, “status”: “confirmed”} POST /events HTTP/1.1
 {“title”: “...”, “description”: “...”} HTTP/1.1 201 CREATED
 {“id”: 4, “title”: “...”, “description”: “...”, “status”: “pending”}
  • 14. HYPERMEDIA CONTROLS • HATEOAS (hypermedia as the engine of application state) • La risorsa espone dei link che indicano come proseguire nell’interazione con la risorsa stessa
  • 15. GET /events?filterBy=confirmed&startIndex=4&size=4 HTTP/1.1 HTTP/1.1 200 OK
 {
 “events”: {
 “0”: “/services/events/1”,
 “1”: “/services/events/12”
 },
 "_links": {
 “self”: “/events?filterBy=confirmed&startIndex=4&size=4”,
 “prev”: “/events?filterBy=confirmed&startIndex=0&size=4”,
 “next”: “/events?filterBy=confirmed&startIndex=8&size=4”,
 }
 }
  • 16. GET /events/1 HTTP/1.1 HTTP/1.1 200 OK
 {
 “title”: “A new talk”,
 “description”: “An interesting talk”
 “events”: {
 “0”: “/services/events/1”,
 “1”: “/services/events/12”
 },
 "_links": {
 “self”: “/events/1”,
 “confirm”: “/events/1/confirm”,
 “post-resource”: “/resources/1”,
 }
 }
  • 17. FLUSSO GIT master develop v. 1.0 v. 2.0 master v. 1.0 v. 2.0 GITHUB OpenShift build & deploy handle
  • 18. VEDIAMO UN PO’ DI COSE • API: services-jugtaas.rhcloud.com/docs/swagger-ui/?url=../api/services.json • ConfigurazioneTomcat OpenShift da git: • https://github.com/jugtaas/services/blob/develop/.openshift/config/server.xml • https://github.com/jugtaas/services/blob/develop/src/main/webapp/WEB-INF/web.xml • Backports ZoeXF: • https://github.com/jugtaas/services/blob/develop/src/main/java/org/jugtaas/services/ zoefxports/rest/AbstractResource.java • https://github.com/jugtaas/services/blob/develop/src/main/java/org/jugtaas/services/ zoefxports/db/Manager.java
  • 19. NOTE • Abbiamo usato json, che non ha hypermedia support (json-ld oppure hal); non abbiamo usato xhtml/atom per AngularJs • PUT (idempotent) o POST (!idempotent)? • Risorse composite (buona idea per la cache):
 /events/3/speakers • Autenticazione/autorizzazione su ogni richiesta • Backport da ZoeFX per manager jpa e hateoas
  • 20. RISORSE • Roy Fielding (tesi di dottorato, idea originale di REST): http:// www.ics.uci.edu/%7Efielding/pubs/dissertation/rest_arch_style.htm • Martin Fowler (articolo RMM): http://martinfowler.com/articles/ richardsonMaturityModel.html • http://www.w3.org/TR/json-ld/ • http://stateless.co/hal_specification.html • https://github.com/jugtaas/services
  • 21. E ora passiamo al client…