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];
combination.addPublishingTo(target);
// add ends at stage
if (target.getName().substring(0, 4).equals(pvStage)) {
break;
} // 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.