Class SqlVersionStorage
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.migration.storage.impl.SqlVersionStorage
-
- All Implemented Interfaces:
VersionStorage
,LogEnabled
,Serviceable
public class SqlVersionStorage extends AbstractLogEnabled implements VersionStorage, Serviceable
SQL implementation ofVersionStorage
, to manage the list of versions in a database
-
-
Field Summary
Fields Modifier and Type Field Description protected SourceResolver
_sourceResolver
Source resolver
-
Constructor Summary
Constructors Constructor Description SqlVersionStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_initVersionsTableIfNeeded(String dataSourceId)
Create the versions table if neededvoid
addVersion(Version version)
Add a versionList<Version>
getAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId)
Get the history of all versions for a component identifierVersionConfiguration
getConfiguration(String componentId, Configuration versionConfiguration)
Create a specific object containing usefull data for the handler/storageVersion
getCurrentVersion(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId)
Find the current version for a component identifiervoid
removeAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration)
Remove all versions for a component identifiervoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_sourceResolver
protected SourceResolver _sourceResolver
Source resolver
-
-
Constructor Detail
-
SqlVersionStorage
public SqlVersionStorage()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCurrentVersion
public Version getCurrentVersion(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId) throws MigrationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Find the current version for a component identifier- Specified by:
getCurrentVersion
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to look forversionConfiguration
- configuration to useversionHandlerId
- id of theVersionHandler
- Returns:
- the current version for this component (can have a versionId null if no version is found), or null if it is impossible to determine the version (e.g. safe mode).
- Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to determine the version
-
getAllVersions
public List<Version> getAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration, String versionHandlerId) throws MigrationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Get the history of all versions for a component identifier- Specified by:
getAllVersions
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to look forversionConfiguration
- configuration to useversionHandlerId
- id of theVersionHandler
- Returns:
- list of all versions for this component
- Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to determine the version
-
addVersion
public void addVersion(Version version) throws MigrationException
Description copied from interface:VersionStorage
Add a version- Specified by:
addVersion
in interfaceVersionStorage
- Parameters:
version
- Version to store (contains the component identifier)- Throws:
MigrationException
- Something went wrong
-
removeAllVersions
public void removeAllVersions(String componentIdentifier, VersionConfiguration versionConfiguration) throws MigrationException
Description copied from interface:VersionStorage
Remove all versions for a component identifier- Specified by:
removeAllVersions
in interfaceVersionStorage
- Parameters:
componentIdentifier
- component to clearversionConfiguration
- configuration to use- Throws:
MigrationException
- Something went wrong
-
_initVersionsTableIfNeeded
protected void _initVersionsTableIfNeeded(String dataSourceId) throws MigrationException
Create the versions table if needed- Parameters:
dataSourceId
- the datasource where the table will be created- Throws:
MigrationException
- Something went wrong
-
getConfiguration
public VersionConfiguration getConfiguration(String componentId, Configuration versionConfiguration) throws ConfigurationException, NotMigrableInSafeModeException
Description copied from interface:VersionStorage
Create a specific object containing usefull data for the handler/storage- Specified by:
getConfiguration
in interfaceVersionStorage
- Parameters:
componentId
- id of the componentversionConfiguration
- configuration from the plugin.xml- Returns:
- the confuguration object
- Throws:
ConfigurationException
- something wrong in the configurationNotMigrableInSafeModeException
- Impossible to determine the version
-
-