Reads the given configuration file.<p>

@param configFile the configuration file to read
@return the configuration data read from the file

@throws CmsException if something goes wrong
776092
public CmsUgcConfiguration readConfiguration(CmsFile configFile) throws CmsException {

        m_content = CmsXmlContentFactory.unmarshal(m_cms, configFile);
        String resourceType = getStringValue(N_CONTENT_TYPE);
        String contentPath = getStringValue(N_CONTENT_PATH);
        CmsResource contentPathResource = m_cms.readResource(contentPath);
        String namePattern = getStringValue(N_NAME_PATTERN);
        String localeStr = getStringValue(N_LOCALE);
        OpenCms.getLocaleManager();
        Locale locale = CmsLocaleManager.getLocale(localeStr);
        Optional<CmsResource> uploadPathResource = Optional.absent();
        String uploadPath = getStringValue(N_UPLOAD_PATH);
        if (uploadPath != null) {
            uploadPathResource = Optional.of(m_cms.readResource(uploadPath));
        }
        Optional<Long> maxUploadSize = getLongValue(N_MAX_UPLOAD_SIZE);
        Optional<Integer> maxNumContents = getIntValue(N_MAX_NUM_CONTENTS);
        Optional<Long> queueWaitTime = getLongValue(N_QUEUE_WAIT_TIME);
        Optional<Integer> maxQueueLength = getIntValue(N_QUEUE_MAX_LENGTH);
        boolean autoPublish = Boolean.parseBoolean(getStringValue(N_AUTO_PUBLISH));
        String validExtensionsStr = getStringValue(N_VALID_EXTENSIONS);
        Optional<List<String>> validExtensions = Optional.absent();
        if (validExtensionsStr != null) {
            validExtensionsStr = validExtensionsStr.trim();
            List<String> extensions = CmsStringUtil.splitAsList(validExtensionsStr, EXTENSIONS_SEPARATOR);
            validExtensions = Optional.of(extensions);
        }

        String userForGuestStr = getStringValue(N_USER_FOR_GUEST);
        Optional<CmsUser> userForGuest = Optional.absent();
        if (userForGuestStr != null) {
            userForGuest = Optional.of(m_cms.readUser(userForGuestStr.trim()));
        }

        String projectGroupStr = getStringValue(N_PROJECT_GROUP);
        CmsGroup projectGroup = m_cms.readGroup(projectGroupStr.trim());
        CmsUUID id = configFile.getStructureId();
        CmsUgcConfiguration result = new CmsUgcConfiguration(
            id,
            userForGuest,
            projectGroup,
            resourceType,
            contentPathResource,
            namePattern,
            locale,
            uploadPathResource,
            maxUploadSize,
            maxNumContents,
            queueWaitTime,
            maxQueueLength,
            autoPublish,
            validExtensions);
        result.setPath(configFile.getRootPath());
        return result;
    }
734118
protected CmsXmlContent getConfigurationContent() {

        if (m_configurationContent == null) {
            String configFileName = getConfigurationVfsPath();
            if (getCms().existsResource(configFileName)) {
                // configuration file found, check VFS cache for unmarshalled content
                CmsVfsMemoryObjectCache vfsCache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache();
                m_configurationContent = (CmsXmlContent)vfsCache.getCachedObject(getCms(), configFileName);
                if (m_configurationContent == null) {
                    // content not found in cache, read the file and unmarshal it
                    try {
                        CmsFile configFile = getCms().readFile(configFileName);
                        CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCms(), configFile);
                        // put the result content in the cache
                        vfsCache.putCachedObject(getCms(), configFileName, content);
                        m_configurationContent = content;
                    } catch (CmsException e) {
                        // should never happen, because we checked the resource existence before
                    }
                }
            }
        }
        return m_configurationContent;
    }
880916
protected function fetchConfig($configFile)
    {
        if (is_string($configFile) && ! is_readable($configFile)) {
            $configFile = [];
        }

        return ConfigFactory::create($configFile);
    }
1300694
CmsModelInfo setDefaultModelPage(CmsResource configFile, CmsUUID modelId) throws CmsException {

        CmsFile file = m_cms.readFile(configFile);
        CmsXmlContent content = CmsXmlContentFactory.unmarshal(m_cms, file);
        Locale locale = getLocale(content);
        int defaultValueIndex = -1;
        String defaultModelTarget = null;
        for (I_CmsXmlContentValue value : content.getValues(CmsConfigurationReader.N_MODEL_PAGE, locale)) {
            I_CmsXmlContentValue linkValue = content.getValue(
                CmsStringUtil.joinPaths(value.getPath(), CmsConfigurationReader.N_PAGE),
                locale);
            I_CmsXmlContentValue isDefaultValue = content.getValue(
                CmsStringUtil.joinPaths(value.getPath(), CmsConfigurationReader.N_IS_DEFAULT),
                locale);
            CmsLink link = ((CmsXmlVfsFileValue)linkValue).getLink(m_cms);
            if ((link != null) && link.getStructureId().equals(modelId)) {
                // store index and site path
                defaultValueIndex = value.getIndex();
                defaultModelTarget = link.getTarget();
            } else {
                isDefaultValue.setStringValue(m_cms, Boolean.FALSE.toString());
            }
        }
        if (defaultValueIndex != -1) {
            // remove the value from the old position and insert it a the top
            content.removeValue(CmsConfigurationReader.N_MODEL_PAGE, locale, defaultValueIndex);
            content.addValue(m_cms, CmsConfigurationReader.N_MODEL_PAGE, locale, 0);
            content.getValue(
                CmsConfigurationReader.N_MODEL_PAGE + "[1]/" + CmsConfigurationReader.N_PAGE,
                locale).setStringValue(m_cms, defaultModelTarget);
            content.getValue(
                CmsConfigurationReader.N_MODEL_PAGE + "[1]/" + CmsConfigurationReader.N_DISABLED,
                locale).setStringValue(m_cms, Boolean.FALSE.toString());
            content.getValue(
                CmsConfigurationReader.N_MODEL_PAGE + "[1]/" + CmsConfigurationReader.N_IS_DEFAULT,
                locale).setStringValue(m_cms, Boolean.TRUE.toString());
        }
        content.setAutoCorrectionEnabled(true);
        content.correctXmlStructure(m_cms);
        file.setContents(content.marshal());
        m_cms.writeFile(file);
        OpenCms.getADEManager().waitForCacheUpdate(false);
        m_adeConfig = OpenCms.getADEManager().lookupConfiguration(m_cms, m_rootResource.getRootPath());
        return getModelInfo();
    }
479827
func ReadConfigFile(filePath string) error {
	data, err := ioutil.ReadFile(filePath)
	if err != nil {
		return err
	}
	return ReadConfigBytes(data)
}
310862
private static void updateFile(CmsObject cms, CmsFile file, CmsMacroResolver macroResolver) throws CmsException {

        String encoding = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, true).getValue(
            OpenCms.getSystemInfo().getDefaultEncoding());
        String content;
        try {
            content = macroResolver.resolveMacros(new String(file.getContents(), encoding));
        } catch (UnsupportedEncodingException e) {
            try {
                content = macroResolver.resolveMacros(
                    new String(file.getContents(), Charset.defaultCharset().toString()));
            } catch (UnsupportedEncodingException e1) {
                content = macroResolver.resolveMacros(new String(file.getContents()));
            }
        }
        // update the content
        try {
            file.setContents(content.getBytes(encoding));
        } catch (UnsupportedEncodingException e) {
            try {
                file.setContents(content.getBytes(Charset.defaultCharset().toString()));
            } catch (UnsupportedEncodingException e1) {
                file.setContents(content.getBytes());
            }
        }
        // write the target file
        cms.writeFile(file);
    }
689480
@SuppressWarnings("unchecked")
    @Override
    public T readConfig(String filePath) throws ConfigurationException {
        try {
            YamlReader reader = new YamlReader(new FileReader(filePath));
            reader.getConfig().setClassTag(clazz.getSimpleName(), clazz);
            return (T) reader.read();
        } catch (FileNotFoundException e) {
            throw new ConfigurationException("Configuration Exception", "CONF_001", e);
        } catch (YamlException e) {
            throw new ConfigurationException("Configuration Exception", "CONF_002", e);
        }
    }
73396
public final void setConfigFile(@Nonnull final String pConfigFile)
    {
        mdlConfigCallable = new CallableNoEx<MdlConfig>()
        {
            @Override
            @Nonnull
            public MdlConfig call()
            {
                MdlConfig result = null;
                FileInputStream fis = null;
                try {
                    fis = new FileInputStream(Util.canonize(new File(pConfigFile)));
                    result = activateConfigFile(fis, pConfigFile);
                }
                catch (IllegalArgumentException e) {
                    result = activateConfigFile(null, null);
                    throw e;
                }
                catch (FileNotFoundException e) {
                    result = activateConfigFile(null, null);
                    if (!failQuietly) {
                        throw new IllegalArgumentException(
                            "Config file not found for " + ModuleDirectoryLayoutCheck.class.getSimpleName() + ": "
                                + pConfigFile, e);
                    }
                }
                finally {
                    Util.closeQuietly(fis);
                }
                return result;
            }
        };
    }
89415
public static Config loadConfig(ConfigParseOptions parseOptions,
            ConfigResolveOptions resolveOptions, String configFile) {
        return loadConfig(parseOptions, resolveOptions, new File(configFile));
    }
305571
public static IOException convertCmsException(CmsException e) {

        LOG.error(e.getLocalizedMessage(), e);
        if (e instanceof CmsSecurityException) {
            return new AccessDeniedException(e.getMessage(), e);
        } else if (e instanceof CmsVfsResourceAlreadyExistsException) {
            return new FileExistsException("File exists: " + e);
        } else if (e instanceof CmsVfsResourceNotFoundException) {
            return new FileNotFoundException("File does not exist: " + e);
        } else {
            return new IOException(e);
        }
    }
713399
@SuppressWarnings("resource")
    public static byte[] readFile(String filename) throws IOException {

        // create input and output stream
        InputStream in = CmsFileUtil.class.getClassLoader().getResourceAsStream(filename);
        if (in == null) {
            throw new FileNotFoundException(filename);
        }

        return readFully(in);
    }
534525
private void getConfiguration() throws CmsException {

        if ((m_configuredErrorChecks == null) || (m_configuredWarningChecks == null)) {
            // get the configuration file
            CmsResource res = m_cms.readResource(CONFIGURATION);
            if (LOG.isDebugEnabled()) {
                LOG.debug(
                    Messages.get().getBundle().key(Messages.LOG_DEBUG_PROPERTY_CONFIG_FILENAME_1, res.getRootPath()));
            }
            CmsFile file = m_cms.readFile(res);
            if (LOG.isDebugEnabled()) {
                LOG.debug(
                    Messages.get().getBundle().key(
                        Messages.LOG_DEBUG_PROPERTY_CONFIG_FILE_1,
                        new String(file.getContents())));
            }
            CmsXmlContent configuration = CmsXmlContentFactory.unmarshal(m_cms, file);

            // now extract the configured error checks from it
            m_configuredErrorChecks = getConfiguredChecks(configuration, XPATH_ERROR);
            m_configuredWarningChecks = getConfiguredChecks(configuration, XPATH_WARNUING);
        }
    }
1119255
private void readConfigFile() {
    File configFile = new File(CONFIG_FILE_PATH);
    /* config file is not there -> create config file with default */
    if (!configFile.exists()) {
      resetConfigToDefault();
    }

    try {
      PropertiesConfiguration conf = new PropertiesConfiguration(CONFIG_FILE_PATH);
      chemistry = conf.getString(CHEMISTRY_PLUGIN);
    } catch (ConfigurationException e) {
      resetConfigToDefault();
      e.printStackTrace();
    }
  }
367459
public void parse(CmsResource resource) throws CmsException {

        CmsFile file = m_cms.readFile(resource);
        parse(file);
    }
92241
private List<CmsGitConfiguration> readConfigFiles() {

        List<CmsGitConfiguration> configurations = new LinkedList<CmsGitConfiguration>();

        // Default configuration file for backwards compatibility
        addConfigurationIfValid(configurations, new File(DEFAULT_CONFIG_FILE));

        // All files in the config folder
        File configFolder = new File(DEFAULT_CONFIG_FOLDER);
        if (configFolder.isDirectory()) {
            for (File configFile : configFolder.listFiles()) {
                addConfigurationIfValid(configurations, configFile);
            }
        }
        return configurations;
    }
1109038
private void saveToXmlVfsBundle() throws CmsException {

        if (m_lockedBundleFiles.get(null) != null) { // If the file was not locked, no changes were made, i.e., storing is not necessary.
            for (Locale l : m_locales) {
                SortedProperties props = m_localizations.get(l);
                if (null != props) {
                    if (m_xmlBundle.hasLocale(l)) {
                        m_xmlBundle.removeLocale(l);
                    }
                    m_xmlBundle.addLocale(m_cms, l);
                    int i = 0;
                    List<Object> keys = new ArrayList<Object>(props.keySet());
                    Collections.sort(keys, CmsCaseInsensitiveStringComparator.getInstance());
                    for (Object key : keys) {
                        if ((null != key) && !key.toString().isEmpty()) {
                            String value = props.getProperty(key.toString());
                            if (!value.isEmpty()) {
                                m_xmlBundle.addValue(m_cms, "Message", l, i);
                                i++;
                                m_xmlBundle.getValue("Message[" + i + "]/Key", l).setStringValue(m_cms, key.toString());
                                m_xmlBundle.getValue("Message[" + i + "]/Value", l).setStringValue(m_cms, value);
                            }
                        }
                    }
                }
                CmsFile bundleFile = m_lockedBundleFiles.get(null).getFile();
                bundleFile.setContents(m_xmlBundle.marshal());
                m_cms.writeFile(bundleFile);
            }
        }
    }
957301
public CmsResource loadXmlContent(String fileName) throws CmsUgcException {

        checkNotFinished();
        checkEditResourceNotSet();
        if (fileName.contains("/")) {
            String message = Messages.get().container(Messages.ERR_INVALID_FILE_NAME_TO_LOAD_1, fileName).key(
                getCmsObject().getRequestContext().getLocale());
            throw new CmsUgcException(CmsUgcConstants.ErrorCode.errMisc, message);
        }
        try {
            String contentSitePath = m_cms.getRequestContext().removeSiteRoot(
                m_configuration.getContentParentFolder().getRootPath());
            String path = CmsStringUtil.joinPaths(contentSitePath, fileName);
            m_editResource = m_cms.readResource(path);
            CmsLock lock = m_cms.getLock(m_editResource);
            if (!lock.isOwnedBy(m_cms.getRequestContext().getCurrentUser())) {
                m_cms.lockResourceTemporary(m_editResource);
            }
            return m_editResource;
        } catch (CmsException e) {
            throw new CmsUgcException(CmsUgcConstants.ErrorCode.errMisc, e.getLocalizedMessage());
        }
    }