Skip to content

Commit e4f8121

Browse files
authored
Update InitWorkspaceServer.java
1 parent cc0611a commit e4f8121

File tree

1 file changed

+14
-32
lines changed

1 file changed

+14
-32
lines changed

service/src/main/java/us/kbase/workspace/kbase/InitWorkspaceServer.java

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -540,29 +540,26 @@ private static AuthToken getToken(
540540
private static BlobStore setupBlobStore(
541541
final MongoDatabase db,
542542
final KBaseWorkspaceConfig cfg,
543-
final InitReporter rep) // Added rep to track progress
543+
final InitReporter rep)
544544
throws WorkspaceInitException {
545545

546546
rep.reportInfo("Entering setupBlobStore...");
547-
548-
// Check what backend type is being used
549547
rep.reportInfo("Backend type: " + cfg.getBackendType().name());
550548

551549
if (cfg.getBackendType().equals(BackendType.GridFS)) {
552550
rep.reportInfo("Initializing GridFSBlobStore...");
553-
BlobStore store = new GridFSBlobStore(db);
554-
rep.reportInfo("GridFSBlobStore initialized successfully.");
555-
return store;
551+
return new GridFSBlobStore(db);
556552
}
557553

558554
if (cfg.getBackendType().equals(BackendType.S3)) {
559555
rep.reportInfo("Initializing S3BlobStore...");
556+
560557
try {
561558
rep.reportInfo("Creating S3 client with the following parameters:");
562-
rep.reportInfo("Backend URL: " + cfg.getBackendURL());
563-
rep.reportInfo("Backend User: " + cfg.getBackendUser());
564-
rep.reportInfo("Backend Region: " + cfg.getBackendRegion());
565-
rep.reportInfo("Trust All Certs: " + cfg.getBackendTrustAllCerts());
559+
rep.reportInfo(" - Backend URL: " + cfg.getBackendURL());
560+
rep.reportInfo(" - Backend User: " + cfg.getBackendUser());
561+
rep.reportInfo(" - Backend Region: " + cfg.getBackendRegion());
562+
rep.reportInfo(" - Trust All Certs: " + cfg.getBackendTrustAllCerts());
566563

567564
final S3ClientWithPresign cli = new S3ClientWithPresign(
568565
cfg.getBackendURL(),
@@ -572,36 +569,21 @@ private static BlobStore setupBlobStore(
572569
cfg.getBackendTrustAllCerts());
573570

574571
rep.reportInfo("S3 client created successfully.");
572+
573+
rep.reportInfo("Initializing S3BlobStore with Backend Container: " + cfg.getBackendContainer());
575574

576-
577-
578-
// Add logs before initializing S3BlobStore
579-
rep.reportInfo("Initializing S3BlobStore with:");
580-
581-
rep.reportInfo(" - Backend Container: " + cfg.getBackendContainer());
582-
583-
try {
584-
BlobStore store = new S3BlobStore(db.getCollection(COL_S3_OBJECTS), cli, cfg.getBackendContainer());
585-
rep.reportInfo("S3BlobStore initialized successfully.");
586-
return store;
587-
} catch (Exception e) {
588-
rep.reportInfo("Error initializing S3BlobStore: " + e.getMessage());
589-
throw new WorkspaceInitException("Failed to initialize S3BlobStore: " + e.getMessage(), e);
590-
}
575+
return new S3BlobStore(db.getCollection(COL_S3_OBJECTS), cli, cfg.getBackendContainer());
591576

592577
} catch (URISyntaxException e) {
593-
rep.reportInfo("Error: Invalid S3 URL: " + e.getMessage());
594-
throw new WorkspaceInitException("S3 url is not a valid URI: " + e.getMessage(), e);
595-
} catch (BlobStoreCommunicationException e) {
596-
rep.reportInfo("Error: BlobStore communication issue: " + e.getMessage());
597-
throw new WorkspaceInitException("Error communicating with the blob store: " + e.getMessage(), e);
578+
throw new WorkspaceInitException("S3 URL is not a valid URI: " + e.getMessage(), e);
598579
} catch (IllegalArgumentException e) {
599-
rep.reportInfo("Error: Illegal S3 bucket name: " + e.getMessage());
600580
throw new WorkspaceInitException("Illegal S3 bucket name: " + e.getMessage(), e);
581+
} catch (Exception e) {
582+
// Catch any unexpected errors in S3BlobStore initialization
583+
throw new WorkspaceInitException("Failed to initialize S3BlobStore: " + e.getMessage(), e);
601584
}
602585
}
603586

604-
rep.reportInfo("Error: Unknown backend type: " + cfg.getBackendType().name());
605587
throw new WorkspaceInitException("Unknown backend type: " + cfg.getBackendType().name());
606588
}
607589

0 commit comments

Comments
 (0)