OCI object storage api fehler behoben
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package de.galabau.dateieingang.oci;
|
||||
|
||||
import com.oracle.bmc.Region;
|
||||
import com.oracle.bmc.auth.SimpleAuthenticationDetailsProvider;
|
||||
import com.oracle.bmc.objectstorage.ObjectStorage;
|
||||
import com.oracle.bmc.objectstorage.ObjectStorageClient;
|
||||
@@ -9,6 +10,7 @@ import de.galabau.dateieingang.exception.OciException;
|
||||
import de.galabau.dateieingang.model.FileEntry;
|
||||
import de.galabau.dateieingang.model.ProcessingContext;
|
||||
import io.quarkus.logging.Log;
|
||||
import io.quarkus.runtime.Startup;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -23,6 +25,7 @@ import java.util.List;
|
||||
* Lädt die entpackten Dateien und den Marker in OCI Object Storage hoch.
|
||||
* Authentifizierung via OCI HTTP Signature V1 (entspricht APEX Web Credential vom Typ OCI).
|
||||
*/
|
||||
//@Startup
|
||||
@ApplicationScoped
|
||||
public class OciUploadService {
|
||||
|
||||
@@ -34,24 +37,29 @@ public class OciUploadService {
|
||||
@PostConstruct
|
||||
void init() {
|
||||
Log.info("Initialisiere OCI ObjectStorage-Client...");
|
||||
SimpleAuthenticationDetailsProvider auth = SimpleAuthenticationDetailsProvider.builder()
|
||||
.tenantId(config.tenancyId())
|
||||
.userId(config.userId())
|
||||
.fingerprint(config.fingerprint())
|
||||
.privateKeySupplier(() -> {
|
||||
try {
|
||||
return Files.newInputStream(Path.of(config.privateKeyPath()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("OCI Private Key nicht lesbar: "
|
||||
+ config.privateKeyPath(), e);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
Log.info("Auhtentifizierung...");
|
||||
client = ObjectStorageClient.builder()
|
||||
.endpoint("https://objectstorage." + config.region() + ".oraclecloud.com")
|
||||
.build(auth);
|
||||
Log.infof("OCI ObjectStorage-Client initialisiert (Region: %s, Bucket: %s)", config.region(), config.bucket());
|
||||
try {
|
||||
SimpleAuthenticationDetailsProvider auth = SimpleAuthenticationDetailsProvider.builder()
|
||||
.tenantId(config.tenancyId())
|
||||
.userId(config.userId())
|
||||
.fingerprint(config.fingerprint())
|
||||
.region(Region.fromRegionId(config.region()))
|
||||
.privateKeySupplier(() -> {
|
||||
try {
|
||||
return Files.newInputStream(Path.of(config.privateKeyPath()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("OCI Private Key nicht lesbar: "
|
||||
+ config.privateKeyPath(), e);
|
||||
}
|
||||
})
|
||||
.build();
|
||||
Log.info("Authentifizierung...");
|
||||
client = ObjectStorageClient.builder()
|
||||
.build(auth);
|
||||
Log.infof("OCI ObjectStorage-Client initialisiert (Region: %s, Bucket: %s)", config.region(), config.bucket());
|
||||
} catch (Throwable e) {
|
||||
Log.errorf(e, "OCI ObjectStorage-Client Initialisierung fehlgeschlagen");
|
||||
throw new RuntimeException("OCI-Client konnte nicht initialisiert werden", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,7 +69,7 @@ public class FileProcessingPipeline {
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
processAll();
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) { // nicht exception catchen, weil Error in OCI SDK auftreten können, die Throwable aber nicht Excption sind. Die würden sonst nicht geloggt
|
||||
Log.errorf(e, "Unerwarteter Fehler im Pipeline-Lauf");
|
||||
} finally {
|
||||
isRunning.set(false);
|
||||
|
||||
Reference in New Issue
Block a user