Michael Emmerich, Alkacon Software 
Workshop track Updating to OpenCms 9.5 
03.11.2014
●Update your current OpenCms installation to OpenCms 9.5 
●Update OpenCms with OCEE 
●API changes 
●Content Collectors 
●SOLR Postprocessor 
●Showcase: Enhancing your Application with OpenCms 9.5 features 
2 
Agenda
Update your current OpenCms installation to OpenCms 9.5 
3
Good news: Your existing OpenCms 8 or OpenCms 9 webapp will run in OpenCms 9.5 – without any changes  
(At least – in most cases….) 
4 
Update to OpenCms 9.5
How to upgrade: 
Use the OpenCms update wizard! 
5 
Update to OpenCms 9.5
Update OpenCms with OCEE 
6
●Updating OCEE within a major OpenCms version 
●Example: OpenCms 9.0.0 (OCEE 4.0.0) to OpenCms 9.0.1 (OCEE 4.0.1) 
-Very Easy 
●Simply install the new OCEE modules before updating the OpenCms core 
7 
Updating OpenCms with OCEE
●Updating OpenCms from one major version to another in a cluster 
●Requires more planning to reduce downtimes 
●Manual work on config files needed 
8 
Updating OpenCms with OCEE
9 
Updating OpenCms with OCEE 
Master 
MDB 
SDB 
Slave 1 
Slave 2 
●A typical OpenCms/OCEE update scenario 
●One master, two slaves, with DB replication 
●How to update OpenCms and OCEE? 
●Reduce downtime for delivery servers 
OCEE-Cluster 
OCEE-Cluster
10 
Updating OpenCms with OCEE 
Master 
MDB 
SDB 
Slave 1 
Slave 2 
Step 1 
●Content Freeze! 
●Disable Cluster & Replication 
Content delivery from Slave 1 and Slave 2
11 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
Step 2 
●Clone Slave DB 
●Connect each Slave to its own Database 
Content delivery from Slave 1 and Slave 2 
SDB 2 
Slave 1 
Slave 2 
SDB
12 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
Step 3 
●Direct all traffic to Slave 2 
●Shutdown Slave 1 
●Uninstall OCEE on master server 
●Run Update Wizard on Master Server 
●Test Master Server 
Content delivery Slave 2 
Master Server is updated to OpenCms 9.5 
SDB 2 
Slave 1 
Slave 2 
SDB
13 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
SDB 2 
Slave 1 
Slave 2 
Step 4 
●Install new OCEE on master 
Content delivery from Slave 2 
Master Server is updated to OpenCms 9.5 
SDB
14 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
SDB 2 
Slave 1 (9.5) 
Slave 2 
Step 5 
●Replace all .jar Files on Slave 1 
●Adjust configuration files on Slave 1 (if required) 
●Enable OCEE Cluster for Master and Slave 1 
●Replicate system folder (alternatively: replicate all) 
●Rebuild Searchindexes on Slave 1 
●Test combination Master and Slave 1 
Content delivery from Slave 2 
Master Server and Slave 1 are updated to OpenCms 9.5 
SDB
15 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
Slave 1 (9.5) 
Slave 2 (9.5) 
Step 6 
●Direct all traffic to Slave 1 
●Copy Webapplication from Slave 1 to Slave 2 
●Adjust configuration files on Slave 2 
●Enable OCEE Cluster for all Server 
●Reconnect Slave 2 to Slave DB 
●Rebuild Searchindexes on Slave 2 
●Test combination Master and Slave 2 
●Cancel content freeze 
Content delivery from Slave 1 
All servers are updated to OpenCms 9.5 
SDB
16 
Updating OpenCms with OCEE 
Master (9.5) 
MDB 
Slave 1 (9.5) 
Slave 2 (9.5) 
Step 7 
●Direct all traffic to both delivery servers 
DONE ! 
SDB
API Changes 
17
●Containerpages are now locale independend (like other configuration files) 
●Important when using localization & siblings of containerpages (which you should not have done !) 
18 
API changes
●A few plugable Interfaces have changed in OpenCms 9.5 
●But: Don’t panik! 
●Code-Changes are minimal and can be done in short time 
19 
API changes
●Content Collectors collect content items (e.g. News) to display them in a list view 
●New method added to Interface I_CmsResourceCollector 
●Why changes? Enhancements in the ADE Publish function 
20 
API changes – Content Collectors
●How to change my own collectors? 
●Add additional getResult Method: 
21 
API changes - Content Collectors 
List<CmsResource> 
getResults(CmsObject cms, 
String collectorName, 
String params, 
int numResults) 
throws CmsException;
●New function in Content Collectors since OpenCms 9.0 
●The problem so far: Collectors do not show expired or unreleased content items for editing 
●The solution: add the “excludeTimerange” as last value to the parameter string 
22 
API changes – Content Collectors 
param="${newspath}news_%(number).html|news|150|excludeTimerange"
23 
API changes – Content Collectors
●The Solr PostProcessor allows to manipulate Solr results 
●New method added to Interface I_CmsSolrPostSearchProcessor 
●Why changes? To allow new options in post-proccessing 
24 
API changes – Solr PostProcessor
25 
API changes – Solr PostProcessor 
SOLR Handler 
SOLR 
Post Processor (Access Check) 
Custom Post Processor 
Query 
Result 
Query 
Result
●How to change my own post processors? 
●Add additional init() method: 
●The method is called for each new Solr query 
26 
API changes – Solr PostProcessor 
void init();
●Example use-case: Do only display one sibling in search result 
27 
API changes – Solr PostProcessor 
private Set<CmsUUID> m_processedResources; 
public void init() { 
m_processedResources.clear(); 
} 
public SolrDocument process(CmsObject searchCms, CmsResource resource, SolrInputDocument document) { 
CmsUUID resourceId = resource.getResourceId(); 
if (!m_processedResources.contains(resourceId)) { 
m_processedResources.add(resourceId); 
return ClientUtils.toSolrDocument(document); 
} 
return null; 
} 
}
Extending your application with OpenCms 9.5 features 
28
●Element views and new roles 
●Content editors only see editpoints which they are allowed to see 
●PDF-Generation on the fly 
●Simple way to produce PDF files from News or other contents 
29 
Add OpenCms 9.5 features
Element views: 
●Assign Content Types to Element views 
●Assign Users to Element views 
Users can only use the Content Types supported by the selected view 
Different users have different edit points 
30 
Element views and roles
New OpenCms 9.5 roles: 
●So far: Editors had to be “Workplace User” 
●Now: Finer subdivision 
●Element author 
●Editor 
●Category Editor 
●Gallery Editor 
●Workplace user 
31 
Element views and roles
Sample use-case 
●2 Views: 
●Content View: Edit Articles and branding content 
●News View: Edit News 
●3 Editors with different views and roles 
●Jeb (Editor): Content View, News View 
●Bill (Element author): Content View 
●Bob (Element author): News View 
32 
Element views and roles
What to do? 
●Create the Views 
●/elementviews/ folder in Module 
●Set permission to views 
●Workplace permission dialog 
●Assign contents to views 
●Module configuration 
●Sitemap configuration 
33 
Element views and roles
●Live Demo 
34 
Element views and roles 
Demo 
Demo 
Demo 
Demo 
デモ
●Create PDF-Files from XmlContents 
●Write a special PDF template 
●Use HTML/CSS for formating the PDF layout 
●We need: 
●Configuration 
●PDF Template 
●Create the correct link to the PDF 
35 
PDF generation on the fly
Step 1: Configuration 
●ResourceInitHandler must be configured in opencms-system.xml 
36 
PDF generation on the fly 
[…] 
<resourceinit> 
<resourceinithandler class="org.opencms.pdftools.CmsPdfResourceHandler"/> 
[…] 
</resourceinit> 
[…]
Step 2: “PDF-Template 
●A complete HTML template, styled by CSS 
●Use <cms:contentload> and <cms:contentaccess> to access content 
●Like a Formatter or old-style detail JSP 
37 
PDF generation on the fly
Step 2: “PDF-Template 
38 
PDF generation on the fly 
<html> 
<cms:contentload collector="singleFile" param="%(opencms.uri)" > 
<cms:contentaccess var="content" /> 
<head> 
[...] 
<link rel="stylesheet" href="..." type="text/css" /> 
[...] 
</head> 
<body> 
[...] 
${content.value.myvalue} 
[...] 
</body> 
</cms:contentload> 
</html>
Step 3: Integration 
●Add a link by using the <cms:pdf> tag 
●format: Path to the PDF Template 
●content: Filename of the content (e.g. ${content.filename} 
●locale: Locale to be displayed 
39 
PDF generation on the fly 
<a href="<cms:pdf format='...' content='...' locale='...'/>" >PDF</a>
●Live Demo 
40 
PDF generation on the fly 
Demo 
Demo 
Demo 
Demo 
デモ
●Any Questions? 
41 
Any Questions? 
Fragen? 
Questions ? 
Questiones? 
¿Preguntas? 
質問
Michael Emmerich 
Alkacon Software GmbH 
http://www.alkacon.com 
http://www.opencms.org 
Thank you very much for your attention! 
42

OpenCms Days 2014 - Updating to OpenCms 9.5

  • 1.
    Michael Emmerich, AlkaconSoftware Workshop track Updating to OpenCms 9.5 03.11.2014
  • 2.
    ●Update your currentOpenCms installation to OpenCms 9.5 ●Update OpenCms with OCEE ●API changes ●Content Collectors ●SOLR Postprocessor ●Showcase: Enhancing your Application with OpenCms 9.5 features 2 Agenda
  • 3.
    Update your currentOpenCms installation to OpenCms 9.5 3
  • 4.
    Good news: Yourexisting OpenCms 8 or OpenCms 9 webapp will run in OpenCms 9.5 – without any changes  (At least – in most cases….) 4 Update to OpenCms 9.5
  • 5.
    How to upgrade: Use the OpenCms update wizard! 5 Update to OpenCms 9.5
  • 6.
  • 7.
    ●Updating OCEE withina major OpenCms version ●Example: OpenCms 9.0.0 (OCEE 4.0.0) to OpenCms 9.0.1 (OCEE 4.0.1) -Very Easy ●Simply install the new OCEE modules before updating the OpenCms core 7 Updating OpenCms with OCEE
  • 8.
    ●Updating OpenCms fromone major version to another in a cluster ●Requires more planning to reduce downtimes ●Manual work on config files needed 8 Updating OpenCms with OCEE
  • 9.
    9 Updating OpenCmswith OCEE Master MDB SDB Slave 1 Slave 2 ●A typical OpenCms/OCEE update scenario ●One master, two slaves, with DB replication ●How to update OpenCms and OCEE? ●Reduce downtime for delivery servers OCEE-Cluster OCEE-Cluster
  • 10.
    10 Updating OpenCmswith OCEE Master MDB SDB Slave 1 Slave 2 Step 1 ●Content Freeze! ●Disable Cluster & Replication Content delivery from Slave 1 and Slave 2
  • 11.
    11 Updating OpenCmswith OCEE Master (9.5) MDB Step 2 ●Clone Slave DB ●Connect each Slave to its own Database Content delivery from Slave 1 and Slave 2 SDB 2 Slave 1 Slave 2 SDB
  • 12.
    12 Updating OpenCmswith OCEE Master (9.5) MDB Step 3 ●Direct all traffic to Slave 2 ●Shutdown Slave 1 ●Uninstall OCEE on master server ●Run Update Wizard on Master Server ●Test Master Server Content delivery Slave 2 Master Server is updated to OpenCms 9.5 SDB 2 Slave 1 Slave 2 SDB
  • 13.
    13 Updating OpenCmswith OCEE Master (9.5) MDB SDB 2 Slave 1 Slave 2 Step 4 ●Install new OCEE on master Content delivery from Slave 2 Master Server is updated to OpenCms 9.5 SDB
  • 14.
    14 Updating OpenCmswith OCEE Master (9.5) MDB SDB 2 Slave 1 (9.5) Slave 2 Step 5 ●Replace all .jar Files on Slave 1 ●Adjust configuration files on Slave 1 (if required) ●Enable OCEE Cluster for Master and Slave 1 ●Replicate system folder (alternatively: replicate all) ●Rebuild Searchindexes on Slave 1 ●Test combination Master and Slave 1 Content delivery from Slave 2 Master Server and Slave 1 are updated to OpenCms 9.5 SDB
  • 15.
    15 Updating OpenCmswith OCEE Master (9.5) MDB Slave 1 (9.5) Slave 2 (9.5) Step 6 ●Direct all traffic to Slave 1 ●Copy Webapplication from Slave 1 to Slave 2 ●Adjust configuration files on Slave 2 ●Enable OCEE Cluster for all Server ●Reconnect Slave 2 to Slave DB ●Rebuild Searchindexes on Slave 2 ●Test combination Master and Slave 2 ●Cancel content freeze Content delivery from Slave 1 All servers are updated to OpenCms 9.5 SDB
  • 16.
    16 Updating OpenCmswith OCEE Master (9.5) MDB Slave 1 (9.5) Slave 2 (9.5) Step 7 ●Direct all traffic to both delivery servers DONE ! SDB
  • 17.
  • 18.
    ●Containerpages are nowlocale independend (like other configuration files) ●Important when using localization & siblings of containerpages (which you should not have done !) 18 API changes
  • 19.
    ●A few plugableInterfaces have changed in OpenCms 9.5 ●But: Don’t panik! ●Code-Changes are minimal and can be done in short time 19 API changes
  • 20.
    ●Content Collectors collectcontent items (e.g. News) to display them in a list view ●New method added to Interface I_CmsResourceCollector ●Why changes? Enhancements in the ADE Publish function 20 API changes – Content Collectors
  • 21.
    ●How to changemy own collectors? ●Add additional getResult Method: 21 API changes - Content Collectors List<CmsResource> getResults(CmsObject cms, String collectorName, String params, int numResults) throws CmsException;
  • 22.
    ●New function inContent Collectors since OpenCms 9.0 ●The problem so far: Collectors do not show expired or unreleased content items for editing ●The solution: add the “excludeTimerange” as last value to the parameter string 22 API changes – Content Collectors param="${newspath}news_%(number).html|news|150|excludeTimerange"
  • 23.
    23 API changes– Content Collectors
  • 24.
    ●The Solr PostProcessorallows to manipulate Solr results ●New method added to Interface I_CmsSolrPostSearchProcessor ●Why changes? To allow new options in post-proccessing 24 API changes – Solr PostProcessor
  • 25.
    25 API changes– Solr PostProcessor SOLR Handler SOLR Post Processor (Access Check) Custom Post Processor Query Result Query Result
  • 26.
    ●How to changemy own post processors? ●Add additional init() method: ●The method is called for each new Solr query 26 API changes – Solr PostProcessor void init();
  • 27.
    ●Example use-case: Doonly display one sibling in search result 27 API changes – Solr PostProcessor private Set<CmsUUID> m_processedResources; public void init() { m_processedResources.clear(); } public SolrDocument process(CmsObject searchCms, CmsResource resource, SolrInputDocument document) { CmsUUID resourceId = resource.getResourceId(); if (!m_processedResources.contains(resourceId)) { m_processedResources.add(resourceId); return ClientUtils.toSolrDocument(document); } return null; } }
  • 28.
    Extending your applicationwith OpenCms 9.5 features 28
  • 29.
    ●Element views andnew roles ●Content editors only see editpoints which they are allowed to see ●PDF-Generation on the fly ●Simple way to produce PDF files from News or other contents 29 Add OpenCms 9.5 features
  • 30.
    Element views: ●AssignContent Types to Element views ●Assign Users to Element views Users can only use the Content Types supported by the selected view Different users have different edit points 30 Element views and roles
  • 31.
    New OpenCms 9.5roles: ●So far: Editors had to be “Workplace User” ●Now: Finer subdivision ●Element author ●Editor ●Category Editor ●Gallery Editor ●Workplace user 31 Element views and roles
  • 32.
    Sample use-case ●2Views: ●Content View: Edit Articles and branding content ●News View: Edit News ●3 Editors with different views and roles ●Jeb (Editor): Content View, News View ●Bill (Element author): Content View ●Bob (Element author): News View 32 Element views and roles
  • 33.
    What to do? ●Create the Views ●/elementviews/ folder in Module ●Set permission to views ●Workplace permission dialog ●Assign contents to views ●Module configuration ●Sitemap configuration 33 Element views and roles
  • 34.
    ●Live Demo 34 Element views and roles Demo Demo Demo Demo デモ
  • 35.
    ●Create PDF-Files fromXmlContents ●Write a special PDF template ●Use HTML/CSS for formating the PDF layout ●We need: ●Configuration ●PDF Template ●Create the correct link to the PDF 35 PDF generation on the fly
  • 36.
    Step 1: Configuration ●ResourceInitHandler must be configured in opencms-system.xml 36 PDF generation on the fly […] <resourceinit> <resourceinithandler class="org.opencms.pdftools.CmsPdfResourceHandler"/> […] </resourceinit> […]
  • 37.
    Step 2: “PDF-Template ●A complete HTML template, styled by CSS ●Use <cms:contentload> and <cms:contentaccess> to access content ●Like a Formatter or old-style detail JSP 37 PDF generation on the fly
  • 38.
    Step 2: “PDF-Template 38 PDF generation on the fly <html> <cms:contentload collector="singleFile" param="%(opencms.uri)" > <cms:contentaccess var="content" /> <head> [...] <link rel="stylesheet" href="..." type="text/css" /> [...] </head> <body> [...] ${content.value.myvalue} [...] </body> </cms:contentload> </html>
  • 39.
    Step 3: Integration ●Add a link by using the <cms:pdf> tag ●format: Path to the PDF Template ●content: Filename of the content (e.g. ${content.filename} ●locale: Locale to be displayed 39 PDF generation on the fly <a href="<cms:pdf format='...' content='...' locale='...'/>" >PDF</a>
  • 40.
    ●Live Demo 40 PDF generation on the fly Demo Demo Demo Demo デモ
  • 41.
    ●Any Questions? 41 Any Questions? Fragen? Questions ? Questiones? ¿Preguntas? 質問
  • 42.
    Michael Emmerich AlkaconSoftware GmbH http://www.alkacon.com http://www.opencms.org Thank you very much for your attention! 42