Using QueryService to access top-level site areas in IBM Web Content Manager

Technote (troubleshooting)


Problem

If you are trying to use the QueryService to find top-level site areas within a web content library in a scenario where you do not know any of the site area names. You can see below QueryService API to

retrieve only the top level site areas of a library.


Resolving the problem

The query below will return the top level site Areas of the given library, i.e. all site areas under


Solution 1:

'/contentRoot/icm:libraries[7]/Content/'//element(*, icm:documentLibrary)[@icm:title = 'Library Name']/Content/element(*,ibmcontentwcm:siteArea)

Replace the icm:title property value in bold with the library name you want to query.

The above query might take longer if you have lots of libraries, in that scenario the below query can be used as it does not rely on deprecated code and uses the QueryService

Solution 2:
<%
DocumentLibrary lib = workspace.getDocumentLibrary("Web Content");
workspace.setCurrentDocumentLibrary(lib);
Identity contentFolder = lib.getPresetFolder(PresetFolderType.CONTENT).getIdentity();
QueryService service = workspace.getQueryService();

Query topLevelSiteAreas = service.createQuery(SiteArea.class);
topLevelSiteAreas.addParentId(contentFolder, QueryDepth.CHILDREN);
topLevelSiteAreas.returnIds();

ResultIterator resultIterator = queryService.execute(topLevelSiteAreas);
while (resultIterator.hasNext()) {
Object o = resultIterator.next();
%><%= o %><br><%
}
%>



Rate this page:

(0 users)Average rating

Document information


More support for:

IBM Web Content Manager
Web Content Integration

Software version:

8.0.0.0

Operating system(s):

AIX, Linux, Solaris, Windows

Software edition:

Java edition

Reference #:

1640860

Modified date:

2013-07-03

Translate my page

Machine Translation

Content navigation