Set published pages folder for all publication combinations

After you created all publication combinations within a package you need to set the published pages folder for all combinations accordingly.

See the following lines of code with explanations below.

String logonGuid="BDEBF9E5DB8C4D1B88B01DDA25DE370A";
String sessionKey="720BA5E36CC546788629C926D6030D66";
String projectGuid="73671509FA5C43ED8FC4171AD0298AD2";

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

// input value
String subFolderName = “about_us”;

PublicationPackage pubPackage = project.getPublicationPackageByName(“publ_pages_to_” + subFolderName);
java.util.List<PublicationSetting> settings = pubPackage.getPublicationSettings();

for (PublicationSetting setting : settings) {
String settingName = setting.getName();

// skip display_do_not_use* project variant
if (settingName.indexOf(“do_not_use”) > 0) {

// 1. determine root folder by pv
PublicationFolder targetFolder = null;
if (settingName.indexOf(“pages_html”) > 0 || settingName.indexOf(“viewlabels”) > 0) {
targetFolder = project.getPublicationRootFolderByName(“docRoot”);
if (settingName.indexOf(“page_config_xml”) > 0) {
targetFolder = project.getPublicationRootFolderByName(“pageConfig”);

// 2. crawl to folder by lv
System.out.println(”  ” + setting.getLanguageVariant().getRfcLanguageId());
targetFolder = targetFolder.getChildByName(setting.getLanguageVariant().getRfcLanguageId());

// 3. crawl to given folder by name
targetFolder = targetFolder.getChildByName(subFolderName);

// set folder

The most outer loop goes through all publication combinations of the publication package “publ_pages_to_about_us”. Inside this loop the project variant used only for display within SmartEdit is skipped, because this is never used for publishing.

In the next lines the root publication folder is determined depending on the name of the project variant.  The second level of publication structure depends on the language variant, so the next lines navigation within publication structure on level deeper. We are now on the language code (en, de, es, zh) level. Method getRfcLanguageId() returns exactly this code.

At the end we need to navigat the 3. level about_us simply and set the found publication folder into the published pages folder mapping of the current setting.

For me this saves a lot of time, because choosing the right publication folder manually is difficult – there are two trees with same structure under different root folder names.

Post a comment or leave a trackback: Trackback URL.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: