/** * @see org.opencms.main.CmsRuntimeException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsRuntimeException createException(CmsMessageContainer container, Throwable cause) { return new CmsInitException(container, cause); }
/** * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(ServletContextEvent event) { try { // destroy the OpenCms instance OpenCmsCore.getInstance().shutDown(); } catch (CmsInitException e) { if (e.isNewError()) { LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }
/** * Returns the initialized OpenCms singleton instance.<p> * * @return the initialized OpenCms singleton instance */ protected static OpenCmsCore getInstance() { if (m_errorCondition != null) { // OpenCms is not properly initialized throw new CmsInitException(m_errorCondition, false); } if (m_instance == null) { try { // create a new core object with runlevel 1 m_instance = new OpenCmsCore(); } catch (CmsInitException e) { // already initialized, this is all we need LOG.debug(e.getMessage(), e); } } return m_instance; }
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event) { try { // upgrade the OpenCms runlevel OpenCmsCore.getInstance().upgradeRunlevel(event.getServletContext()); } catch (CmsInitException e) { if (e.isNewError()) { // only log new init errors LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); // throw a new init Exception to make sure a "context destroyed" event is triggered throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_GENERIC_1, t.getMessage())); } }
/** * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ @Override public synchronized void init(ServletConfig config) throws ServletException { super.init(config); try { // upgrade the runlevel // usually this should have already been done by the context listener // however, after a fresh install / setup this will be done from here OpenCmsCore.getInstance().upgradeRunlevel(config.getServletContext()); // finalize OpenCms initialization OpenCmsCore.getInstance().initServlet(this); } catch (CmsInitException e) { if (Messages.ERR_CRITICAL_INIT_WIZARD_0.equals(e.getMessageContainer().getKey())) { // if wizard is still enabled - allow retry of initialization (required for setup wizard) // this means the servlet init() call must be terminated by an exception if (CmsServletContainerSettings.isServletThrowsException()) { throw new ServletException(e.getMessage()); } else { // this is needed since some servlet containers does not like the servlet to throw exceptions, // like BEA WLS 9.x and Resin LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), e); } } } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }
/** * Creates a new localized Exception that also containes a root cause.<p> * * @param container the localized message container to use * @param cause the Exception root cause */ public CmsInitException(CmsMessageContainer container, Throwable cause) { super(container, cause); m_newError = true; setErrorCondition(); }
/** * Prints an error message to the System.err stream, indicating that OpenCms * is unable to start up.<p> */ private void setErrorCondition() { CmsMessageContainer errorCondition = getMessageContainer(); OpenCmsCore.setErrorCondition(errorCondition); } }
/** * Initializes the organizational units.<p> * * @param cms the admin CMS context * * @throws CmsException if something goes wrong */ public void initialize(CmsObject cms) throws CmsException { List<CmsOrganizationalUnit> ous = getOrganizationalUnits(cms, "", true); for (CmsOrganizationalUnit ou : ous) { try { m_securityManager.initializeOrgUnit(cms.getRequestContext(), ou); } catch (CmsInitException e) { LOG.error("Error while initializing OU " + ou.getName() + ": " + e.getLocalizedMessage(), e); } } }
/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent event) { try { // upgrade the OpenCms runlevel OpenCmsCore.getInstance().upgradeRunlevel(event.getServletContext()); } catch (CmsInitException e) { if (e.isNewError()) { // only log new init errors LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); // throw a new init Exception to make sure a "context destroyed" event is triggered throw new CmsInitException(Messages.get().container(Messages.ERR_CRITICAL_INIT_GENERIC_1, t.getMessage())); } }
/** * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ @Override public synchronized void init(ServletConfig config) throws ServletException { super.init(config); try { // upgrade the runlevel // usually this should have already been done by the context listener // however, after a fresh install / setup this will be done from here OpenCmsCore.getInstance().upgradeRunlevel(config.getServletContext()); // finalize OpenCms initialization OpenCmsCore.getInstance().initServlet(this); } catch (CmsInitException e) { if (Messages.ERR_CRITICAL_INIT_WIZARD_0.equals(e.getMessageContainer().getKey())) { // if wizard is still enabled - allow retry of initialization (required for setup wizard) // this means the servlet init() call must be terminated by an exception if (CmsServletContainerSettings.isServletThrowsException()) { throw new ServletException(e.getMessage()); } else { // this is needed since some servlet containers does not like the servlet to throw exceptions, // like BEA WLS 9.x and Resin LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), e); } } } catch (Throwable t) { LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }
/** * Creates a new localized Exception that also containes a root cause.<p> * * @param container the localized message container to use * @param cause the Exception root cause */ public CmsInitException(CmsMessageContainer container, Throwable cause) { super(container, cause); m_newError = true; setErrorCondition(); }
/** * Prints an error message to the System.err stream, indicating that OpenCms * is unable to start up.<p> */ private void setErrorCondition() { CmsMessageContainer errorCondition = getMessageContainer(); OpenCmsCore.setErrorCondition(errorCondition); } }
/** * @see org.opencms.main.CmsRuntimeException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable) */ @Override public CmsRuntimeException createException(CmsMessageContainer container, Throwable cause) { return new CmsInitException(container, cause); }
/** * @see javax.servlet.http.HttpSessionListener#sessionDestroyed(javax.servlet.http.HttpSessionEvent) */ public void sessionDestroyed(HttpSessionEvent event) { try { // inform the OpenCms session manager OpenCmsCore.getInstance().getSessionManager().sessionDestroyed(event); } catch (CmsInitException e) { if (e.isNewError()) { LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }
/** * Creates a new localized Exception.<p> * * @param container the localized message container to use * @param newError indicates that the error is new, and OpenCms should be stopped */ public CmsInitException(CmsMessageContainer container, boolean newError) { super(container); m_newError = newError; if (m_newError) { setErrorCondition(); } }
/** * Returns the initialized OpenCms singleton instance.<p> * * @return the initialized OpenCms singleton instance */ protected static OpenCmsCore getInstance() { if (m_errorCondition != null) { // OpenCms is not properly initialized throw new CmsInitException(m_errorCondition, false); } if (m_instance == null) { try { // create a new core object with runlevel 1 m_instance = new OpenCmsCore(); } catch (CmsInitException e) { // already initialized, this is all we need } } return m_instance; }
/** * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent) */ public void sessionCreated(HttpSessionEvent event) { try { // inform the OpenCms session manager OpenCmsCore.getInstance().getSessionManager().sessionCreated(event); } catch (CmsInitException e) { if (e.isNewError()) { LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }
/** * Creates a new localized Exception.<p> * * @param container the localized message container to use * @param newError indicates that the error is new, and OpenCms should be stopped */ public CmsInitException(CmsMessageContainer container, boolean newError) { super(container); m_newError = newError; if (m_newError) { setErrorCondition(); } }
/** * Public constructor for user defined relation types.<p> * * @param id the id of the relation type * @param name the name of the relation * @param type the type of relation type, strong or weak */ public CmsRelationType(int id, String name, String type) { m_name = name.toUpperCase(); if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { // allow relation type definitions only during startup throw new CmsInitException(Messages.get().container(Messages.ERR_RELATION_TYPE_INIT_1, m_name)); } m_strong = type.toUpperCase().equals(VALUE_STRONG); m_defInContent = false; m_id = USER_DEFINED_MODE_LIMIT + id; }
/** * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent) */ public void sessionCreated(HttpSessionEvent event) { try { // inform the OpenCms session manager OpenCmsCore.getInstance().getSessionManager().sessionCreated(event); } catch (CmsInitException e) { if (e.isNewError()) { LOG.error(e.getLocalizedMessage(), e); } } catch (Throwable t) { // make sure all other errors are displayed in the OpenCms log LOG.error(Messages.get().getBundle().key(Messages.LOG_ERROR_GENERIC_0), t); } }