41
Mindquarry Mindquarry for Cocoon Users Lars Trieloff, Mindquarry 1

Mindquarry For Cocoon Users

Embed Size (px)

DESCRIPTION

Implementation and architecture notes for the Mindquarry Collaboration Server. Presented at the 7th Cocoon GetTogether in Rome.

Citation preview

Page 1: Mindquarry For Cocoon Users

Mindquarry

Mindquarry for Cocoon Users

Lars Trieloff, Mindquarry

1

Page 2: Mindquarry For Cocoon Users

Mindquarry

What is Mindquarry 2

Page 3: Mindquarry For Cocoon Users

Mindquarry

What is Mindquarry 2

Page 4: Mindquarry For Cocoon Users

Mindquarry

What is Mindquarry 2

Page 5: Mindquarry For Cocoon Users

Mindquarry

What is Mindquarry 2

Page 6: Mindquarry For Cocoon Users

Mindquarry

What is Mindquarry 2

Page 7: Mindquarry For Cocoon Users

Mindquarry

Short Demo 3Mindquarry Collaboration Server:

Teams, Files, Tasks and TalkMindquarry Desktop Client:

File Synchronization, Task ManagementLive Sites:

http://www.mindquarry.org

Page 8: Mindquarry For Cocoon Users

Mindquarry

Mindquarry InternalsServer based on

Apache Cocoon 2.2Apache JackrabbitApache Lucene SolrSubversionApache Web Servermod_perlSubethaSMTPJRuby

Client based onJava 5SWTSvnkit

4

Page 9: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Page 10: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

Page 11: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

Team Block

Page 12: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

Apache Jackrabbit

Team Block

Page 13: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Page 14: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

DForms Block

Page 15: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

DForms Block

Page 16: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Page 17: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Files Block

Page 18: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Files Block

SVN Repo

Page 19: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Talk Block

Files Block

SVN Repo

Page 20: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Talk Block

Files Block

SubethaSMTP

SVN Repo

Page 21: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Talk Block

Files Block

SubethaSMTP

Mail Parser

SVN Repo

Page 22: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Talk Block

Files Block

SubethaSMTP

Mail Parser

REST Client

SVN Repo

Page 23: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Talk Block

Files Block

SubethaSMTP

Mail Parser

REST Client

SVN Repo

Page 24: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Search Block

Talk Block

Files Block

SubethaSMTP

Mail Parser

REST Client

SVN Repo

Page 25: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Search Block

Talk Block

Solr Servlet

Files Block

SubethaSMTP

Mail Parser

REST Client

SVN Repo

Page 26: Mindquarry For Cocoon Users

Mindquarry

Architecture 5Jetty Web App Container

Apache Cocoon 2.2

PostgreSQL

Apache Jackrabbit

Team Block

Wiki Block

Tasks Block

DForms Block

Search Block

Talk Block

Solr Servlet

Files Block

SubethaSMTP

Mail Parser

REST Client

SVN Repo

Lucene Index

Page 27: Mindquarry For Cocoon Users

Mindquarry

Lessons learned 6

1. Integrating Jackrabbit and Cocoon2.Using the Servlet Services Architecture3. Integrating Solr-based search with Cocoon4.Tuning AJAX Performance5.Neat REST Tricks in Mindquarry

Code and Libraries available at www.mindquarry.org

Page 28: Mindquarry For Cocoon Users

Mindquarry

Jackrabbit and CocoonJackrabbit: JCR/JSR-173 Container

Versioned, Typed, Queryable Node StoreIdeal for document-centric applications

Mindquarry's Enhancementscom.mindquarry.jcr.xml.source.JCRNodeSource

an JCR-to-XML mappingcom.mindquarry.jcr.jackrabbit.xpath.JaxenQueryHandler

a XPath 1.0 Query handler for Jackrabbit based on Jaxen Mindquarry's most popular Pitfalls

Having many small nodes in JCR affects performanceMapping Business objects to JCR is no good ideaThere is no easy way to limit the result size of queries

7

Page 29: Mindquarry For Cocoon Users

Mindquarry

Mapping XML to JCR 8/

rep:root

users

nt:folder

images

nt:folder

alex.saar

nt:file

xt:element

nt:unstructured

*

photo154

nt:file

jcr:content

nt:resource

BINARY jcr:data

STRING jcr:mimeType

nt:resource

xt:versionableresource

mix:versionable

namext:element

jcr:content

xt:document

<user>

<name>Alexander Saar</name>

<email type="business">[email protected]</name>

</user>

XML

Binary Data

xt:text

STRING xt:characters

textxt:text

STRING xt:characters = Alexander Saar

textxt:text

STRING xt:characters = [email protected]

xt:element: child nodes of

type xt:element (XML

elements)xt:element: child

properties of type

STRING (XML attribute)

emailxt:element

STRING type = business

DATE jcr:lastModified

Later

user

xt:element

xt:document

nt:unstructured

Page 30: Mindquarry For Cocoon Users

Mindquarry

Using Servlet ServicesServlet Services allow running and interacting with arbitrary servlets in the Cocoon "Container"What works great

Shielding: Conflicting dependencies are no problemInheritance: Define a parent block that handles all requests that the child cannot handle

What needs more handworkInheritance of resources, e.g. having a common styling resource for all blocksPassing complex requests (e.g. including authentication) between blocksPolymorphy: e.g. a parent block passing sub-requests back to the child

9

Page 31: Mindquarry For Cocoon Users

Mindquarry

Mindquarry's Servlet Services 10

Team Block

Wiki Block Tasks Block

DForms Block

Search Block

Talk Block

Solr Servlet

Files Block

Resources Block Usage

Inheritance

Page 32: Mindquarry For Cocoon Users

Mindquarry

Integrating Solr and Cocoon

Solr is a REST-based search engine based on LuceneImplemented as a Servlet, easy to embed in Cocoon

11

Solr Servlet

Lucene Index

SolrPostSerializer

AJAX Client

HTTP POST XML

HTTPGETJSON

XSLTTextFilterGenerator

Document

When using with Jackrabbit, Shielding is neccessarycom.mindquarry.cocoon.TextFilterGenerator

Page 33: Mindquarry For Cocoon Users

MindquarryTuning AJAX Performance

Cocoon uses Dojo, which is very powerfulAnd up to 500 kb big, which need to be

downloadedparsed

for every page reloadbetter use cachingand better do not reload

Mindquarry uses following solutionspecial AJAX representation of every resourcecustomization stylesheet (html2lightbox.xsl)Client side: Dojo widget AjaxLink

replaces every (internal) link with an AJAX call

12

Page 34: Mindquarry For Cocoon Users

Mindquarry

REST in MindquarryWhat means REST?

Everything is a resource and has an URIDifferent representations of a resource possible

HTML, XML, RSS, JSON, Atom...Interaction via GET, PUT, POST, DELETE

13

HTTP Authentication

HTTPAccept-Headers

Session-lessweb applications

Page 35: Mindquarry For Cocoon Users

Mindquarry

Specify what content the client can processmost often HTML, images, but also XML, JSON, etc.

Definition:

14HTTP

Accept-Headers

<selector name="REST" src="org.apache.cocoon.selection.RegexpHeaderSelector"> <header-name>accept</header-name> <pattern name="html">application/xhtml\+xml|text/html|\*/\*</pattern> <pattern name="xml">text/xml</pattern> <pattern name="atom">application/atom.xml</pattern> <pattern name="pdf">application/pdf</pattern> <pattern name="opml">text/x-opml</pattern> <pattern name="ical">text/calendar</pattern> <pattern name="json">(text|application)/json</pattern></selector>

Page 36: Mindquarry For Cocoon Users

Mindquarry

Usage Example:

15HTTP

Accept-Headers

<select type="REST"> <when test="json"> <transform src="xslt/json/log2jsonXML.xsl"> <parameter name="baselink" value="/tasks/{1}/{2}" /> </transform> <transform type="i18n"> <parameter name="locale" value="{request-attr:locale}" /> <parameter name="default-catalogue-id" value="mindquarry" /> </transform> <serialize type="json" /> </when> <otherwise> <serialize type="xml" /> </otherwise></select>

Page 37: Mindquarry For Cocoon Users

Mindquarry

What to do if my client does not support Accept-Headers?

16HTTP

Accept-Headers

<filter> <filter-name>HttpHeaderSpoofingFilter</filter-name> <display-name>HTTP Header Spoofing Filter</display-name> <filter-class> com.mindquarry.webapp.servlet.HttpHeaderSpoofingFilter </filter-class></filter>

Turns http-*-header request parameters into actual HTTP headers

Example usagehttp://localhost:8888/changes?http-accept-header=application/json

Page 38: Mindquarry For Cocoon Users

Mindquarry

HTTP-Basic or HTTP-Digest Authenticationcross client support (even non-interactive)no Cookies neededno Sessions neededBut: ugly login window

17HTTP

Authentication

Page 39: Mindquarry For Cocoon Users

Mindquarry

Mindquarry's solution combinesa servlet filtera Dojo (AJAX) widget

18HTTP

Authentication

<filter> <filter-name>MindquarryAuthenticationFilter</filter-name> <display-name> Mindquarry Authentication filter </display-name> <filter-class> com.mindquarry.user.webapp.AuthenticationFilter </filter-class> <init-param> <param-name>realm</param-name> <param-value>Mindquarry Server</param-value> </init-param></filter>

Page 40: Mindquarry For Cocoon Users

Mindquarry

Mindquarry needs no sessionsREST architectureHTTP AuthenticationEasy to cluster

But Mindquarry uses CForms, which uses Continuations, which is very close to sessionsA better solution:

AJAX-based formsconstruct XML document from form valuessend PUT, POST or DELETE afterwards

But not yet implemented

19Session-less

web applications