Publish a page – manually configure a publishing job

To configure a publishing job in detail jRQL has the class PublishingJob. To create a publishing job instance you need the start page and the flags if you want to publish with following pages and with related pages.

The following lines will prepare a publishin job starting from page with ID 34009 without following pages, but with related pages.

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

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

Page currentPg = project.getPageById(“34009”);
boolean withFollowingPages = false;
boolean withRelated = true;
PublishingJob job = new PublishingJob(currentPg, withFollowingPages, withRelated);

The job cannot be started at that moment, because neiter a project variant nor a language variant is set. Now you can use several methods to select the variants you need.

I prefer to use the project variant GUIDs and language variant GUID to define publishing, because they can not change.  To configure your publishing job with several project variants but only one language variant you should use this style:

job.addToPublish("projectVariantGuid1,projectVariantGuid2,projectVariantGuid3", ",", "languageVariantGuid");

The project variant GUIDs are contained in a simple string separated by , (the 2nd parameter) in our example and for one language variant guid. The style for the project variant GUIDs is a simple style for parameter handling.

If you need to add all combinations between project and language variants you should use this method:

currentPg.publishAllCombinations(withFollowingPages, projectVariantGuids, separator, languageVariantGuids)

This will add all combinations of project and language variants. You can override the withFollwingPages flag from the constructor. Either the projectVariantGuids and languageVariantGuids are separated by the same (the separator parameter).

Regardless how you configure your project and language variants you can decide which use should get the publishing e-mail. With the next line the e-mail will be send to the currently connected user, but it could be another existing user too.

job.setMailReceiver(client.getConnectedUser());

Finally you have to start your job using

job.start();

If you try to start a job which did not have at least one project and language variant you will get a IncompletePublishingJobException.

You can ask how many e-mail the job will send if you requested it:

job.getNumberOfPublishingMails();

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: