SlideShare a Scribd company logo
1 of 34
Shooting rabbits with sling
Introduction to Apache Jackrabbit &
Apache Sling
JCR
• Content Repository API for Java
• JSR-170 & JSR-283
• javax.jcr
• Object database
• Hierarchical data model
• Apache Jackrabbit – reference implementation
Mantra: everything is content
• Content is content
– Blogs, articles, posts, etc.
• Structured data
– List of addresses in e-mail database
• Unstructured data
– Word document
• ACLs
• Code
Content hierarchy
• JCR has tree-like data model
• Repository consists of items
• Item can be node or property
• Node children are properties or other nodes
• Properties are leaves
Node
• Nodes form content hierarchy
• Nodes are named
• Each node has primary type specifying it’s structure
(allowed and required children and properties)
– Something like class
– Eg. myapp:Contact requires properties myapp:givenName
and myapp:familyName
• Nodes can also have mixin types
– Something like interface
– Eg. mix:versionable, mix:lockable or myapp:Emailable
• Popular types:
– nt:base, nt:unstructured, nt:folder
Property
• Property contains data
• Types:
– string, binary, long, double, date, boolean, name,
path, reference
• Can be multivalued
Searching
• Node names and properties are indexed
• Jackrabbit uses Apache Lucene
• Supported query languages:
– XPath
– JCR-SQL
– JCR-SQL2 (recommended)
SQL2
SELECT * FROM [cq:PageContent] AS s
WHERE ISDESCENDANTNODE([/content])
AND s.[jcr:title] = ’Moja strona’
• Main purpose: find node by property contents
• Avoid queries with parent path (as it’s not
indexed)
– It’s better to create a mixin or marker property
• We don’t JOIN
• SQL and XPath are isomorphic
Versioning
• Any subtree can be versioned
• Add mixin mix:versionable
• node.checkin()
– Creates new version
– Makes the node read-only
• node.checkout()
– Allows to modify the node
• Usage examples:
– Page versions at many levels
Observation
• Event listener
• We can filter events with:
– Event type
– Path
– Node types
– An explicit list of nodes
• Usage examples:
– Automatic workflows
– Generating thumbnails
– “Last modified” date
– Indexing in internal and external search engine
Other features
• Locking
• Access control
– Users & groups
– Groups can be members of other groups
– Privileges on nodes to read, write, etc.
JCR – advantages and problems
• Advantages
– Site structure is easy to reflect
– Flexible
– Hierarchical structure
• Disadvantages
– Storing large amount of structured data is neither easy nor
efficient
• Don’t load CSV file with 1 000 000 rows
– Data has to be denormalized (as there is no JOINs)
– Clustering is tricky
• Master-slave works OK
• Waiting for Jackrabbit 3.0 – codename Oak
– Transactions…
Apache Sling
HTTP access to JCR repository
Apache Sling
• Web framework
• RESTful access to JCR nodes
• Powered by OSGi
• Support multiple scripting languages (JSP,
Groovy, …)
• Open source, developed by Adobe within
Apache foundation
REST
# Create / Update
$ curl -u admin:admin –d name=‚Java User Group‛ –d city=Poznan 
localhost:8080/content/hello
# Read
$ curl localhost:8080/content/hello.tidy.json
# Delete
$ curl -X DELETE -u admin:admin 
localhost:8080/content/hello
Resource URL
• Resource path: /content/hello
– http://localhost:8080/content/hello.xml
– http://localhost:8080/content/hello.json
– http://localhost:8080/content/hello.html
• There are simple built-in renderers
• Each can be overridden
sling:resourceType
• In order to create custom rendition we need
to set sling:resourceType property
• It’s a JCR path to some renderer
• Renderer can be JSP, Java Servlet, Scala,
Python, Groovy, Ruby or ESP (internal Sling
language, kind of backend JS)
• Content-centric: you don’t invoke script
directly
Sample HTML renderer
<html>
<head><title>ESP example</title>
</head>
<body>
<h1>
Hello
<%= currentNode.getProperty('name') %>
</h1>
<h2>
<%= currentNode.getProperty('city') %>
</h2>
</body>
</html>
How does it work?
• Get node path from
URL
• Get extension
• Get HTTP method
GET /content/home.html
• Find
sling:resourceType
• Choose appropriate
script
(POST.jsp, json.jsp, e
tc.)
/apps/jug/hellocomponent
• Render node using
found renderer and
appropriate script
Hello JUG!
URL decomposition
/content/corporate/jobs/developer.print.a4.html/mysuffix
• Resource path
• Selectors
• Extension
• Suffix
Resource path
/content/corporate/jobs/developer.print.a4.html/mysuffix
• Substring before the first dot
• Path to the resource in JCR
• This part of the URL defines data.
– Rest defines way of the presentation.
Extension
/content/corporate/jobs/developer.print.a4.html/mysuffix
• Defines content format
• Most common: html, json, xml
• But may be png
Selectors
/content/corporate/jobs/developer.print.a4.html/mysuffix
• Specifies additional variants of the given content type
• Optional
• Multiple selectors are allowed
Suffix
/content/corporate/jobs/developer.print.a4.html/mysuffix
• Additional information passed to the rendering script
• Similar to GET ?name=value parameter, but can be cached
Script resolution
GET /content/corporate/jobs/developer.print.a4.html/mysuffix
/content/corporate/jobs/developer/sling:resourceType = cognifide/hr/jobs
/apps/cognifide/hr/jobs:
1. jobs.print.a4.GET.html.esp
2. jobs.print.a4.html.esp
3. jobs.print.a4.esp
4. jobs.print.GET.html.esp
5. jobs.print.html.esp
6. jobs.print.esp
7. jobs.GET.html.esp
8. jobs.html.esp
9. jobs.GET.esp
10. jobs.esp
Composed resources
Page
title
Left column Main
<html>
<head><title><%= currentNode.getProperty(’title') %></title></head>
<body>
<div class=‚left_column‛>
<sling:include path=‚left‛ resourceType=‚foundation/parsys‛/>
</div>
<div class=‚main‛>
<sling:include path=‚main‛ resourceType=‚foundation/parsys‛/>
<div>
</body>
</html>
Paragraph system
<c:forEach var=‚par‛ items=‚${resource.children}‛>
<sling:include
path=‚${par.path}‛
resourceType=‚${par[‘sling:resourceType’]}‛/>
</c:forEach>
Left column
Article
list
Twitter
widget
Contact
info
Resource Resolver
• In JCR we had Node
• In Sling we have Resource
• Virtual tree of resources, reflecting the JCR
• ResourceResolver – transforms nodes to resources
• It’s possible to create own ResourceResolvers and
reflect other data sources
– Filesystem,
– MongoDB,
– PostgreSQL
• Many ResourceResolvers may work together
– Like mount in UNIX
Resolver usage
Resource res = resourceResolver.getResource(‚/content/hello‛);
ModifiableValueMap map = res.adaptTo(ModifiableValueMap.class);
String name = map.get(‚name‛, String.class);
map.put(‚name‛, name.toUpperCase());
resourceResolver.commit();
Node node = res.adaptTo(javax.jcr.Node);
Session = resourceResolver.adaptTo(javax.jcr.Session);
Why do we use resolver?
• API is friendlier than JCR
• Sling provides us resources and resolver in
many places
– Servlets
– Scripts
Servlets
• Like ordinary servlets but…
• Can be assigned to:
– Paths
– Selectors
– Extensions
– Resource types (so can act as rendering script)
• doGet(), doPost() methods are invoked with
– SlingHttpServletRequest and …Response
– Additional methods for getting requested resource,
resolver, decompose URL, etc.
Sample Sling servlet
@Component
@Service
@SlingServlet(resourceTypes = ‛jug/hellocomponent‛)
public class AuthCheckerServlet extends SlingSafeMethodsServlet {
@Reference
private ResourceResolverFactory resolverFactory;
public void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) {
response.getWriter().println(‚Hello world‛);
}
}
Sling – pros and cons
• Similar to JCR
• Pros
– Natural reflection of site and filesystem structure
• Document repositories, Digital Asset Management
– OSGi stack
– Javascript has easy access to repository
• Cons
– Security issues
• internal resources available as xml and json,
• handling user generated content
– Lack of free tools, eg. repo explorer
Q&A

More Related Content

What's hot

RDFa: introduction, comparison with microdata and microformats and how to use it
RDFa: introduction, comparison with microdata and microformats and how to use itRDFa: introduction, comparison with microdata and microformats and how to use it
RDFa: introduction, comparison with microdata and microformats and how to use itJose Luis Lopez Pino
 
If You Have The Content, Then Apache Has The Technology!
If You Have The Content, Then Apache Has The Technology!If You Have The Content, Then Apache Has The Technology!
If You Have The Content, Then Apache Has The Technology!gagravarr
 
Rails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsRails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsToru Kawamura
 
OSOM - Ruby on Rails
OSOM - Ruby on Rails OSOM - Ruby on Rails
OSOM - Ruby on Rails Marcela Oniga
 
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017BookNet Canada
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsAlex Tumanoff
 
QueryPath, Mash-ups, and Web Services
QueryPath, Mash-ups, and Web ServicesQueryPath, Mash-ups, and Web Services
QueryPath, Mash-ups, and Web ServicesMatt Butcher
 
Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernates4al_com
 
Slug: A Semantic Web Crawler
Slug: A Semantic Web CrawlerSlug: A Semantic Web Crawler
Slug: A Semantic Web CrawlerLeigh Dodds
 
QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!Matt Butcher
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspectiveajshort
 
Drupal is not your Website
Drupal is not your Website Drupal is not your Website
Drupal is not your Website Phase2
 
Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)오석 한
 
Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01jgregory1234
 
Web technology P B Jadhav
Web technology  P B JadhavWeb technology  P B Jadhav
Web technology P B JadhavPRASHANT JADHAV
 

What's hot (20)

RDFa: introduction, comparison with microdata and microformats and how to use it
RDFa: introduction, comparison with microdata and microformats and how to use itRDFa: introduction, comparison with microdata and microformats and how to use it
RDFa: introduction, comparison with microdata and microformats and how to use it
 
Avik_RailsTutorial
Avik_RailsTutorialAvik_RailsTutorial
Avik_RailsTutorial
 
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
 
If You Have The Content, Then Apache Has The Technology!
If You Have The Content, Then Apache Has The Technology!If You Have The Content, Then Apache Has The Technology!
If You Have The Content, Then Apache Has The Technology!
 
Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
Rails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patternsRails Gems realize RESTful modeling patterns
Rails Gems realize RESTful modeling patterns
 
OSOM - Ruby on Rails
OSOM - Ruby on Rails OSOM - Ruby on Rails
OSOM - Ruby on Rails
 
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
In the Trenches with Accessible EPUB - Charles LaPierre - ebookcraft 2017
 
Serialization and performance by Sergey Morenets
Serialization and performance by Sergey MorenetsSerialization and performance by Sergey Morenets
Serialization and performance by Sergey Morenets
 
QueryPath, Mash-ups, and Web Services
QueryPath, Mash-ups, and Web ServicesQueryPath, Mash-ups, and Web Services
QueryPath, Mash-ups, and Web Services
 
Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernate
 
Slug: A Semantic Web Crawler
Slug: A Semantic Web CrawlerSlug: A Semantic Web Crawler
Slug: A Semantic Web Crawler
 
QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspective
 
Drupal is not your Website
Drupal is not your Website Drupal is not your Website
Drupal is not your Website
 
Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)Serialization (Avro, Message Pack, Kryo)
Serialization (Avro, Message Pack, Kryo)
 
Qcon
QconQcon
Qcon
 
Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01Qcon 090408233824-phpapp01
Qcon 090408233824-phpapp01
 
Web technology P B Jadhav
Web technology  P B JadhavWeb technology  P B Jadhav
Web technology P B Jadhav
 

Viewers also liked

AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLo Ki
 
Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with SlingBertrand Delacretaz
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson AEM HUB
 
Rapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingRapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingFelix Meschberger
 
Global Giving Briefing for Staff and Partners
Global Giving Briefing for Staff and PartnersGlobal Giving Briefing for Staff and Partners
Global Giving Briefing for Staff and PartnersBeth Kanter
 
Cookies, Convening, and Coffee: Measuring the Networked Nonprofit
Cookies, Convening, and Coffee:  Measuring the Networked NonprofitCookies, Convening, and Coffee:  Measuring the Networked Nonprofit
Cookies, Convening, and Coffee: Measuring the Networked NonprofitBeth Kanter
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6Yuval Ararat
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEMAccunity Software
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?connectwebex
 
Content Management Standards
Content Management StandardsContent Management Standards
Content Management StandardsDavid Nuescheler
 
From WTF to KPI: Demonstrating the Business Value of Public Relations
From WTF to KPI: Demonstrating the Business Value of Public RelationsFrom WTF to KPI: Demonstrating the Business Value of Public Relations
From WTF to KPI: Demonstrating the Business Value of Public RelationsShonali Burke
 
Introducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformIntroducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformNuxeo
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repositorynobby
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsStefano Celentano
 
From ROI to KPI: Practical Solutions to Measurement Conundrums
From ROI to KPI: Practical Solutions to Measurement ConundrumsFrom ROI to KPI: Practical Solutions to Measurement Conundrums
From ROI to KPI: Practical Solutions to Measurement ConundrumsShonali Burke
 
Cms integration of apache solr how we did it.
Cms integration of apache solr   how we did it.Cms integration of apache solr   how we did it.
Cms integration of apache solr how we did it.lucenerevolution
 
Hippo get together presentation solr integration
Hippo get together presentation   solr integrationHippo get together presentation   solr integration
Hippo get together presentation solr integrationHippo
 
Metrics, Metrics Everywhere (but where the heck do you start?)
Metrics, Metrics Everywhere (but where the heck do you start?)Metrics, Metrics Everywhere (but where the heck do you start?)
Metrics, Metrics Everywhere (but where the heck do you start?)SOASTA
 

Viewers also liked (20)

AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with Sling
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Rapid JCR Applications Development with Sling
Rapid JCR Applications Development with SlingRapid JCR Applications Development with Sling
Rapid JCR Applications Development with Sling
 
Sling Models Overview
Sling Models OverviewSling Models Overview
Sling Models Overview
 
Global Giving Briefing for Staff and Partners
Global Giving Briefing for Staff and PartnersGlobal Giving Briefing for Staff and Partners
Global Giving Briefing for Staff and Partners
 
Cookies, Convening, and Coffee: Measuring the Networked Nonprofit
Cookies, Convening, and Coffee:  Measuring the Networked NonprofitCookies, Convening, and Coffee:  Measuring the Networked Nonprofit
Cookies, Convening, and Coffee: Measuring the Networked Nonprofit
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?
 
Content Management Standards
Content Management StandardsContent Management Standards
Content Management Standards
 
From WTF to KPI: Demonstrating the Business Value of Public Relations
From WTF to KPI: Demonstrating the Business Value of Public RelationsFrom WTF to KPI: Demonstrating the Business Value of Public Relations
From WTF to KPI: Demonstrating the Business Value of Public Relations
 
2008-12 OJUG JCR Demo
2008-12 OJUG JCR Demo2008-12 OJUG JCR Demo
2008-12 OJUG JCR Demo
 
Introducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformIntroducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management Platform
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
Introduction to Sightly and Sling Models
Introduction to Sightly and Sling ModelsIntroduction to Sightly and Sling Models
Introduction to Sightly and Sling Models
 
From ROI to KPI: Practical Solutions to Measurement Conundrums
From ROI to KPI: Practical Solutions to Measurement ConundrumsFrom ROI to KPI: Practical Solutions to Measurement Conundrums
From ROI to KPI: Practical Solutions to Measurement Conundrums
 
Cms integration of apache solr how we did it.
Cms integration of apache solr   how we did it.Cms integration of apache solr   how we did it.
Cms integration of apache solr how we did it.
 
Hippo get together presentation solr integration
Hippo get together presentation   solr integrationHippo get together presentation   solr integration
Hippo get together presentation solr integration
 
Metrics, Metrics Everywhere (but where the heck do you start?)
Metrics, Metrics Everywhere (but where the heck do you start?)Metrics, Metrics Everywhere (but where the heck do you start?)
Metrics, Metrics Everywhere (but where the heck do you start?)
 

Similar to Shooting rabbits with sling

Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Lucidworks
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik Hatcher
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoFu Cheng
 
hibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdfhibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdfPatiento Del Mar
 
Apache Content Technologies
Apache Content TechnologiesApache Content Technologies
Apache Content Technologiesgagravarr
 
itPage LDC 09 Presentation
itPage LDC 09 PresentationitPage LDC 09 Presentation
itPage LDC 09 PresentationEric Landmann
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: ScalingChris Miller
 
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesNot Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesBrett Meyer
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development TutorialErik Hatcher
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewoodjaxconf
 
Drupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for YouDrupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for YouAcquia
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkRahul Jain
 

Similar to Shooting rabbits with sling (20)

Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
hibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdfhibernateormfeatures-140223193044-phpapp02.pdf
hibernateormfeatures-140223193044-phpapp02.pdf
 
Apache Content Technologies
Apache Content TechnologiesApache Content Technologies
Apache Content Technologies
 
itPage LDC 09 Presentation
itPage LDC 09 PresentationitPage LDC 09 Presentation
itPage LDC 09 Presentation
 
CI_CONF 2012: Scaling - Chris Miller
CI_CONF 2012: Scaling - Chris MillerCI_CONF 2012: Scaling - Chris Miller
CI_CONF 2012: Scaling - Chris Miller
 
CI_CONF 2012: Scaling
CI_CONF 2012: ScalingCI_CONF 2012: Scaling
CI_CONF 2012: Scaling
 
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesNot Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
 
Solr Application Development Tutorial
Solr Application Development TutorialSolr Application Development Tutorial
Solr Application Development Tutorial
 
HDFCloud Workshop: HDF5 in the Cloud
HDFCloud Workshop: HDF5 in the CloudHDFCloud Workshop: HDF5 in the Cloud
HDFCloud Workshop: HDF5 in the Cloud
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewood
 
Drupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for YouDrupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for You
 
01 html-introduction
01 html-introduction01 html-introduction
01 html-introduction
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
 

More from Tomasz Rękawek

Deep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesDeep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesTomasz Rękawek
 
Emulating Game Boy in Java
Emulating Game Boy in JavaEmulating Game Boy in Java
Emulating Game Boy in JavaTomasz Rękawek
 
Zero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerZero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerTomasz Rękawek
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationTomasz Rękawek
 
Inter-Sling communication with message queue
Inter-Sling communication with message queueInter-Sling communication with message queue
Inter-Sling communication with message queueTomasz Rękawek
 

More from Tomasz Rękawek (9)

Radio ad blocker
Radio ad blockerRadio ad blocker
Radio ad blocker
 
Deep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on KubernetesDeep-dive into cloud-native AEM deployments based on Kubernetes
Deep-dive into cloud-native AEM deployments based on Kubernetes
 
Emulating Game Boy in Java
Emulating Game Boy in JavaEmulating Game Boy in Java
Emulating Game Boy in Java
 
Zero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using DockerZero downtime deployments for the Sling-based apps using Docker
Zero downtime deployments for the Sling-based apps using Docker
 
CRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migrationCRX2Oak - all the secrets of repository migration
CRX2Oak - all the secrets of repository migration
 
SlingQuery
SlingQuerySlingQuery
SlingQuery
 
Code metrics
Code metricsCode metrics
Code metrics
 
Inter-Sling communication with message queue
Inter-Sling communication with message queueInter-Sling communication with message queue
Inter-Sling communication with message queue
 
Sling Dynamic Include
Sling Dynamic IncludeSling Dynamic Include
Sling Dynamic Include
 

Recently uploaded

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Shooting rabbits with sling

  • 1. Shooting rabbits with sling Introduction to Apache Jackrabbit & Apache Sling
  • 2. JCR • Content Repository API for Java • JSR-170 & JSR-283 • javax.jcr • Object database • Hierarchical data model • Apache Jackrabbit – reference implementation
  • 3. Mantra: everything is content • Content is content – Blogs, articles, posts, etc. • Structured data – List of addresses in e-mail database • Unstructured data – Word document • ACLs • Code
  • 4. Content hierarchy • JCR has tree-like data model • Repository consists of items • Item can be node or property • Node children are properties or other nodes • Properties are leaves
  • 5. Node • Nodes form content hierarchy • Nodes are named • Each node has primary type specifying it’s structure (allowed and required children and properties) – Something like class – Eg. myapp:Contact requires properties myapp:givenName and myapp:familyName • Nodes can also have mixin types – Something like interface – Eg. mix:versionable, mix:lockable or myapp:Emailable • Popular types: – nt:base, nt:unstructured, nt:folder
  • 6. Property • Property contains data • Types: – string, binary, long, double, date, boolean, name, path, reference • Can be multivalued
  • 7. Searching • Node names and properties are indexed • Jackrabbit uses Apache Lucene • Supported query languages: – XPath – JCR-SQL – JCR-SQL2 (recommended)
  • 8. SQL2 SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE([/content]) AND s.[jcr:title] = ’Moja strona’ • Main purpose: find node by property contents • Avoid queries with parent path (as it’s not indexed) – It’s better to create a mixin or marker property • We don’t JOIN • SQL and XPath are isomorphic
  • 9. Versioning • Any subtree can be versioned • Add mixin mix:versionable • node.checkin() – Creates new version – Makes the node read-only • node.checkout() – Allows to modify the node • Usage examples: – Page versions at many levels
  • 10. Observation • Event listener • We can filter events with: – Event type – Path – Node types – An explicit list of nodes • Usage examples: – Automatic workflows – Generating thumbnails – “Last modified” date – Indexing in internal and external search engine
  • 11. Other features • Locking • Access control – Users & groups – Groups can be members of other groups – Privileges on nodes to read, write, etc.
  • 12. JCR – advantages and problems • Advantages – Site structure is easy to reflect – Flexible – Hierarchical structure • Disadvantages – Storing large amount of structured data is neither easy nor efficient • Don’t load CSV file with 1 000 000 rows – Data has to be denormalized (as there is no JOINs) – Clustering is tricky • Master-slave works OK • Waiting for Jackrabbit 3.0 – codename Oak – Transactions…
  • 13. Apache Sling HTTP access to JCR repository
  • 14. Apache Sling • Web framework • RESTful access to JCR nodes • Powered by OSGi • Support multiple scripting languages (JSP, Groovy, …) • Open source, developed by Adobe within Apache foundation
  • 15. REST # Create / Update $ curl -u admin:admin –d name=‚Java User Group‛ –d city=Poznan localhost:8080/content/hello # Read $ curl localhost:8080/content/hello.tidy.json # Delete $ curl -X DELETE -u admin:admin localhost:8080/content/hello
  • 16. Resource URL • Resource path: /content/hello – http://localhost:8080/content/hello.xml – http://localhost:8080/content/hello.json – http://localhost:8080/content/hello.html • There are simple built-in renderers • Each can be overridden
  • 17. sling:resourceType • In order to create custom rendition we need to set sling:resourceType property • It’s a JCR path to some renderer • Renderer can be JSP, Java Servlet, Scala, Python, Groovy, Ruby or ESP (internal Sling language, kind of backend JS) • Content-centric: you don’t invoke script directly
  • 18. Sample HTML renderer <html> <head><title>ESP example</title> </head> <body> <h1> Hello <%= currentNode.getProperty('name') %> </h1> <h2> <%= currentNode.getProperty('city') %> </h2> </body> </html>
  • 19. How does it work? • Get node path from URL • Get extension • Get HTTP method GET /content/home.html • Find sling:resourceType • Choose appropriate script (POST.jsp, json.jsp, e tc.) /apps/jug/hellocomponent • Render node using found renderer and appropriate script Hello JUG!
  • 21. Resource path /content/corporate/jobs/developer.print.a4.html/mysuffix • Substring before the first dot • Path to the resource in JCR • This part of the URL defines data. – Rest defines way of the presentation.
  • 22. Extension /content/corporate/jobs/developer.print.a4.html/mysuffix • Defines content format • Most common: html, json, xml • But may be png
  • 23. Selectors /content/corporate/jobs/developer.print.a4.html/mysuffix • Specifies additional variants of the given content type • Optional • Multiple selectors are allowed
  • 24. Suffix /content/corporate/jobs/developer.print.a4.html/mysuffix • Additional information passed to the rendering script • Similar to GET ?name=value parameter, but can be cached
  • 25. Script resolution GET /content/corporate/jobs/developer.print.a4.html/mysuffix /content/corporate/jobs/developer/sling:resourceType = cognifide/hr/jobs /apps/cognifide/hr/jobs: 1. jobs.print.a4.GET.html.esp 2. jobs.print.a4.html.esp 3. jobs.print.a4.esp 4. jobs.print.GET.html.esp 5. jobs.print.html.esp 6. jobs.print.esp 7. jobs.GET.html.esp 8. jobs.html.esp 9. jobs.GET.esp 10. jobs.esp
  • 26. Composed resources Page title Left column Main <html> <head><title><%= currentNode.getProperty(’title') %></title></head> <body> <div class=‚left_column‛> <sling:include path=‚left‛ resourceType=‚foundation/parsys‛/> </div> <div class=‚main‛> <sling:include path=‚main‛ resourceType=‚foundation/parsys‛/> <div> </body> </html>
  • 27. Paragraph system <c:forEach var=‚par‛ items=‚${resource.children}‛> <sling:include path=‚${par.path}‛ resourceType=‚${par[‘sling:resourceType’]}‛/> </c:forEach> Left column Article list Twitter widget Contact info
  • 28. Resource Resolver • In JCR we had Node • In Sling we have Resource • Virtual tree of resources, reflecting the JCR • ResourceResolver – transforms nodes to resources • It’s possible to create own ResourceResolvers and reflect other data sources – Filesystem, – MongoDB, – PostgreSQL • Many ResourceResolvers may work together – Like mount in UNIX
  • 29. Resolver usage Resource res = resourceResolver.getResource(‚/content/hello‛); ModifiableValueMap map = res.adaptTo(ModifiableValueMap.class); String name = map.get(‚name‛, String.class); map.put(‚name‛, name.toUpperCase()); resourceResolver.commit(); Node node = res.adaptTo(javax.jcr.Node); Session = resourceResolver.adaptTo(javax.jcr.Session);
  • 30. Why do we use resolver? • API is friendlier than JCR • Sling provides us resources and resolver in many places – Servlets – Scripts
  • 31. Servlets • Like ordinary servlets but… • Can be assigned to: – Paths – Selectors – Extensions – Resource types (so can act as rendering script) • doGet(), doPost() methods are invoked with – SlingHttpServletRequest and …Response – Additional methods for getting requested resource, resolver, decompose URL, etc.
  • 32. Sample Sling servlet @Component @Service @SlingServlet(resourceTypes = ‛jug/hellocomponent‛) public class AuthCheckerServlet extends SlingSafeMethodsServlet { @Reference private ResourceResolverFactory resolverFactory; public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) { response.getWriter().println(‚Hello world‛); } }
  • 33. Sling – pros and cons • Similar to JCR • Pros – Natural reflection of site and filesystem structure • Document repositories, Digital Asset Management – OSGi stack – Javascript has easy access to repository • Cons – Security issues • internal resources available as xml and json, • handling user generated content – Lack of free tools, eg. repo explorer
  • 34. Q&A

Editor's Notes

  1. Show examples here: CRXDE and Eclipse “Helloworld”
  2. Eclipse example Versioning
  3. jug/hellocomponent
  4. Show CQ as demo – what page?