@@ -70,8 +70,8 @@ class SilverpeasMigrationTask extends DefaultTask {
70
70
71
71
@TaskAction
72
72
void performMigration () {
73
- initMigrationTask()
74
- loadMigrationModules(). each { module ->
73
+ Map< String , String > modulesStatus = initMigrationTask()
74
+ loadMigrationModules(modulesStatus ). each { module ->
75
75
try {
76
76
module. migrate()
77
77
} catch (Exception ex) {
@@ -82,13 +82,13 @@ class SilverpeasMigrationTask extends DefaultTask {
82
82
}
83
83
84
84
/**
85
- * Initializes the migration task first by loading the settings of the migration process, then by
86
- * performing any migration of these settings if it is required.
87
- * </p>
88
- * The migration settings are also persisted in a data source and they could be subject to a
89
- * migration before doing anything .
85
+ * Initializes the migration task first by loading the actual status of each modules in Silverpeas
86
+ * and then by migrating, if needed, the migration process module itself (the status of this
87
+ * module is also persisted into the Silverpeas data source).
88
+ * @return the status of each module in a dictionary; in each entry, the key is the name of the
89
+ * module and the value the actual version of the module .
90
90
*/
91
- private void initMigrationTask () {
91
+ private Map< String , String > initMigrationTask () {
92
92
log. info ' Migration initialization...'
93
93
def status = loadInstalledModuleStatus()
94
94
Path descriptor = Paths . get(migrationHome. path, ' modules' , MIGRATION_SETTING_MODULE )
@@ -99,14 +99,18 @@ class SilverpeasMigrationTask extends DefaultTask {
99
99
.loadMigrationsFrom(descriptor. toFile())
100
100
module. migrate()
101
101
log. info ' Migration initialization done'
102
+ return status
102
103
}
103
104
104
105
/**
105
- * Loads all the available migration modules in Silverpeas.
106
+ * Loads all of the available migration modules in Silverpeas from their descriptor and the
107
+ * specified status. The descriptor of each module is an XML file located in a predefined
108
+ * folder of the Silverpeas distribution home directory.
109
+ * @param status the status of all the modules from which each module will know what migration
110
+ * it has to do.
106
111
* @return a list of the available migration modules.
107
112
*/
108
- private List<MigrationModule > loadMigrationModules () {
109
- def status = loadInstalledModuleStatus()
113
+ private List<MigrationModule > loadMigrationModules (Map<String , String > status ) {
110
114
List<MigrationModule > modules = []
111
115
new File (migrationHome, ' modules' ). listFiles(). each { descriptor ->
112
116
if (descriptor. name != MIGRATION_SETTING_MODULE ) {
@@ -123,10 +127,17 @@ class SilverpeasMigrationTask extends DefaultTask {
123
127
}
124
128
}
125
129
126
- private def loadInstalledModuleStatus () {
130
+ /**
131
+ * Loads from the Silverpeas data source the status of all of the currently installed modules.
132
+ * If it is a fresh installation, then the returned status will be empty as there will be no
133
+ * modules yet installed.
134
+ * @return the status of all of the modules actually installed. It is a dictionary with, for each
135
+ * entry, the name of the module as the key and the actual version of that module as value.
136
+ */
137
+ private Map<String , String > loadInstalledModuleStatus () {
127
138
def level = logging. level
128
139
logging. captureStandardOutput(LogLevel . ERROR )
129
- def status = [:]
140
+ Map< String , String > status = [:]
130
141
DataSourceProvider dataSourceProvider = ManagedBeanContainer . get(DataSourceProvider . class)
131
142
Sql sql = new Sql (dataSourceProvider. dataSource)
132
143
try {
0 commit comments