use of com.google.gerrit.server.securestore.SecureStore in project gerrit by GerritCodeReview.
the class SwitchSecureStore method run.
@Override
public int run() throws Exception {
SitePaths sitePaths = new SitePaths(getSitePath());
Path newSecureStorePath = Paths.get(newSecureStoreLib);
if (!Files.exists(newSecureStorePath)) {
logger.atSevere().log("File %s doesn't exist", newSecureStorePath.toAbsolutePath());
return -1;
}
String newSecureStore = getNewSecureStoreClassName(newSecureStorePath);
String currentSecureStoreName = getCurrentSecureStoreClassName(sitePaths);
if (currentSecureStoreName.equals(newSecureStore)) {
logger.atSevere().log("Old and new SecureStore implementation names " + "are the same. Migration will not work");
return -1;
}
IoUtil.loadJARs(newSecureStorePath);
SiteLibraryLoaderUtil.loadSiteLib(sitePaths.lib_dir);
logger.atInfo().log("Current secureStoreClass property (%s) will be replaced with %s", currentSecureStoreName, newSecureStore);
Injector dbInjector = createDbInjector();
SecureStore currentStore = getSecureStore(currentSecureStoreName, dbInjector);
SecureStore newStore = getSecureStore(newSecureStore, dbInjector);
migrateProperties(currentStore, newStore);
removeOldLib(sitePaths, currentSecureStoreName);
copyNewLib(sitePaths, newSecureStorePath);
updateGerritConfig(sitePaths, newSecureStore);
return 0;
}
Aggregations