net.nemerosa.ontrack.model.support.ConfigurationService Maven / Gradle / Ivy
Show all versions of ontrack-model Show documentation
package net.nemerosa.ontrack.model.support;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
public interface ConfigurationService {
List getConfigurations();
List getConfigurationDescriptors();
T newConfiguration(T configuration);
/**
* Gets a configuration by its name and fails if not found.
*
* Note that the returned configuration is not obfuscated. It can be used internally safely
* and will be obfuscated whenever sent to the client.
*
* @param name Name of the configuration to find
* @return Found configuration
* @throws ConfigurationNotFoundException If the configuration cannot be found
*/
T getConfiguration(String name);
Optional getOptionalConfiguration(String name);
void deleteConfiguration(String name);
/**
* Tests a configuration
*/
ConnectionResult test(T configuration);
/**
* Gets the former password if new password is blank for the same user. For a new user,
* a blank password can be accepted.
*/
void updateConfiguration(String name, T configuration);
/**
* Tries to replace a configuration by another based on its name.
*
* If the replacement function, applied on the configuration name, would
* give the same exact name, this method returns the configuration.
*
* If the names are different, there are two cases:
*
* - If the current user is allowed to create a new configuration,
* the given configuration is transformed using the replacement
* function and a new configuration is created.
* - If the current user is not allowed to create a configuration,
* a {@link ConfigurationNotFoundException}
* exception is thrown.
*
*/
T replaceConfiguration(T configuration, Function replacementFunction) throws ConfigurationNotFoundException;
/**
* Type of configuration handled by this service
*/
Class getConfigurationType();
/**
* Adds a configuration event listener to this service
*/
void addConfigurationServiceListener(ConfigurationServiceListener listener);
}