/** * Initializes the internal FIFO queue with publish jobs from the database.<p> */ protected void initialize() { CmsDriverManager driverManager = m_publishEngine.getDriverManager(); CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { OpenCms.getMemoryMonitor().flushCache(CmsMemoryMonitor.CacheType.PUBLISH_HISTORY); // read all finished published jobs from the database List publishJobs = driverManager.readPublishJobs(dbc, 1L, Long.MAX_VALUE); for (Iterator i = publishJobs.iterator(); i.hasNext();) { CmsPublishJobInfoBean job = (CmsPublishJobInfoBean)i.next(); OpenCms.getMemoryMonitor().cachePublishJobInHistory(job); } } catch (CmsException exc) { if (LOG.isErrorEnabled()) { LOG.error(exc.getLocalizedMessage(), exc); } } finally { dbc.clear(); } }
/** * Sets publish locks of resources in a publish list.<p> * * @param publishJob the publish job * @throws CmsException if something goes wrong */ protected void lockPublishList(CmsPublishJobInfoBean publishJob) throws CmsException { CmsPublishList publishList = publishJob.getPublishList(); // lock them CmsDbContext dbc = getDbContextFactory().getDbContext(publishJob.getCmsObject().getRequestContext()); try { Iterator itResources = publishList.getAllResources().iterator(); while (itResources.hasNext()) { CmsResource resource = (CmsResource)itResources.next(); m_driverManager.lockResource(dbc, resource, CmsLockType.PUBLISH); } } finally { dbc.clear(); } }
/** * Removes all publish locks of resources in a publish list of a publish job.<p> * * @param publishJob the publish job * @throws CmsException if something goes wrong */ protected void unlockPublishList(CmsPublishJobInfoBean publishJob) throws CmsException { CmsPublishList publishList = publishJob.getPublishList(); List allResources = publishList.getAllResources(); // unlock them CmsDbContext dbc = getDbContextFactory().getDbContext(publishJob.getCmsObject().getRequestContext()); try { Iterator itResources = allResources.iterator(); while (itResources.hasNext()) { CmsResource resource = (CmsResource)itResources.next(); m_driverManager.unlockResource(dbc, resource, true, true); } } finally { dbc.clear(); } }
/** * Updates the given job in the list.<p> * * @param publishJob the publish job to */ protected void update(CmsPublishJobInfoBean publishJob) { if (OpenCms.getMemoryMonitor().requiresPersistency()) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { m_publishEngine.getDriverManager().writePublishJob(dbc, publishJob); } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } finally { dbc.clear(); } } } }
if (revive) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); List publishJobs; try { dbc = m_publishEngine.getDbContextFactory().getDbContext(); if (!job.isStarted()) {
/** * Pushes a new publish job with the given information in publish queue.<p> * * If possible, the publish job starts immediately.<p> * * @param publishJob the publish job to enqueue * * @throws CmsException if something goes wrong */ protected void add(CmsPublishJobInfoBean publishJob) throws CmsException { // set the queue status in the publish job publishJob.enqueue(); // add job to database if necessary if (OpenCms.getMemoryMonitor().requiresPersistency()) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { // this operation may in rare circumstances fail with a DB exception // if this is the case the publish job must NOT be in the queue m_publishEngine.getDriverManager().createPublishJob(dbc, publishJob); } finally { dbc.clear(); } } // add publish job to cache OpenCms.getMemoryMonitor().cachePublishJob(publishJob); }
/** * Removes the given job from the list.<p> * * @param publishJob the publish job to remove * * @throws CmsException if something goes wrong */ protected void remove(CmsPublishJobInfoBean publishJob) throws CmsException { try { // signalizes that job will be removed m_publishEngine.publishJobRemoved(publishJob); } finally { // remove publish job from cache OpenCms.getMemoryMonitor().uncachePublishJob(publishJob); } // remove job from database if necessary if (OpenCms.getMemoryMonitor().requiresPersistency()) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { m_publishEngine.getDriverManager().deletePublishJob(dbc, publishJob.getPublishHistoryId()); } finally { dbc.clear(); } } }
/** * Removes the given job from the list.<p> * * @param publishJob the publish job to remove * * @throws CmsException if something goes wrong */ protected void remove(CmsPublishJobInfoBean publishJob) throws CmsException { OpenCms.getMemoryMonitor().uncachePublishJobInHistory(publishJob); // delete job from db if necessary if (OpenCms.getMemoryMonitor().requiresPersistency()) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { OpenCms.getPublishManager().getEngine().getDriverManager().deletePublishJob( dbc, publishJob.getPublishHistoryId()); } finally { dbc.clear(); } } m_publishEngine.publishJobRemoved(publishJob); } }
/** * Adds the given publish job to the list.<p> * * @param publishJob the publish job object to add * * @throws CmsException if something goes wrong */ protected void add(CmsPublishJobInfoBean publishJob) throws CmsException { OpenCms.getMemoryMonitor().cachePublishJobInHistory(publishJob); // write job to db if necessary if (OpenCms.getMemoryMonitor().requiresPersistency()) { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(); try { m_publishEngine.getDriverManager().writePublishJob(dbc, publishJob); // additionally, write the publish report m_publishEngine.getDriverManager().writePublishReport(dbc, publishJob); // delete publish list of started job m_publishEngine.getDriverManager().deletePublishList(dbc, publishJob.getPublishHistoryId()); } finally { dbc.clear(); } } }
CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(getCms().getRequestContext()); try { CmsDbContext dbc = m_publishEngine.getDbContextFactory().getDbContext(getCms().getRequestContext()); try {