Search in sources :

Example 1 with SecureStore

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;
}
Also used : Path(java.nio.file.Path) Injector(com.google.inject.Injector) SitePaths(com.google.gerrit.server.config.SitePaths) SecureStore(com.google.gerrit.server.securestore.SecureStore) DefaultSecureStore(com.google.gerrit.server.securestore.DefaultSecureStore)

Aggregations

SitePaths (com.google.gerrit.server.config.SitePaths)1 DefaultSecureStore (com.google.gerrit.server.securestore.DefaultSecureStore)1 SecureStore (com.google.gerrit.server.securestore.SecureStore)1 Injector (com.google.inject.Injector)1 Path (java.nio.file.Path)1