Initializes the internal FIFO queue with publish jobs from the database.<p>

@param adminCms an admin cms object
@param revive <code>true</code> if the publish queue should be revived from the database
502750
protected void initialize(CmsObject adminCms, boolean revive) {

        CmsDriverManager driverManager = m_publishEngine.getDriverManager();

        try {
            OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PUBLISH_QUEUE);
            if (revive) {
                // read all pending publish jobs from the database
                CmsDbContext dbc = m_publishEngine.getDbContext(null);
                List<CmsPublishJobInfoBean> publishJobs = null;
                try {
                    publishJobs = driverManager.readPublishJobs(dbc, 0L, 0L);
                } catch (Exception e) {
                    dbc.rollback();
                } finally {
                    dbc.clear();
                    dbc = null;
                }
                if (publishJobs != null) {
                    for (Iterator<CmsPublishJobInfoBean> i = publishJobs.iterator(); i.hasNext();) {
                        CmsPublishJobInfoBean job = i.next();
                        dbc = m_publishEngine.getDbContext(null);
                        if (!job.isStarted()) {
                            // add jobs not already started to queue again
                            try {
                                job.revive(adminCms, driverManager.readPublishList(dbc, job.getPublishHistoryId()));
                                m_publishEngine.lockPublishList(job);
                                OpenCms.getMemoryMonitor().cachePublishJob(job);
                            } catch (CmsException exc) {
                                // skip job
                                dbc.rollback();
                                if (LOG.isErrorEnabled()) {
                                    LOG.error(
                                        Messages.get().getBundle().key(
                                            Messages.ERR_PUBLISH_JOB_INVALID_1,
                                            job.getPublishHistoryId()),
                                        exc);
                                }
                                m_publishEngine.getDriverManager().deletePublishJob(dbc, job.getPublishHistoryId());
                            } finally {
                                dbc.clear();
                            }
                        } else {
                            try {
                                // remove locks, set finish info and move job to history
                                job.revive(adminCms, driverManager.readPublishList(dbc, job.getPublishHistoryId()));
                                m_publishEngine.unlockPublishList(job);
                                new CmsPublishJobEnqueued(job).m_publishJob.finish();
                                m_publishEngine.getPublishHistory().add(job);
                            } catch (CmsException exc) {
                                dbc.rollback();
                                LOG.error(exc.getLocalizedMessage(), exc);
                            } finally {
                                dbc.clear();
                            }
                        }
                    }
                }
            }
        } catch (CmsException exc) {
            if (LOG.isErrorEnabled()) {
                LOG.error(exc.getLocalizedMessage(), exc);
            }
        }
    }
521319
protected void persistData() {

        try {
            // save the resource locks to db
            m_securityManager.writeLocks();
            // save the log entries to db
            m_securityManager.updateLog();
        } catch (Throwable t) {
            if (LOG.isErrorEnabled()) {
                LOG.error(
                    org.opencms.lock.Messages.get().getBundle().key(org.opencms.lock.Messages.ERR_WRITE_LOCKS_0),
                    t);
            }
        }
    }
893216
public void initialize(CmsObject cms) {

        if (!m_availableLocales.contains(Locale.ENGLISH)) {
            throw new RuntimeException("The locale 'en' must be configured in opencms-system.xml.");
        }
        // init the locale handler
        m_localeHandler.initHandler(cms);
        // set default locale
        m_defaultLocale = m_defaultLocales.get(0);
        initLanguageDetection();
        // set initialized status
        m_initialized = true;
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_I18N_CONFIG_VFSACCESS_0));
        }
    }
101685
private void iniCmsObject() {

        try {
            m_cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            m_cms.getRequestContext().setSiteRoot("");
        } catch (CmsException e) {
            LOG.error("Unable to clone CmsObject", e);
        }
    }
523791
private void showConfirmOverwrite(List<CmsResource> collidingResources) {

        final Window window = CmsBasicDialog.prepareWindow();
        window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_TITLE_0));
        final CmsConfirmationDialog dialog = new CmsConfirmationDialog(
            CmsVaadinUtils.getMessageText(Messages.GUI_COPY_MOVE_CONFIRM_OVERWRITE_MESSAGE_0),
            new Runnable() {

                public void run() {

                    window.close();
                    submit(true, null);
                }
            },
            new Runnable() {

                public void run() {

                    window.close();
                    cancel();
                }
            });
        dialog.displayResourceInfo(collidingResources);
        window.setContent(dialog);
        UI.getCurrent().addWindow(window);
    }
1159341
private void updateNoUploadReason(CmsObject searchCms, CmsGallerySearchBean searchObj) {

        if ((searchObj.getGalleries().size() + searchObj.getFolders().size()) == 1) {
            String target = !searchObj.getGalleries().isEmpty()
            ? searchObj.getGalleries().get(0)
            : searchObj.getFolders().iterator().next();
            try {
                CmsResource targetRes;
                if (searchCms.existsResource(target, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                    targetRes = searchCms.readResource(target, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
                } else {
                    CmsObject rootCms = OpenCms.initCmsObject(searchCms);
                    rootCms.getRequestContext().setSiteRoot("");
                    targetRes = rootCms.readResource(target, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
                }
                searchObj.setNoUploadReason(
                    new CmsResourceUtil(searchCms, targetRes).getNoEditReason(getWorkplaceLocale(), true));
            } catch (CmsException e) {
                searchObj.setNoUploadReason(e.getLocalizedMessage(getWorkplaceLocale()));
            }
        } else {
            searchObj.setNoUploadReason(null);
        }
    }
353645
protected void publishJobStarted(CmsPublishJobInfoBean publishJob) {

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

        // fire the publish start event
        m_listeners.fireStart(new CmsPublishJobEnqueued(publishJob));
    }
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()));
        }
    }
113701
public void onBeforeSetEditorMode(final EditorMode mode) {

        EditorMode oldMode = m_editorMode;
        if ((oldMode == EditorMode.categories) && ((mode == EditorMode.vfs) || (mode == EditorMode.navigation))) {
            final CmsRpcAction<Void> action = new CmsRpcAction<Void>() {

                @Override
                public void execute() {

                    start(200, true);
                    getController().refreshRoot(this);
                }

                @Override
                protected void onResponse(Void result) {

                    stop(false);
                    setEditorMode(mode);
                }
            };
            action.execute();
        } else {
            setEditorMode(mode);
        }

    }
1050457
public void initialize(CmsObject cms) throws CmsException {

        m_publishEngine.initialize(cms, m_publishQueuePersistance, m_publishQueueShutdowntime);
        m_frozen = true;
    }
1145974
public void publish() {

        CmsDirectPublishDialogAction action = new CmsDirectPublishDialogAction();
        List<CmsResource> resources = getBundleResources();
        I_CmsDialogContext context = new A_CmsDialogContext("", ContextType.appToolbar, resources) {

            public void focus(CmsUUID structureId) {

                //Nothing to do.
            }

            public List<CmsUUID> getAllStructureIdsInView() {

                return null;
            }

            public void updateUserInfo() {

                //Nothing to do.
            }
        };
        action.executeAction(context);
        updateLockInformation();

    }
19042
public synchronized void setCms(CmsObject cms) {

        if (m_perThreadCmsObject == null) {
            m_perThreadCmsObject = new ThreadLocal<CmsObject>();
        }
        m_perThreadCmsObject.set(cms);
    }
1184896
protected void start(CmsUUID threadUUID) {

        if (m_startTime != 0) {
            throw new CmsRuntimeException(Messages.get().container(Messages.ERR_PUBLISH_JOB_ALREADY_STARTED_0));
        }
        m_startTime = System.currentTimeMillis();
        m_threadUUID = threadUUID;
        if (getPublishReport() instanceof CmsPublishReport) {
            ((CmsPublishReport)m_publishReport).start();
        }
    }
675382
public static function adminInit( $callback, $priority = null, $accepted_args = null ) {
		self::action( 'admin_init', $callback, $priority, $accepted_args );
	}
65772
public void prepareUpdateStep1b() {

        if (!isInitialized()) {
            return;
        }

        if ((m_dbUpdateThread != null) && (m_dbUpdateThread.isFinished())) {
            // update is already finished, just wait for client to collect final data
            return;
        }

        if (m_dbUpdateThread == null) {
            m_dbUpdateThread = new CmsUpdateDBThread(this);
        }

        if (!m_dbUpdateThread.isAlive()) {
            m_dbUpdateThread.start();
        }
    }
814660
public void reinitServiceDirectoryManagerFactory(ServiceDirectoryManagerFactory factory) throws ServiceException{
        if (factory == null) {
            throw new IllegalArgumentException("The ServiceDirectoryManagerFactory cannot be NULL.");
        }

        synchronized(this){
            if(isShutdown){
                ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_IS_SHUTDOWN);
                throw new ServiceException(error);
            }

            if (this.directoryManagerFactory != null) {

                if (directoryManagerFactory instanceof Closable) {
                    ((Closable) directoryManagerFactory).stop();
                }

                LOGGER.info("Resetting ServiceDirectoryManagerFactory, old="
                        + this.directoryManagerFactory.getClass().getName()
                        + ", new=" + factory.getClass().getName() + ".");

                this.directoryManagerFactory = factory;
            } else {
                this.directoryManagerFactory = factory;
                LOGGER.info("Setting ServiceDirectoryManagerFactory,  factory="
                        + factory.getClass().getName() + ".");
            }
            this.directoryManagerFactory.initialize(this);
        }
    }
732409
protected void initialize() {

        CmsDriverManager driverManager = m_publishEngine.getDriverManager();
        CmsDbContext dbc = m_publishEngine.getDbContext(null);

        try {
            OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PUBLISH_HISTORY);
            // read all finished published jobs from the database
            List<CmsPublishJobInfoBean> publishJobs = driverManager.readPublishJobs(dbc, 1L, Long.MAX_VALUE);
            for (Iterator<CmsPublishJobInfoBean> i = publishJobs.iterator(); i.hasNext();) {
                CmsPublishJobInfoBean job = i.next();
                OpenCms.getMemoryMonitor().cachePublishJobInHistory(job);
            }
        } catch (CmsException exc) {
            dbc.rollback();
            if (LOG.isErrorEnabled()) {
                LOG.error(exc.getLocalizedMessage(), exc);
            }
        } finally {
            dbc.clear();
        }
    }