<commit_before>package org.jboss.forge.addon.configuration;

import java.io.File;
import java.io.IOException;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.apache.commons.io.FileUtils;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.furnace.util.OperatingSystemUtils;

@ApplicationScoped
public class ConfigurationFactoryImpl implements ConfigurationFactory
{
   static final String USER_CONFIG_PATH = "org.jboss.forge.addon.configuration.USER_CONFIG_PATH";

   private Configuration userConfiguration;

   @Override
   @Produces
   @ApplicationScoped
   public Configuration getUserConfiguration() throws ConfigurationException
   {
      if (userConfiguration == null)
      {
         String property = System.getProperty(USER_CONFIG_PATH);
         File userConfigurationFile;
         if (property == null || property.isEmpty())
         {
            userConfigurationFile = new File(OperatingSystemUtils.getUserForgeDir(), "config.xml");
         }
         else
         {
            userConfigurationFile = new File(property);
         }
         if (!userConfigurationFile.exists() || userConfigurationFile.length() == 0L)
         {
            try
            {
               FileUtils.writeStringToFile(userConfigurationFile, "<configuration/>");
            }
            catch (IOException e)
            {
               throw new ConfigurationException("Error while create user configuration", e);
            }
         }
         userConfiguration = getConfiguration(userConfigurationFile);
      }
      return userConfiguration;
   }

   @Override
   public Configuration getConfiguration(FileResource<?> configFile)
   {
      return getConfiguration(configFile.getUnderlyingResourceObject());
   }

   private Configuration getConfiguration(File file)
   {
      try
      {
         XMLConfiguration commonsConfig = new XMLConfiguration(file);
         commonsConfig.setEncoding("UTF-8");
         commonsConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
         commonsConfig.setAutoSave(true);
         return new ConfigurationAdapter(commonsConfig);
      }
      catch (org.apache.commons.configuration.ConfigurationException e)
      {
         throw new ConfigurationException(e);
      }
   }
}
<commit_msg>Fixed compilation error<commit_after>package org.jboss.forge.addon.configuration;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.furnace.util.OperatingSystemUtils;

@ApplicationScoped
public class ConfigurationFactoryImpl implements ConfigurationFactory
{
   static final String USER_CONFIG_PATH = "org.jboss.forge.addon.configuration.USER_CONFIG_PATH";

   private Configuration userConfiguration;

   @Override
   @Produces
   @ApplicationScoped
   public Configuration getUserConfiguration() throws ConfigurationException
   {
      if (userConfiguration == null)
      {
         String property = System.getProperty(USER_CONFIG_PATH);
         File userConfigurationFile;
         if (property == null || property.isEmpty())
         {
            userConfigurationFile = new File(OperatingSystemUtils.getUserForgeDir(), "config.xml");
         }
         else
         {
            userConfigurationFile = new File(property);
         }
         if (!userConfigurationFile.exists() || userConfigurationFile.length() == 0L)
         {
            try (FileWriter fw = new FileWriter(userConfigurationFile))
            {
               fw.write("<configuration/>");
            }
            catch (IOException e)
            {
               throw new ConfigurationException("Error while create user configuration", e);
            }
         }
         userConfiguration = getConfiguration(userConfigurationFile);
      }
      return userConfiguration;
   }

   @Override
   public Configuration getConfiguration(FileResource<?> configFile)
   {
      return getConfiguration(configFile.getUnderlyingResourceObject());
   }

   private Configuration getConfiguration(File file)
   {
      try
      {
         XMLConfiguration commonsConfig = new XMLConfiguration(file);
         commonsConfig.setEncoding("UTF-8");
         commonsConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
         commonsConfig.setAutoSave(true);
         return new ConfigurationAdapter(commonsConfig);
      }
      catch (org.apache.commons.configuration.ConfigurationException e)
      {
         throw new ConfigurationException(e);
      }
   }
}

{'fraction_non_alphanumeric': 0.08368537517602093, 'fraction_numerical': 0.0008046670690002012, 'mean_word_length': 3.032441200324412, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3756457', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1207, 'n_words': 231}