Copyright© 2008-2026 Sitevision AB, all rights reserved.
@Requireable(value="PublisherBuilder") public interface PublisherBuilder extends Builder<Publisher>
Publisher with a specific setup of state.
Initial state of a PublisherBuilder is:
publishDate is null == imminent publishingunpublishDate is null == no unpublishingnotificationDate is null == no ("Best before") notificationnotifyMobileUsers is false == no mobile notificationExample of how to use PublisherBuilder and Publisher to publish a page at a given time using server-side JavaScript:
// 1. Import PublishingUtil in apps (WebApp, RESTApp, Widget, MCPServer etc)
// NOTE! Use the require function instead in other server-side JavaScripts (e.g. Script module), i.e:
// const publishingUtil = require("PublishingUtil");
import publishingUtil from "@sitevision/api/server/PublishingUtil";
// 2. Create a publisher builder instance
const publisherBuilder = publishingUtil.getPublisherBuilder();
const page = ... // Get the page node to publish
const date = ... // Create a specific publish date, or null for imminent publishing
// 3. Create a publisher
const publisher = publisherBuilder
.setPublishDate(date)
.build();
// 4. Publish
try {
publisher.publish(page);
console.log("Page published successfully!");
} catch (e) {
console.log("Failed to publish page");
}
Tip! The Builder interface documentation contains
more information about Builders and how to work with them!
An instance of the Sitevision class implementing this interface can be obtained via
PublishingUtil.getPublisherBuilder().
See PublishingUtil for how to obtain an instance of the PublishingUtil interface.
| Modifier and Type | Method and Description |
|---|---|
Publisher |
build()
Creates a Publisher instance using currently specified state.
|
PublisherBuilder |
setNotificationDate(Date aNotificationDate)
Sets the ("Best before") notification date.
|
PublisherBuilder |
setNotifyMobileUsers(boolean aNotifyMobileUsers)
Whether mobile users should be notified when the page is published.
|
PublisherBuilder |
setPublishDate(Date aPublishDate)
Sets the publish date.
|
PublisherBuilder |
setUnpublishDate(Date aUnpublishDate)
Sets the unpublish date.
|
PublisherBuilder setPublishDate(Date aPublishDate)
A publish date before "now" will throw an IllegalStateException when calling build().
Use null for immediate publishing.
aPublishDate - the publish date to set, or null for immediate publishingPublisherBuilder setUnpublishDate(Date aUnpublishDate)
A unpublish date before "now" will throw an IllegalStateException when calling build().
A unpublish date must differ at least one minute from the actual publish date,
otherwise an IllegalStateException will be thrown when calling build().
aUnpublishDate - the unpublish date to set, or null for no unpublishingPublisherBuilder setNotificationDate(Date aNotificationDate)
A notification date before "now" will throw an IllegalStateException when calling build().
A notification date must be equal or after the actual publish date,
otherwise an IllegalStateException will be thrown when calling build().
aNotificationDate - the notification date to set, or null for no notificationPublisherBuilder setNotifyMobileUsers(boolean aNotifyMobileUsers)
Note that this setting in practice is only applicable when publishing a sv:article
and current user must have PermissionUtil.Permission.SEND_PUSH_NOTIFICATIONS
for it to have any effect.
aNotifyMobileUsers - true if mobile users should be notified, false otherwisePublisher build() throws IllegalStateException
build in interface Builder<Publisher>IllegalStateException - if state for publisher execution is not valid, see individual set methods for value restrictionsSitevision - Content Management Made Easy
Sitevision is an advanced Java enterprise portal product that implements Java Content Repository (JSR 283).
Copyright© 2008-2026 Sitevision AB, all rights reserved.