* current ScmSyncConfigurationPlugin instance
*/
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
ScmSyncConfigurationPlugin plugin;
if(context.currentObject() == null || !(context.currentObject() instanceof ScmSyncConfigurationPlugin)){
// This should never happen to get here
plugin = new ScmSyncConfigurationPlugin();
} else {
// Retrieving already instantiated ScmSyncConfiguration plugin into current context ..
plugin = (ScmSyncConfigurationPlugin)context.currentObject();
}
// Retrieving data representation version number
String version = reader.getAttribute(VERSION_ATTRIBUTE);
// Before version 1 (version 0), there wasn't any version in the scm sync configuration
// configuration file
int versionNumber = 0;
if(version != null){
versionNumber = Integer.parseInt(version);
}
if(versionNumber != getCurrentScmSyncConfigurationVersionNumber()){
// There will be a data migration ..
LOGGER.info("Your version of persisted ScmSyncConfigurationPlugin data is not up-to-date (v"+versionNumber+" < v"+getCurrentScmSyncConfigurationVersionNumber()+") : data will be migrated !");
}
// Calling version's reader to read data representation
ScmSyncConfigurationPOJO pojo = MIGRATORS[versionNumber].readScmSyncConfigurationPOJO(reader, context);
// Migrating old data into up-to-date data
// Added "+1" because we take into consideration InitialMigrator
for(int i=versionNumber+1; i<getCurrentScmSyncConfigurationVersionNumber()+1; i++){
pojo = MIGRATORS[i].migrate(pojo);
}
// Populating latest POJO information into ScmSyncConfigurationPlugin
plugin.loadData(pojo);
return plugin;
}