Skip to content

Commit

Permalink
app: Fix NPE. Add appHome to OrganizationMigration. #TASK-7118
Browse files Browse the repository at this point in the history
  • Loading branch information
j-coll committed Oct 24, 2024
1 parent d2c8073 commit bfe1925
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void runMigrationToV3() throws Exception {
setCatalogDatabaseCredentials(options, options.commonOptions);

OrganizationMigration organizationMigration = new OrganizationMigration(configuration, options.commonOptions.adminPassword,
options.user, options.organizationId);
options.user, options.organizationId, Paths.get(appHome));
organizationMigration.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bson.conversions.Bson;
import org.opencb.commons.datastore.mongodb.MongoDataStore;
import org.opencb.commons.utils.CryptoUtils;
import org.opencb.commons.utils.FileUtils;
import org.opencb.opencga.analysis.variant.manager.VariantStorageManager;
import org.opencb.opencga.catalog.auth.authentication.CatalogAuthenticationManager;
import org.opencb.opencga.catalog.db.api.StudyDBAdaptor;
Expand Down Expand Up @@ -45,6 +46,7 @@
import java.lang.reflect.Modifier;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.NoSuchAlgorithmException;
import java.util.*;
Expand All @@ -70,21 +72,25 @@ private enum MigrationStatus {
ERROR
}

public OrganizationMigration(Configuration configuration, String adminPassword, String userId, String organizationId)
throws CatalogException {
public OrganizationMigration(Configuration configuration, String adminPassword, String userId, String organizationId, Path appHome)
throws CatalogException, IOException {
this.configuration = configuration;
this.adminPassword = adminPassword;
this.userId = userId;
this.organizationId = organizationId;
this.appHome = appHome;

this.status = checkAndInit();
}

private MigrationStatus checkAndInit() throws CatalogException {
private MigrationStatus checkAndInit() throws CatalogException, IOException {
this.oldDatabase = configuration.getDatabasePrefix() + "_catalog";
this.mongoDBAdaptorFactory = new MongoDBAdaptorFactory(configuration);
this.oldDatastore = mongoDBAdaptorFactory.getMongoManager().get(oldDatabase, mongoDBAdaptorFactory.getMongoDbConfiguration());

FileUtils.checkDirectory(appHome);
readStorageConfiguration();

MongoCollection<Document> userCol = oldDatastore.getDb().getCollection(OrganizationMongoDBAdaptorFactory.USER_COLLECTION);
FindIterable<Document> iterable = userCol.find(Filters.eq("id", ParamConstants.OPENCGA_USER_ID));
try (MongoCursor<Document> cursor = iterable.cursor()) {
Expand Down

0 comments on commit bfe1925

Please sign in to comment.