private Boolean getDebugFlag(String element, Boolean defaultValue) { Boolean debugValue = defaultValue; Map<String, ConfigElement> global = scriptConfigModel.getGlobal(); if (global != null) { Object flags = global.get(FLAGS); if (flags instanceof GenericConfigElement) { ConfigElement clientDebugElement = ((GenericConfigElement) flags).getChild(element); if (clientDebugElement != null) { debugValue = Boolean.valueOf(clientDebugElement.getValue()); } } } return debugValue; }
protected boolean isDebugMode() { if (this.isDebugMode == null) { Boolean debugValue = false; if (configService != null) { Config global = configService.getGlobalConfig(); if (global != null) { ConfigElement flags = global.getConfigElement("flags"); if (flags != null) { ConfigElement clientDebug = flags.getChild("client-debug"); if (clientDebug != null) { debugValue = Boolean.valueOf(clientDebug.getValue()); } } } } this.isDebugMode = debugValue; } return this.isDebugMode; }
protected List<String> getInlineEditableMimeTypes() { if ((this.inlineEditableMimeTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) { this.inlineEditableMimeTypes = new ArrayList<String>(8); // get the create mime types list from the config ConfigService svc = Application.getConfigService(FacesContext.getCurrentInstance()); Config wizardCfg = svc.getConfig("Content Wizards"); if (wizardCfg != null) { ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types"); if (typesCfg != null) { for (ConfigElement child : typesCfg.getChildren()) { String currentMimeType = child.getAttribute("name"); this.inlineEditableMimeTypes.add(currentMimeType); } } } } return this.inlineEditableMimeTypes; }
/** * Initialize the debug interface using the specified parameters. * * @param params ConfigElement * @param config ServerConfiguration */ public void initialize(ConfigElement params, ServerConfiguration config) throws Exception { // Check for a logging level ConfigElement logLevelElem = params.getChild("logLevel"); if (logLevelElem != null) { // Validate the logging level String logLevelStr = logLevelElem.getValue(); if (logLevelStr != null) { if (logLevelStr.equalsIgnoreCase("Debug")) m_logLevel = Debug.Debug; else if (logLevelStr.equalsIgnoreCase("Info")) m_logLevel = Debug.Info; else if (logLevelStr.equalsIgnoreCase("Warn")) m_logLevel = Debug.Warn; else if (logLevelStr.equalsIgnoreCase("Error")) m_logLevel = Debug.Error; else if (logLevelStr.equalsIgnoreCase("Fatal")) m_logLevel = Debug.Fatal; else throw new Exception("Invalid debug logging level, " + logLevelStr); } } }
/** * Initialize the file loader using the specified parameters * * @param params ConfigElement * @param ctx DeviceContext * @exception FileLoaderException * @exception IOException */ public void initializeLoader(ConfigElement params, DeviceContext ctx) throws FileLoaderException, IOException { // Debug output enable if (params.getChild("Debug") != null) m_debug = true; // Get the count of worker threads to create ConfigElement nameVal = params.getChild("ThreadPoolSize"); if (nameVal != null && (nameVal.getValue() == null || nameVal.getValue().length() == 0)) throw new FileLoaderException("FileLoader ThreadPoolSize parameter is null"); // Convert the thread pool size parameter, or use the default value m_readWorkers = DefaultWorkerThreads; m_writeWorkers = DefaultWorkerThreads; if (nameVal != null) { try { // Check for a single value or split read/write values String numVal = nameVal.getValue(); int rdCnt = -1; int wrtCnt = -1; int pos = numVal.indexOf(':'); if (pos == -1) { // Use the same number of read and write worker threads rdCnt = Integer.parseInt(numVal); wrtCnt = rdCnt; } else { // Split the string value into read and write values, and convert to integers String val = numVal.substring(0, pos); rdCnt = Integer.parseInt(val); val = numVal.substring(pos + 1); wrtCnt = Integer.parseInt(val); } // Set the read/write thread pool sizes m_readWorkers = rdCnt; m_writeWorkers = wrtCnt; } catch (NumberFormatException ex) { throw new FileLoaderException("ObjIdLoader Invalid ThreadPoolSize value, " + ex.toString()); } } // Range check the thread pool size if (m_readWorkers < MinimumWorkerThreads || m_readWorkers > MaximumWorkerThreads) throw new FileLoaderException( "ObjIdLoader Invalid ThreadPoolSize (read), valid range is " + MinimumWorkerThreads + "-" + MaximumWorkerThreads); if (m_writeWorkers < MinimumWorkerThreads || m_writeWorkers > MaximumWorkerThreads) throw new FileLoaderException( "ObjIdLoader Invalid ThreadPoolSize (write), valid range is " + MinimumWorkerThreads + "-" + MaximumWorkerThreads); // Get the temporary file data directory ConfigElement tempArea = params.getChild("TempDirectory"); if (tempArea == null || tempArea.getValue() == null || tempArea.getValue().length() == 0) throw new FileLoaderException("FileLoader TempDirectory not specified or null"); // Validate the temporary directory File tempDir = new File(tempArea.getValue()); if (tempDir.exists() == false) { // Temporary directory does not exist, create the directory if (tempDir.mkdir() == false) throw new FileLoaderException( "Failed to create temporary directory " + tempDir.getAbsolutePath()); } m_tempDirName = tempDir.getAbsolutePath(); if (m_tempDirName != null && m_tempDirName.endsWith(File.separator) == false) m_tempDirName = m_tempDirName + File.separator; m_tempDir = new File(m_tempDirName); if (m_tempDir.exists() == false || m_tempDir.isDirectory() == false) throw new FileLoaderException( "FileLoader TempDirectory does not exist, or is not a directory, " + m_tempDirName); if (m_tempDir.canWrite() == false) throw new FileLoaderException("FileLoader TempDirectory is not writeable, " + m_tempDirName); // Create the starting temporary sub-directory createNewTempDirectory(); // Check if the maxmimum files per sub-directory has been specified ConfigElement maxFiles = params.getChild("MaximumFilesPerDirectory"); if (maxFiles != null) { try { m_tempMax = Integer.parseInt(maxFiles.getValue()); // Range check the maximum files per sub-directory if (m_tempMax < 10 || m_tempMax > 20000) throw new FileLoaderException( "FileLoader MaximumFilesPerDirectory out of valid range (10-20000)"); } catch (NumberFormatException ex) { throw new FileLoaderException( "FileLoader MaximumFilesPerDirectory invalid, " + maxFiles.getValue()); } } else m_tempMax = MaximumFilesPerSubDir; // Check if there are any file processors configured ConfigElement fileProcs = params.getChild("FileProcessors"); if (fileProcs != null) { // Validate the file processor classes and add to the file loader List<ConfigElement> elems = fileProcs.getChildren(); for (ConfigElement className : elems) { // Get the current file processor class name if (className == null || className.getValue() == null || className.getValue().length() == 0) throw new FileLoaderException("Empty file processor class name"); // Validate the file processor class name and create an instance of the file processor try { // Create the file processor instance Object procObj = Class.forName(className.getValue()).newInstance(); // Check that it is a file processor implementation if (procObj instanceof FileProcessor) { // Add to the list of file processors addFileProcessor((FileProcessor) procObj); } else throw new FileLoaderException( "Class " + className.getValue() + " is not a FileProcessor implementation"); } catch (ClassNotFoundException ex) { throw new FileLoaderException("File processor class not found, " + className.getValue()); } catch (InstantiationException ex) { throw new FileLoaderException("File processor exception, " + ex.toString()); } catch (IllegalAccessException ex) { throw new FileLoaderException("File processor exception, " + ex.toString()); } } } // Check if the database interface being used supports the required features if (ctx instanceof DBDeviceContext) { // Access the database device context m_dbCtx = (DBDeviceContext) ctx; // Check if the request queue is supported by the database interface if (getContext().getDBInterface().supportsFeature(DBInterface.FeatureQueue) == false) throw new FileLoaderException("DBLoader requires queue support in database interface"); if (getContext().getDBInterface() instanceof DBQueueInterface == false) throw new FileLoaderException("Database interface does not implement queue interface"); // Check if the object id feature is supported by the database interface if (getContext().getDBInterface().supportsFeature(DBInterface.FeatureObjectId) == false) throw new FileLoaderException("DBLoader requires data support in database interface"); if (getContext().getDBInterface() instanceof DBObjectIdInterface) m_dbObjectIdInterface = (DBObjectIdInterface) getContext().getDBInterface(); else throw new FileLoaderException("Database interface does not implement object id interface"); } else throw new FileLoaderException("Requires database device context"); // Check if background loader debug is enabled if (params.getChild("ThreadDebug") != null) m_threadDebug = true; }