/** * Publishes the current project and waits until it finishes.<p> * * @throws Exception if something goes wrong */ public void publishProjectAndWait() throws Exception { OpenCms.getPublishManager().publishProject(m_cms); OpenCms.getPublishManager().waitWhileRunning(); }
/** * Publishes the current project.<p> * * @param report an instance of <code>{@link I_CmsReport}</code> to print messages * * @return the publish history id of the published project * * @throws CmsException if something goes wrong * * @deprecated use <code>{@link OpenCms#getPublishManager()}.{@link org.opencms.publish.CmsPublishManager#publishProject(CmsObject, I_CmsReport) publishProject(CmsObject, I_CmsReport)}</code> instead */ public CmsUUID publishProject(I_CmsReport report) throws CmsException { CmsUUID publishHistoryId = OpenCms.getPublishManager().publishProject( this, report, OpenCms.getPublishManager().getPublishList(this)); OpenCms.getPublishManager().waitWhileRunning(); return publishHistoryId; }
/** * Returns the publish history list with already publish jobs, filtered by the given user.<p> * * @param user the user to filter the jobs with * * @return a list of {@link CmsPublishJobFinished} objects */ public List<CmsPublishJobFinished> getPublishHistory(CmsUser user) { List<CmsPublishJobFinished> result = new ArrayList<CmsPublishJobFinished>(); Iterator<CmsPublishJobFinished> it = getPublishHistory().iterator(); while (it.hasNext()) { CmsPublishJobFinished publishJob = it.next(); if (publishJob.getUserId().equals(user.getId())) { result.add(publishJob); } } return result; }
/** * Publishes the current project.<p> * * @param cms the cms request context * @param report an instance of <code>{@link I_CmsReport}</code> to print messages * * @return the publish history id of the published project * * @throws CmsException if something goes wrong */ public CmsUUID publishProject(CmsObject cms, I_CmsReport report) throws CmsException { return publishProject(cms, report, getPublishList(cms)); }
OpenCms.getPublishManager().validateRelations( cms, OpenCms.getPublishManager().getPublishList(cms), report); OpenCms.getPublishManager().publishProject(cms, report); OpenCms.getPublishManager().waitWhileRunning(); finishMessage = Messages.get().getBundle().key(Messages.LOG_PUBLISH_FINISHED_1, project.getName()); } catch (CmsException e) {
/** * Publishes a single resource.<p> * * @param cms the cms request context * @param resourcename the name of the resource to be published * @param publishSiblings if <code>true</code>, all siblings of the resource are also published * @param report the report to write the progress information to * * @return the publish history id of the published project * * @throws Exception if something goes wrong */ public CmsUUID publishResource(CmsObject cms, String resourcename, boolean publishSiblings, I_CmsReport report) throws Exception { CmsResource resource = cms.readResource(resourcename, CmsResourceFilter.ALL); return publishProject(cms, report, resource, publishSiblings); }
/** * Returns a publish list with all new/changed/deleted resources of the current (offline) * project that actually get published for a direct publish of a List of resources.<p> * * @param cms the cms request context * @param directPublishResources the resources which will be directly published * @param directPublishSiblings <code>true</code>, if all eventual siblings of the direct * published resources should also get published. * * @return a publish list * * @throws CmsException if something goes wrong */ public CmsPublishList getPublishList(CmsObject cms, List directPublishResources, boolean directPublishSiblings) throws CmsException { return getPublishList(cms, directPublishResources, directPublishSiblings, true); }
/** * Imports a module (zipfile) from the default module directory, * creating a temporary project for this.<p> * * @param moduleName the name of the module to replace * @param importFile the name of the import .zip file located in the update module directory * @param report the shell report to write the output * * @throws Exception if something goes wrong * * @see org.opencms.importexport.CmsImportExportManager#importData(org.opencms.file.CmsObject, I_CmsReport, org.opencms.importexport.CmsImportParameters) */ protected void updateModule(String moduleName, String importFile, I_CmsReport report) throws Exception { String fileName = getModuleFolder() + importFile; report.println( Messages.get().container(Messages.RPT_BEGIN_UPDATE_MODULE_1, moduleName), I_CmsReport.FORMAT_HEADLINE); removeModule(moduleName, report); OpenCms.getPublishManager().stopPublishing(); OpenCms.getPublishManager().startPublishing(); OpenCms.getPublishManager().waitWhileRunning(); OpenCms.getImportExportManager().importData(m_cms, report, new CmsImportParameters(fileName, "/", true)); report.println( Messages.get().container(Messages.RPT_END_UPDATE_MODULE_1, moduleName), I_CmsReport.FORMAT_HEADLINE); OpenCms.getPublishManager().stopPublishing(); OpenCms.getPublishManager().startPublishing(); OpenCms.getPublishManager().waitWhileRunning(); }
/** * Publishes the given list of resources.<p> * * @param resources list of resources to publish * * @throws CmsException if something goes wrong */ public void publishResources(List<CmsResource> resources) throws CmsException { CmsObject cms = m_cms; I_CmsReport report = new CmsHtmlReport( cms.getRequestContext().getLocale(), cms.getRequestContext().getSiteRoot()); CmsPublishManager publishManager = OpenCms.getPublishManager(); CmsPublishList publishList = publishManager.getPublishListAll(m_cms, resources, false, true); OpenCms.getPublishManager().publishProject(m_cms, report, publishList); }
/** * @see org.opencms.workplace.list.A_CmsListResourceCollector#getResources(org.opencms.file.CmsObject, java.util.Map) */ @Override public List<CmsResource> getResources(CmsObject cms, Map<String, String> params) { if (m_publishRelated && getSettings().getPublishList().isDirectPublish()) { try { CmsPublishList relatedPL = OpenCms.getPublishManager().getRelatedResourcesToPublish( cms, getSettings().getPublishList()); CmsPublishList mergedPL = OpenCms.getPublishManager().mergePublishLists( cms, getSettings().getPublishList(), relatedPL); m_publishList = mergedPL; } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(getLocale()), e); } } } else { m_publishList = getSettings().getPublishList(); } return m_publishList.getAllResources(); }
/** * Publishes a single resource, printing messages to a shell report.<p> * * The siblings of the resource will not be published.<p> * * @param resourcename the name of the resource to be published * * @return the publish history id of the published project * * @throws Exception if something goes wrong * * @see CmsShellReport * * @deprecated use <code>{@link OpenCms#getPublishManager()}.{@link org.opencms.publish.CmsPublishManager#publishResource(CmsObject, String) publishResource(CmsObject, String)}</code> instead */ public CmsUUID publishResource(String resourcename) throws Exception { CmsUUID publishHistoryId = OpenCms.getPublishManager().publishResource( this, resourcename, false, new CmsShellReport(m_context.getLocale())); OpenCms.getPublishManager().waitWhileRunning(); return publishHistoryId; }
m_publishManager.setPublishEngine(m_publishEngine); m_publishManager.setSecurityManager(m_securityManager); m_publishManager.initialize(initCmsObject(adminCms)); m_publishManager.startPublishing(); } catch (CmsException e) { throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_MANAGERS_0), e);
/** * Waits until no publish jobs remain.<p> */ public void waitWhileRunning() { waitWhileRunning(Long.MAX_VALUE); }
if (OpenCms.getPublishManager().isRunning()) { CmsPublishJobRunning currentJob = OpenCms.getPublishManager().getCurrentPublishJob(); if (currentJob != null) { CmsListItem item = getList().newItem(currentJob.getPublishList().getPublishHistoryId().toString()); Iterator iter = OpenCms.getPublishManager().getPublishQueue().iterator(); while (iter.hasNext()) { CmsPublishJobEnqueued publishJob = (CmsPublishJobEnqueued)iter.next();
publishList = OpenCms.getPublishManager().getPublishListAll( m_cms, pubResources, true); if (m_options.isIncludeRelated()) { CmsPublishList related = publishManager.getRelatedResourcesToPublish(m_cms, publishList); publishList = publishManager.mergePublishLists(m_cms, publishList, related);
CmsPublishJobRunning publishJob = publishManager.getCurrentPublishJob(); if (publishJob == null) { publishManager.checkCurrentPublishJobThread(); return; publishManager.abandonThread();
CmsPublishJobRunning publishJob = publishManager.getCurrentPublishJob(); if (publishJob != null) { publishManager.checkCurrentPublishJobThread();
/** * Waits until no publish jobs remain or the given max milliseconds.<p> * * @param ms the max milliseconds to wait */ public void waitWhileRunning(long ms) { int i = 0; // wait until it is done or time is over synchronized (this) { try { this.wait(100); // wait a bit to give the publish engine the chance to actualize the state } catch (InterruptedException e) { // ignore e.printStackTrace(); } while (isRunning() && ((MS_ONE_SECOND * i) <= ms)) { try { this.wait(MS_ONE_SECOND); // wait a second } catch (InterruptedException e) { // ignore e.printStackTrace(); } i++; } } }
CmsPublishJobRunning publishJob = OpenCms.getPublishManager().getCurrentPublishJob(); if (publishJob == null) { throw new Exception(); setAction(ACTION_DEFAULT); CmsPublishJobRunning publishJob = OpenCms.getPublishManager().getCurrentPublishJob();
/** * Finishes the startup sequence after last runlevel upgrade.<p> */ private void afterUpgradeRunlevel() { try { // read the persistent locks m_instance.m_securityManager.readLocks(); } catch (CmsException e) { if (LOG.isErrorEnabled()) { LOG.error( org.opencms.lock.Messages.get().getBundle().key(org.opencms.lock.Messages.ERR_READ_LOCKS_0), e); } } // everything is initialized, now start publishing m_publishManager.startPublishing(); }