/** * Schedules a bundle reload.<p> */ private void scheduleReload() { if (!isReloadScheduled() && (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT)) { // only schedule a reload if the system is not going down already m_threadCount++; Thread thread = new Thread("Bundle reload Thread " + m_threadCount) { @Override public void run() { setReloadScheduled(true); try { Thread.sleep(1000); } catch (Exception e) { // ignore } if (isReloadScheduled()) { reload(false); } setReloadScheduled(false); } }; thread.start(); } } }
/** * Creates an instance with default settings that tries to use the log file path obtained * from <code>{@link OpenCms}'s {@link org.opencms.main.CmsSystemInfo}</code> instance.<p> * * If the log file path is invalid or not configured correctly a logging is performed and the * path remains empty to allow user-specified file selection.<p> */ public CmsRfsFileViewer() { if (OpenCms.getRunLevel() >= OpenCms.RUNLEVEL_3_SHELL_ACCESS) { m_rootPath = new File(OpenCms.getSystemInfo().getLogFileRfsPath()).getParent(); } m_isLogfile = true; // system default charset: see http://java.sun.com/j2se/corejava/intl/reference/faqs/index.html#default-encoding m_fileEncoding = Charset.forName(new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding()); m_enabled = true; m_windowSize = 200; }
/** * Creates an instance with default settings that tries to use the log file path obtained * from <code>{@link OpenCms}'s {@link org.opencms.main.CmsSystemInfo}</code> instance.<p> * * If the log file path is invalid or not configured correctly a logging is performed and the * path remains empty to allow user-specified file selection.<p> */ public CmsRfsFileViewer() { if (OpenCms.getRunLevel() >= OpenCms.RUNLEVEL_3_SHELL_ACCESS) { m_rootPath = new File(OpenCms.getSystemInfo().getLogFileRfsPath()).getParent(); } m_isLogfile = true; m_fileName2lineIndex = new HashMap(); // system default charset: see http://java.sun.com/j2se/corejava/intl/reference/faqs/index.html#default-encoding m_fileEncoding = Charset.forName(new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding()); m_enabled = true; m_windowSize = 200; }
/** * 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; }
/** * 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; }
public void run() { // Although discouraged, use polling to make sure the indexing process does not start // before OpenCms has reached runlevel 4 while (OpenCms.getRunLevel() == OpenCms.RUNLEVEL_2_INITIALIZING) { try { // Repeat check every five seconds Thread.sleep(5 * 1000); } catch (InterruptedException e) { LOG.warn(e.getLocalizedMessage(), e); // maybe OpenCms is being shutdown, just return return; } } // Check whether indexing is needed if not running the shell if ((OpenCms.getRunLevel() == OpenCms.RUNLEVEL_4_SERVLET_ACCESS) && CmsSpellcheckDictionaryIndexer.updatingIndexNecessesary(adminCms)) { CmsSolrSpellchecker spellchecker = OpenCms.getSearchManager().getSolrDictionary(adminCms); if (spellchecker != null) { spellchecker.parseAndAddDictionaries(adminCms); } } }
/** * Reads the latest saved locks from the database and installs them to * this lock manager.<p> * * @param dbc the current database context * * @throws CmsException if something goes wrong */ public void readLocks(CmsDbContext dbc) throws CmsException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_3_SHELL_ACCESS) { // read the locks only if the wizard is not enabled Map lockCache = new HashMap(); List locks = m_driverManager.getProjectDriver().readLocks(dbc); Iterator itLocks = locks.iterator(); while (itLocks.hasNext()) { CmsLock lock = (CmsLock)itLocks.next(); internalLockResource(lock, lockCache); } OpenCms.getMemoryMonitor().flushLocks(lockCache); m_runningInServlet = true; } }
/** * Reads the latest saved locks from the database and installs them to * this lock manager.<p> * * @param dbc the current database context * * @throws CmsException if something goes wrong */ public void readLocks(CmsDbContext dbc) throws CmsException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_3_SHELL_ACCESS) { // read the locks only if the wizard is not enabled Map<String, CmsLock> lockCache = new HashMap<String, CmsLock>(); List<CmsLock> locks = m_driverManager.getProjectDriver(dbc).readLocks(dbc); Iterator<CmsLock> itLocks = locks.iterator(); while (itLocks.hasNext()) { CmsLock lock = itLocks.next(); internalLockResource(lock, lockCache); } OpenCms.getMemoryMonitor().flushLocks(lockCache); m_runningInServlet = true; } }
/** * Sets the system-wide file view settings for the workplace.<p> * * @param cms the CmsObject for ensuring security constraints. * * @param fileViewSettings the system-wide file view settings for the workplace to set * * @throws CmsRoleViolationException if the current user does not own the administrator role ({@link CmsRole#ROOT_ADMIN}) * */ public void setFileViewSettings(CmsObject cms, CmsRfsFileViewer fileViewSettings) throws CmsRoleViolationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } m_fileViewSettings = fileViewSettings; // disallow modifications of this "new original" m_fileViewSettings.setFrozen(true); }
/** * Sets the system-wide file view settings for the workplace.<p> * * @param cms the CmsObject for ensuring security constraints. * * @param fileViewSettings the system-wide file view settings for the workplace to set * * @throws CmsRoleViolationException if the current user does not own the administrator role ({@link CmsRole#ROOT_ADMIN}) * */ public void setFileViewSettings(CmsObject cms, CmsRfsFileViewer fileViewSettings) throws CmsRoleViolationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } m_fileViewSettings = fileViewSettings; // disallow modifications of this "new original" m_fileViewSettings.setFrozen(true); }
/** * Initializes all additional resource types stored in the modules.<p> * * @param cms an initialized OpenCms user context with "module manager" role permissions * * @throws CmsRoleViolationException in case the provided OpenCms user context did not have "module manager" role permissions * @throws CmsConfigurationException in case of duplicate resource types in the configuration */ public synchronized void initialize(CmsObject cms) throws CmsRoleViolationException, CmsConfigurationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) { // some simple test cases don't require this check OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER); } // initialize the resource types initResourceTypes(); // call initialize method on all resource types Iterator i = m_configuration.m_resourceTypeList.iterator(); while (i.hasNext()) { I_CmsResourceType type = (I_CmsResourceType)i.next(); type.initialize(cms); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LOADER_CONFIG_FINISHED_0)); } }
/** * Sets the login message to display if a user logs in.<p> * * This operation requires that the current user has role permissions of <code>{@link CmsRole#ROOT_ADMIN}</code>.<p> * * @param cms the current OpenCms user context * @param message the message to set * * @throws CmsRoleViolationException in case the current user does not have the required role permissions */ public void setLoginMessage(CmsObject cms, CmsLoginMessage message) throws CmsRoleViolationException { if (OpenCms.getRunLevel() >= OpenCms.RUNLEVEL_3_SHELL_ACCESS) { // during configuration phase no permission check id required OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } m_loginMessage = message; if (m_loginMessage != null) { m_loginMessage.setFrozen(); } }
/** * Initializes all additional resource types stored in the modules.<p> * * @param cms an initialized OpenCms user context with "module manager" role permissions * * @throws CmsRoleViolationException in case the provided OpenCms user context did not have "module manager" role permissions * @throws CmsConfigurationException in case of duplicate resource types in the configuration */ public synchronized void initialize(CmsObject cms) throws CmsRoleViolationException, CmsConfigurationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) { // some simple test cases don't require this check OpenCms.getRoleManager().checkRole(cms, CmsRole.DATABASE_MANAGER); } // initialize the resource types initResourceTypes(); // call initialize method on all resource types Iterator<I_CmsResourceType> i = m_configuration.m_resourceTypeList.iterator(); while (i.hasNext()) { I_CmsResourceType type = i.next(); type.initialize(cms); } if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_LOADER_CONFIG_FINISHED_0)); } }
/** * Initializes XML content types managed in this XML content type manager.<p> * * @param cms an initialized OpenCms user context with "Administrator" role permissions * * @throws CmsRoleViolationException in case the provided OpenCms user context doea not have "Administrator" role permissions */ public synchronized void initialize(CmsObject cms) throws CmsRoleViolationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) { // simple test cases don't require this check OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } // initialize the special entity resolver CmsXmlEntityResolver.initialize(cms, getSchemaBytes()); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info(Messages.get().getBundle().key( Messages.INIT_NUM_ST_INITIALIZED_1, new Integer(m_registeredTypes.size()))); } }
/** * Initializes XML content types managed in this XML content type manager.<p> * * @param cms an initialized OpenCms user context with "Administrator" role permissions * * @throws CmsRoleViolationException in case the provided OpenCms user context doea not have "Administrator" role permissions */ public synchronized void initialize(CmsObject cms) throws CmsRoleViolationException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) { // simple test cases don't require this check OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } // initialize the special entity resolver CmsXmlEntityResolver.initialize(cms, getSchemaBytes()); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_NUM_ST_INITIALIZED_1, new Integer(m_registeredTypes.size()))); } }
/** * Sets the login message to display if a user logs in.<p> * * This operation requires that the current user has role permissions of <code>{@link CmsRole#ROOT_ADMIN}</code>.<p> * * @param cms the current OpenCms user context * @param message the message to set * * @throws CmsRoleViolationException in case the current user does not have the required role permissions */ public void setLoginMessage(CmsObject cms, CmsLoginMessage message) throws CmsRoleViolationException { if (OpenCms.getRunLevel() >= OpenCms.RUNLEVEL_3_SHELL_ACCESS) { // during configuration phase no permission check id required OpenCms.getRoleManager().checkRole(cms, CmsRole.ROOT_ADMIN); } m_loginMessage = message; if (m_loginMessage != null) { m_loginMessage.setFrozen(); } }
public void initConfiguration(String name, String id, String className) throws CmsConfigurationException { if ((OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) && m_staticFrozen) {
/** * Creates a new instance of the OpenCms security manager.<p> * * @param configurationManager the configuration manager * @param runtimeInfoFactory the initialized OpenCms runtime info factory * @param publishEngine the publish engine * * @return a new instance of the OpenCms security manager * * @throws CmsInitException if the security manager could not be initialized */ public static CmsSecurityManager newInstance( CmsConfigurationManager configurationManager, I_CmsDbContextFactory runtimeInfoFactory, CmsPublishEngine publishEngine) throws CmsInitException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { // OpenCms is already initialized throw new CmsInitException( org.opencms.main.Messages.get().container(org.opencms.main.Messages.ERR_ALREADY_INITIALIZED_0)); } CmsSecurityManager securityManager = new CmsSecurityManager(); securityManager.init(configurationManager, runtimeInfoFactory, publishEngine); return securityManager; }
/** * Creates a new instance of the OpenCms security manager.<p> * * @param configurationManager the configuration manager * @param runtimeInfoFactory the initialized OpenCms runtime info factory * @param publishEngine the publish engine * * @return a new instance of the OpenCms security manager * * @throws CmsInitException if the security manager could not be initialized */ public static CmsSecurityManager newInstance( CmsConfigurationManager configurationManager, I_CmsDbContextFactory runtimeInfoFactory, CmsPublishEngine publishEngine) throws CmsInitException { if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { // OpenCms is already initialized throw new CmsInitException(org.opencms.main.Messages.get().container( org.opencms.main.Messages.ERR_ALREADY_INITIALIZED_0)); } CmsSecurityManager securityManager = new CmsSecurityManager(); securityManager.init(configurationManager, runtimeInfoFactory, publishEngine); return securityManager; }
/** * Sets the logical key/name of this search index source.<p> * * @param name the logical key/name of this search index source * * @throws CmsIllegalArgumentException if argument name is null, an empty or whitespace-only Strings * or already used for another indexsource's name. */ public void setName(String name) throws CmsIllegalArgumentException { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_INDEXSOURCE_CREATE_MISSING_NAME_0)); } // already used? Don't test this at xml-configuration time (no manager) if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { CmsSearchManager mngr = OpenCms.getSearchManager(); // don't test this if the indexsource is not new (widget invokes setName even if it was not changed) if (mngr.getIndexSource(name) != this) { if (mngr.getSearchIndexSources().keySet().contains(name)) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_INDEXSOURCE_CREATE_INVALID_NAME_1, name)); } } } m_name = name; }