Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / LiveCycle Developer Center /

Creating packages based on query parameters

by Yogesh Bahuguna

Yogesh Bahuguna

Content

  • Querying the repository
  • Creating packages from the list of nodes

Created

25 July 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
CMS content management LiveCycle

Requirements

User level

Beginning

Sample files

  • createPkgWithQuery-1.zip

When working with content management systems, many times we have requirements to extract content based on certain parameters. A very generic use case might be to update the Stage or Dev systems from production based on the date the last sync had been done or the last modified date of the content on production systems. We can easily solve that problem by writing a small component by first querying the repository and using the Search result to create a package on the server.

Querying the repository

Day OOTB povides components to search the repository e.g. http://localhost:4502/libs/cq/search/content/querydebug.hml , http://localhost:4502/crx/ui/search.jsp.

One can query based on the query parameters or by specifying the XPath/SQL in a query (e.g. search the whole contents changed after April 1, 2010).

Params-based search

On http://localhost:4502/libs/cq/search/content/querydebug.html, type the params in the text area below:

type=cq:Page path=/content daterange.property=jcr:content/cq:lastModified daterange.lowerBound=2010-04-01 orderby=@jcr:content/cq:lastModified orderby.index=true orderby.sort=asc

XPath-based query

On http://localhost:5502/crx/ui/search.jsp, use XPath, as below:

/jcr:root/content//element(*, cq:Page) [ (@jcr:content/cq:lastModified > xs:dateTime('2010-04-01T00:00:00.000+05:30')) ] order by jcr:content/@cq:lastModified

We can also create our own component to search by creating a PredicateGroup based on the properties (parameters) passed and then a builder object (created with the predicateGroup and the available jcr session) can be used to create the query, as shown below:

QueryBuilder builder = resource.getResourceResolver().adaptTo(QueryBuilder.class); Session session = resource.getResourceResolver().adaptTo(Session.class); String queryParam = request.getParameter(“query”); Properties props = new Properties(); props.load(new ByteArrayInputStream(queryParam.getBytes(“ISO-8859-1″))); PredicateGroup root = PredicateConverter.createPredicates(props); // avoid slow //* queries if (!root.isEmpty()) { query = builder.createQuery(root, session); query.setHitsPerPage(0); } SearchResult result = query.getResult();

From the SearchResult object we can extract the Hits (result.getHits) and loop through the list to show the results. We can use the same list to create the packages, as explained next.

Creating packages from the list of nodes

If we have a list of nodes we can easily create a package by creating the filters and using the same for Jcr package defintion:

DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter(); for (Hit hit: hits) { PathFilterSet pathFilterSet = new PathFilterSet(hit.getPath()); filter.add(pathFilterSet); } JcrPackage jcrPackage = packMgr.create(“testGroup”,”testPackage”); JcrPackageDefinition jcrPackageDefinition = jcrPackage.getDefinition(); jcrPackageDefinition.setFilter(filter, false); PrintWriter pkgout = new PrintWriter(System.out); packMgr.assemble(jcrPackage, new DefaultProgressListener(pkgout));

On execution of assembling a package with group name "testGroup" and a package within it, "testPackage" will be created and can be accessed from the package manager.

I have created a sample component by extending the default search component that creates a package with group name testGroup and package name testPackage. If a package with the same name already exists, it ignores the request and doesn't overwrite the existing one. You can get the sample component from here.

Install the package and use it at http://servername:port/apps/packages/createPkgWithQuery/createPkg.html. You can use parameters like the ones below:

type=cq:Page path=/content daterange.property=jcr:content/cq:lastModified daterange.lowerBound=2010-04-01 orderby=@jcr:content/cq:lastModified orderby.index=true orderby.sort=asc

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Programmatically accessing LiveCycle Content Services ES
  • Content rich vs content managed applications using LiveCycle Content Services ES
  • Seamlessly storing and managing documents protected with LiveCycle ES

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement