[Webinar] An Hour with the CTO: All About APIs and the Nuxeo Platform
-
Upload
nuxeo -
Category
Technology
-
view
450 -
download
5
description
Transcript of [Webinar] An Hour with the CTO: All About APIs and the Nuxeo Platform
NUXEO PLATFORM&
APIwhat is coming in the next releases ?
NUXEO PLATFORMnot only a Content Repository
provide tools to build Content AppsConfiguration StudioAPI, SDK, Dev tools, Test toolsPackaging and deployment tools
these 2 trends are driving the Roadmap for 5.9.x fastracks
BUILD MODERN WEB APPS
Back to the client sideHtml 5 / JavaScriptMobile Apps
Leverage Cloud promisesECM as a serviceEasy scaling
APIIS THE MAIN ENTRY POINT
API is a major focus for next FastTrack releases
NUXEO API CHALLENGESexpose Nuxeo Platform via http without losing our soul
BEING DYNAMICServices to expose depends on deployment option
Contribute custom Services
Data Structures (users, docs ...) depends on configuration
+workflowService +conversionService -relationService
+myCustomBusinessService
{ common : {...}, dublincore : {...}, customSchema : {...}, ...}
BEING COMPOSABLE"Pack" several services calls inside the same transaction
Fetch all required information in one call
aggregate all required info
updateDoc + validateTask + generatePDF
doc attributes + associated tasks + urls
AND ALSOefficiently manage streams
manage authentication in an easy and pluggable way
be HTML/JavaScript friendly
byte[] ==> evilMultiPart ==> pain
new XMLHttpRequest()
HOW WE BUILT THE AUTOMATION APIexpose a dynamic http API
AUTOMATION REST ENDPOINTExpose Nuxeo entities as REST resources
Documents, Users, Workflows, Tasks ...
CRUD via GET, PUT, POST, DELETEGET /nuxeo/api/v1/path/<font color="#6aa84f">{path}</font> HTTP/1.1
GET /nuxeo/api/v1/id/<font color="#6aa84f">{uid}</font> HTTP/1.1
GET /nuxeo/api/v1/user/<font color="#6aa84f">{userName}</font> HTTP/1.1
GET /nuxeo/api/v1/group/<font color="#6aa84f">{groupId}</font> HTTP/1.1
REST ENDPOINT : GET DOCUMENTGET /nuxeo/api/v1/path/default-domain/workspaces/WS/TestNote HTTP/1.1
HTTP/1.1 200 OKContent-Type: application/json
{ "entity-type": "document", "repository": "default", "uid": "6a3998e3-6890-45f5-9c19-b708814a9c1c", "path": "/default-domain/workspaces/WS/TestNote", "type": "Note", "state": "project", "versionLabel": "0.0", "isCheckedOut": true, "title": "TestNote", "lastModified": "2014-01-20T13:11:29.64Z", ...}
AUTOMATION RPC : OPERATIONS ENDPOINTCoarse grained API on top of Java API
each services can contribute Operations
Expose endpoint for OperationsGET to retrieve definitionPOST to execute
OPERATIONS ENDPOINTGET /nuxeo/site/automation/Document.PageProvider HTTP/1.1
HTTP/1.1 200 OKContent-Type: application/json
id":"Document.PageProvider", "label":"PageProvider", "description":"Perform a query ...", "signature":[ "void", "documents" ], "params":[ { "name":"page", "type":"integer", "required":false },{ "name":"query", "type":"string", "required":false, }, ... ]}
OPERATIONS ENDPOINTPOST /nuxeo/site/automation/Document.PageProvider HTTP/1.1Content-Type: application/json+nxrequest{ "params" : { "query" : "select * from Note", "page" : 0 }}
HTTP/1.1 200 OKContent-Type: application/json{ "entity-type": "documents", "pageIndex": 0, "pageSize": 2, "pageCount": 2, "entries": [ { "entity-type": "document", "repository": "default", "uid": "3f76a415-ad73-4522-9450-d12af25b7fb4", ... }, { ...}, ... ]}
DYNAMIC DATA STRUCTUREFetch all needed data in one call
CONTROL MARSHALINGuse header to control what schemas should be sent
fetch the data needed on the client side and nothing more
X-NXDocumentProperties dublincore, common, file
GET /nuxeo/api/v1/path/default-domain/workspaces/WS/TestNote HTTP/1.1
<b>X-NXDocumentProperties note, files</b>
CONTROL MARSHALING GET /nuxeo/api/v1/path/default-domain/workspaces/WS/TestNote HTTP/1.1<span style="font-family: monospace;"> <font color="#6aa84f">X-NXDocumentProperties note, files</font> </span>
HTTP/1.1 200 OKContent-Type: application/json{ "entity-type": "document", ... <font color="#6aa84f">"properties": { "note:mime_type": "text/x-web-markdown", "note:note": "##Hello", "files:files": [ { "file": { "name": "layout.png", "mime-type": "image/png", "length": "43627", "data": "files/6a3998e3-6890-45f5-9c19-b708814a9c1c" } } ] } ...</font>}
FETCH EXTRA INFOuse RestContributor to fetch additional info (Mixins)
urls, breadcrumb info, comments, related documents ...
use header to tell server what info is neededX-NXContext-Category breadcrumb
GET /nuxeo/api/v1/path/default-domain/workspaces/WS/TestNote HTTP/1.1
X-NXContext-Category breadcrumb
FETCH REST CONTRIBUTIONS GET /nuxeo/api/v1/path/default-domain/workspaces/WS/TestNote HTTP/1.1<span style="font-family: monospace;"> <font color="#6aa84f">X-NXContext-Category breadcrumb</font> </span>
HTTP/1.1 200 OKContent-Type: application/json{ "entity-type": "document", ... <font color="#6aa84f"> "contextParameters": { "breadcrumb": { "entity-type": "documents", "entries": [ { "entity-type": "document", "repository": "default", "path": "/default-domain", ... }, ... ] } }</font>}
LEVERAGE ADAPTER SYSTEMcontribute custom logic
@WebAdapter(name = BOAdapter.NAME,type = "BOService", targetType = "Document")@Produces({ "application/json+nxentity"})public class BOAdapter extends DefaultAdapter {
expose as business object with custom marshalingGET /nuxeo/api/v1/path/domain/workspaces/WS/note/<font color="#6aa84f">@audit</font> HTTP/1.1
GET /nuxeo/api/v1/path/domain/workspaces/WS/note/<font color="#6aa84f">@bo/MyBO</font> HTTP/1.1
FETCH AUDIT RECORDS VIA ADAPTERGET /nuxeo/api/v1/path/domain/workspaces/WS/note/<font color="#6aa84f">@audit</font> HTTP/1.1
HTTP/1.1 200 OKContent-Type: application/json{ "entity-type":"<font color="#6aa84f">logEntries</font>", ... "entries":[ { "entity-type":"<font color="#6aa84f">logEntry</font>", "principalName":"tdelprat", "docType":"Note", "eventId":"documentCreated", "repositoryId":"default", "eventDate":"2014-01-12T16:58:55.294+01:00", ... }, <span style="font-family: monospace;">...</span><span style="font-family: monospace;">}</span>
COMPOSABLE APIExpose the API that matches your needs
AUTOMATION CHAINSOperations have Input / Output and Arguments
Operations can be chained on the service sideone call , one transaction
doc => updateDoc =(doc)=> validateTask =(doc)=> generatePDF =(Blob)=>
Create new Operations via composition
COMPOSE CHAINvia XML / via Drag&Drop
OPERATIONS AND RESOURCESBridge Operations and Resource Endpoints
"pipe Operation or Chain" on resourcefetch resource => feed Operation or Chain
POST /nuxeo/api/v1/path/domain/workspaces/WS/note/<font color="#6aa84f">@op/Blob.ToPDF</font>
OPERATIONS AND EXTENSIONSContribute new Operations via Extension Point
Contribute new Adapters via Extension Point
Compose Operations via Workflow
DYNAMIC AND COMPOSABLE APICool, but what is the trade-off
API IS MORE POWERFUL, BUT MORE COMPLEXData mapping needs to be dynamic
Calling dynamic endpoints is more complex than static API
endpoint.invoke("createDocument", {input: ... , params:...})
nuxeo.createDocument(path, name, type)
SOLUTION : Provide introspection
methods and data types
Provide client lib provides some data mapping(document, blob)provides a high level simple API (createDocument, addComment ...) does some checks(validate method definition)
Java, Javascript, Python, Dart, Php, ObjectiveC ...
MULE CLOUDHUB EXAMPLELeverage Java Lib service wrapper
Plug Mule DataSense with Nuxeo Types introspectionMule fetches datatypes from Nuxeo
Use invoke like pattern for dynamic Operationscannot dynamicaly build UI from Automation metadata
DYNAMIC DATA MAPPING
ROADMAP & NEXT STEPS when is it ready ?
NEXT STEPS : APIAPI improvements are part of 5.9.x FastTrack releases
REST EndPointsRestContributors and changes in marshaling
SDK are in progressJavaScriptAngularDartiOsAndroid
Sample Apps and playground
NEXT STEPS : CLOUDnuxeo.io : Nuxeo Platform as a ServiceCloud provisioning + API + online IDE
ScalingElastic Search integrationNoSQL backend
Q&A ?