Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
The Synchronization REST module provides a convenient REST API for publishing content from a source Magnolia instance (typically an author instance) to a target Magnolia instance (typically a public instance). It provides another way to synchronize content using the Synchronization module and start synchronization, monitor synchronizations and stop synchronizations remotely through via a REST service.
The module allows you to publish a large amount of content selectively. Only previously published content is transferred to the target instance. You can use the module to add content to new public instances without shutting down existing instances and impacting their ability to serve content.
Command REST vs Sync REST
You could launch a launch a synchronization with the command API of the REST module, however, synchronizing using the Synchronization REST API has several advantages compared to the command REST API:
synchronous
- The API will not return a result until the synchronization has finished. Synchronizations may take some time to finish depending on the amount of content.
fixed configuration
- Must be configured before launching a synchronization. The synchronization command uses a receiver defined in the Synchronization module's configuration. The receiver defines the target Magnolia instance to send content to and can't be passed to the synchronization command.
uncontrolled execution
- It is possible to launch identical synchronizations to the same instance if not carefully orchestrated. You can launch many synchronizations simultaneously. Synchronizations adds load on the source Magnolia instance; you can overload the source Magnolia instance by launching too many synchronizations at the same time.
- A synchronization launched with the Synchronization REST API returns immediately with a job ID and provides calls to check on the status of the synchronization job (waiting for execution, running, finished successfully and finished with errors).
In addition, if you need to define a site specific receiver using workspace path mappings, you can define a template receiver in the configuration of the Synchronization REST module and use the mappings in the template to perform the synchronization.
no configuration
- You can specify all the details of the synchronization (URL for the Magnolia instance, workspace, path and more) when launching the synchronization. No configuration is needed to start a synchronization.
controlled execution
Using these policies, you can avoid overloading the source Magnolia instance and prevent duplicate synchronizations of the same content to a Magnolia instance.
- The synchronization policy can be set to control synchronizations:
- Allow only one synchronization at a time
- Allow only one synchronization to a target Magnolia instance
- Allow only one synchronization of a workspace to a target Magnolia instance
- Allow all requested synchronizations
Installing
<dependency> <groupId>info.magnolia.synchronization</groupId> <artifactId>magnolia-synchronization-rest</artifactId> <version>1.9</version> </dependency>
Synchronization REST API
This page describes the synchronization endpoint, which can be used to launch synchronization and check on their status.
GET
Get status
Returns the status of a specified synchronization request.
Request URL
/.rest/synchronization/v1/status/{synchId}
Parameters
Parameter | Description | Parameter type | Data type |
---|---|---|---|
| required Specify the synchronization request ID. Note: the synchronization request ID is returned by |
|
|
Returns the status of a synchronization request with:
jobId
- the ID of the synchronization request (same as synchId)status
- the synchronization request status, one of:WAITING
- waiting for executionRUNNING
- currently executingDONE
- completed successfully without errorsFAILED
- completed unsuccessfully due to an errorCANCELLED
- synchronization was cancelled before executionERROR
- synchronization was completed but was unable to determine results
Clear jobs
Clears the status of all synchronization jobs.
Important
This call will not stop running synchronization jobs or synchronization jobs awaiting execution.
Request URL
/.rest/synchronization/v1/reset
Returns an HTTP status of:
204
- the reset was successful
POST
Trigger synchronization
Launch a synchronization of designated workspace on a Magnolia instance.
Request URL
/.rest/synchronization/v1/trigger
Parameters
Parameter | Description | Parameter type | Data type |
---|---|---|---|
url | required The URL of the Magnolia instance. | query | String |
workspace
| required The workspace to be synchronized. | query | String |
recursive | optional, default is Indicates if subnodes of path should also be synchronized. | query | boolean |
fromDate | optional Specifies a Unix epoch timestamp in milliseconds. Nodes modified since If | query | long |
fromPath | required Workspace path on the author instance from which content is published. | query | String |
toPath | optional Workspace path on the public instance to which the content is published. Nodes at or below | query | String |
Returns an HTTP status of:
200
- the synchronization request was launched and awaiting execution409
- another synchronization request is running and the request cannot be launched at this time500
- an error occurred and the synchronization request was not launched
If the request was launched, the status of a synchronization request is returned with:
jobId
- the ID of the synchronization request (same as synchId)status
- the synchronization request status, one of:WAITING
- waiting for executionRUNNING
- currently executingDONE
- completed successfully without errorsFAILED
- completed unsuccessfully due to an errorCANCELLED
- synchronization was cancelled before executionERROR
- synchronization was completed but was unable to determine results
Example
Here is an example call for triggering a synchronization
curl -u superuser:superuser http://localhost:8080/magnoliaAuthor/.rest/synchronization/v1/trigger --data ' {"url" : "http://localhost:8080/magnoliaPublic", "workspace": "website", "fromPath" : "/", "fromDate" : "2012-03-29T10:05:45-06:00"} ' --header "Content-Type: application/json"
Known Issues
Due to the fact that update/install tasks are not run from beta to final versions there will be some manual steps if you were using one of the beta releases.
Import manager config
- The following configuration will have to be imported manually. (See config.modules.synchronization-core.config.manager.xml).
Remove command config
RestSynchronizationCommand removed from final module. This is harmless but the command node configuration will have to be removed manually from the JCR configuration. (i.e.
/modules/synchronization-rest/commands
)2020-06-25 15:10:19,851 WARN magnolia.transformer.ClassPropertyBasedTypeResolver: Encountered the 'class' property but failed to resolved the type from its value: [info.magnolia.synchronization.commands.RestSynchronizationCommand]
Remove sender config
In case 1.9-beta3 was installed, the synchronization sender node will have to be removed manually from JCR configuration. (i.e.
/modules/synchronization-core/commands/synchronization/synchronize/synchronizationSenderClass
).