13.07.2015 Views

PDF doc - Day

PDF doc - Day

PDF doc - Day

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CQ5 WCM How To - A Collection


CQ5 WCM How To - A CollectionCQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Contents1. Introduction ........................................................................................................................ 11.1. Introduction ............................................................................................................. 11.2. Purpose of this Document ........................................................................................ 11.3. Target Audience ...................................................................................................... 12. How to Quickly Create a Website ....................................................................................... 22.1. Introduction ............................................................................................................. 22.2. Creating the application, the Content Page Template, the Content Page Componentand a Web Page ........................................................................................................... 22.3. Setting up the Designer ........................................................................................... 32.4. Importing the original Web Page (CSS, HTML and images) into your project ................ 32.5. Replacing static content by dynamic content using CQ Foundation Components .......... 42.6. Creating a Media Library ......................................................................................... 53. How to Develop Components ............................................................................................. 63.1. Developing Components .......................................................................................... 63.1.1. Developing a new component by adapting an existing component .................... 63.1.2. Adding a new component to the paragraph system (design mode) ................... 73.1.3. Extending the Text and Image Component - An Example ................................ 74. How to Set Up a Cluster .................................................................................................. 144.1. How to Set Up a Cluster in Communiqué ................................................................ 145. How to Monitor Performance ............................................................................................ 165.1. Introduction ........................................................................................................... 165.1.1. Purpose of this How To .............................................................................. 165.1.2. Target Audience ......................................................................................... 165.2. Performance - some theory .................................................................................... 165.3. Performance - basic rules ...................................................................................... 185.4. Recognizing some common performance problems ................................................. 185.5. Monitoring, and optimizing, the performance ........................................................... 195.5.1. Tools and mechanisms ............................................................................... 195.5.2. Interpreting the request.log .......................................................................... 205.5.3. Caching ...................................................................................................... 225.5.4. Analyzing Search ........................................................................................ 246. How to Create and Use a Workflow .................................................................................. 256.1. Creating a Workflow .............................................................................................. 256.1.1. Creating a new Workflow Model .................................................................. 256.1.2. Editing the Workflow ................................................................................... 256.2. Using the Workflow ............................................................................................... 286.2.1. Starting the Workflow for an individual page ................................................. 286.2.2. Automatically Assigning a Workflow ............................................................. 306.2.3. Taking actions on a Participant Step ............................................................ 326.2.4. Suspending, Resuming and Terminating a Workflow instance ........................ 346.2.5. Monitoring the Status of Workflow Instances ................................................. 357. Upgrading to CQ5 ............................................................................................................ 377.1. How to Upgrade Your Communiqué Instance (3 or 4) to CQ5 ................................... 378. Installing CQ5 .................................................................................................................. 398.1. How to Install CQ WCM Author and Publish Instances using Quickstart ..................... 398.1.1. Installing a CQ WCM instance - Generic procedure ....................................... 398.1.2. Installing an Author instance ........................................................................ 408.1.3. Installing a Publish instance ........................................................................ 408.2. How to install CQ5 with an Application Server ......................................................... 418.2.1. WebSphere v6.1 ......................................................................................... 418.2.2. WebLogic v10.3 .......................................................................................... 438.2.3. Tomcat v6 .................................................................................................. 458.2.4. JBoss v4 .................................................................................................... 478.2.5. Generic Procedures .................................................................................... 509. How to Use, Create, and Edit a Page ............................................................................... 52Page iii of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


CQ5 WCM How To - A Collection9.1. Managing Pages within CQ WCM .......................................................................... 529.1.1. Creating a New Page .................................................................................. 529.1.2. Editing a Page ............................................................................................ 549.1.3. Moving or Renaming Page .......................................................................... 589.1.4. Deleting a Page .......................................................................................... 599.1.5. Setting the Page Properties ......................................................................... 5910. How to Publish a Page ................................................................................................... 6410.1. How To Publish Pages ........................................................................................ 6410.1.1. Activating Content ..................................................................................... 6410.1.2. Deactivating Content ................................................................................. 6510.1.3. Determining Page Publication Status .......................................................... 6510.1.4. Locking Pages .......................................................................................... 6610.1.5. Unlocking Pages ....................................................................................... 6610.1.6. Using Preview Mode ................................................................................. 6611. How to Restore a Page .................................................................................................. 6811.1. How To Restore Pages ........................................................................................ 6812. How to Create Templates ............................................................................................... 6912.1. Developing Page Templates ................................................................................. 6912.1.1. Creating a new Template (based on an existing template) ............................ 6913. How to Use Tags ........................................................................................................... 7013.1. How to Manage Tags in CQ WCM ....................................................................... 7013.1.1. Using Sidekick to access and assign Tags ................................................. 7013.1.2. The Tag Administration Console ................................................................ 7113.1.3. Searching for Tags .................................................................................... 7314. Integrating with CQ DAM ................................................................................................ 7514.1. How to Integrate CQ DAM into your CQ5 WCM Installation .................................... 7515. How to Find Logs and Audit Entries ................................................................................ 7715.1. Finding the Audit Records and Log Files ............................................................... 7715.1.1. Audit Records ........................................................................................... 7715.1.2. Log files ................................................................................................... 7816. Security Checklists ......................................................................................................... 8016.1. Security Checklist for System Administrators ......................................................... 8016.1.1. Disable WebDAV ...................................................................................... 8016.1.2. Restrict Access via the Dispatcher ............................................................. 8016.1.3. Check for Cross-Site Scripting (XSS) ......................................................... 8116.2. Security Checklist for Power Users ....................................................................... 8116.2.1. Change Default Passwords ........................................................................ 8116.3. Security Checklist for Developers ......................................................................... 8316.3.1. Use the user session, not the administrative session ................................... 8317. Defining Performance Tests on Your Publish Environment ................................................ 8417.1. Introduction ......................................................................................................... 8417.1.1. Purpose of this How To ............................................................................. 8417.1.2. Target Audience ....................................................................................... 8417.2. Phases to be used .............................................................................................. 8417.3. Verification of Knowledge ..................................................................................... 8517.3.1. Test Architecture ....................................................................................... 8517.3.2. Application Map ........................................................................................ 8517.4. Scope Definition .................................................................................................. 8617.5. Test Methodologies .............................................................................................. 8617.6. Defining the Performance Goals ........................................................................... 8717.6.1. Single Component Tests ........................................................................... 8717.6.2. Combined Component Tests ...................................................................... 8817.6.3. Going Live Tests ....................................................................................... 8817.6.4. Error Tests ............................................................................................... 8917.6.5. Endurance Tests ....................................................................................... 8917.7. Optimization ........................................................................................................ 8917.8. Reporting ............................................................................................................ 9018. How to Create a Fully Featured Internet Website ............................................................. 91Page iv of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


CQ5 WCM How To - A Collection19. How to Set Up the Development Environment with Eclipse ............................................... 9219.1. How to Set Up the Development Environment with Eclipse ..................................... 9219.1.1. Creating the Project Structure in CQ5 ........................................................ 9219.1.2. Installing FileVault (VLT) ............................................................................ 9219.1.3. Installing Eclipse ....................................................................................... 9319.1.4. Creating the Project Structure in Eclipse ..................................................... 9419.1.5. Scripting with Eclipse and CQ5 .................................................................. 9819.1.6. Java Developing with Eclipse and CQ5 .................................................... 10019.1.7. Building collaborative and automated projects ........................................... 10220. How to Model Data ....................................................................................................... 10320.1. Data Modeling - David Nuescheler's Model .......................................................... 10320.1.1. Source .................................................................................................... 10320.1.2. Introduction from David ............................................................................ 10320.1.3. Seven Simple Rules ................................................................................ 10321. JSP Tag Libraries ......................................................................................................... 10921.1. JSP Tag Libraries .............................................................................................. 10921.1.1. CQ Tag Library ....................................................................................... 10921.1.2. Sling Tag Library ..................................................................................... 113A. Copyright, Licenses and Formatting Conventions ............................................................. 117A.1. Formatting Conventions ....................................................................................... 117Page v of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


1 Introduction1.1 IntroductionTo help you perform certain tasks within CQ5 this collection of How To articles has been compiled.1.2 Purpose of this DocumentTo collect all the How To articles into one <strong>doc</strong>ument.1.3 Target Audience• see individual How To sectionsPage 1 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


2 How to Quickly Create a Website2.1 IntroductionThis tutorial enables you to quickly create a website with CQ5, based on an existing website. It ismainly targeted at <strong>Day</strong> Pre-Sales staff and <strong>Day</strong> Partners preparing Proof Of Concept for a project.You only need CQ5 WCM, CQDE and a Web browser.2.2 Creating the application, the Content Page Template, theContent Page Component and a Web Page1. In CRX Explorer, copy the node apps/geometrixx, name the target node and paste it under apps.2. Set the title (jcr:title property) of the Template apps//templates/contentpage to Content Page Template.3. Replace the thumbnail /apps//templates/contentpage/thumbnail.png with one representing your Template.• Create a PNG image, 128 x 98 px big.• In your file system, copy the image and paste it into /apps//templates/contentpage/ .4. Delete the property allowedPaths of the Template /apps//templates/contentpage.5. Set the property sling:resourceType of the node /apps//templates/contentpage/jcr:content to /components/contentpage.6. In CQDE, under the Component /apps//components/contentpage,create the file contentpage.jsp.7. Copy/paste following code into the script contentpage.jsp:MyCustomerHeadMyCustomerBody8. In your browser, open the CQ site administration.9. Under Websites, create a new page with the Title www..com, the label and the Content Page Template.10. Under the Page www..com, create a new page with the Title English,the label en and the Content Page Template. If needed, create one Pagewith the Title French, the label fr and one Page the Title German, the label de.Page 2 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Quickly Create a Website11. Under the Page English, create as many pages as needed in order to reproduce the sitemap of your customer site.12. Open the English Page. It should look as follows:2.3 Setting up the Designer1. In CRX Explorer, copy the node /etc/designs/geometrixx, name the target node and paste it under /etc/designs.2. In contentpage.jsp, insert at theappropriate location.3. In CQDE, open the file /etc/designs//static.css and adapt thestyles to your needs.4. Link your pages to the designer: in CRX Explorer, select the node /content//jcr:content. Double-click Property cq:designPath andset /etc/designs/ as Value.2.4 Importing the original Web Page (CSS, HTML and images) intoyour project1. In Firefox, browse to the page that you want to import, select Save Page As …, enter as Filename and save it on your desktop.2. Test the downloaded website on your desktop: open the downloaded.htm file in your browser and compare the result with the original website.If it is different, open the file in a text editor and fix the problems. Problems are often causedby paths for css files and images that need to be correctly reset.3. In your filesystem, zip all the resources of your webpage (html, css, images, ...).4. In CRX Explorer, under the node /apps//components/contentpage,create a New Node: set the Name to resources and the Type to sling:Folder.Page 3 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Quickly Create a Website5. In CRX Content Loader, import the zip file and expand it into the node /apps//components/contentpage/resources:• Browse to http://localhost:4502/crx/loader/index.jsp.• Click Browse beside Root path for import:, browse to the node /apps//components/contentpage/resources and click Open.• Click Browse beside File to upload:, browse to your zip file and click Open.• Check Auto-Expand and Expand file content directly below selectedroot checkboxes.• Click Import.NoteIn a normal project setup, the resources wouldn't be placed under the Component. Itis only done here to maximize your efficiency.6. In CQDE, open the file .html and copy the content between the and tags. In the script contentpage.jsp, selectMyCustomerHeadand paste the previously copied content.7. In the file .html, copy the content between the and tags.In the script contentpage.jsp, selectMyCustomerBodyand paste the previously copied content.8. In the script contentpage.jsp, reset the paths of the css files and the images by replacing:_fileswith:/apps//components/contentpage/resources.NoteMake sure that the names of your resources don't start with _ (underscore).9. In the script contentpage.jsp, replace all external links with internal links. This way theexternal links don't appear broken when your machine is not online.10. In your browser, in the CQ Site Administration, open the page www..com. Itshould display your web page.2.5 Replacing static content by dynamic content using CQFoundation Components1. In CQDE, in the file contentpage.jsp, select the content of the middle part of the page andreplace it with:Page 4 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Quickly Create a Website. The content has been replaced by the parsys Foundation Component.2. In your browser, refresh your page. The features of the Paragraph System are now availableto you: you can include other Components, for example, Flash, Text or Text Image.3. By following the previous steps, you can add other CQ Foundation Components as forexample topnav or toolnav.4. In your browser, in the CQ Site Administration, open a page of your choice from yourapplication. Copy content from the original web page and paste it into your page.5. Adapt the design to look like the design of the original website.2.6 Creating a Media Library1. In your browser, download about 20 resources (pictures, banners, pdf, …) from the originalwebsite: open a Google page, type site:, click search and click theImages tab. Save the desired resources on your computer.2. In your filesystem, zip all the resources.3. In CRX Content Loader, import the zip file and expand it into the node content/dam/. The resources are now available in the contentfinder, when browsingthrough the Pages.Page 5 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


3 How to Develop Components3.1 Developing ComponentsThis section describes how to create your own components and add them to the paragraphsystem.A quick way to get started is to copy an existing component and then make the changes you want.You can also use this method to edit existing components (although <strong>Day</strong> recommends that youback up the original component).An example of how to develop a component is described in detail in Extending the Text and ImageComponent - An Example.3.1.1 Developing a new component by adapting an existing componentTo develop new components for CQ WCM based on existing component, you copy the componentand create a javascript file for the new component and store it in a location accessible to CQ5:1. Create a new component folder in /apps//components/ by copying an existing component, such as the Textcomponent, and renaming it.2. In the CRX Explorer, modify the jcr:description and jcr:title to reflect its new name.3. Open the new component folder and make the changes you require; also, delete anyextraneous information in the folder.You can make changes such as:• adding a new field in the dialog box• replacing the .jsp file (name it after your new component)• or completely reworking the entire component if you wantFor example, if you take a copy of the standard Text component, you can add an additionalfield to the dialog box, then update the .jsp to process the input made there.Page 6 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Develop Components4. In the Content Explorer, navigate to the component and change the allowedParentsproperty to */parsys, which makes it available to the paragraph system.NoteEither cq:editConfig node, dialog, or design_dialog node should be present andproperly initialized for the new component to appear.5. Activate the new component in your paragraph system either by adding /apps//components/to the /etc/designs/default//jcr:content/contentpage/parsys/componentsproperty in CRX or byfollowing the instructions in Adding new components to paragraph systems.6. In CQ WCM, open a page in your web site and insert a new paragraph of the type you justcreated to make sure the component is working properly.NoteTo see timing statistics for page loading, you can use Ctrl-Shift-U - with ?debugClientLibs=true set in the URL.3.1.2 Adding a new component to the paragraph system (design mode)After the component has been developed, you add it to the paragraph system, which enablesauthors to select and use the component when editing a page.1. Access a page within your authoring environment that uses the paragraph system; forexample /Test.html.2. Switch to Design mode by either:• adding ?cmsmode=design to the end of the URL and accessing again; for example/ Test.html?cmsmode=design.• clicking Design in SidekickYou are now in designmode and can edit the paragraph system:3. Click Edit.A list of components belonging to the paragraph system are shown (all those defined with theproperty allowedParents=*/parsys). Your new component is also listed.The components can be activated (or deactivated) to determine which are offered to theauthor when editing a page.4. Activate your component, then return to normal edit mode to confirm that it is available foruse.3.1.3 Extending the Text and Image Component - An ExampleThis section provides an example on how to extend the widely used text and image standardcomponent with a configurable image placement feature.The extension to the text and image component allows editors to use all the existing functionality ofthe component plus have an extra option to specify the placement of the image either:• on the left-hand side of the text (current behavior and the new default)• as well as on the right-hand sidePage 7 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Develop ComponentsAfter extending this component, you can configure the image placement through the component'sdialog box.The following techniques are described in this exercise:• Copying existing component node and modifying its metadata• Modifying the component's dialog, including inheritance of widgets from parent dialog boxes• Modifying the component's script to implement the new functionality3.1.3.1 Extending the existing textimage componentTo create the new component, we use the standard textimage component as a basis and modifyit. We store the new component in the Geometrixx CQ WCM example application. To extend thetextimage component, go to the CRX Explorer (server name:port number/crx) and log in asadmin and then navigate to the Content Explorer.1. Copy the standard textimage component from /libs/foundation/components/textimage into the Geometrixx component folder, /apps/geometrixx/components,using textimage as the target node name. (Copy the component by navigating to thecomponent, right-clicking and selecting Copy and browsing to the target directory.)2. To keep this example simple, navigate to the component you copied and delete all thesubnodes of the new textimage node except for the following ones:• dialog definition: textimage/dialog• component script: textimage/textimage.jspPage 8 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Develop Components3. Edit the component metadata:• Component name• Set jcr:description to Text Image Component (Extended)• Set jcr:title to Text Image (Extended)• Component listing in the paragraph (parsys component) system (leave as is)• Leave allowedParents defined as */parsys• Group, where the component is listed in the sidekick (leave as is)• Leave componentGroup set to General• Parent component for the new component (the standard textimage component)• Set sling:resourceSuperType to foundation/components/textimageAfter these steps the component node looks like the following:4. Modify the component's dialog box to include the new option. The new component inheritsthe parts of the dialog box that are the same as in the original. The only addition we make isto extend the Advanced tab, adding an Image Position dropdown list, with options Leftand Right:• Leave the textimage/dialog properties unchanged.• Note how textimage/dialog/items has three subnodes, tab1 to tab3, representingthe three tabs of the textimage dialog box.• For the first two tabs (tab1 and tab2):• Change xtype to cqinclude (to inherit from the standard component).• Add a pathParameter property with values /libs/foundation/components/textimage/dialog/items/tab1.infinity.json and /libs/foundation/components/textimage/dialog/items/tab2.infinity.json, respectively.• Remove all other properties or subnodes.• For tab3:• Leave the properties and subnodes without changes• Add a new field definition to tab3/items, node position of type cq:Widget• Set the following properties (of type String) for the new tab3/items/position nodePage 9 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Develop Components• name: ./imagePosition• xtype: selection• fieldLabel: Image Position• type: select• Add subnode position/options of type cq:WidgetCollection to represent thetwo choices for image placement, and under it create two nodes, o1 and o2 of typent:unstructured• For node position/options/o1 set the properties: text to Left and value to left• For node position/options/o2 set the properties: text to Right and value torightImage position is persisted in content as the imagePosition property of the noderepresenting textimage paragraph.After these steps, the component dialog box looks like this:5. Extend the component script, textimage.jsp, with extra handling of the new parameter.• Open the /apps/geometrixx/components/textimage/textimage.jsp script forediting.• We are going to manipulate the style of the tag, generated by thecomponent, to float the image to the right. It is located in the following area of the code:Image img = new Image(resource, "image");if (img.hasContent() || WCMMode.fromRequest(request) == WCMMode.EDIT) {%>


How to Develop Components• Copy the following code fragment, and replace the %>


How to Develop Components6. Open the dialog of the text and image paragraph, and change the Image Position on theAdvanced tab to Right, and click OK to save the changes.7. You see the paragraph rendered with the image on the right:Page 12 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Develop Components8. The component is now ready to use.The component stores its content in a paragraph on the Company page. The following screenshotshows how our new configuration parameter is persisted in the repository, with the noderepresenting the paragraph we have just created.The textimage/imagePosition parameter represents the position of the image for thisparagraph on /content/geometrixx/en/company page.Page 13 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


4 How to Set Up a Cluster4.1 How to Set Up a Cluster in CommuniquéClustering uses two or more live servers, so if one server breaks down, the other can take over.Therefore, even if a node fails, the other nodes are active and accessible for your applications andthere is no system interruption. This allows you to recover and re-start failed nodes easily. Also,new nodes can be added to an existing cluster, allowing for simple extensibility.Clustering is beneficial in the following scenarios.• A server breaks down – The cluster agent relays requests to the servers that are still running.Service continues without interruption.• A repository breaks down – If the repository breaks down, the server becomes unavailable, andthe cluster agent relays the requests to the other servers. Service continues without interruption.• Increased performance – clustering enables your system to perform better even when nodes fail.NoteAs long as both servers are active, you can use their combined computational power.This means that this solution improves performance during normal use. On the otherhand, if one server breaks down, you lose its performance, so your overall applicationperformance may suffer.Following section describes how to set up a cluster in Communiqué with two cluster nodes on twoseparate networked machines.The master node is called node 1, the slave node is called node 2.On the node 1 (master):1. In the file system, create a folder /node1.2. Install Communiqué under /node1. For a complete description of the installation, please refer tothe section called “Installing an Author instance”.3. In the file system, share the folder node1/crx-quickstart/repository/shared so that itcan be accessed from the node 2.On the node 2 (slave):1. In the file system, create a folder /node2.2. Install Communiqué under /node2. For a complete description of the installation, please refer tothe section called “Installing an Author instance”.3. In the file system, map the folder on node 1 node1/crx-quickstart/repository/sharedto a drive, Z: in our case.4. In your browser, open the CRX Main Console5. Browse to http://localhost:4502/crx to open the CRX Main Console.6. Log in as administrator.7. Click Repository Configuration.8. Under Tools, click Cluster.Page 14 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up a Cluster9. Under Join Cluster, as Shared path, enter Z:\ and click Join.NoteIn order to add more nodes to the cluster, repeat the steps on the slave node as manytimes as needed.Page 15 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


5 How to Monitor Performance5.1 IntroductionCQ5 encompasses several applications, and interacts with several more.Performance (or the lack of it) is one of the first things that your users notice, so as with anyapplication with a user interface, performance is of key importance. To optimize the performance ofyour CQ5 WCM installation various attributes of the behavior should be monitored.5.1.1 Purpose of this How ToTo give a short introduction on what to monitor, and how, when optimizing the performance of yourCQ5 implementation.NoteThis <strong>doc</strong>ument deals primarily with the mechanics of monitoring performance. Issuessuch as setting the target metrics of the performance you want to achieve are coveredelsewhere. See the CQ5 WCM Project Manager Guide for more information.5.1.2 Target Audience• Power Users• System Administrators• Project Managers5.2 Performance - some theoryThe problems that cause performance issues are often difficult to track down, even when theireffects are easy to see.A basic starting point is a good knowledge of your system when it is operating as normal. If youdon't know how your environment "looks" and "behaves" when it is performing properly, it canbe difficult to locate the problem when performance deteriorates. This means that you shouldspend some time investigating your system when it is running smoothly and ensure that collectingperformance information is an ongoing task. This will provide you with a basis for comparisonshould the performance suffer.The following diagram illustrates the path that a request for CQ5 content can take - and thereforethe number of different elements which can impact the performance.Page 16 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Monitor PerformanceFigure 5.1. CQ5 request - the web-chainPerformance is also a balance between Volume and Capacity:Volumethe amount of output that is processed and delivered by the system.Capacitythe system’s ability to deliver the volume.This can be illustrated in various locations throughout the web-chain.Page 17 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Monitor PerformanceFigure 5.2. Capacity vs. VolumeThere are several functional areas which are often responsible for impacting the performance:• Caching• Application (your project) code• Search functionality5.3 Performance - basic rulesCertain rules should be kept in mind when optimizing performance:1. Performance tuning must be part of every project.2. Do not optimize early in the development cycle.3. Performance is only as good as the weakest link.4. Always think about capacity vs. volume.5. Optimize important things first.6. Never optimize without realistic goals.NoteBear in mind that the mechanism you use to measure performance will often affectexactly what you are trying to measure. You should always try to account for thesediscrepancies, and eliminate as much of their effect as possible; in particular browserplug-ins should be de-activated wherever possible.5.4 Recognizing some common performance problemsThe following lists common performance issues which occur, together with proposals on how tospot and counteract them.Page 18 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Monitor PerformanceTable 5.1. Recognizing common performance problemsArea Symptom(s) To increase capacity... To reduce volume...Client High client CPU usage. Install a client CPU withhigher performance.ServerNetworkLow server CPU usage.Some clients fast, someslow.CPU usage low on bothservers and clients.Browsing locally on theserver is (comparatively)fast.Web-server CPU usage on the webserveris high.Application Server CPU usage is high.RepositoryCacheSimplify (HTML) layout.Upgrade to a faster browser. Improve client-side cache.Remove any networkbottlenecks.Increase networkbandwidth.Cluster your web-servers.Use a hardware loadbalancer.Improve/optimize theconfiguration of the clientcache.Reduce the "weight" ofyour web pages (e.g. lessimages, optimized HTML).Reduce the hits per page(visit).Cluster your CQ5 instances. Search for, and eliminate,CPU and memory hogs (usecode review, timing output,etc).High memory consumption. Improve caching on alllevels.Low response times. Optimize templates andcomponents (e.g. structure,logic).5.5 Monitoring, and optimizing, the performancePerformance issues may stem from a number of causes that have nothing to do with your website,including temporary slowdowns in connection speed, CPU load, and many more.It may also impact either all your visitors, or only a subset of them.All this information needs to be obtained, sorted and analyzed before you can optimize theperformance.If you experience a performance issue:• try to replicate it: with one (or preferably more) standard web-browsers, on a different client thatyou know has good general performance and/or on the server itself (if possible)• check whether anything (related to the system) has changed within an appropriate time-space,and if any of these changes could have impacted the performance• collect as much information as possible to compare with your knowledge of the system undernormal circumstances5.5.1 Tools and mechanismsThe following gives a short overview of some of the tools available for monitoring performance.Page 19 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Monitor PerformanceNoteSome of these will be dependent on your operating system.Table 5.2. Tools and mechanisms for monitoring performanceTool Used to analyze... Usage / More information...request.logResponse times andconcurrency.Interpreting the request.log.truss/strace Page Loads Unix command. Include the misc.truss log level toINFO.CQ5 statusmonitorThread dumpsMonitor CQ5 requests;including request-type,long-running requests,pending requests.Observe JVM threads.Identify contentions,locks and long-runners.Dependent on the operating system, e.g. kill -QUIT on Unix/Linux whereas Ctrl-Break on Windows.System calls Identify timing issues. Calls to System.currentTimeMillis() orcom.day.util.Timing are used to generatetimestamps from your code, or via HTML-comments.Note: These should be implemented so that they canbe activated / deactivated as required; when a system isrunning smoothly the overhead of collecting statistics willnot be needed.Apache BenchSearchAnalysisJMeterJProfilertruss/strace,lsofIdentify memory leaks,selectively analyzeresponse time.Execute search queriesoffline, identify responsetime of query, test andconfirm result set.Load and functionaltests.In-depth CPU andmemory profiling.In depth kernel call andprocess analysis (Unix).5.5.2 Interpreting the request.logFor full details: http://httpd.apache.org/<strong>doc</strong>s/2.0/programs/ab.html; basic usage is: ab -k -n -c Analyzing Search.http://jakarta.apache.org/jmeter/http://www.ej-technologies.com/Unix/Linux commands.This file registers basic information about every request made to CQ5. From this valuableconclusions can be extracted.5.5.2.1 Monitoring traffic on your websiteThe request log registers each request made, together with the response made:09:43:41 [66] -> GET /author/y.html HTTP/1.109:43:41 [66]


How to Monitor PerformanceA good starting point for performance analysis is the request log.You can find the request log at data\author\logs and data\publish\logs for the authorand publish instance respectively.The log looks as follows (the lines are shortened for simplicity):09:43:41 [66] -> GET /author/y.html HTTP/1.109:43:41 [66] GET /author/z.gif HTTP/1.109:43:48 [67] GET /author/x.html HTTP/1.109:43:49 [68] GET /author/playground/en/tools/search.html?query=dilbert&size=5&dispenc=utf-8 HTTP/1.122.05.2008 12:27:42 [338]


How to Monitor PerformanceTests must be made to determine how many concurrent users the system can handle before anegative impact is seen. Again scripts can be used to extract results from the log file:• monitor how many requests are made within a specific time span e.g. one minute• test the effects of a specific number of users all making the same requests at (as close aspossible) the same time; e.g. 30 users clicking Save at the same time22.05.2008 12:27:22 [333] -> GET /author/libs/Personalize/content/statics.close.gifHTTP/1.122.05.2008 12:27:22 [334] -> GET /author/libs/Personalize/content/statics.detach.gifHTTP/1.122.05.2008 12:27:22 [335] -> GET /author/libs/CFC/content/imgs/logo.rZMNURccynWcTpCxyuBNiTCoiBMmw000.default.gif HTTP/1.122.05.2008 12:27:22 [335]


How to Monitor PerformanceFigure 5.4. Cache vs. Uncached - maximum hits / secondAlthough there are many algorithms to ensure that data is retrieved from the source system whenappropriate, circumstances can arise where the data residing in a cache is out of date. Retrievingevery page individually is the only guaranteed method of ensuring your content is up-to-date, but itis very costly in terms of response, and can indeed cause knock-on effects.This is particularly relevant when using personalized pages, where at least some content of apage is dependent on the user, and the account they used to login.Figure 5.5. Cache speed vs. Data IntegrityPage 23 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Monitor Performance5.5.3.1 Optimizing your content for cache performanceMake sure you use realistic cache settings for the browser cache. If you have disabled the browsercache for development, this may increase traffic and decrease responsiveness.5.5.4 Analyzing SearchFirst steps to analyzing the search function can be made with Monitoring search response timeswith the CQ5 request.log.However, once you have determined the response time, you may need to analyze why the requestis taking the time it does, and what can be done to improve the response.Page 24 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


6 How to Create and Use a Workflow6.1 Creating a WorkflowFirst you must create your workflow. You can then apply an instance of this (version dependent)when managing your website.ImportantActions on workflows can only be undertaken if:• you are working with the admin account• the account has been assigned to the default group workflow-users, which holds allthe privileges necessary for your users to perform workflow actions.NoteFor simplicity, the following examples have all been made using the admin account.6.1.1 Creating a new Workflow ModelThe actual creation is a small step - a skeleton workflow (with 3 default steps) will be created.1. Open the Workflow console.2. From the Models tab, select New from the top navigation bar. The New Workflow dialog willopen.3. Specify the Title for your workflow.4. Click OK to save and close the dialog. You will be returned to the Models tab, where you seeyour new workflow in the list.6.1.2 Editing the WorkflowAs mentioned above, a skeleton workflow is created with a minimum of steps. For the workflow tobecome meaningful, you must edit it immediately.1. Open the Workflow console.2. From the Models tab, select your workflow.3. Either click Edit or double-click the name of the workflow. A new tab (named after theworkflow) will open for editing and configuring a workflow. This shows 3 panes:• ToolboxPage 25 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a WorkflowLists the Step and Split types. Click to display the appropriate list, then use drag theelement you want into the appropriate position to build your workflow.Note• Workflow ModelA complete explanation of all types of workflow steps and splits, together withtheir related properties, can be found in the next section - the section called “Thetypes of Workflow Steps available”.Contains the graphical representation of your workflow. Here you can position the stepsand splits, edit the workflow name or description and save changes.The Save button is also located here, as is the Model Version. The Model Version isincremented every time the workflow model is updated. This is reflected in the monitoringdisplays. As multiple versions of a workflow can be in use at any one time, this helps youtrack the version being used in each instance.• PropertiesAllows you to edit properties of the individual steps and splits.NoteA complete explanation of all types of workflow steps and splits, together withtheir related properties, can be found in the next section - the section called “Thetypes of Workflow Steps available”.Three steps have already been created:StartA mandatory step to start the workflow. This cannot be edited, nor deleted.Step 1A Participant step which is an example. This must be edited, or replaced if required.Further steps can be added.EndA mandatory step for every workflow. The End step is used to cleanly terminate theworkflow, or to pass control back to the parent workflow if used as a child workflow.Page 26 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a WorkflowYou can either define a full workflow, or a sub-section of a workflow. Sub-workflows can thenbe referenced by other workflows to form part of a complete workflow. This simplifies theconstruction of complex workflows, and also allows you to reuse sub-workflows which occurrepeatedly.4. Enter a Model Description for the workflow (you can also edit the Model Title) fromthe center pane. Click on the field to enter edit mode.5. You can now design your workflow by dragging steps onto the Workflow Model, thenconfiguring the properties.6. When finished, Save your model, then close the tab.6.1.2.1 ExampleTo illustrate some of the possibilities for creating a workflow, the following example emulates avariation of the Publish Example workflow.1. Edit Step 1 usingon the step itself.a. Enter Validate Content for the Title and Description.b. Set the User/Group to admin.c. Set the Timeout to Off and Timeout Handler empty.2. Click on Splits to display the list of split types.3. Drag an Or Split onto the workflow and position it between Validate Content and End.An Or Split will be added to your workflow.4. Edit the left-hand branch:a. Click theicon on the actual branch.b. Set Default Route to true.c. Click theicon on New Step in the left-hand branch. This will be a Participant step.d. Enter Cancel Publish for the Title and Description.e. Set the User/Group to admin.5. Edit the right-hand branch:a. Click theicon on the actual branch.Page 27 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflowb. Set Default Route to false.c. Leave the Rule empty. This is for demonstration purposes.d. Click theicon on New Step in the right-hand branch. Change this from a Participant to aProcess step; the properties available will be updated.e. Enter Publish Page for the Title and Description.f. Set the Handler Advance to false.g. Select com.day.cq.workflow.example.publish.PublishProcess as theImplementation script. This implementation will publish the selected page to the publisherinstances.6. Now you have specified all steps in your workflow, click Save.7. Finally close the tab and return to the main console.6.2 Using the WorkflowAfter you have defined your workflow you will want it to be used when managing your website. Thefollowing sections detail the different tasks when using workflows.6.2.1 Starting the Workflow for an individual pageThere are two methods of starting a workflow; from the Workflow Console or the siteadmin:In either case you need to link a workflow to its payload. The payload (including pages, nodes,resources) will then be subject to this instance of the workflow.Page 28 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a WorkflowImportantThe current version of the workflow model is assigned; if the main copy of the workflow isupdated later then the changes will have no impact on the instance assigned.Procedure 6.1. Starting a workflow from the workflow console1. Open the Workflow console.2. From the Models tab select the required workflow.3. Click Start from the top navigation.4. The Start Workflow dialog opens allowing you to enter the payload and a comment.Specify the payload (includes pages, nodes, resources, etc) to which the workflow is to beapplied. You can use the drop down selector to browse the repository when selecting:5. Click OK to save your selection and start the workflow. Now the workflow is running.Procedure 6.2. Starting a workflow from the sidekick1. Open the siteadmin.2. Open the required page.3. Select the Workflow tab from the sidekick.4. Select Start Workflow... to open a new dialog allowing you to select the workflow and aenter a comment.Page 29 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow5. Click Start to save your selection and start the workflow. Now the workflow is running.Once a page has been linked to a workflow it will be indicated in the siteadmin:6.2.2 Automatically Assigning a WorkflowTo simplify the action of starting a workflow it is possible to Auto Assign workflows. With this, youcan automatically assign one or more workflows to a content tree, dependent on the page templatebeing used. As soon as a page is created within this tree and with the specified template, theworkflow is applied to that page.1. Open the siteadmin.2. Select the page at the root of the content tree. Any pages created underneath this page willbe subject the specified workflow.3. From the Workflow menu select Auto Assign. The Auto Assign Workflow dialog willopen.4. Click Add to open the Auto Assign Rule dialog:Page 30 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a WorkflowThis allows you to specify the:TemplateAny page created using this template will be subject to the rule.WorkflowThe workflow to be applied to any page created - with the specified template and in thegiven path.PathPath to which the rule is applied.5. Click OK to save the rule.6. The rule will now be listed in the Auto Assign Workflow window.NoteYou can create several rules, so you must take care that the rules do not conflict.Page 31 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow7. Click Close to complete the definition. From now on, as soon as a page is created within thespecified trees with the specified templates the appropriate workflows are applied. This will beindicated in the In Workflow column,6.2.3 Taking actions on a Participant StepAny participant steps that you have created will be assigned to the specific user or group, who willneed to take action:• When the task is completed they then acknowledge this fact by completing the workflow step(see Completing a Participant step).• If the specific user(s) are unable to take action they can delegate responsibility to another user orgroup (see Delegating a Participant step).• If necessary they can step back to repeat a section of the workflow (see Performing Step Backon a Participant step).6.2.3.1 Selecting a Participant Step to take actionBefore you can take any action on a Participant step, you need to select it:1. Open the Workflow console.2. Select the Inbox tab to see when an action is assigned to you. This occurs when a workflowreaches a Participant step with your account, or group, specified:Page 32 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow3. Select the entry.6.2.3.2 Completing a Participant stepAfter you have taken the action indicated you can complete the workflow step, thus allowing theworkflow to continue.1. Click the Complete button in the top navigation bar.2. In the resulting dialog, select the Next Step; that is, the step to execute next. A drop downlist will show all appropriate destinations. A Comment can also be entered.NoteThe number of steps listed depends on the design of the workflow.3. Click OK to confirm the action.6.2.3.3 Delegating a Participant StepIf a step has been assigned to you, but for any reason you are unable to take action, you candelegate the step to another user or group.1. Click the Delegate button in the top navigation bar.2. In the resulting dialog, select the User you want to pass the action to.A drop down list will show all appropriate users.If the step has been defined with one user, then only this user will be available - the stepcannot be delegated to anyone else.If a group has been defined, then the list will show the group itself and all individual userswithin the group. You can delegate to either the entire group, or an individual user within thatgroup.A Comment can also be entered.Page 33 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow3. Click OK to confirm the action.6.2.3.4 Performing Step Back on a Participant stepIf you discover that a step, or series of steps, needs to be repeated you can step back. This allowsyou to select a step which occurred earlier in the workflow for reprocessing. The workflow willreturn to the step you specify, then proceed from there.1. Click the Step Back button in the top navigation bar.2. In the resulting dialog, select the Previous Step; that is, the step to execute next - eventhough it is a step that occurs earlier in the workflow. A drop down list will show all appropriatedestinations.NoteThe number of previous steps available in the list depends on the design of theworkflow.3. Click OK to confirm the action.6.2.4 Suspending, Resuming and Terminating a Workflow instanceAside from workflow instances that require your immediate action and show up in your WorkflowInbox, you can perform certain other actions on running workflow instances.Page 34 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow1. Open the Workflow console.2. Select the Instances tab. You will see a list of active (neither finished, nor terminated)workflow instances.3. Select an entry.4. To suspend the workflow, click the Suspend button in the navigation bar. The State willchanged to Suspended. This can be helpful in exceptional cases when you do not want theworkflow to proceed; for instance for maintenance.5. While a workflow is suspended, you can then click Resume. This will restart the workflow fromwhere it was suspended, with the same configuration. Again the State will be updated.6. To finally terminate the workflow, click Terminate. This will immediately end the workflowexecution - the state will change to ABORTED. A terminated workflow instance cannot berestarted.The Instances tab is not only useful for taking action on running workflows, you can also use it tomonitor workflow instances, without necessarily modifying them.6.2.5 Monitoring the Status of Workflow InstancesTo monitor the status of workflow instances, you can use the Instances or Archive tabs.Instances tabShows all running instances.Archive tabShows terminated workflow instances.6.2.5.1 Monitoring Workflows in progressFrom the Instances tab you can see the status of a Workflow in progress. A list of the activeModels is shown; in this case RUNNING:With the Instances tab you can take various actions (see Suspending, Resuming andTerminating a Workflow instance) and also Open History to show the actions executed to dateon the workflow instance:Page 35 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Create and Use a Workflow6.2.5.2 Archived WorkflowsAfter a Workflow instance has finished, for whatever reason (terminated, as below, or aftersuccessful completion), it can (only) be seen in the Archive tab:As the workflow has already completed, no further action can be taken on these instances.However, if you need further details of a completed workflow you can still use Open History.Page 36 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


7 Upgrading to CQ57.1 How to Upgrade Your Communiqué Instance (3 or 4) to CQ5The upgrade tool allows you to launch a standardized upgrade process. It is delivered with aconfiguration to be used “out of the box,” though several settings can be updated when necessary.You:• provide the URL of the Communiqué instance to be upgraded, together with the superuseraccess credentials• can configure a list of page handles to be included in the upgrade• can set debug parameters if required.NoteThe following procedure uses a standard Communiqué 4 installation, complete withPlayground and DesignGround, to illustrate the upgrade process.1. Navigate to the Upgrade window, by one of the following methods:a. Select the Miscellaneous tab in CQ WCM, then double-click on the MigratePage to open.b. Navigate directly to http:///etc/migration for example,http://localhost:4502/etc/migration (if not already logged in you will berequired to).In either case the following form will be shown:2. Update any of the default settings if required.Page 37 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Upgrading to CQ53. Click Migrate to start the process. A status message will shown while this is running:4. When complete, the upgraded items will be listed (the following screenshot is an extract):5. You can now access the upgraded items in your CQ5 instance:NoteYou must test the operation of the upgraded website; highly customized items mayneed to be upgraded separately.Page 38 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


8 Installing CQ58.1 How to Install CQ WCM Author and Publish Instances usingQuickstartThis section describes how to install CQ WCM. Generally, when you set up CQ WCM, you need toset up an Author and a Publish instance, which are described in Installing an Author instance andInstalling a Publish instance. If, for testing or other purposes, you need to install CQ WCM out ofthe box, you can use the generic procedure.8.1.1 Installing a CQ WCM instance - Generic procedureThis procedure is a generic, quickstart procedure for installing CQ WCM. You do not need toperform this procedure before installing an author or publish instance. To install an author orpublish instance, see Installing an Author instance and Installing the Publish instance.To install a CQ WCM instance:1. Copy the CQ WCM cq-wcm-quickstart-.jar file (for example, cq-wcmquickstart-5.1.0.20081114.jar)to the desired directory on the host file system.2. Copy a valid license.properties file into the same directory as the cq-wcmquickstart-.jarfile.NoteIf when starting the application, you do not provide the license.properties file,CQ WCM redirects you to the Welcome screen where you enter a valid license key.You can also request a valid license key from <strong>Day</strong> at this time.3. Start CQ WCM Quickstart by doing one of the following:• If using a GUI file-system explorer, double-click the cq-wcm-quickstart-.jar file. This installs and automatically starts the server.NoteThe repository data is stored in the subdirectory crx-quickstart/repository.• If using the command line, type the following:java -jar cq-wcm-quickstart-.jar• Use a custom script located in the crx quickstart folder, such as server.bat tostart CQ. The Start and Stop scripts are for UNIX, Linux, and Macintosh. The server.batscript is for Windows.NoteYou cannot use a custom script when you install the quickstart.jar fileunless you expand the file first. Use the -unpack option on the command lineto unpack the contents before running the script as in java -jar cq-wcmquickstart-.jar-unpack.4. When the installation is complete, you are automatically redirected to http://localhost:4502/bin/login.html.Page 39 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5NoteCQ WCM quickstart selects the first available port from the following list:4502,8080,8081,8082,8083,8084,8085,8888,9362,. You canalso set the port number. See installing an author instance for an example on how toset a port number.8.1.2 Installing an Author instanceThis procedure describes how to set up a default Author instance on port 4502 of the desired host.To install an author instance:1. On the host file system, create a directory and name it author.2. Copy the CQ5 cq-wcm-quickstart-.jar file into author/ and rename thefile cq5-author-4502.jar. A different port can be set in the filename.3. Copy a valid license.properties file into the same directory as the cq-wcmquickstart-.jarfile.NoteIf when starting the application, you do not provide the license.properties file,CQ WCM redirects you to the Welcome screen where you enter a valid license key.You can also request a valid license key from <strong>Day</strong> at this time.4. Start CQ WCM Quickstart:• If using a GUI file-system explorer, double-click the cq5-author-4502.jar file.• If using the command line, type:java -jar cq5-author-4502.jar• Use a custom script located in the crx quickstartfolder, such as server.bat to startCQ. The Start and Stop scripts are for UNIX, Linux, and Macintosh. The server.batscript is for Windows.ImportantYou cannot use a custom script when you install the quickstart.jar fileunless you expand the file first. Use the -unpack option on the command lineto unpack the contents before running the script as in java -jar cq-wcmquickstart-.jar-unpack.5. When the installation is completed, you are automatically redirected to http://localhost:4502/bin/login.html.NoteWith the default settings, the syndication agent points toward the publish instance athttp://localhost:4503/.8.1.3 Installing a Publish instanceTo set up a publish instance on port 4503 of the desired host, you perform the same steps asin installing an author instance except that you create a directory named publish (instead ofauthor) and you rename the quickstart.jar file as cq5-publish-4503.jar. You can select anyport number.Page 40 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5To install a publish instance:1. On the host file system, create a directory and name it publish.2. Copy the CQ WCM cq-wcm-quickstart-.jar file into publish/ andrename it cq5-publish-4503.jar. A different port can be set in the filename.3. Copy a valid license.properties file into the same directory as the cq-wcmquickstart-.jarfile.NoteIf when starting the application, you do not provide the license.properties file,CQ WCM redirects you to the Welcome screen where you enter a valid license key.You can also request a valid license key from <strong>Day</strong> at this time.4. Start CQ WCM Quickstart:• If using a GUI file-system explorer, double-click the cq5-publish-4503.jar file.• If using the command line, type:java -jar cq5-publish-4503.jar• Use a custom script located in the crx quickstartfolder, such as server.bat to startCQ. The Start and Stop scripts are for UNIX, Linux, and Macintosh. The server.batscript is for Windows.ImportantYou cannot use a custom script when you install the quickstart.jar file unlessyou expand the file first. Use the -unpack option on the command line to unpackthe contents before running the script as in java -jar cq-wcm-quickstart-.jar -unpack.5. When the installation is completed, you can browse your site (for example, http://localhost:4503/content/geometrixx/en/company.html)8.2 How to install CQ5 with an Application ServerThe following sections detail how to install CQ5 in conjunction with various application servers:• WebSphere v6.1• WebLogic v10.1• Tomcat v6• JBoss v4A generic overview is also given for general usage and information:• Generic Procedures8.2.1 WebSphere v6.1After installing WebSphere v6.1 you:8.2.1.1 Install CQ51. Unpack the installation files of the CQ5 Quickstart into a directory (without starting the server);the installation directory will be referred to as :Page 41 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5• Start the CQ5 Quickstart jar with the option -unpack; for example:java -jar cq-wcm-quickstart-5.1.0.jar -unpackThis will create a folder crx-quickstart containing thefiles and folders used for installation, without actually starting the installation.ImportantThis must be done from the command line. If you open the jar file directly you willactivate the Quickstart installation and start the server.2. Copy the following jar files to the application server folder holding shared libraries:a. CRX\server\lib\container\jcr-1.0.jarb. CRX\server\lib\container\crx-shared.jar3. Restart WebSphere.4. Deploy the following web applications; they can be found in \crx-quickstart\server\webapps:a. CRX webapp; crx-explorer_crx.war.For example, deploy with the context path /crx.b. Launchpad webapp; crx-launchpad.war.For example, deploy with the context path /launchpad.5. Start the two applications.6. Register your CRX license:a. Access your CRX installation:http://://index.jspfor example: http://:/crx/index.jspb. Click the red warning message - “Click here...” (the message is a link).c. Enter your license key.8.2.1.2 Configure the default JDKWebSphere v6.1 uses JDK 1.5. By default the SAMLv2 JSP JDK source level uses JDK 1.3. As theSAMLv2 sample configuration uses the JDK 1.5 syntax, running it with the default source level willnot work. The following steps should be used to configure the source level as 1.5:1. Within the deployed crx-explorer_crx.war, edit ibm-web-ext.xmi and add thefollowing configuration parameter to specify the JSP engine:NoteThe integer (n) referenced in JSPAttribute_ must be unique within the file.2. Repeat for crx-launchpad.war.Page 42 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5Note3. Restart Websphere.The default configuration directory for the web module is:\profiles\profilename\config\cells\cellname\applications\enterpriseappname\ deployments\deployedname\webmodulename\WEB-INF\If you have already checked the option Use Binary Configuration the files areextracted to the following directory, where they can be edited:\profiles\profilename\installedApps\nodename\enterpriseappname\webmodulename\Where is the root directory of the web application server installation.8.2.1.3 Install your Content Packages1. Access the CRX main console.2. Log in to the crx.system workspace as admin.3. Navigate to the Package Manager in CRX.4. Upload and install the following CQ5 package from \crxquickstart\repository\install\system:• WCM Security Content Package; cq-security-content-.jar.5. Switch to the crx.default workspace, again as admin6. Upload and install the following CQ5 packages from \crxquickstart\repository\installin the following order:a. Sling Content Package; 0001-cq-wcm-sling-content-.jar.b. WCM Content Package; 0002-cq-wcm-content-.jar.8.2.1.4 Enable Replication for Author instances of CQ5For an author instance of CQ5 you must configure it to start in “author run mode” so that you canperform replications.1. Open the file: \crx-quickstart\launchpad\sling.properties for edit.2. Add the following two properties to the file:sling.jcrinstall.folder.name.regexp = .*/(install|config)(.author)?$sling.run.modes = author3. Restart the crx-launchpad web application.8.2.2 WebLogic v10.3After installing WebLogic v10.3 and creating your domain you:8.2.2.1 Configure the Server LocaleWhen you deploy CQ5 with WebLogic 10.3 you must have the server locale set to en_US to avoiderrors such as:Page 43 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5java.lang.IllegalArgumentException: Bad date header: 'Wed, 12 Nov 200816:34:28 GMT'These can occur when, for example, requesting a resource such as /libs/widgets/0.gif.To configure the server locale on Microsoft Windows:1. Open the Control Panel.2. Open Regional and Languages Options.3. In the Regional Options tab, for Standards and formats select English(UnitedStates).To configure the server locale on Linux or Unix:• set the environment variable LANG to en_US.8.2.2.2 Enable Basic Authentication HeadersTo enable out-of-the-box authentication of users in CQ5, authentication by the application servermust be switched off:1. Open /user_projects/domains//config/config.xml.2. Locate the element .3. Add the following child element to it:false4. If you had already started WebLogic then you will need to restart it.8.2.2.3 Install CQ51. Unpack the installation files of the CQ5 Quickstart into a directory (without starting the server);the installation directory will be referred to as :• Start the CQ5 Quickstart jar with the option -unpack; for example:java -jar cq-wcm-quickstart-5.1.0.jar -unpackThis will create a folder crx-quickstart containing thefiles and folders used for installation, without actually starting the installation.ImportantThis must be done from the command line. If you open the jar file directly you willactivate the Quickstart installation and start the server.2. Copy the following jar files to the application server folder holding shared libraries:a. CRX\server\lib\container\jcr-1.0.jarb. CRX\server\lib\container\crx-shared.jar3. Restart WebLogic.4. Deploy the following web applications; they can be found in \crx-quickstart\server\webapps:Page 44 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5a. CRX webapp; crx-explorer_crx.war.For example, deploy with the context path /crx.b. Launchpad webapp; crx-launchpad.war.For example, deploy with the context path /launchpad.5. Start the two applications.6. Register your CRX license:a. Access your CRX installation:http://://index.jspfor example: http://:/crx/index.jspb. Click the red warning message - “Click here...” (the message is a link).c. Enter your license key.8.2.2.4 Install your Content Packages1. Access the CRX main console.2. Log in to the crx.system workspace as admin.3. Navigate to the Package Manager in CRX.4. Upload and install the following CQ5 package from \crxquickstart\repository\install\system:• WCM Security Content Package; cq-security-content-.jar.5. Switch to the crx.default workspace, again as admin6. Upload and install the following CQ5 packages from \crxquickstart\repository\installin the following order:a. Sling Content Package; 0001-cq-wcm-sling-content-.jar.b. WCM Content Package; 0002-cq-wcm-content-.jar.8.2.2.5 Enable Replication for Author instances of CQ5For an author instance of CQ5 you must configure it to start in “author run mode” so that you canperform replications.1. Open the file: \crx-quickstart\launchpad\sling.properties for edit.2. Add the following two properties to the file:sling.jcrinstall.folder.name.regexp = .*/(install|config)(.author)?$sling.run.modes = author3. Restart the crx-launchpad web application.8.2.3 Tomcat v6After installing Tomcat v6 you:Page 45 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ58.2.3.1 Configure Tomcat access accountsTomcat enables neither admin nor manager access at installation.Therefore you have to manually edit tomcat-users.xml to allow access for these accounts:1. Navigate to the Tomcat configuration folder.2. Edit tomcat-users.xml to include access for admin and manager. The configurationshould look similar to the following example:8.2.3.2 Install CQ51. Unpack the installation files of the CQ5 Quickstart into a directory (without starting the server);the installation directory will be referred to as :• Start the CQ5 Quickstart jar with the option -unpack; for example:java -jar cq-wcm-quickstart-5.1.0.jar -unpackThis will create a folder crx-quickstart containing thefiles and folders used for installation, without actually starting the installation.ImportantThis must be done from the command line. If you open the jar file directly you willactivate the Quickstart installation and start the server.2. Copy the following jar files to the application server folder holding shared libraries:a. CRX\server\lib\container\jcr-1.0.jarb. CRX\server\lib\container\crx-shared.jar3. Restart Tomcat.4. Deploy the following web applications; they can be found in \crx-quickstart\server\webapps:a. CRX webapp; crx-explorer_crx.war.For example, deploy with the context path /crx.b. Launchpad webapp; crx-launchpad.war.For example, deploy with the context path /launchpad.5. Start the two applications.6. Register your CRX license:Page 46 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5a. Access your CRX installation:http://://index.jspfor example: http://:/crx/index.jspb. Click the red warning message - “Click here...” (the message is a link).c. Enter your license key.8.2.3.3 Install your Content Packages1. Access the CRX main console.2. Log in to the crx.system workspace as admin.3. Navigate to the Package Manager in CRX.4. Upload and install the following CQ5 package from \crxquickstart\repository\install\system:• WCM Security Content Package; cq-security-content-.jar.5. Switch to the crx.default workspace, again as admin6. Upload and install the following CQ5 packages from \crxquickstart\repository\installin the following order:a. Sling Content Package; 0001-cq-wcm-sling-content-.jar.b. WCM Content Package; 0002-cq-wcm-content-.jar.8.2.3.4 Enable Replication for Author instances of CQ5For an author instance of CQ5 you must configure it to start in “author run mode” so that you canperform replications.1. Open the file: \crx-quickstart\launchpad\sling.properties for edit.2. Add the following two properties to the file:sling.jcrinstall.folder.name.regexp = .*/(install|config)(.author)?$sling.run.modes = author3. Restart the crx-launchpad web application.8.2.4 JBoss v4After installing JBoss v4 you:8.2.4.1 Install CQ51. Unpack the installation files of the CQ5 Quickstart into a directory (without starting the server);the installation directory is referred to as :• Start the CQ5 Quickstart jar with the option -unpack; for example:java -jar cq-wcm-quickstart-5.1.0.jar -unpackThis creates a folder crx-quickstart containing the filesand folders used for installation, without actually starting the installation.Page 47 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5ImportantThis must be done from the command line. If you open the jar file directly you willactivate the Quickstart installation and start the server.2. Copy the following jar files to the application server folder holding shared libraries():a. CRX\server\lib\container\jcr-1.0.jarb. CRX\server\lib\container\crx-shared.jar3. Restart JBoss.4. Unpack the crx-explorer_crx.war file located in the \crxquickstart\server\webappsfolder.NoteIn Windows, change the .war extension to .zip and unpack like any zip file. InLinux, type jar xvf crx-explorer_crx.war to unpack.5. In the WEB-INF folder, open log4j.xml.6. Remove or comment the line which is in the Loggerssection of the file and save your changes and exit the file. This disables console logging in theCRX web application.7. In the WEB-INF folder, navigate to the lib folder and delete the following files:• jcr-1.0.jar• jackrabbit-api-1.4.jar• day-commons-naming-1.1.1.jar• crx-api-1.4.1.jar8. Pack the crx-explorer_crx.war file.NoteIn Windows, run the zip utility to compress it and rename the crxexplorer_crx.zipfile to crx-explorer_crx.war. In Linux, type jar cvfcrx-explorer_crx.war.9. Deploy the following web applications; they can be found in \crx-quickstart\server\webapps:a. CRX webapp; crx-explorer_crx.war.For example, deploy with the context path /crx.b. Launchpad webapp; crx-launchpad.war.For example, deploy with the context path /launchpad.JBoss supports Hot Deployment, so you can simply drag the two files to \server\default\deploy.10. Start the two applications.Page 48 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ511. Register your CRX license:a. Access your CRX installation:http://://index.jspfor example: http://:/crx/index.jspb. Click the red warning message - “Click here...” (the message is a link).c. Enter your license key.8.2.4.2 Configure the JBoss Server Login ModuleBy default JBoss' default login configuration attempts to authenticate users against a list of usersin the users.properties file. You must configure JBoss as follows to let login attempts byunknown users to pass to the web application (CRX Explorer). The web application will thenprocess authentication by itself.1. Open the file for editing:\server\default\conf\login-config.xml2. In the section application-policy name="other" (at the bottom of the file) add theattribute:unauthenticatedIdentity="nobody"to the login-module entry.8.2.4.3 Install your Content PackagesOnce you have installed CQ5 you will want to install content packages.1. Access the CRX main console:http://:/crx-explorer_crx/index.jsp2. Log in to the crx.system workspace as admin.3. Navigate to the Package Manager in CRX.4. Upload and install the following CQ5 package from \crxquickstart\repository\install\system:• WCM Security Content Package; cq-security-content-.jar.5. Switch to the crx.default workspace, again as admin6. Upload and install the following CQ5 packages from \crxquickstart\repository\installin the following order:a. Sling Content Package; 0001-cq-wcm-sling-content-.jar.b. WCM Content Package; 0002-cq-wcm-content-.jar.7. Restart JBoss.8.2.4.4 Enable Replication for Author instances of CQ5For an author instance of CQ5 you must configure it to start in “author run mode” so that you canperform replications.Page 49 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ51. Open the file: \crx-quickstart\launchpad\sling.properties for edit.2. Add the following two properties to the file:sling.jcrinstall.folder.name.regexp = .*/(install|config)(.author)?$sling.run.modes = author3. Restart the crx-launchpad web application.8.2.5 Generic ProceduresAfter installing the appropriate web application server you:8.2.5.1 Generic Installation ProcedureThis section provides generic information about installing CQ5 with an application server.1. Unpack the installation files of the CQ5 Quickstart into a directory (without starting the server);the installation directory will be referred to as :• Start the CQ5 Quickstart jar with the option -unpack; for example:java -jar cq-wcm-quickstart-5.1.0.jar -unpackThis will create a folder crx-quickstart containing thefiles and folders used for installation, without actually starting the installation.ImportantThis must be done from the command line. If you open the jar file directly you willactivate the Quickstart installation and start the server.2. Copy the following jar files to the application server folder holding shared libraries:a. CRX\server\lib\container\jcr-1.0.jarb. CRX\server\lib\container\crx-shared.jar3. Restart your web application server.4. Deploy the following web applications; they can be found in \crx-quickstart\server\webapps:a. CRX webapp; crx-explorer_crx.war.For example, deploy with the context path /crx.b. Launchpad webapp; crx-launchpad.war.For example, deploy with the context path /launchpad.5. Start the two applications.6. Register your CRX license:a. Access your CRX installation:http://://index.jspfor example: http://:/crx/index.jspb. Click the red warning message - “Click here...” (the message is a link).Page 50 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Installing CQ5c. Enter your license key.8.2.5.2 Install Content PackagesOnce you have installed CQ5 you will want to install content packages.1. Access the CRX main console.2. Log in to the crx.system workspace as admin.3. Navigate to the Package Manager in CRX.4. Upload and install the following CQ5 package from \crxquickstart\repository\install\system:• WCM Security Content Package; cq-security-content-.jar.5. Switch to the crx.default workspace, again as admin6. Upload and install the following CQ5 packages from \crxquickstart\repository\installin the following order:a. Sling Content Package; 0001-cq-wcm-sling-content-.jar.b. WCM Content Package; 0002-cq-wcm-content-.jar.8.2.5.3 Enable Replication for Author instances of CQ5For an author instance of CQ5 you must configure it to start in “author run mode” so that you canperform replications.1. Open the file: \crx-quickstart\launchpad\sling.properties for edit.2. Add the following two properties to the file:sling.jcrinstall.folder.name.regexp = .*/(install|config)(.author)?$sling.run.modes = author3. Restart the crx-launchpad web application.Page 51 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


9 How to Use, Create, and Edit a Page9.1 Managing Pages within CQ WCMThis section describes how to create a page within CQ WCM and then create content on that page.ImportantYour account needs the appropriate access rights to create or edit pages.9.1.1 Creating a New PageUnless all pages have been created for you in advance, before you can start creating content, youmust create a page:1. From the wcm/siteadmin window, select the level at which you want to create a new page.In the following example, you are creating a page under the level English - shown in the leftpane; the right pane shows the existing pages at this level.2. In the Page menu, select Create. The Create Page window opens.3. In the Title field, select a title that is displayed to the user.4. In the Label field, select a label that is used to create the URI.5. Click the template used to create the new page, which determines the basic layout of thepage.Page 52 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page6. Click Create to create the page. You return to the wcm/siteadmin window where you cansee an entry for the new page.This provides information about the page (for example when it was lasted edited and bywhom) which is updated as necessary.Page 53 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page9.1.2 Editing a PageAfter the page has been created, you can edit its content. When you first create a page, the pageincludes only the text and elements from the template. You add content by double-clicking ordragging and dropping components onto the page.9.1.2.1 Opening a pageYou can open the page to be edited by one of several methods:• From wcm/siteadmin, you can double-click on the page title to open it for editing. Your pageopens in a new window.• After you have opened a page, you can navigate to other pages within the site to edit them byclicking hyperlinks.9.1.2.2 Inserting a new paragraphAfter you open the page, you can start to add content. You do this by adding paragraphs (alsocalled components).To insert a new paragraph:1. Double-click the area labeled Drag components or assets here... or drag acomponent from the floating toolbar to insert a new paragraph. This area appears wherevernew content can be added, such as at the end of the list if other paragraphs exist or at theend of a column.NoteIf a paragraph already exists, you can right-click the paragraph and selectInsert. This inserts the new paragraph before the existing one.2. After you select to insert a paragraph, you see a list of the available paragraph types.NoteDepending on your production environment, these choices may differ. For completedetails on components, see Default Components.Page 54 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page3. Select the component that you want and click OK. A window opens that allows you toconfigure your paragraph and add content.9.1.2.3 Editing a paragraphTo edit an existing paragraph, do one of the following:• Double-click the paragraph to open it. You see the same window as when you created theparagraph with the existing content. Make your changes and click OK.• Right-click the paragraph and click Edit.9.1.2.4 Moving a paragraphTo move a paragraph:1. Click the paragraph you want to move. CQ WCM highlights the paragraph.Page 55 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page2. Drag the paragraph to the new location and drop it. Your paragraph is moved. CQ WCMindicates where paragraphs can be moved to with a green checkmark.Page 56 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page9.1.2.5 Deleting a paragraphTo delete a paragraph:1. Select the paragraph and right-click.Page 57 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page2. Select Delete from the menu. CQ WCM confirms that you want to delete the paragraph asthis action cannot be undone.3. Click OK.9.1.3 Moving or Renaming PageThe procedure to move or rename a page is the same. You do not need to do both: you canrename a page without moving it or vice versa.To move or rename a page:1. From the wcm/siteadmin window, click to select the page, then select the Page menu andselect Move. (You can also right-click after you click the page and select Move.) The Movewindow opens where you can either specify a new location, a new name for the page, or both.Page 58 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page2. Fill in the following fields, as appropriate:MoveSpecify the page to be moved - this is usually filled in by default, depending on how andwhere you started the move action.toUse the sitemap (available via the drop-down menu) to select the location where the page should be moved to. If you are only renaming thepage, ignore this field.Rename toThe current page label displays by default. Specify the new page label, if required.3. Click Move. CQ WCM confirms that you want to move or rename the current page. Click OK toconfirm.9.1.4 Deleting a Page1. You can delete a page from various locations:• Within the wcm/siteadmin window, click to select the page, then open the Page menu andselect Delete.• Within sidekick use the page actions tab to select Delete - this deletes the page currentlyopen• Within sidekick use the site map tab - navigate to page to be deleted, then right-clickand select Delete2. After the page has been selected you must confirm the deletion of the page - as the actioncannot be undone.NoteIf the page has been published you can restore the latest (or a specific) version,but this may not have exactly the same content. See the section called “How ToRestore Pages” for further details.9.1.5 Setting the Page PropertiesPage Properties define the various properties of the page, such as titles, when they appear on thewebsite and others.1. Open the page you want to edit.2. In the sidekick, click the Page icon. Select Page Properties... from the list.Page 59 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Page3. In the window that opens, you can modify the global, advanced, tags, impressions, and pageanalytics of a page:a. GlobalTitle TextThe page title - as appears in the siteadmin list.Page TitleA title to be used on the page.Navigation TitleA title for the page for use within the navigation map. Often shorter than the full title.Page 60 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a PageSubtitleA subtitle for use on the page.Page LanguageTheHide Page in NavigationA toggle switch to indicate whether the page will be shown, or hidden in the pagenavigation.b. AdvancedOn TimeThe date and time at which the published page will be activated. When published thispage will be kept dormant until the specified time. Leave these fields empty for pagesyou want to publish immediately (the normal scenario).Off TimeThe time at which the published page will be deactivated. Again leave these fieldsempty for pages you want to publish immediately.Vanity URLAllows you to enter a vanity URL for this page.Redirect Vanity URLIndicates whether you want the page to use the vanity URL.c. Tags/KeywordsHere you can add, or remove tags from the page by updating the list in the selection box:• A completely new tag can be entered by typing the name on an empty space in theselection box.• With the drop-down functionality you can select from existing tags.• An x will appear when you mouse-over a tag entry in the selection box; this can beused to remove that tag for this page.Page 61 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a Paged. ImpressionsThis shows the activity on the page as in the impressions generated.e. Page AnalyticsPage 62 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use, Create, and Edit a PageProviderThe provider who will be generating the analytical statistics.ID / SnippetThe ID or code snippet to be included on the page.4. Click OK to save the new properties.Page 63 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


10 How to Publish a Page10.1 How To Publish PagesThis section describes how to publish pages in CQ WCM. To publish a page, you activate itscontents. Conversely, to remove a page from publication, you deactivate its contents.When you are working on pages that you are modifying, you can lock the pages so other userscannot make changes or accidentally activate the content. In addition, you preview a page beforepublishing by selecting Preview Mode in the sidekick.If you are a system administrator and need to test the publish environment, see How to install CQ5author and publish instances.10.1.1 Activating ContentYou activate pages in the wcm/siteadmin window. After you have opened a page and modifiedits contents, you return to the wcm/siteadmin window to activate the content of that page or of anentire tree of pages.To activate page content:1. In the siteadmin/wcm window, select the page that you want to activate.2. In the Page menu, select Activation and then either Activate or Activate Tree.To activate the content of only that page, select Activate. To activate the content of thepage and all its sub-pages, click Activate Tree. If you want to cancel the activation, clickCancel.3. CQ WCM activates the selected content. To see that the page and its sub-pages (if selected)have been published, refresh the page. The published page or pages appears in thesiteadmin/wcm window with information about who activated the content as well as date andtime of activation.Page 64 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Publish a Page10.1.2 Deactivating ContentTo remove a page from the publish environment, you deactivate the content.To deactivate a page:1. In the siteadmin/wcm window, select the page that you want to deactivate.2. In the Page menu, select Activation and then Deactivate.3. Refresh the siteadmin/wcm window and the content is no longer published.10.1.3 Determining Page Publication StatusThe colors next to pages in the siteadmin/wcm window indicate publication status.Table 10.1.GreenYellowColorDescriptionPublication was successful. Content is published.Publication is pending. Confirmation of publication has not yetbeen received by the system.Page 65 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Publish a PageRedColorDescriptionPublication failed. There is no connection with the publishinstance. This can also mean that the content was deactivated.10.1.4 Locking PagesTo lock a page that you are working on so no one can modify the contents or activate it:1. In the siteadmin/wcm window, select the page that you want to lock.2. In the Page menu, select Locking and then Lock. That page is locked to other users.3. CQ WCM displays the page as locked and indicates which user has locked the page.10.1.5 Unlocking PagesYou can only unlock locked pages if you locked the page or if you have administrator privileges.To unlock a page:1. In the siteadmin/wcm window, select the page you want to unlock.2. In the Page menu, select Locking and then Unlock. CQ WCM indicates that the page isno longer locked.10.1.6 Using Preview ModeThis mode allows you to preview the page as if it were appearing on your website in its final form.Page 66 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Publish a PageTo access Preview mode:1. In the siteadmin/wcm window, open the page you want to view in Preview mode.2. In the sidekick, click the magnifying glass (preview mode). CQ WCM displays the page as itappears on your web site in its final form.Page 67 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


11 How to Restore a Page11.1 How To Restore PagesThis section describes how to restore pages that have been previously deleted.NoteOnly pages that have been previously activated can be restored. Each time you activate apage or tree, CQ WCM creates a new version of that page or tree.To restore a page to a previous version:1. In the wcm/siteadmin window, navigate to the page you want to restore and select it.2. In the Page menu, select Restore and then Version or Tree. Selecting Version listsprevious versions of the <strong>doc</strong>ument. Selecting Tree lists previous version of the content tree.3. Click Restore. CQ WCM restores the version or tree to the one you selected.Page 68 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


12 How to Create Templates12.1 Developing Page TemplatesCQ5 page templates are simply models used to create new pages. They can contain as little, or asmuch, initial content as needed, their role being to create the correct initial node structures, with therequired properties (primarily sling:resourceType) set to allow editing and rendering.12.1.1 Creating a new Template (based on an existing template)Needless to say a new template can be created completely from scratch, but often an existingtemplate will be copied and updated to save you time and effort. For example, the templates withinGeometrixx can be used to get you started.1. Copy an existing template (preferably with a definition as close as possible to what you wantto achieve) to a new node.NoteTemplates are usually stored in /apps//templates/.2. Change the jcr:title of the new template node to reflect its new role. You can also update thejcr:description if appropriate.3. Copy the component on which the template is based (this is indicated by thesling:resourceType property of the jcr:content node within the template) to create a newinstance.NoteComponents are usually stored in /apps//components/.4. Update the jcr:title and jcr:description of the new component.5. Replace the thumbnail.png if you want a new thumbnail picture to be shown in thetemplate selection list.6. Update the sling:resourceType of the template's jcr:content node to reference the newcomponent.7. Make any further changes to the functionality or design of the template and/or its underlyingcomponent.Changes made to the /apps//templates/ node will affectthe template instance (as in the selection list).Changes made to the /apps//components/ node willaffect the content page created when the template is used.You can now create a page within your website using the new template.Page 69 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


13 How to Use Tags13.1 How to Manage Tags in CQ WCM13.1.1 Using Sidekick to access and assign TagsMany users will assign tags directly to the page they are editing. This can be done using thesidekick:1. Within sidekick select the Page tab.2. Open Page Properties.3. Select the Tags/Keywords tab.Here you can either enter a tag by either typing a new name, or selecting an existing tag fromthe list of matching tags:Or selecting a tag according to namespace, by using the drop-down option:Page 70 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use Tags13.1.2 The Tag Administration ConsoleThe Tag Administration console can be used to manage your tags and taxonomies.It shows information about the tags already created for your website, and a count of how often theyare referenced in the website:From here you can perform various actions on tags and/or namespaces.13.1.2.1 Creating or Editing Tags and Namespaces1. Depending on the level you are starting from you can create either a tag or a namespace:a. If you select Tags you can create a namespace:Page 71 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use Tagsb. If you select a namespace (for example Demo) you can create a tag within thatnamespace:2. In both cases enter a name, title and description then click Create.13.1.2.2 Deleting Tags1. In the right-hand pane select the namespace or tag that you want to delete.2. Click Delete.3. You will be asked to confirm the delete action. Click Yes to delete the item.13.1.2.3 Activating and Deactivating Tags1. In the right-hand pane select the namespace or tag that you want to activate or deactivate.2. Click Activate, Activate Tree or Deactivate as required.13.1.2.4 List - showing where tags are referencedList will open a new window showing the paths of all pages using the highlighted tag:Page 72 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use Tags13.1.3 Searching for TagsYou can search for tags in both the author and publish environments.13.1.3.1 Searching for tags with the Search componentThe search component covers tags and can be used in both the author and publish environments.Page 73 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Use Tags13.1.3.2 Searching for tags with the Content FinderIn the author environment you can use the content finder to search for tags:1. Select the Pages tab in the content finder.2. Enter the tag you want to search for.Using the prefix “tags:” will limit the search to tags only.Page 74 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


14 Integrating with CQ DAM14.1 How to Integrate CQ DAM into your CQ5 WCM InstallationThe following details how to integrate an existing installation of CQ DAM into CQ5 WCM.In this scenario CQ WCM and CQ DAM will be installed separately. The integration will result in anew tab in the CQ WCM content finder that allows you to find and use media from DAM.NoteCQ DAM has to be mounted as a virtual repository for ALL author and publishinstallations (independently if in a cluster). See the CRX <strong>doc</strong>umentation for furtherinformation.1. Install and start CQ5 WCM. See the section called “How to Install CQ WCM Author andPublish Instances using Quickstart” for further information.2. Create a mount point in the repository.a. Open the CRX explorer.b. Create /etc/mnt/dam (see the code sample in step 7.b). The new nodes /mnt and /dam should be of type sling:Folder.c. With Mixins... add mix:referenceable to /etc/mnt/dam.3. Integrate CQ DAM functionality.a. Copy the file crx-quickstart/opt/examples/extensions/contentfinder/dam.js to /libs/wcm/extensions/contentfinder by using WebDAV.b. Stop CQ5.4. Enable RMI in the CRX used by CQ DAM.a. Open /server/runtime/0/_crx/WEB-INF/web.xml.b. Configure the RMI configuration for the Repository Servlet; set the port to 8303.rmi-port8303The RMI port for registering the repository in the RMI Registry.If equals 0, the default port is used. Omit this parameter todisable RMI server entirely.5. Configure CQ DAM as the virtual repository for CQ5 WCM.NoteCQ DAM has an issue if it is installed in a path containing space characters.In such a case you have to add the JVM Property -Djava.rmi.server.useCodebaseOnly=true as the first parameter to CQ5, when DAMis mounted as a virtual repository in CQ5.Page 75 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Integrating with CQ DAMa. Open /server/runtime/0/_crx/WEB-INF/web.xml.b. In the Repository Servlet definition replace the following (either comment out, or remove):com.day.crx.j2ee.CRXRepositoryStartupServletwith the following configuration:com.day.crx.mount.virtual.VirtualRepositoryStartupServletprimaryWorkspacecrx.defaultmount.crx.default@rmi://127.0.0.1:8303/crx/etc/mnt/dam6. Start CQ5.NoteMake sure that:• the port in rmi://127.0.0.1:8303 matches the port used in step 5.b(Enable RMI in the CRX used by CQ DAM).• the mount point /etc/mnt/dam matches that specified in step 2.b (Create amount point in the repository).7. A new tab in the content finder allows you to find and use your media from CQ DAM:Page 76 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


15 How to Find Logs and AuditEntries15.1 Finding the Audit Records and Log FilesAuditing records and log files relating to CQ5 can be found at various locations. The following isprovided to give you a overview of what you can find where.NoteAs CQ WCM is based on CRX, some of the log files listed below are actually generatedby CRX. Please see the CRX <strong>doc</strong>umentation for full details of these.15.1.1 Audit RecordsAudit records are held to provide a record of who did what when. Different audit records aregenerated for both CQ WCM and OSGi events.15.1.1.1 CQ WCM Audit records from within the siteadmin1. Open a page.2. From the sidekick you can select thetab, then double-click on Audit Log...3. A new window will open showing the list of audit records for the current page.4. Click OK when you want to close the window.15.1.1.2 CQ WCM Auditing records within the repositoryWithin the /var/audit folder, audit records are held according to the resource. You can drilldown until you can see the individual records and the information they contain.NoteThese entries hold the same information as displayed above in the siteadmin.Page 77 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Find Logs and Audit Entries15.1.1.3 OSGi Audit records from within the Felix consoleOSGi events also generate audit records which can be seen from the Audit Log tab in the FelixWeb Management Console:15.1.2 Log filesVarious log files are held on the file server where you installed CQ5:• \launchpad\logs• error.logError messages, of varying levels of severity, related to the CRX Quick launchpad areregistered here.• \logs• access.logAll access requests to CQ WCM and the repository are registered here.• error.logError messages (of varying levels of severity) are registered here.• request.logEach access request is registered here together with the response.• server.logAll actions made by the server are registered here.• stderr.logHolds error messages, again of varying levels of severity, generated during startup.• stdout.logHolds logging messages indicating events during startup.Page 78 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Find Logs and Audit Entries• \logs\crx• error.logError messages (of varying levels of severity) related to the repository are registered here.• translation.logTranslation journaling.• \repository\• revision.logRevision journaling information.• \repository\repository\index• redo.logRedo event journaling.• \repository\shared\journal• journal.logEvent journaling on the repository; multiple versions.• \repository\workspaces\\index• indexing_queue.logIndex journaling.• redo.logRedo event journaling.• \server\logs• access.logAll access requests to CQ WCM and the repository are registered here.Page 79 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


16 Security ChecklistsThis section deals with various steps you should take to ensure that your CQ5 installation issecure.16.1 Security Checklist for System Administrators16.1.1 Disable WebDAVWebDAV should be disabled on the publish environment.See the CRX <strong>doc</strong>umentation for further details.16.1.2 Restrict Access via the DispatcherBy configuring the Dispatcher you should restrict access so that only the following are available toexternal visitors:• /content - Site content• /etc - Miscellaneous content such as designsThe following should be entered in the configuration file dispatcher.any:# only handle the requests in the following acl. default is 'none'# the glob pattern is matched against the first request line/filter{/0001{/glob "*"/type "deny"}/0002{/glob "* /content[./]"/type "allow"}/0003{/glob "* /etc[./]"/type "allow"}NoteThis configuration includes the following restrictions:1. Restricts access to the Servlet Engine Administration /admin2. Restricts access to the Sling Console /system3. Restricts access to CRX /crx4. Restricts access to the following application specific folders:• /apps – Application data• /libs – CQ5 Library• /var – var folderPage 80 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Security Checklists• /etc – Miscellaneous folder• /home – User’s home folder5. Restricts access to /tmp6. Denies POST requests in case forms are not used.16.1.3 Check for Cross-Site Scripting (XSS)Cross-site scripting (XSS) allows attackers to inject code into web pages viewed by other users.This security vulnerability can be exploited by malicious web users to bypass access controls.WarningCQ5 example code is not protected against such attacks.16.2 Security Checklist for Power Users16.2.1 Change Default Passwords<strong>Day</strong> strongly recommends that you change the passwords for the following two accounts:1. Change the password for the CQ5 admin account.ImportantTo change the password for the CQ5 admin account, you need to change theadmin password in both CRX and the OSGi Console. See the section called“Changing the admin account in the CRX console” and the section called “Changingthe admin account in the OSGi Apache Felix console”.2. Change the password for the CQSE (Communiqué Servlet Engine) admin account.ImportantFurther actions are described in the table the section called “Default Users andGroups”, which gives an overview of the default users and groups included in thestandard installation.16.2.1.1 Changing the admin account in the CRX consoleTo change the admin account in the CRX console:1. Log in to http://:/crx to open the CRX console.2. Log in as the administrator and switch to the crx.system workspace.3. Open the Content Explorer and navigate to the admin user and select it.Page 81 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Security Checklists4. In the Security menu, select Set User Password. A Set User Password windowopens.5. Enter the new password and re-enter to confirm and click OK.6. Save your changes.16.2.1.2 Changing the admin account in the OSGi Apache Felix consoleTo change the admin account in the OSGi Apache Felix console:1. Log in to http://:/system/console/configMgr to openconfigurations in the Apache Felix console.2. In the Configurations menu, select CRX Sling Client Repository.Page 82 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Security Checklists3. In the Admin password field, change the password to match the one you entered in the CRXconsole.4. Click Save to save your changes.16.3 Security Checklist for Developers16.3.1 Use the user session, not the administrative sessionThis means you should use:slingRequest.getResourceResolver().adaptTo(Session.class);Page 83 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


17 Defining Performance Tests onYour Publish Environment17.1 IntroductionPerformance is of prime importance to your publish environment. Therefore, you need tocarefully plan and analyze the performance tests you will make for the publish environment whileimplementing your project.17.1.1 Purpose of this How ToTo give a standardized overview of the issues involved with defining a Test Concept specifically forPerformance Tests on your Publish environment.17.1.2 Target Audience• QA Engineers• Project Managers• System Administrators17.2 Phases to be usedThis <strong>doc</strong>ument covers a standardized approach to performance tests for a CQ5 application on thePublish environment. This involves the following 5 phases (which will be covered in more detail inthe next 5 sections):1. Verification of Knowledge2. Definition of Scope3. Definition of Performance Goals4. Test Methodologies5. OptimizationControlling is an additional, all-encompassing process - necessary but not limited to testing.Page 84 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish EnvironmentFigure 17.1. The 5 Phases of Performance Testing on your PublishEnvironment17.3 Verification of KnowledgeA first step is to <strong>doc</strong>ument the basis information which you need to know before you can starttesting:• the architecture of your test environment• an application map detailing the internal elements which will need testing (both in isolation andcombination)17.3.1 Test ArchitectureYou should clearly <strong>doc</strong>ument the architecture of the test environment being used for yourperformance testing.You will need a reproduction of your planned production Publish environment, together withDispatcher and Load Balancer.17.3.2 Application MapTo get a clear overview you can create a map of the entire application (you may well have this fromtests on the Author environment).A diagram representation of the internal elements of the application, can give an overview of thetesting requirements; with color-coding it can also act as a basis for reporting.The example below illustrates the level of detail appropriate:Page 85 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish EnvironmentFigure 17.2. Verification Map17.4 Scope DefinitionAn application will usually have a selection of use cases. Some will be very important, others lessso.To focus the scope of the performance testing on publish, we recommend that you define the:• most important business use cases• most critical technical use casesThe number of use cases is up to you, but it should be limited to an easily manageable number(e.g. between 5 to 10).Once the key use cases have been selected, then the key performance indicators (KPI) and thetools used to measure them can be defined for each case. Examples of common KPIs include:• End to end response time• Servlet response time• Response time for a single component• Response time for the services• Number of idle threads in the thread pool• Number of free connections• System resources such as CPU and I/O access17.5 Test MethodologiesThis concept has 4 scenarios used for defining and testing the performance goals:1. Single component tests2. Combined component testsPage 86 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish Environment3. Going Live scenario4. Error scenariosBased on the following principles.Component BreakpointsEach component has a specific breaking point when related to performance. This meansthat a component can show good performance until a specific point is reached, after whichperformance will degrade rapidly.To get a full overview of the application, you must first verify your components to determinewhen the breakpoint of each is reached.To find the breakpoint you can perform a load test where, over a period of time, you increasethe number of users to create an increasing load. By monitoring this load, and the response ofthe components, you will encounter specific performance behavior when the breaking point ofthe component is reached. The point can be qualified by the number of concurrent transactionsper second, together with the number of concurrent users (if the component is sensitive to thisKPI).This information can then act as a benchmark for improvements, indicate the efficiency of themeasures being used, and help define test scenarios.TransactionsThe term transaction is used to represent the request of a complete web page, including thepage itself and all subsequent calls; i.e. the page request, any AJAX calls, images and otherobjects.Request Drill DownTo fully analyze each request you can represent each element of the call stack, then total theaverage processing time for each.17.6 Defining the Performance GoalsOnce the scope, and related KPIs have been defined, the specific performance goals can be set.This involves devising test scenarios, together with target values.You will need to test performance under both average and peak conditions. In addition, you willneed Going Live scenario tests to ensure that you can cater for increased interest in your websitewhen it is first made available.Any experience, or statistics which you may have collected from an existing website can also beuseful in determining future goals; for example top traffic from your live website.NoteAs already mentioned, performance is of prime importance to a CQ5 project. Thereforethe goals (for both individual components and scenarios) should be defined at thebeginning of the project and verified during the implementation phase.See also the Target Metrics section in the Project Manager Guide.17.6.1 Single Component TestsCritical components will need to be tested - under both average and peak conditions.In both cases, you can define the expected number of transactions per second when a predefinednumber of users are using the system.Page 87 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish EnvironmentTable 17.1. Example - Single Component TestComponent Test Type #Users Tx/sec(Expected)Homepage Single User Average 1 1Peak 1 3Homepage 100 Users Average 100 317.6.2 Combined Component TestsPeak 100 3Tx/sec(Tested)DescriptionTesting the components in combination gives a closer reflection of the applications behavior. Againaverage and peak conditions must be tested.Table 17.2. Example - Combined Component TestsScenario Component #Users Tx/sec(Expected)Mixed average Homepage 10 1Search 10 1News 10 2Events 10 1Tx/sec(Tested)DescriptionActivations 10 3 Simulation of authorbehavior.Mixed peak Homepage 100 517.6.3 Going Live TestsSearch 50 5News 100 10Events 100 10Activations 20 20 Simulation of authorbehavior.During the first few days after your website is made available, you can expect an increased levelof interest. This will probably be even greater than the peak values you have been testing for. Itis strongly recommended to test Going Live scenarios to ensure that the system can cater for thissituation.Table 17.3. Example - Going Live TestsScenario Test Type #Users Tx/sec(Expected)Going Live peak Homepage 200 20Search 100 10News 200 20Events 200 20Tx/sec(Tested)DescriptionActivations 20 20 Simulationof authorbehavior.Page 88 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish Environment17.6.4 Error TestsError scenarios must also be tested to ensure that the system reacts correctly and appropriately.Not only in how the error itself is handled, but the impact it may have on performance. Forexample:• what happens when the user tries to input an invalid search term in the search box• what happens when the search term is so general that it returns an excessive number of resultsWhen devising these tests it should be remembered that not all scenarios will occur regularly.However, their impact on the entire system is important.Table 17.4. Example - Error Scenario TestsErrorScenarioSearchcomponentoverloadError Type #Users Tx/sec(Expected)Search on globalwildcard (asterisk)Tx/sec(Tested)Description10 1 Only *** aresearched.Stop word 20 2 Searching for astop word.Empty string 10 1 Searchingfor an emptystring.Special characters 10 1 Searchingfor specialcharacters.17.6.5 Endurance TestsCertain issues will only be encountered after the system has been running for a continued period oftime; be that either hours or even days. An endurance test is used to test an constant average loadover a required period of time. Any performance degradation can then be analyzed.Table 17.5. Example - Endurance TestsScenario Test Type #Users Tx/sec(Expected)Endurance test(72 hours)17.7 OptimizationHomepage 10 1Search 10 1News 20 2Events 10 1Tx/sec(Tested)DescriptionActivations 1 3 Simulation of authorbehavior.In the later stages of implementation you will need to optimize the application to fulfill / maximizethe performance goals.Any optimizations made must be tested to ensure they have not affected the functionality andverified with the load tests before being released.Page 89 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Defining Performance Tests on Your Publish EnvironmentA selection of tools is available to help you with load-generation, performance monitoring and/orresults analysis:• JMeter• Load Runner (HP)• CA Wily Introscope• Determyne InsideApps• InfraRED• Java Interactive Profile• many more...After optimization, you will need to test again to confirm the impact.17.8 ReportingOn-going reporting will be needed to keep everyone informed of the status; as mentionedpreviously with color-coding the Architecture Map can be used for this.After all tests have been completed you will want to report on:• any critical errors encountered• non-critical issues which will still need further investigation• any assumptions made during testing• any recommendations to arise from the testingPage 90 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


18 How to Create a Fully FeaturedInternet WebsiteHow to Create a Fully Featured Internet WebsitePage 91 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


19 How to Set Up the DevelopmentEnvironment with Eclipse19.1 How to Set Up the Development Environment with EclipseThis <strong>doc</strong>ument describes the process of setting up a local development environment for a simpleCQ5 project with Eclipse. It then describes how to integrate logic into the project through Javacoding and JSP scripting. Lastly, it points to open source software to enable collaborative andautomated developing.The setup described here is an alternative among others and may vary from project to project.The local development environment involves:• A CQ5 installation that will act as your local environment.• CRX Explorer within the CQ5 instance to create and edit nodes and properties within the CRXrepository.• FileVault (VLT), a <strong>Day</strong> developed utility that maps the CRX repository to your file system.• Eclipse to edit the project source on your local file system.• Apache Maven to run local snapshot builds.19.1.1 Creating the Project Structure in CQ5This section describes the creation of a simple project structure in CQ5:1. Install CQ5 on your machine. Please refer to the section called “Installing a CQ WCMinstance - Generic procedure” for the detailed procedure. In the current context, CQ5 runslocally on port 4502.If already installed then ensure it is running and connect.2. In the CRX Explorer, create the project structure:1. Under the /apps folder, create the nt:folder myApp.2. Under the myApp folder, create the nt:folder components.3. Under the myApp folder, create the nt:folder templates.4. Under the myApp folder, create the nt:folder install.3. In your browser, navigate to the Miscellaneous tab. Under designs, create the designpage of your application:• Title: My Application Design Page.• Name: myApp.• Template: Design Page Template.19.1.2 Installing FileVault (VLT)FileVault (VLT) is a tool developed by <strong>Day</strong> that maps the content of a CRX instance to yourfile system. The VLT tool has similar functionalities to those of an SVN client, providing normalcheck in, check out and management operations, as well as configuration options for flexiblerepresentation of the project content.Page 92 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with EclipseTo install VLT, follow the steps:1. In your file system, go to /crx-quickstart/opt/filevault.The build is available in both tgz and zip formats.2. Extract the archive.3. Add /crx-quickstart/opt/filevault/vault-cli-/bin to your environment PATH so that the command files vlt or vlt.bat areaccessed as appropriate. For example, /crx-quickstart/opt/filevault/vault-cli-1.1.2/bin4. Open a command line shell and execute vlt --help. Make sure it displays the following helpscreen:19.1.3 Installing EclipseEclipse is open source software used to edit the project source locally on your file system. ApacheMaven is also open source software, used to run local snapshot builds: it compiles Java code andstores the compiled code in a jar file.In this section, you will install Eclipse and a Maven plugin which embeds the Maven functionalitywithin Eclipse:1. Download Eclipse - select the Eclipse IDE for Java EE Developers option.2. Install Eclipse: extract from the downloaded zip file to your destination directory.3. Start Eclipse:a. Navigate to the directory into which you extracted the contents of the Eclipse installationzip file. For example C:\Program Files\Eclipse\.b. Double-click on eclipse.exe (or eclipse.app) to start Eclipse.4. Create a new workspace for your project and name it myApp.Page 93 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse5. Install the Maven plugin (m2) from Sonatype. Disable Maven SCM handler for Subclipse(Optional) and Maven Integration for AJDT (Optional).6. After installation it is recommended to restart Eclipse.19.1.4 Creating the Project Structure in EclipseIn this section, you will create 2 Maven projects:• one called UI (after User Interface) which contains the CQ5 project structure with the JSP scripts.• the other called Core which contains the Java code (source and compiled). The compiled code isstored in a jar file.The advantage of such a structure is that it adds modularity and autonomy to the logic yourapplication because each jar file (bundle) can be managed separately.19.1.4.1 Create the UI Maven ProjectTo create the UI Maven project, follow the steps:1. In Eclipse open the Workbench.2. Create the UI Maven project:1. In the Menu bar, click File, select New, then Other... .2. In the dialog, expand the Maven folder, select Maven Project and click Next.3. Check the Create a simple project box and the Use default Workspacelocations box, then click Next.4. Define the Maven project:• Group Id: com.day.cq5.myapp• Artifact Id: ui• Name: CQ5 MyApp UI• Description: This is the UI module5. Click Finish.3. Set the Java Compiler to version 1.5:1. Right-click the ui project, select Properties.2. Select Java Compiler and set following properties to 1.5:• Compiler compliance level• Generated .class files compatibility• Source compatibility3. Click OK.4. In the dialog window, click Yes.4. Create the filter.xml file which defines the content that will be exported by VLT:1. In Eclipse, navigate to ui/scr/main and create the content folder.Page 94 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse2. Under content, create the META-INF folder.3. Under META-INF, create the vault folder.4. Under vault, create the filter.xml file.5. In filter.xml, copy the following code to filter.xml:6. Save the changes.5. Check out the CQ5 content into your ui project with VLT:1. From the system command line, navigate to the directory holding your Eclipseworkspace //myApp/ui/src/main/content.2. Execute the command: vlt --credentials admin:admin co http://localhost:4502/crxThis command creates the folder jcr_root under //myApp/ui/src/main/content. This maps to the CRX root (/). Under jcr_root thefollowing files and folders are created, as defined in filter.xml:• apps/myApp• etc/designs/myAppIt also creates two files, config.xml and settings.xml in //myApp/ui/src/main/content/META-INF/vault. These are usedby VLT.6. To enable Eclipse to map the file paths used in the JSP scripts, create a link to the appsfolder under ui:1. Right-click ui, select New, then Folder.2. In the dialog window, click Advanced and check the Link to folder in the filesystem box.3. Click Browse, then specify //myApp/ui/src/main/content/jcr_root/apps.4. Click OK.5. Click Finish.7. To enable Eclipse to identify the Java classes, methods and objects used in the JSP scripts,export the needed Java libraries from the CQ5 server to your file system and reference themin the ui project.In this example, you will reference the following libraries:• libs/cq/install stored in the CQ5 server• libs/sling/install stored in the CQ5 serverPage 95 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse• libs/wcm/install stored in the CQ5 server• /crx-quickstart/server/lib/container stored inyour file systemProceed as follows:1. In your file system, create a CQ5 libraries folder called cq5libs. This folder can becreated anywhere.2. Under cq5libs, create the folders: cq, sling and wcm.3. From the system command line go to .../cq5libs/cq and execute vlt co http://localhost:4502/crx /libs/cq/install . to export the libraries stored under /libs/cq/install from the CQ5 server.4. From the system command line go to .../cq5libs/sling and execute vlt co http://localhost:4502/crx /libs/sling/install . to export the libraries stored under /libs/sling/install from the CQ5 server.5. From the system command line go to .../cq5libs/wcm and execute vlt co http://localhost:4502/crx /libs/wcm/install . to export the libraries stored under /libs/wcm/install from the CQ5 server.6. In Eclipse, right-click the ui project, select Build Path, then Configure BuildPath. In the dialog select the Libraries tab.7. Click Add External JARS..., navigate to .../cq5libs/cq/jcr_root, select allthe jar files and click Open.8. Click Add External JARS..., navigate to .../cq5libs/sling/jcr_root, selectall the jar files and click Open.9. Click Add External JARS..., navigate to .../cq5libs/wcm/jcr_root, select allthe jar files and click Open.10. Click Add External JARS..., navigate to /crxquickstart/server/lib/container,select all the jar files and click Open.11. Click OK.19.1.4.2 Create the Core Maven ProjectTo create the Core Maven project, follow the steps:1. In Eclipse, create the Core Maven project:1. In the Menu bar, click File, select New, then Other... .2. In the dialog, expand the Maven folder, select Maven Project and click Next.3. Check the Create a simple project box and the Use default Workspacelocations box, then click Next.4. Define the Maven project:• Group Id: com.day.cq5.myapp• Artifact Id: core• Name: CQ5 MyApp CorePage 96 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse• Description: This is the Core module5. Click Finish.2. Add the necessary plugins and dependencies to the core project:1. Open the pom.xml file under core.2. Copy-paste following code before the tag:bundleorg.apache.maven.pluginsmaven-compiler-plugin1.51.5org.apache.felixmaven-bundle-plugin1.4.3true com.day.cq5.myapp.*;version=${pom.version}com.day.cq.wcmcq-wcm-api5.1.20com.day.cqcq-commons5.1.18org.apache.slingorg.apache.sling.api2.0.3-incubator-R7089513. Save the changes.3. Deploy the CQ5 specific artifacts as defined in the pom.xml (cq-wcm-api, cq-commons andorg.apache.sling.api) to the local Maven repository:Page 97 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse1. From the system command line go to /.m2/repository/com/day/cq/wcm/cq-wcm-api/5.1.20 (create the folders if they don't exist) and executevlt co http://localhost:4502/crx /libs/wcm/install/cq-wcm-api-5.1.20.jar . to export thelibrary from the CQ5 server.2. From the system command line go to /.m2/repository/com/day/cq/cq-commons/5.1.18 (create the folders if they don't exist) and execute vltco http://localhost:4502/crx /libs/cq/install/cq-commons-5.1.18.jar . to export thelibrary from the CQ5 server.3. From the system command line go to /.m2/repository/org/apache/sling/org.apache.sling.api/2.0.3-incubator-R708951 (createthe folders if they don't exist) and execute vlt co http://localhost:4502/crx /libs/sling/install/org.apache.sling.api-2.0.3-incubator-R708951.jar . to export the library fromthe CQ5 server.NoteYou don't need to perform this step if the three CQ5 artifacts are globally deployedfor the project on a Maven repository (e.g. using Apache Archiva).4. Set the Java Compiler to version 1.5:1. Right-click the core project, select Properties.2. Select Java Compiler and set following properties to 1.5:• Compiler compliance level• Generated .class files compatibility• Source compatibility3. Click OK.4. In the dialog window, click Yes.5. Create the package com.day.cq5.myapp that will contain the Java classes under core/src/main/java:1. Under core, right-click src/main/java, select New, then Package.2. Name it com.day.cq5.myapp and click Finish.19.1.5 Scripting with Eclipse and CQ5When editing UI code use the following sequence:• Create a template and a component with the CRX Explorer.• Update the changes with VLT (export from the repository to your file system) .• Create a component script (JSP) with Eclipse.• Check in the changes from the file system into the repository with VLT.The following example illustrates this process:1. Create a new template with the CRX Explorer:1. In the CRX Explorer, under /apps/myApp/templates, create a new template: Name:contentpage Type: cq:TemplatePage 98 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse2. Under the contentpage Node, edit the Property jcr:title and add as Value:MyApp Content Page Template3. Under the contentpage Node, add a new Node: Name: jcr:content Type:cq:PageContent4. Under the jcr:content Node, edit the Property sling:resourceType and add asValue: myApp/components/contentpage5. Under the jcr:content Node, add a new Property: Name: personName Value:myName2. Create a new component with the CRX Explorer:• In the CRX Explorer, under /apps/myApp/components, create a new component:Name: contentpage Type: cq:Component3. Use VLT to update the changes made from your repository to your file system, and thereforeEclipse:1. From the system command line navigate to //myApp/ui/src/main/content/jcr_root.2. Execute: vlt st --show-update to see the changes made on the repository.3. Execute: vlt up to update the changes from the repository to your file system.4. Create the component script (JSP) with Eclipse:1. In Eclipse, navigate to ui/src/main/content/jcr_root/apps/myApp/components/contentpage.2. Right-click contentpage, select New, then File.3. In the dialog, name the file contentpage.jsp and click Finish.4. Copy the following code into contentpage.jsp:This is the contentpage component.5. Save the changes.5. With VLT check in the changes from the file system into the repository:1. From the system command line navigate to //myApp/ui/src/main/content/jcr_root.2. Execute: vlt st to see the changes made on the file system.3. Execute: vlt add apps/myApp/components/contentpage/contentpage.jsp to add thecontentpage.jsp file to VLT control.4. Execute: vlt ci to commit the contentpage.jsp file to the repository.6. From CQ5 create a page based on this template. Open the page to make sure it displays thefollowing message:This is the contentpage component.Page 99 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with EclipseTipIt is possible to define the VLT commands as External Tools in Eclipse. This enables youto run the VLT commands from within Eclipse.19.1.6 Java Developing with Eclipse and CQ5When editing Core code use the following sequence:• Create a Java class.• Compile the Java class.• Reference the jar file in the ui library.• Embed the Java Class logic into the JSP script.• Use VLT to check these changes to the JSP script (in the file system) into the repository.• Use VLT to deploy the jar file (with the compiled class) from the file system into the repository.The following example illustrates this process:1. Create the Java class:1. In Eclipse, under core/src/main/java, right-click the com.day.cq5.myapppackage, select New, then Class.2. In the dialog window, name the Java Class HelloPerson and click Finish. Eclipsecreates and opens the file HelloPerson.java.3. In HelloPerson.java replace the existing code with the following:package com.day.cq5.myapp;import com.day.cq.wcm.api.Page;public class HelloPerson {private Page personPage;public static final String PN_PERSON_NAME = "personName";public HelloPerson(Page personPage) {this.personPage = personPage;}public String getHelloMessage() {String personName = personPage.getProperties().get(PN_PERSON_NAME).toString();return personName != null ? personName : "--empty--";}}4. Save the changes.2. Compile the Java class:1. Right-click the core project, select Run As, then Maven Install.2. Make sure that a new file core-0.0.1-SNAPSHOT.jar (containing the compiledclass) is created under core/target.3. Reference this jar file in the ui library to enable the code completion when accessing thisclass with the JSP script:Page 100 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse1. In Eclipse, right-click the ui project, select Build Path, then Configure BuildPath. In the dialog select the Libraries tab.2. Click Add JARS... and navigate to core/target, select the core-0.0.1-SNAPSHOT.jar file and click OK.3. Click OK to close the dialog.4. Embed the Java Class logic into the JSP script:1. In Eclipse, open the JSP script contentpage.jsp in ui/src/main/content/jcr_root/apps/myApp/components/contentpage.2. Replace the existing code with the following:Hello, .This is the contenpage component.3. Save the changes.5. With VTL check in the changes to the JSP script from the file system to the repository:1. From the system command line navigate to //myApp/ui/src/main/content/jcr_root.2. Execute: vlt st to see the changes made on the file system.3. Execute: vlt ci to commit the modified contentpage.jsp file to the repository.6. Deploy the jar file containing the compiled class from the file system into the repository withVLT:1. In Eclipse, under core/target, copy the core-0.0.1-SNAPSHOT.jar file.2. In Eclipse navigate to ui/scr/main/content/jcr_root/apps/myapp/installand paste the copied file.3. From the system command line navigate to //myApp/ui/src/main/content/jcr_root.4. Execute: vlt st to see the changes made on the file system.5. Execute: vlt add apps/myApp/install/core-0.0.1-SNAPSHOT.jar to add the jar file toVLT control.6. Execute: vlt ci to commit the jar file to the repository.7. In your browser, refresh the CQ5 page to make sure it displays following message:Hello, myName.This is the contentpage component.8. In CRX Explorer, change the value myName and make sure that the new value is displayedwhen you refresh the page.Page 101 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Set Up the Development Environment with Eclipse19.1.7 Building collaborative and automated projectsThis section points to three open source softwares which enhance the development of CQ5projects by adding collaboration and automation features:• Subversion (SVN) to manage a central repository where all the developers involved in the projectcan commit and retrieve the code and the content they generate on their local instance.• Apache Archiva to centrally store and retrieve the project libraries.• Apache Continuum to automate the build process.19.1.7.1 Collaboration with Subversion (SVN)As the CQ5 repository can be mapped to your file system with VLT, it is now easy to set up acentral repository with SVN. This is used by all developers in the project as a place they cancommit, and retrieve, the code and content they generate on their local instances.The setup of an SVN server is not covered in this <strong>doc</strong>ument as many tutorials are already availableonline.When VLT is in operation it creates .vlt files within the local directory structure. These .vlt files holdtimestamps and other VLT-specific information that should not be checked into the SVN repository.This can be prevented by adding .vlt to the ignore list of the local SVN setup. To do this you addthe following code to the local SVN setup file - settings.xml in the .subversion directory of youruser's HOME directory:[miscellany]### Set global-ignores to a set of whitespace-delimited globs### which Subversion will ignore in its 'status' output, and### while importing or adding files and directories.global-ignores = .vlt19.1.7.2 Central dependency management with Apache ArchivaJava libraries, called artifacts in Maven language, can be managed centrally through ApacheArchiva, an artifact repository that is used to store and retrieve the project artifacts. The setup ofArchiva is well detailed online and can be referenced during setup. The Archiva server requireslittle management outside that of configuring local developer accounts to obtain access to thesnapshots and full releases.19.1.7.3 Build automation with Apache ContinuumOnce the project content and code is centrally available through an SVN server, it is possible toautomate the build process and run the build on a daily basis (for example a nightly build). This isdone with Apache Continuum, a continuous integration server with the sole duty of providing buildmanagement of artifacts and releases.The setup of Continuum is also well detailed online.Page 102 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


20 How to Model Data20.1 Data Modeling - David Nuescheler's Model20.1.1 SourceThe following details are ideas and comments expressed by David Nuescheler.David is co-founder and CTO of <strong>Day</strong> Software AG, a leading provider of global contentmanagement and content infrastructure software. He also leads the development of JSR-170, theJava Content Repository (JCR) application programming interface (API), the technology standardfor content management.Further updates can also be seen on http://wiki.apache.org/jackrabbit/DavidsModel.20.1.2 Introduction from DavidIn various discussions I found that developers are somewhat at unease with the features andfunctionalities presented by JCR when it comes to content modeling. There is no guide and verylittle experience yet on how to model content in a repository and why one content model is betterthan the other.While in the relational world the software industry has a lot of experience on how to model data, weare still at the early stages for the content repository space.I would like to start filling this void by expressing my personal opinions on how content shouldbe modeled, hoping that this could some day graduate into something more meaningful to thedevelopers community, which is not just "my opinion" but something that is more generallyapplicable. So consider this my quickly evolving first stab at it.ImportantDisclaimer: These guidelines express my personal, sometimes controversial views. I amlooking forward to debate these guidelines and refine them.20.1.3 Seven Simple Rules20.1.3.1 Rule #1: Data First, Structure Later. Maybe.20.1.3.1.1 ExplanationI recommend not to worry about a declared data structure in an ERD sense. Initially.Learn to love nt:unstructured (& friends) in development.I think Stefano pretty much sums this one up.My bottom-line: Structure is expensive and in many cases it is entirely unnecessary to explicitlydeclare structure to the underlying storage.There is an implicit contract about structure that your application inherently uses. Let's say I storethe modification date of a blog post in a lastModified property. My App will automatically knowto read the modification date from that same property again, there is really no need to declare thatexplicitly.Further data constraints like mandatory or type and value constraints should only be applied whererequired for data integrity reasons.Page 103 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Model Data20.1.3.1.2 ExampleThe above example of using a "lastModified" Date property on for example "blog post" node, reallydoes not mean that there is a need for a special nodetype. I would definitely use "nt:unstructured"for my blog post nodes at least initially. Since in my blogging application all I am going to do is todisplay the lastModified date anyway (possibly "order by" it) I barely care if it is a Date at all. SinceI implicitly trust my blog-writing application to put a "date" there anyway, there really is no need todeclare the presence of a "lastModified" date in the form a of nodetype.20.1.3.1.3 Discussionhttp://www.nabble.com/DM-Rule-#1:-Data-First,-Structure-Later.-Maybe.-tf4039967.html20.1.3.2 Rule #2: Drive the content hierarchy, don't let it happen.20.1.3.2.1 ExplanationThe content hierarchy is a very valuable asset. So don't just let it happen, design it. If you don'thave a "good", human-readable name for a node, that's probably that you should reconsider.Arbitrary numbers are hardly ever a "good name".While it may be extremely easy to quickly put an existing relational model into a hierarchical model,one should put some thought in that process.In my experience if one thinks of access control and containment usually good drivers for thecontent hierarchy. Think of it as if it was your file system. Maybe even use files and folders tomodel it on your local disk.Personally I prefer hierarchy conventions over the nodetyping system in a lot of cases initially, andintroduce the typing later.20.1.3.2.2 ExampleI would model a simple blogging system as follows. Please note that initially I don't even care aboutthe respective nodetypes that I use at this point./content/myblog/content/myblog/posts/content/myblog/posts/what_i_learned_today/content/myblog/posts/iphone_shipping/content/myblog/comments/iphone_shipping/i_like_it_too/content/myblog/comments/iphone_shipping/i_like_it_too/i_hate_itI think one of the things that become apparent is that we all understand the structure of the contentbased on the example without any further explanations.What may be unexpected initially is why I wouldn't store the "comments" with the "post", which isdue to access control which I would like to be applied in a reasonably hierarchical way.Using the above content model I can easily allow the "anonymous" user to "create" comments, butkeep the anonymous user on a read-only basis for the rest of the workspace.20.1.3.2.3 Discussionhttp://www.nabble.com/DM-Rule-#2:-Drive-the-content-hierarchy,-don't-let-it-happen.-tf4039994.html20.1.3.3 Rule #3: Workspaces are for clone(), merge() and update().20.1.3.3.1 ExplanationIf you don't use clone(), merge() or update() methods in your application a single workspace isprobably the way to go.Page 104 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Model Data"Corresponding nodes" is a concept defined in the JCR spec. Essentially, it boils down to nodesthat represent the same content, in different so-called workspaces.JCR introduces the very abstract concept of Workspaces which leaves a lot of developers unclearon what to do with them. I would like to propose to put your use of workspaces to the following totest.If you have a considerable overlap of "corresponding" nodes (essentially the nodes with the sameUUID) in multiple workspaces you probably put workspaces to good use.If there is no overlap of nodes with the same UUID you are probably abusing workspaces.Workspaces should not be used for access control. Visibility of content for a particular group ofusers is not a good argument to separate things into different workspaces. JCR features "AccessControl" in the content repository to provide for that.Workspaces are the boundary for references and query.20.1.3.3.2 ExampleUse workspaces for things like:• v1.2 of your project vs. a v1.3 of your project• a "development", "QA" and a "published" state of contentDo not use workspaces for things like:• user home directories• distinct content for different target audiences like public, private, local, ...• mail-inboxes for different users20.1.3.3.3 Discussionhttp://www.nabble.com/DM-Rule-#3:-Workspaces-are-for-corresponding-nodes.-tf4040010.html20.1.3.4 Rule #4: Beware of Same Name Siblings.20.1.3.4.1 ExplanationWhile Same Name Siblings (SNS) have been introduced into the spec to allow compatibility withdata structures that are designed for and expressed through XML and therefore are extremelyvaluable to JCR, SNS come with a substantial overhead and complexity for the repository.Any path into the content repository that contains an SNS in one of its path segments becomesmuch less stable, if an SNS is removed or reordered, it has an impact on the paths of all the otherSNS and their children.For import of XML or interaction with existing XML SNS maybe necessary and useful but I havenever used SNS, and never will in my "green field" data models.20.1.3.4.2 ExampleUse/content/myblog/posts/what_i_learned_today/content/myblog/posts/iphone_shippinginstead ofPage 105 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Model Data/content/blog[1]/post[1]/content/blog[1]/post[2]20.1.3.4.3 Discussionhttp://www.nabble.com/DM-Rule-#4:-Beware-of-Same-Name-Siblings.-tf4040024.html20.1.3.5 Rule #5: References considered harmful.20.1.3.5.1 ExplanationReferences imply referential integrity. I find it important to understand that references do not justadd additional cost for the repository managing the referential integrity, but they also are costlyfrom a content flexibility perspective.Personally I make sure I only ever use references when I really cannot deal with a danglingreference and otherwise use a path, a name or a string UUID to refer to another node.20.1.3.5.2 ExampleLet's assume I allow "references" from a <strong>doc</strong>ument (a) to another <strong>doc</strong>ument (b). If I model thisrelation using reference properties this means that the two <strong>doc</strong>uments are linked on a repositorylevel. I cannot export/import <strong>doc</strong>ument (a) individually, since the reference property's target maynot exist. Other operations like merge, update, restore or clone are affected as well.So I would either model those references as "weak-references" (in JCR v1.0 his essentially boilsdown to string properties that contain the uuid of the target node) or simply use a path. Sometimesthe path is more meaningful to begin with.I think there are use cases where a system really can't work if a reference is dangling, but I justcan't come up with a good "real" yet simple example from my direct experience.20.1.3.5.3 Discussionhttp://www.nabble.com/DM-Rule-#5:-References-considered-harmful.-tf4040042.html20.1.3.6 Rule #6: Files are Files are Files.20.1.3.6.1 ExplanationIf a content model exposes something that even remotely smells like a file or a folder I try to use (orextend from) nt:file, nt:folder and nt:resource.In my experience a lot of generic applications allow interaction with nt:folder and nt:files implicitlyand know how to handle and display those event if they are enriched with additional metainformation.For example a direct interaction with file server implementations like CIFS or WebDAVsitting on top of JCR become implicit.I think as good rule of thumb one could use the following: If you need to store the filename andthe mime-type then nt:file/nt:resource is a very good match. If you could have multiple "files" annt:folder is a good place to store them.If you need to add meta information for your resource, let's say an "author" or a "description"property, extend nt:resource not the nt:file. I rarely extend nt:file and frequently extend nt:resource.20.1.3.6.2 ExampleLet's assume that someone would like to upload an image to a blog entry at:/content/myblog/posts/iphone_shippingPage 106 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Model Dataand maybe the initial gut reaction would be to add a binary property containing the picture.While there certainly are good use cases to use just a binary property (let's say the name isirrelevant and the mime-type is implicit) in this case I would recommend the following structure formy blog example./content/myblog/posts/iphone_shipping/attachments [nt:folder]/content/myblog/posts/iphone_shipping/attachments/front.jpg [nt:file]/content/myblog/posts/iphone_shipping/attachments/front.jpg/jcr:content [nt:resource]20.1.3.6.3 Discussionhttp://www.nabble.com/DM-Rule-#6:-Files-are-Files-are-Files.-tf4040063.html20.1.3.7 Rule #7: IDs are evil.20.1.3.7.1 ExplanationIn relational databases IDs are a necessary means to express relations, so people tend to usethem in content models as well. Mostly for the wrong reasons through.If your content model is full of properties that end in "Id" you probably are not leveraging thehierarchy properly.It is true that some nodes need a stable identification throughout their live cycle. Much fewer thanyou might think though. mix:referenceable provides such a mechanism built into the repository,so there really is no need to come up with an additional means of identifying a node in a stablefashion.Keep also in mind that items can be identified by path, and as much as "symlinks" make waymore sense for most users than hardlinks in a unix filesystem, a path makes a sense for mostapplications to refer to a target node.More importantly, it is **mix**:referenceable which means that it can be applied to a node at thepoint in time when you actually need to reference it.So let's say just because you would like to be able to potentially reference a node of type"Document" does not mean that your "Document" nodetype has to extend from mix:referenceablein a static fashion since it can be added to any instance of the "Document" dynamically.20.1.3.7.2 Exampleuse:/content/myblog/posts/iphone_shipping/attachments/front.jpginstead of:[Blog]- blogId- author[Post]- postId- blogId- title- text- date[Attachment]- attachmentId- postId- filenamePage 107 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


How to Model Data+ resource (nt:resource)20.1.3.7.3 Discussionhttp://www.nabble.com/DM-Rule-#7:-IDs-are-evil.-tf4040076.htmlPage 108 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


21 JSP Tag Libraries21.1 JSP Tag LibrariesThe CQ and Sling tab libraries give you access to specific functions for use in the JSP script ofyour templates and components.21.1.1 CQ Tag LibraryThe CQ tag library contains helpful CQ functions.To use the CQ Tag Library in your script, the script must start with the following code:NoteWhen the /libs/wcm/global.jsp file is included in the script, the cq taglib isautomatically declared.TipWhen you develop the jsp script of a CQ5 component, it is recommended to includefollowing code at the top of the script:It declares the sling, cq and jstl taglibs and exposes the regularly used scripting objectsdefined by the tag. This shortens and simplifies the jsp code of yourcomponent.21.1.1.1 The tag creates an i18n localization context and stores it in thejavax.servlet.jsp.jstl.fmt.localizationContext configuration variable.It has the following attribute:languageThe language of the locale for which to retrieve the resource bundle.The "content bundle" can be simply used by standard JSTL tags. The lookup ofmessages by keys is two-fold:1. First, the JCR properties of the underlying resource that is currently rendered are searched fortranslations. This allows you to define a simple component dialog to edit those values.2. If the node does not contain a property named exactly like the key, the fallback is to load aresource bundle from the sling request (SlingHttpServletRequest.getResourceBundle(Locale)).The language or locale for this bundle is defined this way:a. First, if the parameter language of the tag is set, this is used.b. Otherwise, the locale of the page is looked up. This is taken from the page path (eg. the path/content/site/en/some/page produces the "en" locale).Example:


JSP Tag Libraries%>21.1.1.2 The tag includes a resource into the current page.It has the following attributes:flushA boolean defining whether to flush the output before including the target.pathThe path to the resource object to be included in the current request processing. If this path isrelative it is appended to the path of the current resource whose script is including the givenresource. Either path and resourceType, or script must be specified.resourceTypeThe resource type of the resource to be included. If the resource type is set, the path must bethe exact path to a resource object: in this case, adding parameters, selectors and extensionsto the path is not supported.If the resource to be included is specified with the path attribute that cannot be resolved to aresource, the tag may create a synthetic resource object out of the path and this resource type.Either path and resourceType, or script must be specified.scriptThe jsp script to include. Either path and resourceType, or script must be specified.ignoreComponentHierarchyA boolean controlling whether the component hierarchy should be ignored for script resolution.If true, only the search paths are respected.Example:NoteShould you use or to include a script?• The directive informs the JSP compiler to includea complete file into the current file. It is as if the contents of the included file werepasted directly into the original file.• With the directive, the file is included at runtime.NoteShould you use or ?Page 110 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag Libraries• When developing CQ5 components, <strong>Day</strong> recommends that you use .• allows you to directly include script files by their name when using thescript attribute. This takes component and resource type inheritance into account, andis often simpler than strict adherence to Sling's script resolution using selectors andextensions.21.1.1.3 The tag exposes the following, regularly used, scripting objects which can bereferenced by the developer. It also exposes the objects defined by the tag.componentContextthe current component context object of the request(com.day.cq.wcm.api.components.ComponentContext interface).componentthe current CQ5 component object of the current resource(com.day.cq.wcm.api.components.Component interface).currentDesignthe current design object of the current page (com.day.cq.wcm.api.designer.Design interface).currentPagethe current CQ WCM page object (com.day.cq.wcm.api.Page interface).currentStylethe current style object of the current cell (com.day.cq.wcm.api.designer.Style interface).designerthe designer object used to access design information (com.day.cq.wcm.api.designer.Designerinterface).editContextthe edit context object of the CQ5 component (com.day.cq.wcm.api.components.EditContextinterface).pageManagerthe page manager object for page level operations (com.day.cq.wcm.api.PageManagerinterface).pagePropertiesthe page properties object of the current page (org.apache.sling.api.resource.ValueMap).propertiesthe properties object of the current resource (org.apache.sling.api.resource.ValueMap).resourceDesignthe design object of the resource page (com.day.cq.wcm.api.designer.Design interface).resourcePagethe resource page object (com.day.cq.wcm.api.Page interface).It has the following attributes:requestNameinherited from slingresponseNameinherited from slingPage 111 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag LibrariesresourceNameinherited from slingnodeNameinherited from slinglogNameinherited from slingresourceResolverNameinherited from slingslingNameinherited from slingcomponentContextNamespecific to wcmeditContextNamespecific to wcmpropertiesNamespecific to wcmpageManagerNamespecific to wcmcurrentPageNamespecific to wcmresourcePageNamespecific to wcmpagePropertiesNamespecific to wcmcomponentNamespecific to wcmdesignerNamespecific to wcmcurrentDesignNamespecific to wcmresourceDesignNamespecific to wcmcurrentStyleNamespecific to wcmExample:NoteWhen the /libs/wcm/global.jsp file is included in the script, the tag is automatically included.Page 112 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag Libraries21.1.1.4 The tag writes the current request URL to the JspWriter. The two tags and may be used inside the body of this tag to modify thecurrent request URL before it is written.It allows you to create links to the current page with varying parameters. For example, it enablesyou to transform the request:mypage.html?mode=view&query=something into mypage.html?query=something.The use of addParam or removeParam only changes the occurence of the given parameter, allother parameters are unaffected. does not have any attribute.Examples:remove filter${label} (${bucket.count})21.1.1.5 The tag adds a request parameter with the given name and value to the enclosing tag.It has the following attributes:namename of the parameter to be addedvaluevalue of the parameter to be addedExample:${label} (${bucket.count})21.1.1.6 The tag removes a request parameter with the given name and value fromthe enclosing tag. If no value is provided all parameters with the given name areremoved.It has the following attributes:namename of the parameter to be removedExample:remove filter21.1.2 Sling Tag LibraryThe Sling tag library contains helpful Sling functions.Page 113 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag LibrariesWhen you use the Sling Tag Library in your script, the script must start with the following code:NoteWhen the /libs/wcm/global.jsp file is included in the script, the sling taglib isautomatically declared.21.1.2.1 The tag includes a resource into the current page.It has the following attributes:flushA boolean defining whether to flush the output before including the target.resourceThe resource object to be included in the current request processing. Either resource or pathmust be specified. If both are specified, the resource takes precedence.pathThe path to the resource object to be included in the current request processing. If this path isrelative it is appended to the path of the current resource whose script is including the givenresource. Either resource or path must be specified. If both are specified, the resource takesprecedence.resourceTypeThe resource type of the resource to be included. If the resource type is set, the path must bethe exact path to a resource object: in this case, adding parameters, selectors and extensionsto the path is not supported.If the resource to be included is specified with the path attribute that cannot be resolved to aresource, the tag may create a synthetic resource object out of the path and this resource type.replaceSelectorsWhen dispatching, the selectors are replaced with the value of this attribute.addSelectorsWhen dispatching, the value of this attribute is added to the selectors.replaceSuffixWhen dispatching, the suffix is replaced by the value of this attribute.Examples:NoteThe resolution of the resource and the script that are included with the tagis the same as for a normal sling URL resolution. By default, the selectors, extension, etc.from the current request are used for the included script as well. They can be modifiedthrough the tag attributes: for example replaceSelectors="foo.bar" allows you to overwritethe selectors.Page 114 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag Libraries21.1.2.2 The tag exposes the following, regularly used, scripting objects which can bereferenced by the developer:slingRequestSlingHttpServletRequest object, providing access to the HTTP request header information -extends the standard HttpServletRequest - and provides access to Sling-specific things likeresource, path info, selector, etc.slingResponseSlingHttpServletResponse object, providing access for the HTTP response that is created bythe server. This is currently the same as the HttpServletResponse from which it extends.requestThe standard JSP request object which is a pure HttpServletRequest.responseThe standard JSP response object which is a pure HttpServletResponse.resourceResolverThe current ResourceResolver object. It is the same as slingRequest.getResourceResolver().slingA SlingScriptHelper object, containing convenience methods for scripts, mainly sling.include('/some/other/resource') for including the responses of other resources inside this response (eg.embedding header html snippets) and sling.getService(foo.bar.Service.class) to retrieve OSGiservices available in Sling (Class notation depending on scripting language).resourcethe current Resource object to handle, depending on the URL of the request. It is the same asslingRequest.getResource().currentNodeIf the current resource points to a JCR node (which is typically the case in Sling), this givesdirect access to the Node object. Otherwise this object is not defined.logProvides an SLF4J Logger for logging to the Sling log system from within scripts, eg.log.info("Executing my script").It has the following attributes:requestNameresponseNameresourceNamenodeNamelogNameresourceResolverNameslingNamePage 115 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


JSP Tag LibrariesExample:Page 116 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG


Appendix A. Copyright, Licenses andFormatting ConventionsFor all copyright statements and license agreements see Copyright, Licenses and Disclaimers.A.1 Formatting ConventionsThe following tables detail formatting conventions used within this guide:Table A.1. Formatting Conventions - TextStyle Description ExampleCross-reference Cross-reference to external <strong>doc</strong>uments. See the Microsoft Manual ofStyle for Technical Publications.GUI Item User interface items. Click Save.Keyboard shortcut Keyboard shortcuts. Press Ctrl+A.Mouse Button Mouse buttons. Secondary-mouse button(usually the right-mousebutton).LinkLink to anchor-points within the current<strong>doc</strong>ument and/or external sources.http://www.day.comCode Example of programming code. if (weather == sunny) smile;User Input[OptionalParameter]Example of text, or commands, that youtype.Example of variable text - you type theactual value needed.An optional parameter.ls *.xmlls ls [] []Computer Output Logging and error messages. ls: cannot accesserror.log:Table A.2. Formatting Conventions - ActionsWhen you see this...Ctrl+ARight-clickDragIt means do this...Hold down the Ctrl key, then press the A key.Press the right-mouse button (or the left-mouse button if your mousehas been configured for left-handed use).Hold down the left mouse button while moving the item, then release themouse button at the new location (or the right mouse button if your mousehas been configured for left-handed use).Page 117 of 117CQ 5.1 WCMCopyright 1993-2008 <strong>Day</strong> Management AG

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!