Class CmsPublishEngine


  • public final class CmsPublishEngine
    extends java.lang.Object
    This class is responsible for the publish process.

    Since:
    6.5.5
    • Method Detail

      • abandonThread

        public void abandonThread()
        Abandons the given publish thread.

      • 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 for
        publishList - the resources to publish
        report - the report to write to
        Throws:
        CmsException - if something goes wrong while cloning the cms context
      • getJobByPublishHistoryId

        public CmsPublishJobBase getJobByPublishHistoryId​(CmsUUID publishHistoryId)
        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

        public void setDriverManager​(CmsDriverManager driverManager)
        Sets the driver manager instance.

        Parameters:
        driverManager - the driver manager instance
      • shutDown

        public void 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.

      • disableEngine

        protected void disableEngine()
        Disables the publish engine, i.e. publish jobs are not accepted.

      • enableEngine

        protected void enableEngine()
        Enables the publish engine, i.e. publish jobs are accepted.

      • getCurrentPublishJob

        protected org.opencms.publish.CmsPublishThread getCurrentPublishJob()
        Returns the current running publish job.

        Returns:
        the current running publish job
      • getDbContext

        protected CmsDbContext getDbContext​(CmsRequestContext ctx)
        Returns the a new db context object.

        Parameters:
        ctx - optional request context, can be null
        Returns:
        the a new db context object
      • getPublishHistory

        protected CmsPublishHistory getPublishHistory()
        Returns the publish history list with already publish job.

        Returns:
        the publish history list with already publish job
      • getPublishQueue

        protected CmsPublishQueue getPublishQueue()
        Returns the queue with still waiting publish job.

        Returns:
        the queue with still waiting publish job
      • getReportContents

        protected byte[] getReportContents​(CmsPublishJobFinished publishJob)
                                    throws CmsException
        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

        protected CmsUser getUser​(CmsUUID userId)
        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 cms
        publishQueuePersistance - flag if the queue is persisted
        publishQueueShutdowntime - amount of time to wait for a publish job during shutdown
        Throws:
        CmsException - if something goes wrong
      • isRunning

        protected boolean 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
      • publishJobRemoved

        protected void publishJobRemoved​(CmsPublishJobInfoBean publishJob)
        A publish job has been permanently removed from the history.

        Parameters:
        publishJob - the removed publish job
      • sendMessage

        protected void sendMessage​(CmsUUID toUserId,
                                   java.lang.String message,
                                   boolean hasErrors)
        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 to
        message - the message to send
        hasErrors - flag to determine if the message to send shows an error
      • startEngine

        protected void startEngine()
        Starts the publish engine, i.e. publish jobs are accepted and processed.

      • stopEngine

        protected void stopEngine()
        Stops the publish engine, i.e. publish jobs are still accepted but not published.