Getting WCM Content in a SiteArea on the Server Side

We will look at an example of querying/getting WCM Content in a SiteArea on the server-side. It assumes you already have a working knowledge of WCM (Web Content Management) and have created pieces of content under a SiteArea.

Imports

We will setup the necessary imports first; obviously if you are using an IDE they will be organized and set for you. If for some reason they are undefined, you may need to reference your WCM library for compilation, but do not include it during the build/deployment since the IBM environment would have it already.

Look for ilwwcm-api.jar and add it to your build path:
<PortalServer>/wcm/prereq.wcm/wcm/shared/app

 

The WCM Workspace

To work with WCM we will need the WCM core objects: Workspace and Repository.
We declare the variables outside the try/catch so that we can properly close them afterwards.

 

Setting the Document Library

Before we leverage the workspace to find/query WCM content, we will set the current document library.
You can find the document library unique name in WCM.

 

SiteArea Search

Once the DocumentLibrary is set, we will find the SiteArea where we have our Content stored.

 

Getting the Content

Lastly, we will go through all the child content under our SiteArea and extract properties. The snippet below shows the basic attributes for now.

 

Summary

The examples above show a few snippets on how to use the WCM_API to work with a WCM Workspace, SiteAreas, and going through Content objects. The example stops at the basic properties of the Content object, so if you want to take a look at extracting custom fields (creating in the Authoring Template for a Content template), please read the article below:

Getting WCM Content Custom Fields




References

Leave a Reply

Your email address will not be published. Required fields are marked *