Category Archives: API Editing publication packages

Define publishing targets for publication combinatons

This article describes the automation of the dialog Define Publishing Targets on a publication combination.

Roughly speaking we have always 4 stages I need to publish via FTP.  These stages are the following: WORK, DEVE, TEST, PROD. If an author needs to publich to TEST I want to have all files in WORK and DEVE as well. Otherwise they would not have the latest modification what makes it difficult for development process.

To achieve this includement of lower stages I usually assign all needed stages as publishing targets to the respective publication combinations. In short, WORK has only on publishing target, DEVE has 2, TEST 3 and PROD 4.

See the following lines which achieve the definition of publishing targets accordingly:

String logonGuid="43321CA565FC4D91ACFD3F3E4AB2D92B";
String sessionKey="840BC272ED864906BB44E86F60A1B81B";
String projectGuid="73671509FA5C43ED8FC4171AD0298AD2";

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

// input values
PublishingTarget[] targets = new PublishingTarget[4];
targets[0] = project.getPublishingTargetByNameStartsWith(“WORK_”);
targets[1] = project.getPublishingTargetByNameStartsWith(“DEVE_”);
targets[2] = project.getPublishingTargetByNameStartsWith(“TEST_”);
targets[3] = project.getPublishingTargetByNameStartsWith(“PROD_”);

PublicationPackage publPackage = project.getPublicationPackageByName(“publ_pages_to_about_us”);
for (PublicationSetting combination : publPackage.getPublicationSettings()) {
String pvStage = combination.getProjectVariantName().substring(0, 4);

// add all targets until given stage
for (int i = 0; i < targets.length; i++) {
PublishingTarget target = targets[i];

// add ends at stage
if (target.getName().substring(0, 4).equals(pvStage)) {
} // end if
}  // end for targets
} // end for combinations

The method PublicationSetting.addPublishingTo() adds another publishing target to a publication combination.

jRQL supports the editing of publishing targets on a publication combination with the following methods:

  • addPublishingTo(target)
  • removePublishingTo()
  • setPublishingTarget(target)
  • removePublishingTo(target)

Please check the javadoc for more details.

Create publication combinations within a package

In this example I want to describe how to update publication packages after introducing a new project variant. This is the jRQL automation for the dialog Edit Publication Package on a publication package.

The main method here is PublicationPackage.addSetting(). Similar as the Dialog in SmartTree you can create a new combination by copy the values from another project variant. jRQL assumes you want to use the same language variant.

Follow these lines with the explanation below:

String logonGuid = "8009AB61D06844F48077A9E4D4880A20";
String sessionKey = "C63373D9DB394B94BBAD66106540A123";
String projectGuid = "73671509FA5C43ED8FC4171AD0298AD2";

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

// 1. for these packages do
String[] packages = {“publ_pages_to_languages_root”, “publ_pages_to_newsletter”};
for (int i = 0; i < packages.length; i++) {
String name = packages[i];
PublicationPackage publPackage = project.getPublicationPackageByName(name);

for (PublicationSetting combination : publPackage.getPublicationSettings()) {
// 2. skip all page config
if (combination.getProjectVariantName().contains(“page_config_xml”)) {
System.out.println(”  ” + combination.getName());

// 3. get setting’s values
LanguageVariant lv = combination.getLanguageVariant();
ProjectVariant pv = combination.getProjectVariant();

// 4. determine new project variant
String stage = StringHelper.split(pv.getName(), “_”)[0];
ProjectVariant newPv = project.getProjectVariantByName(stage + “_viewlabels_and_messages_xml”);

// 5. create new setting
PublicationSetting newCombination = publPackage.addSetting(newPv, lv, pv);
// 6. further action with newCombination
} // end for combinations
} // end for packages

In step 1 I define which publication packages I needed to add combination for the new project variant and loop through all of them.

Step 2 in this example skips all combinations (jRQL name a publication combination publication setting) for the  project variants for the page config XMLs.

Step 3 get the language and project variant from the current publication combination.

Step 4 extracts from the project variant the stage (like WORK, DEVE, TEST, PROD) and builds the name of the new viewlabels_and_messages project variant.

Step 5 last but not least create the new setting by copying all settings from the project variant pv to the newPv – all for the same language variant lv.

Step 6 in my example is empty. If you need you can here adjust the newCombination with new publishing targets or a new published pages publication folder.

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.

Create and navigate publication structure

Because on the Hapag-Lloyd’s website every RedDot page needs to be published as a HTML and XML page synchronously, the top folder within publication structure correspond to these project variants.

The publication structure below uses folders per language code and below all main menu item of the website needs to be created. See the following sample:

—- career
—-direct_booking and so on

—- about_us
—- career
—-direct_booking and so on

Use the following jRQL statements to create and/or navigation through such a publication structure:

String logonGuid="0904ABF0E43443D2881FE7481339650E";
String sessionKey="490EC675042F4C5A8A6DF1ED63ADD7A6";
String projectGuid="268F46EF5EB74A75824856D3DA1C6597";

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

PublicationFolder rootFolder1 = project.getPublicationRootFolderByGuid(“publicationFolderGuid”);
PublicationFolder docRoot = project.getPublicationRootFolderByName(“docRoot”);

You can access the root folders (RedDot CMS did not offer a single root folder) the best way by name, but of course it’s possible to access them by GUID as well.

Use one of the following lines to create a subfolder and navigate down the publication structure.

PublicationFolder newChild = rootFolder1.createChildFolder("child folder name");
PublicationFolder child = rootFolder1.getChildByName("child name");

See the next article on how to update the published pages folder for all publication combinations of a package.

How jRQL can help you setup publication combinations

If you have a RedDot CMS project with several language variants and project variants the configuration of publication packages is very tidious, because you have to setup every combination.

And on a usual website you will have several subfolders (in the URL), so you need several publication packages for different parts of your project.

On the new Hapapag-Lloyd’s website I had the need to create publication settings for 4 language variants, 28 project variant (for 4  stages) and 21 subfolders on website (=21 publication packages). Manually this will be a very hard job taking quite long and afterwards a lot of errors will be inside.

jRQL can help you for the really hard work:

  • adding publication settings inside a publication package
  • set the publishing targets on each publication combination
  • create publication structure
  • set the published pages folder mapping for each publication combination

Read the further articles of this category to get in touch with the supported features.

Folder mappings other than published pages cannot be changed with jRQL, because I didn’t need it so far.