SlideShare a Scribd company logo
1 of 93
Download to read offline
Getting Started with
DSpace 7 REST API
Andrea Bollini, 4Science
Terry Brady, Georgetown
Tim Donohue, DuraSpace
Workshop Schedule
❖ Why a new REST API?
❖ Interacting with REST API
❖ (Morning Tea 10:30-11:00)
❖ Design Principles of REST API
❖ Developing the REST API
Version 7.0 goals
★ Single, Angular UI (new)
★ Fully-featured REST API (new)
★ Configurable Entities (new)
★ Align w/ NGR recommendations
★ Existing, core Java backend
(DB, Solr, Assetstore)
Current Status
❏ Enhanced backend (object store, caching, speed improvements)
❏ Browse (Homepage, Community, Collection, Item pages)
❏ Search
❏ Authentication and Authorization
❏ Submission
❏ Approval Workflows
❏ Content Management (Create/Edit/Delete tasks)
❏ Administration
❏ Statistics
❏ Configurable Entities support
Development Planning Spreadsheet
Why a new REST API?
Why a new REST API?
Covers only a
subset of DSpace
functionality
Not based on current
REST best practices
or standards
Handcrafted in Jersey,
while most DSpace code uses
Spring technologies
4.x - 6.x
No search
No submit / workflows
Limited admin operations
Limited write / delete
(4.x was read only)
Why a new REST API?
All features MUST
be in REST API
(for Angular UI)
Defined REST Contract.
HATEOAS, ALPS,
HAL format
Built using Spring technologies
(Spring Boot, MVC, HATEOAS)
7.x
Bonus: better third-party
app integration!
https://github.com/DSpace/DSpace/tree/master/dspace-spring-rest
HATEOAS, HAL, & ALPS, oh my!
ALPS = Application Level Profile Semantics*
Describes the operations (actions) available for all REST endpoints.
(Machine-readable) metadata about how to interact with the API.
HAL Format = Hypertext Application Language (JSON or XML)
A standard format for making REST APIs browseable
(think HTML for machines). Open source HAL Browser available.
RESULT: A standards-based, browseable, self-describing REST API
HATEOAS = Hypertext As The Engine Of Application State
In each response, include “links” to available next requests.
Results in better decoupling, as API is self-describing.
Stateless (no session)
Specifications
• JSON web tokens (JWT)
• Cross-Origin Resource Sharing
(CORS) Headers
HTTP Resources
● URIs reference individual
resources or collections (of
resources)
● /items/{uuid} and /items
Formats: JSON* or XML
HTTP methods
GET (read), HEAD (read headers only)
POST (create)
PUT (replace), PATCH (partial update)
DELETE (remove)
OPTIONS (verify access, e.g. via CORS)
HTTP return codes
2xx (Success)
3xx (Redirect)
4xx (Client error)
5xx (Server error)
REST Terminology
Interacting with the
REST API
(HAL browser, Postman, command line?)
Interacting with a REST API
You can use the command line…
curl "https://dspace7.4science.it/terry/api/core/collections"
But, there are better ways… using a
REST client
Goals for this section
• Understand the endpoints that are
available
• Learn how to call these endpoints
– As an anonymous user
– As an authenticated user
• Appreciate the self-describing nature of
the DSpace REST design
We will look at 2 tools
• HAL Browser
• Postman
The REST API currently supports very
limited modification actions
(create/update/delete). More support will
be added in the future.
HAL Browser
• Development public instance (provided
by 4science)
– https://dspace7.4science.it/dspace-spring-rest
/
• Workshop Link
– https://dspace7.4science.it/terry
• Navigate to the link above to explore
HAL Browsing - Example
Response Object Components
• Response Properties
– Often pagination details
• Links
– What you can do next
• Embedded Resources
– List of objects which may contain
• Properties
• Links
Open the API Landing Page
• Open the Entry Point
– https://dspace7.4science.it/terry
• Request (in HAL Browser)
– /api
Request + Headers
Response Properties
Links: All endpoints are available
from the Entry Point
Response Headers
Response Body
Example: Items Endpoint
Items Response
Links - A generic approach to
paginated results
Embedded Item Properties
Embedded Item Links
Exercise 1: Explore HAL Browser
Exercise 1 - Exploring Endpoints in HAL
Browser
Short Link To Exercises
http://bit.ly/dspace7-rest
The REST contract
• https://github.com/DSpace/Rest7Contract
– Explore the list of endpoints
• Implemented
• Unimplemented
• Under discussion
– Use GitHub pull requests to suggest
changes
The future of REST API Documentation
PR#1915
REST Authentication
• The existing DSpace authentication
methods will be supported
• The REST API returns an authentication
token
• This token is passed to subsequent
REST requests as a header
Why Authenticate?
• View restricted items/bitstreams
• Create/Update/Delete Objects
– Submit items
• Perform admin operations
• View restricted metadata (provenance)
• Note: most of these actions are not yet
supported in DSpace REST
A subset of these operations are
available in HAL
Exercise 2: Authenticating in HAL
Exercise 2 - Authentication in HAL
Browser
• For this workshop, we will use
password authentication
http://bit.ly/dspace7-rest
Limitations of HAL Authn
• Credentials only passed for GET
operations
• File uploads not supported
Postman - A development client for
REST API’s
https://www.getpostman.com/apps
Postman - A tool for sending REST
requests
• Postman is a tool for interacting with
various REST services
– Even ones without a HAL Browser
• Using a web browser, it is difficult to
construct complex requests
Postman
Tabs and Collections help you
organize and re-use requests
Request Area
Parameters and Headers
Response Panel
Response Headers
Browsing with Postman
• View all items
– /api/core/items
• Change page size
– /api/core/items?size=5
• Change starting page
– /api/core/items?size=5&page=2
Exercise 3: Browsing with Postman
Exercise 3 - Browsing with Postman
http://bit.ly/dspace7-rest
Postman - Authenticating as a User
AuthN Status in Postman
(no AuthN token)
Authenticating in Postman
AuthN Status in Postman
(passing Bearer token)
Let’s Attempt to change data
• The current REST API allows a user to
start a submission
• POST
– /api/submission/workspaceitems
– Body: {}
• The response will return an object with
an id
Retrieving the Item that was
created
• GET
– /api/submission/workspaceitems/[id]
• DELETE
– /api/submission/workspaceitems/[id]
• GET
– /api/submission/workspaceitems/[id]
The second GET request will fail
Exercise 4: Modifying data with
Postman
Exercise 4 - Modifying data with
Postman
http://bit.ly/dspace7-rest
Managing Postman
• Postman allows you to use variables
and scripts to manage credentials
Tips on using postman
Design Principles
Stateless (no session)
Specifications
• JSON web tokens (JWT)
• Cross-Origin Resource Sharing
(CORS) Headers
HTTP Resources
● URIs reference individual
resources or collections (of
resources)
● /items/{uuid} and /items
Formats: JSON* or XML
HTTP methods
GET (read), HEAD (read headers only)
POST (create)
PUT (replace), PATCH (partial update)
DELETE (remove)
OPTIONS (verify access, e.g. via CORS)
HTTP return codes
2xx (Success)
3xx (Redirect)
4xx (Client error)
5xx (Server error)
REST Terminology
Hypermedia as the Engine of Application
State - HATEAOS
HAL Format
Links are expressed in a
standard/well-known way in the
json response (it is also suitable for
xml but DSpace7 will focus only on
JSON)
→ enable the interactive navigation
→ abstract routing (URL can change
without break the client)
→ support documentation
ALPS
Available methods, semantics of
request and response objects
discoverable in a standard way
(/profile) and expressed in multiple
standards format (Alps JSON, JSON
Schema, XML, etc)
→ enable to expose only available
methods (i.e. GET on
resourcepolicies is disallowed)
→ document in a machine-readable
way the request and response
semantics
HAL Document
ALPS will enable...
REST Maturity level
Image from: https://martinfowler.com/articles/richardsonMaturityModel.html
Spring technologies
Spring Bootstrap: pre-configured managed
Spring platform
Spring MVC: Front Controller, data binding,
error handling
Spring REST: MVC extension to easily
support Content-Negotiation, Response in
JSON format
Spring technologies
Spring HATEOAS: library to deal with HAL
Document (Resources, Resource, Links, Curie)
Spring Data REST: only for inspiration
(consistent design choices, HTTP error
handling, support classes, etc.)
Spring technologies
Spring Data REST Hal Browser: WebJar of
the HAL browser customized to work at best
with Spring Data REST
Spring REST Docs: Self contained
documentation with snippets from Integration
Tests
Pagination
https://github.com/DSpace/Rest7Contract#pagination
Resource Collections are always paginated
→ pagination information are returned in a
consistent way across all the endpoints
→ pagination parameters are expected in the
same form in all the endpoints
→ common JAVA API to deal with page jump
and offset
Search Methods
https://goo.gl/NSju3q
Collection endpoints that allowing
filtering, search or precise lookup of
resources MUST provide a search link
listing all the available methods
Right use of the HTTP Verbs:
collection
- POST Adds a new element to the
collection.
- GET Returns the first page of the
resources in the collection
Right use of the HTTP Verbs:
element
GET Returns a single entity.
HEAD Returns whether the item resource is
available.
PUT Replaces the state
PATCH Similar to PUT but partially updating
the resources state
DELETE Deletes the resource exposed.
How to deal with PATCH
JSON Patch specification RFC6902
Express change to a JSON Object in JSON
Array of Operations executed in an atomic
transaction
Each successful Patch operation will return a
HTTP 200 CODE with the new state of the
patched resource as body similar to what is
returned for a GET request.
How to deal with PATCH
ADD / REMOVE / REPLACE / MOVE
[
{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
]
TEST & COPY (no plan to support them)
PATCH (More examples: https://goo.gl/G84oRQ)
[{
"op": "add",
"path": "/sections/traditionalpageone/dc.contributor.author/-",
"value": {"value": "Another, Author"}
}]
HTTP status codes - 2xx, 3xx
200 Ok - Normal success state
201 Created - Returned when a resource is created
204 No content - Returned when the operation succeed but no
content is available (i.e. hit the logo endpoint of a community
without logo
206 Partial Content - DSpace 7 provides range support for
bitstream download allowing streaming
302 Found - the PID endpoint redirect to the target resource
HTTP status codes - 4xx
400 Bad Request - if the request is invalid (not a json, etc.)
401 Unauthorized - if the request require a logged-in user
403 Forbidden - if the requester doesn't have enough privilege
to execute the request
404 Not found - if the requested resource doesn't exists
405 Method Not Allowed - if the requested verb is not
supported for the resource
422 Unprocessable Entity - if the request is semantically
invalid (i.e. attempt to add undefined metadata, deposit an
invalid workspace)
Developing the
REST API
Code used in the workshop
https://github.com/4Science/DSpace
Branch: or2018-workshop (final result)
| tags will help to move step by step
 or2018-workshop-start
How URL are translated to JAVA
code
Where is my web.xml?
It is a spring boot application with web
support (MVC)
Controller → are the “new” Servlet
@RestController
What about the lovable spring xml files?
sorry now we use annotations :)
Component scanning enabled on
repository, converter, utils packages
@Component
@Service
Goal: Enhance the EPerson
endpoint
• List EPersons (already exists)
• Get EPerson (already exists)
Walkthrough the implementation and the
Integration Tests
[tag: or2018-workshop-start]
Rest Model Class
• POJO used as DTO between the REST
layer and the services.
• Clean and stable version of our data
model
• The converter class transcode the
DSpace-API objects in REST objects
Repository Class
• It is defined in the Repository design
pattern
• It implements the Data Access Layer in
DDD
• Close to the domain model, abstracting
access to a collection
Resource Class
• Wrap the Domain Class inside an HAL
document
• Provide supports to add links
• Manage embedded objects
Integration Test
Builder and Matcher helper classes to keep code
compact & cleanup the test database between
runs
One or more test for each repository methods
- Separate test for different scenarios
(exception, limit case, normal case)
- Multiple calls in the same test to cross check
the intent changes
Add security check
Learn how to authenticate an user in
the Integration Test [or18-ws1-it]
Secure the main eperson endpoint (only
administrators can access)
[or18-ws1-fix]
Enhancing EPerson endpoint
Implement Search by email, by name
(walkthrough)
1. Write Integration Tests in advance
[or18-ws2-it]
2. Implement the endpoint, run the test
[or18-ws2-search / or18-ws2-search2]
3. Interact using the HAL browser
[or18-ws2-fix]
Enhancing EPerson endpoint
Implement DELETE (walkthrough)
1. ITs successful DELETE, failures due to
Authorization issues, DB constraints
[or18-ws3-it]
2. Check the implementation
[or18-ws3-fix]
Enhancing EPerson endpoint
Implement POST (walkthrough)
• How to test a create operation
• How to implement
[or18-ws4]
Enhancing EPerson endpoint
Implement Patch (walkthrough)
• Change the CanLogin flag
• Change the Password
[or18-ws5]
Enhancing EPerson endpoint
BONUS (discussion only)
• List/Create/Delete RegistrationToken
• How to transform a RegistrationToken
in an EPerson (text/uri-list)
DSpace 7 will arrive more quickly with more help!
❏ 1st DSpace 7 Community Sprint: May 7 - 18
❏ 14 pull requests, 8 contributors (2 first time)
❏ 2nd DSpace 7 Community Sprint: July 9 - 20
No availability requirements! Choose your own tickets/tasks!
No DSpace 7 experience necessary! (Coaches available)
Join a Development Sprint!
Sign-up now!
https://tinyurl.com/dspace7sprints
Questions?
Slides available at
https://tinyurl.com/or2018-dspace-rest
Sl

More Related Content

What's hot

Apache sqoop with an use case
Apache sqoop with an use caseApache sqoop with an use case
Apache sqoop with an use caseDavin Abraham
 
Introduction to XMLUI and Mirage Theming for DSpace 3
Introduction to XMLUI and Mirage Theming for DSpace 3Introduction to XMLUI and Mirage Theming for DSpace 3
Introduction to XMLUI and Mirage Theming for DSpace 3Bram Luyten
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBRavi Teja
 
Spark (Structured) Streaming vs. Kafka Streams
Spark (Structured) Streaming vs. Kafka StreamsSpark (Structured) Streaming vs. Kafka Streams
Spark (Structured) Streaming vs. Kafka StreamsGuido Schmutz
 
DSpace 7 ORCID Integration
DSpace 7 ORCID IntegrationDSpace 7 ORCID Integration
DSpace 7 ORCID Integration4Science
 
Introduction to Apache Sqoop
Introduction to Apache SqoopIntroduction to Apache Sqoop
Introduction to Apache SqoopAvkash Chauhan
 
DSpace standard Data model and DSpace-CRIS
DSpace standard Data model and DSpace-CRISDSpace standard Data model and DSpace-CRIS
DSpace standard Data model and DSpace-CRISAndrea Bollini
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptxSurya937648
 
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...Simplilearn
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisArnab Mitra
 
Dspace configuration on XMLUI DSpace
Dspace configuration on XMLUI DSpaceDspace configuration on XMLUI DSpace
Dspace configuration on XMLUI DSpaceBharat Chaudhari
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
DSpace-CRIS & OpenAIRE
DSpace-CRIS & OpenAIREDSpace-CRIS & OpenAIRE
DSpace-CRIS & OpenAIRE4Science
 
Introduction to NoSQL Databases
Introduction to NoSQL DatabasesIntroduction to NoSQL Databases
Introduction to NoSQL DatabasesDerek Stainer
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with RedisGeorge Platon
 
DSpace-CRIS: new features and contribution to the DSpace mainstream
DSpace-CRIS: new features and contribution to the DSpace mainstreamDSpace-CRIS: new features and contribution to the DSpace mainstream
DSpace-CRIS: new features and contribution to the DSpace mainstream4Science
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMongoDB
 

What's hot (20)

Apache sqoop with an use case
Apache sqoop with an use caseApache sqoop with an use case
Apache sqoop with an use case
 
Introduction to XMLUI and Mirage Theming for DSpace 3
Introduction to XMLUI and Mirage Theming for DSpace 3Introduction to XMLUI and Mirage Theming for DSpace 3
Introduction to XMLUI and Mirage Theming for DSpace 3
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Spark (Structured) Streaming vs. Kafka Streams
Spark (Structured) Streaming vs. Kafka StreamsSpark (Structured) Streaming vs. Kafka Streams
Spark (Structured) Streaming vs. Kafka Streams
 
DSpace 7 ORCID Integration
DSpace 7 ORCID IntegrationDSpace 7 ORCID Integration
DSpace 7 ORCID Integration
 
Introduction to Apache Sqoop
Introduction to Apache SqoopIntroduction to Apache Sqoop
Introduction to Apache Sqoop
 
DSpace standard Data model and DSpace-CRIS
DSpace standard Data model and DSpace-CRISDSpace standard Data model and DSpace-CRIS
DSpace standard Data model and DSpace-CRIS
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...
HBase Tutorial For Beginners | HBase Architecture | HBase Tutorial | Hadoop T...
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Dspace configuration on XMLUI DSpace
Dspace configuration on XMLUI DSpaceDspace configuration on XMLUI DSpace
Dspace configuration on XMLUI DSpace
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
DSpace-CRIS & OpenAIRE
DSpace-CRIS & OpenAIREDSpace-CRIS & OpenAIRE
DSpace-CRIS & OpenAIRE
 
Introduction to sqoop
Introduction to sqoopIntroduction to sqoop
Introduction to sqoop
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Introduction to NoSQL Databases
Introduction to NoSQL DatabasesIntroduction to NoSQL Databases
Introduction to NoSQL Databases
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
DSpace-CRIS: new features and contribution to the DSpace mainstream
DSpace-CRIS: new features and contribution to the DSpace mainstreamDSpace-CRIS: new features and contribution to the DSpace mainstream
DSpace-CRIS: new features and contribution to the DSpace mainstream
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
ElasticSearch
ElasticSearchElasticSearch
ElasticSearch
 

Similar to Getting started with DSpace 7 REST API

Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsLiam Cleary [MVP]
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIsamesar0
 
RESTful for opentravel.org by HP
RESTful for opentravel.org by HPRESTful for opentravel.org by HP
RESTful for opentravel.org by HPRoni Schuetz
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Alliance
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Services in Drupal 8
Services in Drupal 8Services in Drupal 8
Services in Drupal 8Andrei Jechiu
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuseejlp12
 
REST library.pptx
REST library.pptxREST library.pptx
REST library.pptxMSivani
 
ITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesOrtus Solutions, Corp
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearchpmanvi
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisKeith Moore
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisKeith Moore
 

Similar to Getting started with DSpace 7 REST API (20)

Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint Apps
 
Pragmatic REST APIs
Pragmatic REST APIsPragmatic REST APIs
Pragmatic REST APIs
 
RESTful for opentravel.org by HP
RESTful for opentravel.org by HPRESTful for opentravel.org by HP
RESTful for opentravel.org by HP
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
OpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML ResourcesOpenTravel Advisory Forum 2012 REST XML Resources
OpenTravel Advisory Forum 2012 REST XML Resources
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Apex REST
Apex RESTApex REST
Apex REST
 
Rest
RestRest
Rest
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Services in Drupal 8
Services in Drupal 8Services in Drupal 8
Services in Drupal 8
 
RESTful web service with JBoss Fuse
RESTful web service with JBoss FuseRESTful web service with JBoss Fuse
RESTful web service with JBoss Fuse
 
REST library.pptx
REST library.pptxREST library.pptx
REST library.pptx
 
Andrei shakirin rest_cxf
Andrei shakirin rest_cxfAndrei shakirin rest_cxf
Andrei shakirin rest_cxf
 
ITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul Services
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearch
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based Katharsis
 
RESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based KatharsisRESTful HATEOAS standards using Java based Katharsis
RESTful HATEOAS standards using Java based Katharsis
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
 

More from 4Science

From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...
From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...
From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...4Science
 
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...4Science
 
DSpace-CRIS design & Implementation
DSpace-CRIS design & ImplementationDSpace-CRIS design & Implementation
DSpace-CRIS design & Implementation4Science
 
Status of discussions with repository platforms_ DSpace.pdf
Status of discussions with repository platforms_ DSpace.pdfStatus of discussions with repository platforms_ DSpace.pdf
Status of discussions with repository platforms_ DSpace.pdf4Science
 
DSpace GLAM Infographic.pdf
DSpace GLAM Infographic.pdfDSpace GLAM Infographic.pdf
DSpace GLAM Infographic.pdf4Science
 
DSpace CRIS EFS Miami.pdf
DSpace CRIS EFS Miami.pdfDSpace CRIS EFS Miami.pdf
DSpace CRIS EFS Miami.pdf4Science
 
IIIF and DSpace 7 - IIIF Conference 2023.pdf
IIIF and DSpace 7 - IIIF Conference 2023.pdfIIIF and DSpace 7 - IIIF Conference 2023.pdf
IIIF and DSpace 7 - IIIF Conference 2023.pdf4Science
 
Bringing IIIF to the DSpace community
Bringing IIIF to the DSpace communityBringing IIIF to the DSpace community
Bringing IIIF to the DSpace community4Science
 
Implementing the Notify protocol and standard practices in DSpace
Implementing the Notify protocol and standard practices in DSpaceImplementing the Notify protocol and standard practices in DSpace
Implementing the Notify protocol and standard practices in DSpace4Science
 
The EOSC DIH "ELD Advance" project
The EOSC DIH "ELD Advance" projectThe EOSC DIH "ELD Advance" project
The EOSC DIH "ELD Advance" project4Science
 
DSpace implementation of the COAR Notify Project - status update
DSpace implementation of the COAR Notify Project - status updateDSpace implementation of the COAR Notify Project - status update
DSpace implementation of the COAR Notify Project - status update4Science
 
Convegno Stelline 2020 - 4Science -16 settembre _ pubbliche
Convegno Stelline 2020 - 4Science -16 settembre _ pubblicheConvegno Stelline 2020 - 4Science -16 settembre _ pubbliche
Convegno Stelline 2020 - 4Science -16 settembre _ pubbliche4Science
 
Convegno Stelline 2020 - 4Science -16 settembre _ accademiche
Convegno Stelline 2020 - 4Science -16 settembre _ accademicheConvegno Stelline 2020 - 4Science -16 settembre _ accademiche
Convegno Stelline 2020 - 4Science -16 settembre _ accademiche4Science
 
Convegno Stelline 2020 - 4Science
Convegno Stelline 2020 - 4Science Convegno Stelline 2020 - 4Science
Convegno Stelline 2020 - 4Science 4Science
 
DSpace-CRIS 7: What is Coming? OR2020
DSpace-CRIS 7: What is Coming? OR2020DSpace-CRIS 7: What is Coming? OR2020
DSpace-CRIS 7: What is Coming? OR20204Science
 
News about DSpace-CRIS Anwendertreffen 2020
News about DSpace-CRIS Anwendertreffen 2020News about DSpace-CRIS Anwendertreffen 2020
News about DSpace-CRIS Anwendertreffen 20204Science
 
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...4Science
 
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...4Science
 
DSpace-CRIS ORCID Integration
DSpace-CRIS ORCID IntegrationDSpace-CRIS ORCID Integration
DSpace-CRIS ORCID Integration4Science
 
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...4Science
 

More from 4Science (20)

From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...
From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...
From Digital Records to Digital Cultural Landscapes. Beyond Digital Library b...
 
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...
“Adoption DSpace 7 and 8 Challenges and Solutions from Real Migration Experie...
 
DSpace-CRIS design & Implementation
DSpace-CRIS design & ImplementationDSpace-CRIS design & Implementation
DSpace-CRIS design & Implementation
 
Status of discussions with repository platforms_ DSpace.pdf
Status of discussions with repository platforms_ DSpace.pdfStatus of discussions with repository platforms_ DSpace.pdf
Status of discussions with repository platforms_ DSpace.pdf
 
DSpace GLAM Infographic.pdf
DSpace GLAM Infographic.pdfDSpace GLAM Infographic.pdf
DSpace GLAM Infographic.pdf
 
DSpace CRIS EFS Miami.pdf
DSpace CRIS EFS Miami.pdfDSpace CRIS EFS Miami.pdf
DSpace CRIS EFS Miami.pdf
 
IIIF and DSpace 7 - IIIF Conference 2023.pdf
IIIF and DSpace 7 - IIIF Conference 2023.pdfIIIF and DSpace 7 - IIIF Conference 2023.pdf
IIIF and DSpace 7 - IIIF Conference 2023.pdf
 
Bringing IIIF to the DSpace community
Bringing IIIF to the DSpace communityBringing IIIF to the DSpace community
Bringing IIIF to the DSpace community
 
Implementing the Notify protocol and standard practices in DSpace
Implementing the Notify protocol and standard practices in DSpaceImplementing the Notify protocol and standard practices in DSpace
Implementing the Notify protocol and standard practices in DSpace
 
The EOSC DIH "ELD Advance" project
The EOSC DIH "ELD Advance" projectThe EOSC DIH "ELD Advance" project
The EOSC DIH "ELD Advance" project
 
DSpace implementation of the COAR Notify Project - status update
DSpace implementation of the COAR Notify Project - status updateDSpace implementation of the COAR Notify Project - status update
DSpace implementation of the COAR Notify Project - status update
 
Convegno Stelline 2020 - 4Science -16 settembre _ pubbliche
Convegno Stelline 2020 - 4Science -16 settembre _ pubblicheConvegno Stelline 2020 - 4Science -16 settembre _ pubbliche
Convegno Stelline 2020 - 4Science -16 settembre _ pubbliche
 
Convegno Stelline 2020 - 4Science -16 settembre _ accademiche
Convegno Stelline 2020 - 4Science -16 settembre _ accademicheConvegno Stelline 2020 - 4Science -16 settembre _ accademiche
Convegno Stelline 2020 - 4Science -16 settembre _ accademiche
 
Convegno Stelline 2020 - 4Science
Convegno Stelline 2020 - 4Science Convegno Stelline 2020 - 4Science
Convegno Stelline 2020 - 4Science
 
DSpace-CRIS 7: What is Coming? OR2020
DSpace-CRIS 7: What is Coming? OR2020DSpace-CRIS 7: What is Coming? OR2020
DSpace-CRIS 7: What is Coming? OR2020
 
News about DSpace-CRIS Anwendertreffen 2020
News about DSpace-CRIS Anwendertreffen 2020News about DSpace-CRIS Anwendertreffen 2020
News about DSpace-CRIS Anwendertreffen 2020
 
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...
Digital library: riflessioni su scelte e obiettivi. Visibilità delle collezio...
 
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...
How to enhance your DSpace repository: use cases for DSpace-CRIS, DSpace-RDM,...
 
DSpace-CRIS ORCID Integration
DSpace-CRIS ORCID IntegrationDSpace-CRIS ORCID Integration
DSpace-CRIS ORCID Integration
 
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...
Enhancing Interoperability: The Implementation of OpenAIRE Guidelines and COA...
 

Recently uploaded

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

Getting started with DSpace 7 REST API

  • 1. Getting Started with DSpace 7 REST API Andrea Bollini, 4Science Terry Brady, Georgetown Tim Donohue, DuraSpace
  • 2. Workshop Schedule ❖ Why a new REST API? ❖ Interacting with REST API ❖ (Morning Tea 10:30-11:00) ❖ Design Principles of REST API ❖ Developing the REST API
  • 3. Version 7.0 goals ★ Single, Angular UI (new) ★ Fully-featured REST API (new) ★ Configurable Entities (new) ★ Align w/ NGR recommendations ★ Existing, core Java backend (DB, Solr, Assetstore)
  • 4. Current Status ❏ Enhanced backend (object store, caching, speed improvements) ❏ Browse (Homepage, Community, Collection, Item pages) ❏ Search ❏ Authentication and Authorization ❏ Submission ❏ Approval Workflows ❏ Content Management (Create/Edit/Delete tasks) ❏ Administration ❏ Statistics ❏ Configurable Entities support Development Planning Spreadsheet
  • 5. Why a new REST API?
  • 6. Why a new REST API? Covers only a subset of DSpace functionality Not based on current REST best practices or standards Handcrafted in Jersey, while most DSpace code uses Spring technologies 4.x - 6.x No search No submit / workflows Limited admin operations Limited write / delete (4.x was read only)
  • 7. Why a new REST API? All features MUST be in REST API (for Angular UI) Defined REST Contract. HATEOAS, ALPS, HAL format Built using Spring technologies (Spring Boot, MVC, HATEOAS) 7.x Bonus: better third-party app integration! https://github.com/DSpace/DSpace/tree/master/dspace-spring-rest
  • 8. HATEOAS, HAL, & ALPS, oh my! ALPS = Application Level Profile Semantics* Describes the operations (actions) available for all REST endpoints. (Machine-readable) metadata about how to interact with the API. HAL Format = Hypertext Application Language (JSON or XML) A standard format for making REST APIs browseable (think HTML for machines). Open source HAL Browser available. RESULT: A standards-based, browseable, self-describing REST API HATEOAS = Hypertext As The Engine Of Application State In each response, include “links” to available next requests. Results in better decoupling, as API is self-describing.
  • 9. Stateless (no session) Specifications • JSON web tokens (JWT) • Cross-Origin Resource Sharing (CORS) Headers HTTP Resources ● URIs reference individual resources or collections (of resources) ● /items/{uuid} and /items Formats: JSON* or XML HTTP methods GET (read), HEAD (read headers only) POST (create) PUT (replace), PATCH (partial update) DELETE (remove) OPTIONS (verify access, e.g. via CORS) HTTP return codes 2xx (Success) 3xx (Redirect) 4xx (Client error) 5xx (Server error) REST Terminology
  • 10. Interacting with the REST API (HAL browser, Postman, command line?)
  • 11. Interacting with a REST API You can use the command line… curl "https://dspace7.4science.it/terry/api/core/collections" But, there are better ways… using a REST client
  • 12. Goals for this section • Understand the endpoints that are available • Learn how to call these endpoints – As an anonymous user – As an authenticated user • Appreciate the self-describing nature of the DSpace REST design
  • 13. We will look at 2 tools • HAL Browser • Postman The REST API currently supports very limited modification actions (create/update/delete). More support will be added in the future.
  • 14. HAL Browser • Development public instance (provided by 4science) – https://dspace7.4science.it/dspace-spring-rest / • Workshop Link – https://dspace7.4science.it/terry • Navigate to the link above to explore
  • 15. HAL Browsing - Example
  • 16. Response Object Components • Response Properties – Often pagination details • Links – What you can do next • Embedded Resources – List of objects which may contain • Properties • Links
  • 17. Open the API Landing Page • Open the Entry Point – https://dspace7.4science.it/terry • Request (in HAL Browser) – /api
  • 18.
  • 21. Links: All endpoints are available from the Entry Point
  • 26. Links - A generic approach to paginated results
  • 29. Exercise 1: Explore HAL Browser Exercise 1 - Exploring Endpoints in HAL Browser Short Link To Exercises http://bit.ly/dspace7-rest
  • 30. The REST contract • https://github.com/DSpace/Rest7Contract – Explore the list of endpoints • Implemented • Unimplemented • Under discussion – Use GitHub pull requests to suggest changes
  • 31. The future of REST API Documentation PR#1915
  • 32. REST Authentication • The existing DSpace authentication methods will be supported • The REST API returns an authentication token • This token is passed to subsequent REST requests as a header
  • 33. Why Authenticate? • View restricted items/bitstreams • Create/Update/Delete Objects – Submit items • Perform admin operations • View restricted metadata (provenance) • Note: most of these actions are not yet supported in DSpace REST
  • 34. A subset of these operations are available in HAL
  • 35. Exercise 2: Authenticating in HAL Exercise 2 - Authentication in HAL Browser • For this workshop, we will use password authentication http://bit.ly/dspace7-rest
  • 36. Limitations of HAL Authn • Credentials only passed for GET operations • File uploads not supported
  • 37. Postman - A development client for REST API’s https://www.getpostman.com/apps
  • 38. Postman - A tool for sending REST requests • Postman is a tool for interacting with various REST services – Even ones without a HAL Browser • Using a web browser, it is difficult to construct complex requests
  • 40. Tabs and Collections help you organize and re-use requests
  • 45. Browsing with Postman • View all items – /api/core/items • Change page size – /api/core/items?size=5 • Change starting page – /api/core/items?size=5&page=2
  • 46. Exercise 3: Browsing with Postman Exercise 3 - Browsing with Postman http://bit.ly/dspace7-rest
  • 48. AuthN Status in Postman (no AuthN token)
  • 49.
  • 51.
  • 52. AuthN Status in Postman (passing Bearer token)
  • 53.
  • 54.
  • 55. Let’s Attempt to change data • The current REST API allows a user to start a submission • POST – /api/submission/workspaceitems – Body: {} • The response will return an object with an id
  • 56. Retrieving the Item that was created • GET – /api/submission/workspaceitems/[id] • DELETE – /api/submission/workspaceitems/[id] • GET – /api/submission/workspaceitems/[id] The second GET request will fail
  • 57. Exercise 4: Modifying data with Postman Exercise 4 - Modifying data with Postman http://bit.ly/dspace7-rest
  • 58. Managing Postman • Postman allows you to use variables and scripts to manage credentials Tips on using postman
  • 60. Stateless (no session) Specifications • JSON web tokens (JWT) • Cross-Origin Resource Sharing (CORS) Headers HTTP Resources ● URIs reference individual resources or collections (of resources) ● /items/{uuid} and /items Formats: JSON* or XML HTTP methods GET (read), HEAD (read headers only) POST (create) PUT (replace), PATCH (partial update) DELETE (remove) OPTIONS (verify access, e.g. via CORS) HTTP return codes 2xx (Success) 3xx (Redirect) 4xx (Client error) 5xx (Server error) REST Terminology
  • 61. Hypermedia as the Engine of Application State - HATEAOS HAL Format Links are expressed in a standard/well-known way in the json response (it is also suitable for xml but DSpace7 will focus only on JSON) → enable the interactive navigation → abstract routing (URL can change without break the client) → support documentation ALPS Available methods, semantics of request and response objects discoverable in a standard way (/profile) and expressed in multiple standards format (Alps JSON, JSON Schema, XML, etc) → enable to expose only available methods (i.e. GET on resourcepolicies is disallowed) → document in a machine-readable way the request and response semantics
  • 64. REST Maturity level Image from: https://martinfowler.com/articles/richardsonMaturityModel.html
  • 65. Spring technologies Spring Bootstrap: pre-configured managed Spring platform Spring MVC: Front Controller, data binding, error handling Spring REST: MVC extension to easily support Content-Negotiation, Response in JSON format
  • 66. Spring technologies Spring HATEOAS: library to deal with HAL Document (Resources, Resource, Links, Curie) Spring Data REST: only for inspiration (consistent design choices, HTTP error handling, support classes, etc.)
  • 67. Spring technologies Spring Data REST Hal Browser: WebJar of the HAL browser customized to work at best with Spring Data REST Spring REST Docs: Self contained documentation with snippets from Integration Tests
  • 68. Pagination https://github.com/DSpace/Rest7Contract#pagination Resource Collections are always paginated → pagination information are returned in a consistent way across all the endpoints → pagination parameters are expected in the same form in all the endpoints → common JAVA API to deal with page jump and offset
  • 69. Search Methods https://goo.gl/NSju3q Collection endpoints that allowing filtering, search or precise lookup of resources MUST provide a search link listing all the available methods
  • 70. Right use of the HTTP Verbs: collection - POST Adds a new element to the collection. - GET Returns the first page of the resources in the collection
  • 71. Right use of the HTTP Verbs: element GET Returns a single entity. HEAD Returns whether the item resource is available. PUT Replaces the state PATCH Similar to PUT but partially updating the resources state DELETE Deletes the resource exposed.
  • 72. How to deal with PATCH JSON Patch specification RFC6902 Express change to a JSON Object in JSON Array of Operations executed in an atomic transaction Each successful Patch operation will return a HTTP 200 CODE with the new state of the patched resource as body similar to what is returned for a GET request.
  • 73. How to deal with PATCH ADD / REMOVE / REPLACE / MOVE [ { "op": "test", "path": "/a/b/c", "value": "foo" }, { "op": "remove", "path": "/a/b/c" }, { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }, { "op": "replace", "path": "/a/b/c", "value": 42 }, { "op": "move", "from": "/a/b/c", "path": "/a/b/d" }, { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" } ] TEST & COPY (no plan to support them)
  • 74. PATCH (More examples: https://goo.gl/G84oRQ) [{ "op": "add", "path": "/sections/traditionalpageone/dc.contributor.author/-", "value": {"value": "Another, Author"} }]
  • 75. HTTP status codes - 2xx, 3xx 200 Ok - Normal success state 201 Created - Returned when a resource is created 204 No content - Returned when the operation succeed but no content is available (i.e. hit the logo endpoint of a community without logo 206 Partial Content - DSpace 7 provides range support for bitstream download allowing streaming 302 Found - the PID endpoint redirect to the target resource
  • 76. HTTP status codes - 4xx 400 Bad Request - if the request is invalid (not a json, etc.) 401 Unauthorized - if the request require a logged-in user 403 Forbidden - if the requester doesn't have enough privilege to execute the request 404 Not found - if the requested resource doesn't exists 405 Method Not Allowed - if the requested verb is not supported for the resource 422 Unprocessable Entity - if the request is semantically invalid (i.e. attempt to add undefined metadata, deposit an invalid workspace)
  • 78. Code used in the workshop https://github.com/4Science/DSpace Branch: or2018-workshop (final result) | tags will help to move step by step or2018-workshop-start
  • 79. How URL are translated to JAVA code Where is my web.xml? It is a spring boot application with web support (MVC) Controller → are the “new” Servlet @RestController
  • 80. What about the lovable spring xml files? sorry now we use annotations :) Component scanning enabled on repository, converter, utils packages @Component @Service
  • 81. Goal: Enhance the EPerson endpoint • List EPersons (already exists) • Get EPerson (already exists) Walkthrough the implementation and the Integration Tests [tag: or2018-workshop-start]
  • 82. Rest Model Class • POJO used as DTO between the REST layer and the services. • Clean and stable version of our data model • The converter class transcode the DSpace-API objects in REST objects
  • 83. Repository Class • It is defined in the Repository design pattern • It implements the Data Access Layer in DDD • Close to the domain model, abstracting access to a collection
  • 84. Resource Class • Wrap the Domain Class inside an HAL document • Provide supports to add links • Manage embedded objects
  • 85. Integration Test Builder and Matcher helper classes to keep code compact & cleanup the test database between runs One or more test for each repository methods - Separate test for different scenarios (exception, limit case, normal case) - Multiple calls in the same test to cross check the intent changes
  • 86. Add security check Learn how to authenticate an user in the Integration Test [or18-ws1-it] Secure the main eperson endpoint (only administrators can access) [or18-ws1-fix]
  • 87. Enhancing EPerson endpoint Implement Search by email, by name (walkthrough) 1. Write Integration Tests in advance [or18-ws2-it] 2. Implement the endpoint, run the test [or18-ws2-search / or18-ws2-search2] 3. Interact using the HAL browser [or18-ws2-fix]
  • 88. Enhancing EPerson endpoint Implement DELETE (walkthrough) 1. ITs successful DELETE, failures due to Authorization issues, DB constraints [or18-ws3-it] 2. Check the implementation [or18-ws3-fix]
  • 89. Enhancing EPerson endpoint Implement POST (walkthrough) • How to test a create operation • How to implement [or18-ws4]
  • 90. Enhancing EPerson endpoint Implement Patch (walkthrough) • Change the CanLogin flag • Change the Password [or18-ws5]
  • 91. Enhancing EPerson endpoint BONUS (discussion only) • List/Create/Delete RegistrationToken • How to transform a RegistrationToken in an EPerson (text/uri-list)
  • 92. DSpace 7 will arrive more quickly with more help! ❏ 1st DSpace 7 Community Sprint: May 7 - 18 ❏ 14 pull requests, 8 contributors (2 first time) ❏ 2nd DSpace 7 Community Sprint: July 9 - 20 No availability requirements! Choose your own tickets/tasks! No DSpace 7 experience necessary! (Coaches available) Join a Development Sprint! Sign-up now! https://tinyurl.com/dspace7sprints