code: @Override
      public File getPermanentDirectory()
      {
          // Note: We're initializing the permanent directory here instead of in an Initializable.initialize() method
          // since otherwise we get a cyclic dependency with the Configuration Source implementation used to get the
          // Environment configuration property for the permanent directory location (since that Source require the
          // Environment for finding the configuration resource in the executing Environment).
          if (this.permanentDirectory == null) {
              String systemProperty = System.getProperty("xwiki.data.dir");
              final String classSpecified = getPermanentDirectoryName();
              final String configured = this.configurationProvider.get().getPermanentDirectoryPath();
  
              final String[] locations =
                  new String[] { systemProperty, classSpecified, configured, getTemporaryDirectoryName(),
                      DEFAULT_TMP_DIRECTORY };
              this.permanentDirectory = initializeDirectory(locations, false);
  
              if (systemProperty == null && classSpecified == null && configured == null) {
                  // There's no defined permanent directory, fall back to the temporary directory but issue a warning
                  this.logger.warn("No permanent directory configured, fallbacking to temporary directory. "
                      + "You should set the \"environment.permanentDirectory\" configuration property in the "
                      + "xwiki.properties file.");
              }
              this.logger.info("Using permanent directory [{}]", this.permanentDirectory);
          }
  
          return this.permanentDirectory;
      }
docs: {@inheritDoc}
  <p>
  Rather than overriding this, it is safer to override {@link #getPermanentDirectoryName()} if you need to change
  the default behavior. This is because this method does a number of checks to make sure the directory exists, is a
  directory (not a file) and the XWiki process has permission to write to it. If the directory doesn't exist it is
  created and if it cannot be written to, an error is printed in the log and it is passed over for the default
  permanent directory. Thus by overriding {@link #getPermanentDirectoryName()} you'll still benefit from all those
  checks.
  </p>