Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy 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
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
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
CMScontent managementLiveCycle Designer ES4
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

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

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

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

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 © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement