Immerse 2016 Efficient publishing with content fragments

Preview:

Citation preview

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

A virtual developer conference for Adobe Experience Manager

Efficient Publishing with Content FragmentsStefan Grimm | Senior Developer

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Efficient Publishing with Content Fragments

2

1 | Welcome and Overview

2 | Content Fragments - a brief introduction

3 | Use case: A news site

4 | Implementing an efficient workflow

5 | Q&A

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3

Content FragmentsA brief introduction

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4

Ecosystem

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 5

Simple fragment template Generic component Typical AEM workflow required First, create the fragment Then, create a page, add the fragment to the page, configure it, etc.

OOTB

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6

Some use-cases require a more efficient workflow. OOTB component can be too generic Too much flexibility Not enough flexibility

ข Some use-cases require customization

Customizing the component Implement a specific workflow

Context

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7

Use-case:A (imaginary) news site

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 8

Our goal …

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9

Create article. Enter title. Teaser. Text. Assign image(s). Classify. Save. Create page. Add Content Fragment. Reference article. Publish.

Efficiency!

let’s get rid of these steps!

add this new feature

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 10

Our news site

Section

Title

Teaser

Image

Text

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 11

Fragment Elements Title Teaser Text

Metadata Section

Associated Content Image (tagged)

Articles

defining the article imagedefining the article image

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 12

Article template Article component Page component A patched version of the CFM implementation bundle Required for AEM 6.2 only, will be included in upcoming releases

Prerequistes

Introduced in the ”Introducing Content Fragment” session

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on …Prerequisites

13

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 14

Implementation

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

No production-ready codein this session!

Disclaimer

15

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 16

Problems & solutions

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 17

How to determine the article image? Only collections, no 1:1 assignment for associated content

How to automate …? page creation adding Content Fragment component referencing & configuring the article fragment publishing the page

Problems ...

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 18

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

... and solutions

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 19

Finding the article image

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 20

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

Recap

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 21

Getting associated collections:Iterator<Resource> collections = fragment.getAssociatedContent();

Getting all associated resources:SlingScriptHelper ssh = getSlingScriptHelper();ContentFragmentManager cfm = ssh.getService(ContentFragmentManager.class);List<Resource> assets = cfm.resolveAssociatedContentFlat(fragment);

API – Accessing associated content

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Finding the article image

22

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 23

Workflow commons

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 24

Article image Use tagging to classify the images main image part of image gallery …

Component queries associated content uses first image tagged as “main image”.

Automating workflow launcher triggers workflow create page if necessary publish fragment, page & dependency several other stuff

Recap

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 25

Can be registered on low level events node create node update

Can‘t use directly intermediate saves but workflow should only be triggered on “save”

Workflow launcher

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 26

On save Timestamp is persisted (only if content has been modified) jcr:content/lastFragmentSave (*)

Each workflow process Executes only if there has been a “save” since the last publish workflow has been finished jcr:content/lastFragmentSave > jcr:content/lastFragmentPublish

At the end of the publish workflow Updates publish timestamp jcr:content/lastFragmentPublish

(*) patched CFM implementation bundle required

Solution

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Workflow commons

com.adobe.immerse2016.cfm_ep.workflow.AbstractFragmentProcesscom.adobe.immerse2016.cfm_ep.workflow.FinishArticleProcess

27

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 28

Workflow process:Resolving associated

content

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 29

Problem:

Article image defined via collection Collections should not be used on publish

Solution:

Determine article image on save Persist path to image on fragment jcr:content/articleImage

Article image

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Resolving dependencies

com.adobe.immerse2016.cfm_ep.workflow.ResolveDataProcess

30

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 31

Workflow process:Creating the article

page

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 32

Check if a page for the article has already been created If not, create a page, … Path: /<root>/<section>/<year>/<month>/<day>/<article.name>

... create the article paragraph jcr:content/par/<article.name>

... reference the article fragment. jcr:content/par/<article.name>/fileReference

Page on demand

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Auto-create article page

com.adobe.immerse2016.cfm_ep.workflow.CreateOnDemandProcess

33

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 34

Workflow process:Publishing the article

page

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 35

Publish Content Fragment Page Article Image

In a clean implementation … … publish references (Tags, ...) … replicate only if modified

Publishing

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Hands on ...Publish article process

com.adobe.immerse2016.cfm_ep.workflow.PublishArticleProcess

36

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

And … Action!The new, effective publishing

process

37

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 38

Recap

Article image Part of a collection Identified by tag Resolve collection/tag to image path for publish instance

Publishing workflow Triggered by workflow launcher Processes check for “save” event by comparing save/publish timestamps Page created on demand using a fixed/hardcoded pattern Fragment & collaterals published programmatically

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 39

Epilogue

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 40

Not mentioned in this session …

Dispatcher invalidation No easy OOTB solution for invalidating referencing pages Can be solved using path-based dispatcher rules

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 41

Resources

Content Package with example code available from the “Resources” pod in Adobe Connect

Documentation Overview/Authoring Editor - https://docs.adobe.com/docs/en/aem/6-2/author/assets/content-fragments.html Page Authoring - https://docs.adobe.com/docs/en/aem/6-2/author/page-authoring/content-

fragments.html Development Templates - https://docs.adobe.com/docs/en/aem/6-2/develop/templates/content-fragment-

templates.html Extending (WIP) - https://docs.adobe.com/docs/en/aem/6-2/develop/extending/content-fragments.html

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Q&A42

Stefan Grimmsgrimm@adobe.com

© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.