Package org.opencms.publish
Class CmsPublishEngine
java.lang.Object
org.opencms.publish.CmsPublishEngine
This class is responsible for the publish process.
- Since:
- 6.5.5
-
Constructor Summary
ConstructorDescriptionCmsPublishEngine
(I_CmsDbContextFactory dbContextFactory) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Abandons the given publish thread.protected void
abortPublishJob
(CmsUUID userId, CmsPublishJobEnqueued publishJob, boolean removeJob) Aborts the given publish job.protected void
addPublishListener
(I_CmsPublishEventListener listener) Adds a publish listener to listen on publish events.void
Controls the publish process.protected void
Disables the publish engine, i.e.protected void
Enables the publish engine, i.e.void
enqueuePublishJob
(CmsObject cms, CmsPublishList publishList, I_CmsReport report) Enqueues a new publish job with the given information in publish queue.protected org.opencms.publish.CmsPublishThread
Returns the current running publish job.protected CmsDbContext
Returns the a new db context object.protected CmsDriverManager
Returns the driver manager instance.getJobByPublishHistoryId
(CmsUUID publishHistoryId) Returns a publish job based on its publish history id.protected CmsPublishHistory
Returns the publish history list with already publish job.protected CmsPublishQueue
Returns the queue with still waiting publish job.protected byte[]
getReportContents
(CmsPublishJobFinished publishJob) Returns the content of the publish report assigned to the given publish job.protected CmsUser
Returns the user identified by the given id.protected void
initialize
(CmsObject adminCms, boolean publishQueuePersistance, int publishQueueShutdowntime) Initializes the publish engine.protected boolean
Returns the working state, that is if no publish job is waiting to be processed and there is no current running publish job.protected void
lockPublishList
(CmsPublishJobInfoBean publishJob) Sets publish locks of resources in a publish list.protected void
publishJobFinished
(CmsPublishJobInfoBean publishJob) Signalizes that the publish thread finishes.protected void
publishJobRemoved
(CmsPublishJobInfoBean publishJob) A publish job has been permanently removed from the history.protected void
publishJobStarted
(CmsPublishJobInfoBean publishJob) Signalizes that the publish thread starts.protected void
Removes the given publish listener.protected void
sendMessage
(CmsUUID toUserId, String message, boolean hasErrors) Sends a message to the given user, if publish notification is enabled or an error is shown in the message.void
setDriverManager
(CmsDriverManager driverManager) Sets the driver manager instance.void
shutDown()
Shuts down all this static export manager.protected void
Starts the publish engine, i.e.protected void
Stops the publish engine, i.e.protected void
unlockPublishList
(CmsPublishJobInfoBean publishJob) Removes all publish locks of resources in a publish list of a publish job.
-
Constructor Details
-
CmsPublishEngine
Default constructor.- Parameters:
dbContextFactory
- the initialized OpenCms runtime info factory- Throws:
CmsInitException
- if the configured path to store the publish reports is not accessible
-
-
Method Details
-
abandonThread
Abandons the given publish thread. -
checkCurrentPublishJobThread
Controls the publish process. -
enqueuePublishJob
public void enqueuePublishJob(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws CmsException Enqueues a new publish job with the given information in publish queue.All resources should already be locked.
If possible, the publish job starts immediately.
- Parameters:
cms
- the cms context to publish forpublishList
- the resources to publishreport
- the report to write to- Throws:
CmsException
- if something goes wrong while cloning the cms context
-
getJobByPublishHistoryId
Returns a publish job based on its publish history id.The returned publish job may be an enqueued, running or finished publish job.
- Parameters:
publishHistoryId
- the publish history id to search for- Returns:
- the publish job with the given publish history id, or
null
-
setDriverManager
Sets the driver manager instance.- Parameters:
driverManager
- the driver manager instance
-
shutDown
Shuts down all this static export manager.NOTE: this method may or may NOT be called (i.e. kill -9 in the stop script), if a system is stopped.
This is required since there may still be a thread running when the system is being shut down.
-
abortPublishJob
protected void abortPublishJob(CmsUUID userId, CmsPublishJobEnqueued publishJob, boolean removeJob) throws CmsException, CmsPublishException Aborts the given publish job.- Parameters:
userId
- the id of user that wants to abort the given publish jobpublishJob
- the publish job to abortremoveJob
- indicates if the job will be removed or added to history- Throws:
CmsException
- if there is some problem during unlocking the resourcesCmsPublishException
- if the publish job can not be aborted
-
addPublishListener
Adds a publish listener to listen on publish events.- Parameters:
listener
- the publish listener to add
-
disableEngine
Disables the publish engine, i.e. publish jobs are not accepted. -
enableEngine
Enables the publish engine, i.e. publish jobs are accepted. -
getCurrentPublishJob
Returns the current running publish job.- Returns:
- the current running publish job
-
getDbContext
Returns the a new db context object.- Parameters:
ctx
- optional request context, can benull
- Returns:
- the a new db context object
-
getDriverManager
Returns the driver manager instance.- Returns:
- the driver manager instance
-
getPublishHistory
Returns the publish history list with already publish job.- Returns:
- the publish history list with already publish job
-
getPublishQueue
Returns the queue with still waiting publish job.- Returns:
- the queue with still waiting publish job
-
getReportContents
Returns the content of the publish report assigned to the given publish job.- Parameters:
publishJob
- the published job- Returns:
- the content of the assigned publish report
- Throws:
CmsException
- if something goes wrong
-
getUser
Returns the user identified by the given id.- Parameters:
userId
- the id of the user to retrieve- Returns:
- the user identified by the given id
-
initialize
protected void initialize(CmsObject adminCms, boolean publishQueuePersistance, int publishQueueShutdowntime) throws CmsException Initializes the publish engine.- Parameters:
adminCms
- the admin cmspublishQueuePersistance
- flag if the queue is persistedpublishQueueShutdowntime
- amount of time to wait for a publish job during shutdown- Throws:
CmsException
- if something goes wrong
-
isRunning
Returns the working state, that is if no publish job is waiting to be processed and there is no current running publish job.- Returns:
- the working state
-
lockPublishList
Sets publish locks of resources in a publish list.- Parameters:
publishJob
- the publish job- Throws:
CmsException
- if something goes wrong
-
publishJobFinished
Signalizes that the publish thread finishes.- Parameters:
publishJob
- the finished publish job
-
publishJobRemoved
A publish job has been permanently removed from the history.- Parameters:
publishJob
- the removed publish job
-
publishJobStarted
Signalizes that the publish thread starts.- Parameters:
publishJob
- the started publish job
-
removePublishListener
Removes the given publish listener.- Parameters:
listener
- the publish listener to remove
-
sendMessage
Sends a message to the given user, if publish notification is enabled or an error is shown in the message.- Parameters:
toUserId
- the id of the user to send the message tomessage
- the message to sendhasErrors
- flag to determine if the message to send shows an error
-
startEngine
Starts the publish engine, i.e. publish jobs are accepted and processed. -
stopEngine
Stops the publish engine, i.e. publish jobs are still accepted but not published. -
unlockPublishList
Removes all publish locks of resources in a publish list of a publish job.- Parameters:
publishJob
- the publish job- Throws:
CmsException
- if something goes wrong
-