package com.atlassian.stash.internal.config;

import com.atlassian.stash.internal.jdbc.DataSourceConfiguration;

import javax.annotation.Nonnull;
import java.io.IOException;

/**
 * An interface for classes that modify the configuration file.
 */
public interface ConfigurationService {

    /**
     * @return the data source configuration as defined in the stash-config properties
     */
    @Nonnull
    DataSourceConfiguration loadDataSourceConfiguration() throws IOException;

    /**
     * Removes merge strategy properties, commenting out the deprecated properties and leaving a brief
     * message explaining the change.
     *
     * @since 4.9
     */
    void removeMergeStrategyProperties(@Nonnull DeprecateConfigurationRequest request);

    /**
     * Removes setup related properties, leaving comments describing what properties were removed and when
     *
     * @since 3.8
     */
    void removeSetupProperties(@Nonnull RemoveSetupConfigurationRequest request);

    /**
     * Saves the given data source configuration, marking the amendment with the given message, if any.
     *
     * @param dataSourceConfig the data source configuration to be saved
     * @param message          a message describing the purpose or context of the amendments
     */
    void saveDataSourceConfiguration(@Nonnull DataSourceConfiguration dataSourceConfig,
                                     @Nonnull String message);
}
