use of com.helger.phoss.smp.backend.sql.mgr.SMPTransportProfileManagerJDBC in project phoss-smp by phax.
the class V5__MigrateTransportProfilesToDB method migrate.
public void migrate(@Nonnull final Context context) throws Exception {
try (final WebScoped aWS = new WebScoped()) {
LOGGER.info("Migrating all transport profiles to the DB");
final String sFilename = "transportprofiles.xml";
final File aFile = WebFileIO.getDataIO().getFile(sFilename);
if (aFile.exists()) {
final SMPTransportProfileManagerXML aMgrXML = new SMPTransportProfileManagerXML(sFilename);
final ICommonsList<ISMPTransportProfile> aTransportProfiles = aMgrXML.getAll();
if (aTransportProfiles.isNotEmpty()) {
final SMPTransportProfileManagerJDBC aMgrNew = new SMPTransportProfileManagerJDBC(SMPDBExecutor::new);
for (final ISMPTransportProfile aTransportProfile : aTransportProfiles) if (aMgrNew.createSMPTransportProfile(aTransportProfile.getID(), aTransportProfile.getName(), aTransportProfile.isDeprecated()) == null)
LOGGER.error("Failed to migrate " + aTransportProfile + " to DB");
}
// Rename to avoid later inconsistencies
WebFileIO.getDataIO().renameFile(sFilename, sFilename + ".migrated");
LOGGER.info("Finished migrating all " + aTransportProfiles.size() + " transport profiles to the DB");
} else {
LOGGER.info("No transport profile file found");
}
}
}
Aggregations