SlideShare uma empresa Scribd logo
1 de 16
REST... with Peace
Content Management with Apache Sling




                 1
The Problem (abstract)
• Store large amounts of different types of content
• Associate meta data to content
• Access control
• Search for stuff
• Get notified on changes
• ...and all that in a lightweight fashion
   sounds familiar, huh? :-)



                                             2
                                                  REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
JCR: Some History
• The content management market was fragmented heavily:
   many vendors, many implementations

• Users were locked in to specific solutions
• Even the most fundamental concept of content management was not
   standardized: the content repository

• The Content Repository for Java API was proposed in JSR 170 by Day
   Software, finalized in 2005

• JCR 2.0 in 2009, API released as an OSGI bundle
   JCR 1.0: http://jcp.org/en/jsr/detail?id=170

  JCR 2.0: http://jcp.org/en/jsr/detail?id=283
                                                  3
                                                      REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
JCR in a Nutshell
• A hierarchical model for storing structured and unstructured content in
   content repositories

• Conformance Level 1:
 • reading, nodes and properties, XPath queries, export
• Conformance Level 2:
 • write, references and referential integrity, access control, import
• Optional features:
 • versioning, transactions, SQL queries, locking, observation
                                        4
                                                    REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Apache Jackrabbit
• Implements all features of JCR 1.0 and 2.0
• Actively developed, current version is 2.2.4



   http://jackrabbit.apache.org/




• Uses a mix of database (Apache Derby) and filesystem persistence by default


                                        5
                                                 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
a Bit of REST
• It‘s all about resources
• Focused on data, not actions (unlike SOAP, RPC)                                                                                         !")&"#"*+,-$*(



• CRUD via HTTP                                                                                      !"#$%&'"(


                                                                                                                                          !")&"#"*+,-$*(
• Distinguishes between (abstract) resources and
   (concrete) representations

• Probably HTTP‘s most overlooked feature:
   content negotiation based on HTTP headers (e.g. Accept, Accept-Language)

   Roy Fielding‘s thesis: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm



                                                                     6
                                                                                      REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Apache Sling
• REST-based framework on top of Apache Jackrabbit
• Apache top-level project since 2009
• OSGI-driven (Apache Felix)                                                      http://sling.apache.org/site/index.html


• Scripting (JSP, SS-JS, Scala), open to other languages
• Can be deployed standalone or inside a servlet container, Launchpad is ready-
   to-run

• Convention-over-configuration
• What it‘s not: a full-featured, „classic“ web application framework
                                          7
                                                     REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
The Content Model
• Everything evolves around resources, nodes and properties
• Sling allows you to store structured or unstructured content anywhere you
   want:

   curl   -F"foo=bar“ http://localhost:8080/repo
   curl   -F“foo=baz“ -F“sling=rocks“ http://localhost:8080/repo
   curl   -F“andAnotherThing=true“ http://localhost:8080/repo/
   curl   -X DELETE http://localhost:8080/repo



• Resource types give structure to content:
   curl -F"sling:resourceType=sling:Folder" $SAURL/repo




                                                          8
                                                                   REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
How Does it Work?
• Data-centric, resource-first approach
• Simply put:

                                                 012$),(3-'$45$
                  %&'$(&)*+(,&$                                                               "&-(&)&1
      !"#$                         "&)*+(,&$     (&)6$'5-&$.12$
                      -.'/$                                                                    '.9*1$
                                                 (&76$8&'/*2$




• There‘s more: wrapping and decorating resources


                                         9
                                               REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Defining Resource Types
• Two options for defining resource types:
 • Imperative: via Java                       [wcmpp:resource]
                                                - title
                                                                     > nt:folder, sling:Resource
                                                             (string) mandatory
                                                - state        (string) mandatory

 • Declarative:
                                                + changelog        (wcmpp:changelog) autocreated
                                                + tags          (wcmpp:tags) autocreated
                                                + content        (nt:file) version

                                              [wcmpp:tags]             > nt:folder, sling:Resource
   • CND (Compact Node Definition)               +*                (nt:base) = wcmpp:tag

                                              [wcmpp:tag]              > nt:base, sling:Resource


   • XML, JSON (Sling)                        [wcmpp:changelog]
                                                + item
                                                                  > sling:OrderedFolder
                                                              (wcmpp:changelogentry)

                                              [wcmpp:changelogentry] > nt:folder, sling:Resource

• Allows for an exact definition of the          - text       (string) mandatory


   content model                              [wcmpp:image]              > wcmpp:resource




• Supports sub-classing, mixins
                                         10
                                                   REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
URL Decomposition
• Sling has a smart method of decomposing URLs to find the right resource
   representation:

   http://bar.org/repository/path/to/resource.tidy.2.json/in/side


                      resource path          selectors extension suffix


• URL decomposition is Sling‘s way of Content Negotiation
• Advantage: you don‘t need to mess around with HTTP headers

                                      11
                                                REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Servlets and Scripts
• Two methods of adding servlets and scripts:           (well, truth being told, scripts are servlets as well)



 1. Register as OSGI services
                                            sling.servlet.*:
                                            paths, resourceTypes, selectors,
                                            extensions, methods, prefix
   a. using SCR annotations
                                            * @scr.service interface="javax.servlet.Servlet"
                                            * @scr.property name="sling.servlet.resourceTypes" value="wcmpp/feed"

   b. using code (not Sling-ful)            * @scr.property name="sling.servlet.methods" value="GET"




 2. Store in /apps                          path component derived from resource type,
                                            e.g. a GET handling server-side JavaScript for
                                            resource type cms/images needs to be stored in
                                            /apps/cms/images/GET.esp



• Servlet registration is more fine-grained
                                       12
                                                             REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Queries
• JCR supports XPath (deprecated with JCR 2.0) and SQL (JCR 2.0) queries
• Via Java:
   Resource resource = request.getResource();
   Session session = repository.login();
   QueryManager qmngr = session.getWorkspace().getQueryManager();
   
 
   Query query = qmngr.createQuery("//element(*, wcmpp:image)", "xpath");
   NodeIterator result = query.execute().getNodes();


• Using the query servlet:
   http://localhost:8080/repo.query.json?statement=//
   *[@jcr:primaryType='wcmpp:image']&property=jcr:content/jcr:mimeType



 • Parameters: offset, rows, property
                                                      13
                                                                     REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Access Control
• Privilege based access-control model, based on JCR
• Pre-defined privileges are applied to nodes using specific selectors:
 • modifyAce, acl, deleteAcl
                                           You need to register users before setting privileges:
• Privileges:                              curl -F:name=cag -Fpwd=password -FpwdConfirm=password -Fanyproperty=value
                                           http://localhost:8080/system/userManager/user.create.html

 • jcr:read, jcr:write, jcr:all
 • jcr:modifyProperties, jcr:addChildNodes, jcr:modifyAccessControl,
    jcr:nodeTypeManagement, ...
    curl -FprincipalId=cag -Fprivilege@jcr:read=granted http://localhost:8080/test/node.modifyAce.html


                                               14
                                                                   REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
Listening to Events
• A repository sends low-level events:
     •    TOPIC_RESOURCE_ADDED, TOPIC_RESOURCE_REMOVED, TOPIC_RESOURCE_CHANGED,
          TOPIC_RESOURCE_PROVIDER_ADDED


• You‘d typically filter these generic events and transform them into application
         specific events
 /**
  * @scr.component immediate="true"
  * @scr.service interface="org.osgi.service.event.EventHandler"
  * @scr.property name="event.topics" valueRef="org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED"
  */
                                                             String propPath = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
 public class MyHandler implements EventHandler {
                                                             String propResType = (String) event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE);
                                                             if (propPath.startsWith("/tmp/dropbox") && propResType.equals("nt:file")) {
     public void handleEvent(Event event) { }
                                                                final Dictionary<String, Object> props = new Hashtable<String, Object>();
                                                                props.put(EventUtil.PROPERTY_JOB_TOPIC, JOB_TOPIC);
 }
                                                                props.put("resourcePath", propPath);
                                                                Event dropboxJobEvent = new Event(EventUtil.TOPIC_JOB, props);
                                                                eventAdmin.sendEvent(dropboxJobEvent);
                                                             }


                                                                     15
                                                                                         REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
<eop>
        Thank you for your attention.
                Questions?

           Claus Augusti <claus@formatvorlage.de>
           Frontend Architect 1&1 Development Hosting




                      Kudos to the Apache Foundation.You guys *ROCK* :-)

                               16
                                            REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de

Mais conteúdo relacionado

Último

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Destaque

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Destaque (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

REST... with Peace. Content Management with Apache Sling

  • 1. REST... with Peace Content Management with Apache Sling 1
  • 2. The Problem (abstract) • Store large amounts of different types of content • Associate meta data to content • Access control • Search for stuff • Get notified on changes • ...and all that in a lightweight fashion sounds familiar, huh? :-) 2 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 3. JCR: Some History • The content management market was fragmented heavily: many vendors, many implementations • Users were locked in to specific solutions • Even the most fundamental concept of content management was not standardized: the content repository • The Content Repository for Java API was proposed in JSR 170 by Day Software, finalized in 2005 • JCR 2.0 in 2009, API released as an OSGI bundle JCR 1.0: http://jcp.org/en/jsr/detail?id=170 JCR 2.0: http://jcp.org/en/jsr/detail?id=283 3 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 4. JCR in a Nutshell • A hierarchical model for storing structured and unstructured content in content repositories • Conformance Level 1: • reading, nodes and properties, XPath queries, export • Conformance Level 2: • write, references and referential integrity, access control, import • Optional features: • versioning, transactions, SQL queries, locking, observation 4 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 5. Apache Jackrabbit • Implements all features of JCR 1.0 and 2.0 • Actively developed, current version is 2.2.4 http://jackrabbit.apache.org/ • Uses a mix of database (Apache Derby) and filesystem persistence by default 5 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 6. a Bit of REST • It‘s all about resources • Focused on data, not actions (unlike SOAP, RPC) !")&"#"*+,-$*( • CRUD via HTTP !"#$%&'"( !")&"#"*+,-$*( • Distinguishes between (abstract) resources and (concrete) representations • Probably HTTP‘s most overlooked feature: content negotiation based on HTTP headers (e.g. Accept, Accept-Language) Roy Fielding‘s thesis: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm 6 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 7. Apache Sling • REST-based framework on top of Apache Jackrabbit • Apache top-level project since 2009 • OSGI-driven (Apache Felix) http://sling.apache.org/site/index.html • Scripting (JSP, SS-JS, Scala), open to other languages • Can be deployed standalone or inside a servlet container, Launchpad is ready- to-run • Convention-over-configuration • What it‘s not: a full-featured, „classic“ web application framework 7 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 8. The Content Model • Everything evolves around resources, nodes and properties • Sling allows you to store structured or unstructured content anywhere you want: curl -F"foo=bar“ http://localhost:8080/repo curl -F“foo=baz“ -F“sling=rocks“ http://localhost:8080/repo curl -F“andAnotherThing=true“ http://localhost:8080/repo/ curl -X DELETE http://localhost:8080/repo • Resource types give structure to content: curl -F"sling:resourceType=sling:Folder" $SAURL/repo 8 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 9. How Does it Work? • Data-centric, resource-first approach • Simply put: 012$),(3-'$45$ %&'$(&)*+(,&$ "&-(&)&1 !"#$ "&)*+(,&$ (&)6$'5-&$.12$ -.'/$ '.9*1$ (&76$8&'/*2$ • There‘s more: wrapping and decorating resources 9 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 10. Defining Resource Types • Two options for defining resource types: • Imperative: via Java [wcmpp:resource] - title > nt:folder, sling:Resource (string) mandatory - state (string) mandatory • Declarative: + changelog (wcmpp:changelog) autocreated + tags (wcmpp:tags) autocreated + content (nt:file) version [wcmpp:tags] > nt:folder, sling:Resource • CND (Compact Node Definition) +* (nt:base) = wcmpp:tag [wcmpp:tag] > nt:base, sling:Resource • XML, JSON (Sling) [wcmpp:changelog] + item > sling:OrderedFolder (wcmpp:changelogentry) [wcmpp:changelogentry] > nt:folder, sling:Resource • Allows for an exact definition of the - text (string) mandatory content model [wcmpp:image] > wcmpp:resource • Supports sub-classing, mixins 10 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 11. URL Decomposition • Sling has a smart method of decomposing URLs to find the right resource representation: http://bar.org/repository/path/to/resource.tidy.2.json/in/side resource path selectors extension suffix • URL decomposition is Sling‘s way of Content Negotiation • Advantage: you don‘t need to mess around with HTTP headers 11 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 12. Servlets and Scripts • Two methods of adding servlets and scripts: (well, truth being told, scripts are servlets as well) 1. Register as OSGI services sling.servlet.*: paths, resourceTypes, selectors, extensions, methods, prefix a. using SCR annotations * @scr.service interface="javax.servlet.Servlet" * @scr.property name="sling.servlet.resourceTypes" value="wcmpp/feed" b. using code (not Sling-ful) * @scr.property name="sling.servlet.methods" value="GET" 2. Store in /apps path component derived from resource type, e.g. a GET handling server-side JavaScript for resource type cms/images needs to be stored in /apps/cms/images/GET.esp • Servlet registration is more fine-grained 12 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 13. Queries • JCR supports XPath (deprecated with JCR 2.0) and SQL (JCR 2.0) queries • Via Java: Resource resource = request.getResource(); Session session = repository.login(); QueryManager qmngr = session.getWorkspace().getQueryManager(); Query query = qmngr.createQuery("//element(*, wcmpp:image)", "xpath"); NodeIterator result = query.execute().getNodes(); • Using the query servlet: http://localhost:8080/repo.query.json?statement=// *[@jcr:primaryType='wcmpp:image']&property=jcr:content/jcr:mimeType • Parameters: offset, rows, property 13 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 14. Access Control • Privilege based access-control model, based on JCR • Pre-defined privileges are applied to nodes using specific selectors: • modifyAce, acl, deleteAcl You need to register users before setting privileges: • Privileges: curl -F:name=cag -Fpwd=password -FpwdConfirm=password -Fanyproperty=value http://localhost:8080/system/userManager/user.create.html • jcr:read, jcr:write, jcr:all • jcr:modifyProperties, jcr:addChildNodes, jcr:modifyAccessControl, jcr:nodeTypeManagement, ... curl -FprincipalId=cag -Fprivilege@jcr:read=granted http://localhost:8080/test/node.modifyAce.html 14 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 15. Listening to Events • A repository sends low-level events: • TOPIC_RESOURCE_ADDED, TOPIC_RESOURCE_REMOVED, TOPIC_RESOURCE_CHANGED, TOPIC_RESOURCE_PROVIDER_ADDED • You‘d typically filter these generic events and transform them into application specific events /** * @scr.component immediate="true" * @scr.service interface="org.osgi.service.event.EventHandler" * @scr.property name="event.topics" valueRef="org.apache.sling.api.SlingConstants.TOPIC_RESOURCE_ADDED" */ String propPath = (String) event.getProperty(SlingConstants.PROPERTY_PATH); public class MyHandler implements EventHandler { String propResType = (String) event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE); if (propPath.startsWith("/tmp/dropbox") && propResType.equals("nt:file")) { public void handleEvent(Event event) { } final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(EventUtil.PROPERTY_JOB_TOPIC, JOB_TOPIC); } props.put("resourcePath", propPath); Event dropboxJobEvent = new Event(EventUtil.TOPIC_JOB, props); eventAdmin.sendEvent(dropboxJobEvent); } 15 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de
  • 16. <eop> Thank you for your attention. Questions? Claus Augusti <claus@formatvorlage.de> Frontend Architect 1&1 Development Hosting Kudos to the Apache Foundation.You guys *ROCK* :-) 16 REST... with Peace - Content Management with Apache Sling / Claus Augusti / claus@formatvorlage.de

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n