ldp4j: a framework for the development of interoperable read-write linked data applications

23
Center for Open Middleware Center for Open Middleware LDP4j: A framework for the development of interoperable read-write Linked Data applications Miguel Esteban Gutiérrez, Nandana Mihindukulasooriya, Raúl García Castro Center for Open Middleware / Ontology Engineering Group Universidad Politécnica de Madrid, Spain. @nandanamihindu / [email protected]

Upload: nandana-mihindukulasooriya

Post on 05-Dec-2014

357 views

Category:

Technology


0 download

DESCRIPTION

This presentation introduces LDP4j, an open source Java-based framework for the development of read-write Linked Data applications based on the W3C Linked Data Platform 1.0 (LDP) specification and available under the Apache 2.0 license. This was presented in the ISWC 2014 Developer Woskshop. http://www.ldp4j.org/

TRANSCRIPT

Page 1: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

Center for Open Middleware

LDP4j: A framework for the development of interoperable

read-write Linked Data applications

Miguel Esteban Gutiérrez,

Nandana Mihindukulasooriya,

Raúl García CastroCenter for Open Middleware / Ontology Engineering Group

Universidad Politécnica de Madrid,

Spain.

@nandanamihindu / [email protected]

Page 2: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

2

Agenda

• Introduction

• Developing a read-write Linked Data application

• LDP4j to the rescue

• LDP4j 101

• LDP4j in use

• Current status

• Future work

Page 3: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

3

choc

olat

e

Introduction• Linked Data Platform

• a standard protocol for read-write Linked Data

• LDP application ‘flavors’• vanilla vs. chocolate (application-specific)

• Interoperability

LDP Resource (LDPR)

Non-RDF Source

(LDP-NR)

RDF Source (LDP-NR)

LDP Container (LDPC)

Basic Container

Direct Container

Indirect Containerva

nilla

LDP Clients Data model Business logic

Page 4: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

Developing a read-write Linked Data ApplicationWhat we have to consider

4

R+W LD Business Logic

HTTP

SyntaxRouting

Operation semanticsContent negotiationConditional requests

• RFC 2616, 3986, 7230-7235

LDP

RDF SourcesContainers (Basic, direct,

and indirect)Paging

RDF transformation

• LDP (and paging) 1.0• RDF 1.1• LD+JSON• RFC 3987, 5785, 5789,

5988, 6585, 7240

REST best practices

Client-serverStatelessCacheable

Layered systemUniform interface

• Fielding, 2000;• Fielding & Taylor, 2002

Page 5: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

Servlet 3.0JAX-RS

Developing a read-write Linked Data ApplicationWhat we can use up-to-now

5

HTTP

REST best practices

LDP

R+W LD Business Logic

RDF Parsers/SerializersThird party apps and

utilities that support LDP

• RFC 2616, 3986, 7230-7235

• LDP (and paging) 1.0• RDF 1.1• LD+JSON• RFC 3987, 5785, 5789,

5988, 6585, 7240

• Fielding, 2000;• Fielding & Taylor, 2002

Syntax and

routing

No support at

all

Only for RDF-based

data access

Page 6: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

6

LDP4j to the rescue

• Java-based framework for the development of read-write Linked Data applications• Motto: Focus on your business logic, we will take care of the rest• License: Apache License, v2.0

• Features:• Simplified business object handling:

• Lifting from and lowering to an intermediate representation that can be automatically unmarshalled from or marshalled to RDF, respectively.

• LDP support• Protocol conversation control• Transparent metadata management

• REST aware• Transparent publication of RDF URIRefs.

• HTTP compliant• The framework takes care of fulfilling the requirements prescribed by the HTTP related

RFCs (i.e., conditional requests processing, content negotiation, entity tag handling,…)www.ldp4j.org

https://github.com/ldp4j/ldp4j @LDP4j

[email protected]

Page 7: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101High level architecture

7

Application API

Application Engine

Server Frontend Client Frontend

R+W LD App. Consumer

R+W LD App. Provider

Server side HTTP

handling

• LDP protocol handling• RDF transformation• Application management• Resource management• Endpoint management

Client side HTTP

handling

• Templating annotations• Application configuration• Handler API• Handler extensibility APIs

•Data manipulation API•State manipulation API

Page 8: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Application model

8

Application

EndpointResource

Template

Handler

Session Snapshot

publishes

surrogateOfmanipulates

manages

uses

handledBy

definesSemantics definesDeploymentPoliciesDataset

exchanges

provides

Page 9: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Application API

9

«describes»

«describes»

Application ResourceHandler

«annotation» Resource

ContainerHandler

Modifiable

Deletable

Bootstrap Environment DataSet

«uses» «uses»

«produces»

«uses» Individual

Value

Property

Literal

«extend»

ReadSession WriteSession

ResourceSnapshot

AttachmentSnapshot

ContainerSnapshot

«provides» «uses»

«refersTo»

members ManagedIndividual LocalIndividual ExternalIndividual

«represents»

Configuration

«uses»

«uses»

«annotation» BasicContainer

«annotation» DirectContainer

«annotation» IndirectContainer

«describes» «describes»

attachments

«uses»

«uses»

«uses»

«uses»

Page 10: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

Dispatch request

Preprocess request

Op. Request

Prepare Input data

Prepare response

Create application session

Execute business logic

Terminate application session

Enrichresponse data with

LDP metadata

Op. Response

Dataset Dataset

Clie

ntSe

rver

Fro

nten

dAp

plic

ation

Eng

ine

LDP4

j Ap

plic

ation

LDP4j 101Execution Pipeline

10

Handle resource lifecycle changes

Handle endoint lifecycle changes

Dataset lowering RDF marshalling LDP headergeneration

CheckLDP metadata

consistency

Remove LDP metadata

Content negotiation

handling

Entity unmarshalling RDF lifting

Conditional requesthandling

LDP headeranalysis

Page 11: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

11

LDP4j 101Recipe for using LDP4j

1. Get LDP4j sources

2. Build LDP4j sources

3. Create a maven web-app project

4. Implement your business logic

5. Build the project

6. Deploy onto an servlet container

7. Enjoy!!!

Page 12: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

12

<?xml version="1.0" encoding="UTF-8"?><project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- Module coordinates here --> <packaging>war</packaging> <properties> <ldp4j.version>1.0.0-SNAPSHOT</ldp4j.version> <!-- Other properties here --> </properties> <dependencies> <dependency> <groupId>org.ldp4j.framework</groupId> <artifactId>ldp4j-application-api</artifactId> <version>${ldp4j.version}</version> </dependency> <dependency> <groupId>org.ldp4j.framework</groupId> <artifactId>ldp4j-server-core</artifactId> <scope>runtime</scope> <version>${ldp4j.version}</version> </dependency> <!-- Other dependencies here --> </dependencies> <!-- Other build setting here --></project>

• Create a maven web-app project:

Page 13: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

13

package org.example;

import org.ldp4j.application.data.DataSet;import org.ldp4j.application.ext.Deletable;import org.ldp4j.application.ext.ResourceHandler;import org.ldp4j.application.session.ResourceSnapshot;import org.ldp4j.application.session.WriteSession;

public class MyDeletableResourceHandler implements ResourceHandler, Deletable {

@Override public DataSet get(ResourceSnapshot resource) { // TODO Implement your data retrieval logic return null; }

@Override public void delete(ResourceSnapshot resource, WriteSession session) { // TODO Implement your deletion logic }

}

• Implement your resource handlers…

Page 14: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

14

package org.example;

import org.ldp4j.application.data.DataSet;import org.ldp4j.application.ext.ContainerHandler;import org.ldp4j.application.ext.ContentProcessingException;import org.ldp4j.application.ext.Modifiable;import org.ldp4j.application.session.ContainerSnapshot;import org.ldp4j.application.session.ResourceSnapshot;import org.ldp4j.application.session.WriteSession;

public class MyModifiableContainerHandler implements ContainerHandler, Modifiable {

@Override public DataSet get(ResourceSnapshot resource) { // TODO Implement your data retrieval logic return null; }

@Override public ResourceSnapshot create(ContainerSnapshot container, DataSet representation, WriteSession session) { // TODO Implement your creation logic here return null; }

@Override public void update(ResourceSnapshot resource, DataSet content, WriteSession session) throws ContentProcessingException { // TODO Implement your modification logic here }

}

• … and container handlers:

Page 15: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

15

package org.example;

...

import org.ldp4j.application.ext.annotations.BasicContainer;

@BasicContainer( id = "containerTemplateId", memberHandler = MyDeletableResourceHandler.class)public class MyModifiableContainerHandler implements ContainerHandler, Modifiable {

...

}

• Annotate the handlers:package org.example;

...

import org.ldp4j.application.ext.annotations.Resource;

@Resource( id="resourceTemplateId")public class MyDeletableResourceHandler implements ResourceHandler, Deletable {

...

}

Page 16: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

16

package org.example;

import org.ldp4j.application.data.Name;import org.ldp4j.application.data.NamingScheme;import org.ldp4j.application.ext.Application;import org.ldp4j.application.ext.Configuration;import org.ldp4j.application.session.WriteSession;import org.ldp4j.application.setup.Bootstrap;import org.ldp4j.application.setup.Environment;

public class MyApplication extends Application<Configuration> { @Override public void setup(Environment environment, Bootstrap<Configuration> bootstrap) { MyModifiableContainerHandler containerHandler=new MyModifiableContainerHandler(); MyDeletableResourceHandler resourceHandler=new MyDeletableResourceHandler(); // TODO Your handler configuration logic here bootstrap.addHandler(resourceHandler); bootstrap.addHandler(containerHandler);

Name<?> rootContainerName=NamingScheme.getDefault().name("containerName") ; environment.publishResource(rootContainerName, MyModifiableContainerHandler.class, "containerRootPath"); } @Override public void initialize(WriteSession session) { // TODO Your handler initialization logic here // Remember, the session has to be updated to reflect the state of the data managed by the handlers } @Override public void shutdown() { // TODO Your shutdown logic here }}

• Implement your application class:

Page 17: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

LDP4j 101Developing an application

17

<?xml version="1.0" encoding="UTF-8"?><web-app metadata-complete="false" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>My LDP4j Application</display-name>

<context-param> <param-name>ldp4jTargetApplication</param-name> <param-value>org.example.MyApplication</param-value> </context-param>

<!-- Other configuration here -->

</web-app>

• Update the web application descriptor:

Page 18: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

18

LDP4j in UseThe Bugzilla adapter

• Exposes Bugzilla as an LDP-enabled application

RDF HTTP Headers

LDP Clients

Bugzilla LDP Adapter

XML-RPC Native data model

ALM iStack ontology

POST /ita/containers/bugs HTTP/1.1Host: localhostContent-Type: text/turtle

@prefix ai: <http://delicias.dia.fi.upm.es/ontologies/alm-istack#> .

…rest of the namespace declarations are omitted for brevity.

<> a ai:ClientDefect;

dcterms:creator <http://localhost/ita/ldp/resources/users/9> ;

dcterms:title "Bugzilla adapter build is broken"^^xsd:string;

dcterms:description "Bugzilla adapter build fails due to a

test failure"^^xsd:string;

oslc_asset:relatedAsset <http://localhost/ita/ldp/resources/versions/16> ;

ai:relatedIncident <https://bugzilla.mozilla.org/show_bug.cgi?id=730698> .

HTTP/1.1 201 CreatedLocation: http://localhost/ita/ldp/resources/bugs/12Link: <http://www.w3.org/ns/ldp#Resource>; rel='type'Content-Length: 0

An example of bug creation

Mihindukulasooriya, N., Esteban-Gutiérrez, M., García-Castro, R.: A Linked Data Platform adapter for the Bugzilla issue tracker. Demo at the 13th International Semantic Web Conference, Riva del Garda, Italy (Oct 2014)

Page 19: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

19

LDP4j in Usemorph-LDP

• Exposes relational databases as read-write Linked Data

Oegmembers Table

id fname lname

asun Asunción Gómez Pérez

fpriyatna Freddy Priyatna

mesteban Miguel Estebam

nmihindu Nandana Mihindukulas

ocorcho Oscar Corcho

rgarcia Raul Garcia Castro

@prefix rr: <http://www.w3.org/ns/r2rml#> .@prefix foaf: <http://xmlns.com/foaf/0.1/> .<TriplesMapPerson> a rr:TriplesMap; rr:logicalTable [ rr:tableName "oegmembers" ];

rr:subjectMap [ a rr:Subject; rr:class foaf:Person; rr:template “http://example.org/oeg/members/{id}"; rr:termType rr:IRI; ];

rr:predicateObjectMap [ rr:predicateMap [ rr:constant foaf:firstName ]; rr:objectMap [ rr:column “fname"; rr:termType rr:Literal; ]; ];

rr:predicateObjectMap [ rr:predicateMap [ rr:constant foaf:lastName ]; rr:objectMap [ rr:column “lname"; rr:termType rr:Literal; ]; ];…

http://example.org/oeg/members/fpriyatna

RegistrationOffice

morph-LDP Web App

Relational Database

Library

Legacy Applications

configures

exposes

Tabulator

OpenLink Data Explorer

ldspider LDIF

Freddy Priyatna

dereferences to

GET /oeg/members/ HTTP/1.1Host: example.orgAccept: text/turtle

200 OKHTTP/1.1 200 OK Content-Type: text/turtle; charset=UTF-8Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"ETag: W/"195482449"

@prefix dcterms: <http://purl.org/dc/terms/>.@prefix ldp: <http://www.w3.org/ns/ldp#>. <> a ldp:BasicContainer; dcterms:title "Members of OEG, UPM"; ldp:contains <http://example.org/oeg/members/asun> ; ldp:contains <http://example.org/oeg/members/fpriyatna> ; ldp:contains <http://example.org/oeg/members/mesteban>; ldp:contains <http://example.org/oeg/members/nmihindu>; ldp:contains <http://example.org/oeg/members/ocorcho> ; ldp:contains <http://example.org/oeg/members/rgarcia> .

Read-write LDMorph-LDPDatabase + R2RML mappings

Mihindukulasooriya, N., Priyatna, F., Corcho, O., Garcıa-Castro, R., Esteban-Gutiérrez, M.: morph-LDP: An R2RML-based Linked Data Platform implementation. Demo at the 11th Extended Semantic Web Conference, Crete, Greece (May 2014)

Page 20: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

20

Current status

• LDP4j 1.0.0 to be released by the end of October:• Application API, • Application Engine, and • Server Frontend

Supported LDP features

• RDF Sources• Basic Containers• Direct Containers• Sever managed

properties• Content preferences• Interaction models

Unsupported LDP features

• Non-RDF Sources• Put-to-Create

LDP features under development

• Indirect Containers

https://github.com/ldp4j/ldp4j

Page 21: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

21

Implementation report for LDP4j

• Results of W3C LDP test suite • https://dvcs.w3.org/hg/ldpwg/raw-file/default/tests/reports/ldp.html

Feature MUST SHOULD MAY

RDF Sources 24/24 (100.0%) 7/7 (100.0%) 1/1 (100.0%)

Basic Containers 37/37 (100.0%) 15/17 (88.2%) 3/4 (75.0%)

Direct Containers 42/42 (100.0%) 17/19 (89.5%) 3/4 (75.0%)

Indirect Containers 36/39 (92.3%) 15/17 (88.2%) 3/4 (75.0%)

Page 22: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

22

Future work

• Support more LDP features:• Slug headers• Indirect containers• Paging*• Patch*

• Other features beyond the LDP scope:• Vocabulary support

• Content validation

• Co-reference support• Transaction support• AAA support

Page 23: LDP4j: A framework for the development of interoperable read-write Linked Data applications

Center for Open Middleware

Center for Open Middleware

Questions?

Miguel Esteban Gutiérrez,

Nandana Mihindukulasooriya,

Raúl García Castro