Signalizes that the publish thread starts.<p>

@param publishJob the started publish job
353645
protected void publishJobStarted(CmsPublishJobInfoBean publishJob) {

        // update the job
        m_publishQueue.update(publishJob);

        // fire the publish start event
        m_listeners.fireStart(new CmsPublishJobEnqueued(publishJob));
    }
164077
private void publishEvent(WSJobExecution objectToPublish, String eventToPublishTo, String correlationId) {
        if (eventsPublisher != null) {
            eventsPublisher.publishJobExecutionEvent(objectToPublish, eventToPublishTo, correlationId);
        }
    }
79307
private void publish(String buffer){
        CommandResult out = new CommandResult(myType);

        out.setContent(buffer);

        synchronized (lock) {
            publisher.publish(topic, out.toString());
        }
    }
952123
protected void startEngine() {

        if (m_engineState != CmsPublishEngineState.ENGINE_STARTED) {
            m_engineState = CmsPublishEngineState.ENGINE_STARTED;
            // start publish job if jobs waiting
            if ((m_currentPublishThread == null) && !m_publishQueue.isEmpty()) {
                checkCurrentPublishJobThread();
            }
        }
    }
418349
public void deletePublishJob(CmsDbContext dbc, CmsUUID publishHistoryId) throws CmsException {

        getProjectDriver(dbc).deletePublishJob(dbc, publishHistoryId);
    }
1341194
public void publishInternal(Object message) {
        topicStats.incrementPublishes();
        topicService.publishMessage(name, message, multithreaded);
    }
462146
protected void doPublishEvent(final ApplicationEvent e) {
        if (applicationEventPublisher != null) {
            LOGGER.trace("Publishing [{}]", e);
            this.applicationEventPublisher.publishEvent(e);
        }
    }
1104104
public void onCancel() {

        if (m_publishSelectPanel.m_model != null) {
            final List<CmsUUID> toRemove = m_publishSelectPanel.m_model.getIdsOfAlreadyPublishedResources();
            if (toRemove.isEmpty()) {
                hide();
            } else {
                CmsRpcAction<CmsWorkflowResponse> action = new CmsRpcAction<CmsWorkflowResponse>() {

                    @Override
                    public void execute() {

                        start(0, true);
                        CmsWorkflowActionParams params = getWorkflowActionParams();
                        getService().executeAction(
                            new CmsWorkflowAction(CmsWorkflowAction.ACTION_CANCEL, "", true),
                            params,
                            this);
                    }

                    @Override
                    protected void onResponse(CmsWorkflowResponse result) {

                        stop(false);
                        hide();

                    }
                };
                action.execute();
            }
        } else {
            hide();
        }
    }
1194139
public void publish() {
        /*
         * Some care is required here to correctly swap the DataBuffers,
         * but not hold the synchronization object while compiling stats
         * (a potentially long computation).  This ensures that continued
         * data collection (calls to noteValue()) will not be blocked for any
         * significant period.
         */
        DataBuffer tmp = null;
        Lock l = null;
        synchronized (swapLock) {
            // Swap buffers
            tmp = current;
            current = previous;
            previous = tmp;
            // Start collection in the new "current" buffer
            l = current.getLock();
            l.lock();
            try {
                current.startCollection();
            } finally {
                l.unlock();
            }
            // Grab lock on new "previous" buffer
            l = tmp.getLock();
            l.lock();
        }
        // Release synchronizaton *before* publishing data
        try {
            tmp.endCollection();
            publish(tmp);
        } finally {
            l.unlock();
        }
    }
720733
public void onPost(final GitHubTriggerEvent event) {
        if (Objects.isNull(job)) {
            return; // nothing to do
        }

        Job<?, ?> currentJob = notNull(job, "Job can't be null");

        final String pushBy = event.getTriggeredByUser();
        DescriptorImpl d = getDescriptor();
        d.checkThreadPoolSizeAndUpdateIfNecessary();
        d.queue.execute(new Runnable() {
            private boolean runPolling() {
                try {
                    StreamTaskListener listener = new StreamTaskListener(getLogFileForJob(currentJob));

                    try {
                        PrintStream logger = listener.getLogger();

                        long start = System.currentTimeMillis();
                        logger.println("Started on " + DateFormat.getDateTimeInstance().format(new Date()));
                        if (event.getOrigin() != null) {
                            logger.format("Started by event from %s on %tc%n", event.getOrigin(), event.getTimestamp());
                        }
                        SCMTriggerItem item = SCMTriggerItems.asSCMTriggerItem(currentJob);
                        if (null == item) {
                            throw new IllegalStateException("Job is not an SCMTriggerItem: " + currentJob);
                        }
                        boolean result = item.poll(listener).hasChanges();
                        logger.println("Done. Took " + Util.getTimeSpanString(System.currentTimeMillis() - start));
                        if (result) {
                            logger.println("Changes found");
                        } else {
                            logger.println("No changes");
                        }
                        return result;
                    } catch (Error e) {
                        e.printStackTrace(listener.error("Failed to record SCM polling"));
                        LOGGER.error("Failed to record SCM polling", e);
                        throw e;
                    } catch (RuntimeException e) {
                        e.printStackTrace(listener.error("Failed to record SCM polling"));
                        LOGGER.error("Failed to record SCM polling", e);
                        throw e;
                    } finally {
                        listener.close();
                    }
                } catch (IOException e) {
                    LOGGER.error("Failed to record SCM polling", e);
                }
                return false;
            }

            public void run() {
                if (runPolling()) {
                    GitHubPushCause cause;
                    try {
                        cause = new GitHubPushCause(getLogFileForJob(currentJob), pushBy);
                    } catch (IOException e) {
                        LOGGER.warn("Failed to parse the polling log", e);
                        cause = new GitHubPushCause(pushBy);
                    }

                    if (asParameterizedJobMixIn(currentJob).scheduleBuild(cause)) {
                        LOGGER.info("SCM changes detected in " + currentJob.getFullName()
                                + ". Triggering #" + currentJob.getNextBuildNumber());
                    } else {
                        LOGGER.info("SCM changes detected in " + currentJob.getFullName()
                                + ". Job is already in the queue");
                    }
                }
            }
        });
    }
358406
private void sendPublishStopNotify() {
        Status stopStatus = new Status(StatusCodes.NS_UNPUBLISHED_SUCCESS);
        stopStatus.setClientid(getStreamId());
        stopStatus.setDetails(getPublishedName());

        StatusMessage stopMsg = new StatusMessage();
        stopMsg.setBody(stopStatus);
        pushMessage(stopMsg);
        setState(StreamState.STOPPED);
    }
78833
protected void fireRemove(CmsPublishJobFinished publishJob) {

        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_PUBLISH_JOB_REMOVE_0));
        }
        for (Iterator<I_CmsPublishEventListener> it = iterator(); it.hasNext();) {
            I_CmsPublishEventListener listener = it.next();
            try {
                listener.onRemove(publishJob);
            } catch (Throwable t) {
                // catch every thing including runtime exceptions
                if (LOG.isErrorEnabled()) {
                    LOG.error(
                        Messages.get().getBundle().key(
                            Messages.ERR_PUBLISH_JOB_REMOVE_ERROR_1,
                            listener.getClass().getName()),
                        t);
                }
                if (publishJob.m_publishJob.getPublishReport() != null) {
                    publishJob.m_publishJob.getPublishReport().println(t);
                }
            }
        }
    }
802747
private void loadJobs() {

        List<CmsPublishJobFinished> publishJobs;
        if (OpenCms.getRoleManager().hasRole(A_CmsUI.getCmsObject(), CmsRole.ROOT_ADMIN)) {
            publishJobs = OpenCms.getPublishManager().getPublishHistory();
        } else {
            publishJobs = OpenCms.getPublishManager().getPublishHistory(
                A_CmsUI.getCmsObject().getRequestContext().getCurrentUser());
        }
        for (CmsPublishJobFinished job : publishJobs) {
            String state = getState(job);
            Item item = m_container.addItem(job);
            item.getItemProperty(PROP_PROJECT).setValue(job.getProjectName().replace("&#47;", "/")); //TODO better way for unescaping..
            try {
                item.getItemProperty(PROP_RESOURCES).setValue(
                    A_CmsUI.getCmsObject().readPublishedResources(job.getPublishHistoryId()));
            } catch (com.vaadin.v7.data.Property.ReadOnlyException | CmsException e) {
                LOG.error("Error while read published Resources", e);
            }
            item.getItemProperty(PROP_STATUS).setValue(state);
            item.getItemProperty(PROP_STATUS_LOCALE).setValue(
                CmsVaadinUtils.getMessageText(STATUS_MESSAGES.get(state)));
            item.getItemProperty(PROP_START).setValue(new Date(job.getStartTime()));
            item.getItemProperty(PROP_STOP).setValue(new Date(job.getFinishTime()));
            item.getItemProperty(PROP_USER).setValue(job.getUserName(A_CmsUI.getCmsObject()));
            item.getItemProperty(PROP_FILESCOUNT).setValue(Integer.valueOf(job.getSize()));

        }
        //Sort table according to start time of jobs
        m_container.sort(new String[] {PROP_START}, new boolean[] {false});

        List<CmsPublishJobBase> jobs = new ArrayList<CmsPublishJobBase>();

        //a) running jobs
        if (OpenCms.getPublishManager().isRunning()) {
            jobs.add(OpenCms.getPublishManager().getCurrentPublishJob());
        }

        //b) queued jobs
        jobs.addAll(OpenCms.getPublishManager().getPublishQueue());
        for (CmsPublishJobBase job : jobs) {
            Item item = m_container.addItemAt(0, job);
            item.getItemProperty(PROP_PROJECT).setValue(job.getProjectName().replace("&#47;", "/")); //TODO better way for unescaping..

            //distinguish between running and enqueued jobs
            if (job instanceof CmsPublishJobRunning) {
                item.getItemProperty(PROP_RESOURCES).setValue(
                    ((CmsPublishJobRunning)job).getPublishList().getAllResources());
                item.getItemProperty(PROP_START).setValue(new Date(((CmsPublishJobRunning)job).getStartTime()));
                item.getItemProperty(PROP_STATUS).setValue(STATE_RUNNING);
                item.getItemProperty(PROP_STATUS_LOCALE).setValue(
                    CmsVaadinUtils.getMessageText(STATUS_MESSAGES.get(STATE_RUNNING)));

            } else {
                item.getItemProperty(PROP_RESOURCES).setValue(
                    ((CmsPublishJobEnqueued)job).getPublishList().getAllResources());
                item.getItemProperty(PROP_STATUS).setValue(STATE_ENQUEUE);
                item.getItemProperty(PROP_STATUS_LOCALE).setValue(
                    CmsVaadinUtils.getMessageText(STATUS_MESSAGES.get(STATE_ENQUEUE)));

            }
            item.getItemProperty(PROP_USER).setValue(job.getUserName(A_CmsUI.getCmsObject()));
            item.getItemProperty(PROP_FILESCOUNT).setValue(Integer.valueOf(job.getSize()));
        }
    }
958319
protected void publishJobFinished(CmsPublishJobInfoBean publishJob) {

        // in order to avoid not removable publish locks, unlock all assigned resources again
        try {
            unlockPublishList(publishJob);
        } catch (Throwable t) {
            // log failure, most likely a database problem
            LOG.error(t.getLocalizedMessage(), t);
        }

        // trigger the old event mechanism
        CmsDbContext dbc = m_dbContextFactory.getDbContext(publishJob.getCmsObject().getRequestContext());
        try {
            // fire an event that a project has been published
            Map<String, Object> eventData = new HashMap<String, Object>();
            eventData.put(I_CmsEventListener.KEY_REPORT, publishJob.getPublishReport());
            eventData.put(
                I_CmsEventListener.KEY_PUBLISHID,
                publishJob.getPublishList().getPublishHistoryId().toString());
            eventData.put(I_CmsEventListener.KEY_PROJECTID, dbc.currentProject().getUuid());
            eventData.put(I_CmsEventListener.KEY_DBCONTEXT, dbc);
            CmsEvent afterPublishEvent = new CmsEvent(I_CmsEventListener.EVENT_PUBLISH_PROJECT, eventData);
            OpenCms.fireCmsEvent(afterPublishEvent);
        } catch (Throwable t) {
            if (dbc != null) {
                dbc.rollback();
            }
            LOG.error(t.getLocalizedMessage(), t);
            // catch every thing including runtime exceptions
            publishJob.getPublishReport().println(t);
        } finally {
            if (dbc != null) {
                try {
                    dbc.clear();
                } catch (Throwable t) {
                    // ignore
                }
                dbc = null;
            }
        }
        try {
            // fire the publish finish event
            m_listeners.fireFinish(new CmsPublishJobRunning(publishJob));
        } catch (Throwable t) {
            // log failure, most likely a database problem
            LOG.error(t.getLocalizedMessage(), t);
        }
        try {
            // finish the job
            publishJob.finish();
        } catch (Throwable t) {
            // log failure, most likely a database problem
            LOG.error(t.getLocalizedMessage(), t);
        }
        try {
            // put the publish job into the history list
            m_publishHistory.add(publishJob);
        } catch (Throwable t) {
            // log failure, most likely a database problem
            LOG.error(t.getLocalizedMessage(), t);
        }
        if (Thread.currentThread() == m_currentPublishThread) {
            // wipe the dead thread, only if this thread has not been abandoned
            m_currentPublishThread = null;
        }
        // clear the published resources cache
        OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PUBLISHED_RESOURCES);
        // try to start a new publish job
        checkCurrentPublishJobThread();
    }
1008130
@Override
  public <T> T publish(Class<T> beanType, Object id, Transaction transaction) {
    methodCalls.add(MethodCall.of(PUBLISH).with("beanType", beanType).with("id", id));
    return !persistPublish ? null : publish.publish(beanType, id, transaction);
  }
115171
public void publishAllOutstanding() {
    messagesBatchLock.lock();
    OutstandingBatch batchToSend;
    try {
      if (messagesBatch.isEmpty()) {
        return;
      }
      batchToSend = messagesBatch.popOutstandingBatch();
    } finally {
      messagesBatchLock.unlock();
    }
    publishOutstandingBatch(batchToSend);
  }
1122639
protected void checkPublishQueue() {

        // check the publish manager if the current thread is still active
        try {
            CmsPublishManager publishManager = OpenCms.getPublishManager();
            if (publishManager == null) {
                // this can happen during shutdown
                return;
            }
            // get the current publish job
            CmsPublishJobRunning publishJob = publishManager.getCurrentPublishJob();
            if (publishJob == null) {
                // try to start next job
                publishManager.checkCurrentPublishJobThread();
                return;
            }
            // get the thread id of the current publish job
            CmsUUID uid = publishJob.getThreadUUID();
            if ((uid == null) || (uid.isNullUUID())) {
                return;
            }
            // find the thread
            A_CmsReportThread thread = m_threads.get(uid);
            if (thread == null) {
                return;
            }
            // check if the report still has output and so is active
            if ((System.currentTimeMillis() - thread.getLastEntryTime()) > (UPDATE_MINUTES_INTERVAL
                * ONE_MINUTE_IN_MILLIS)) {
                // remove it
                m_threads.remove(thread);
                // abandon thread
                publishManager.abandonThread();
            }
        } catch (Throwable t) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_THREADSTORE_CHECK_PUBLISH_THREAD_ERROR_0), t);
        }
    }