Added session in all methods

This commit is contained in:
luca.frosini 2023-07-11 10:55:53 +02:00
parent 1199570e57
commit 3bfbe5ed9b
1 changed files with 28 additions and 14 deletions

View File

@ -88,6 +88,10 @@ public class CatalogueStorageHubManagement {
}
protected void internalAddRevisionID(String resourceID, String revisionID) throws Exception {
SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
FileContainer fileContainer = storageHubManagement.getPersistedFile();
if(fileContainer != null) {
Metadata metadata = fileContainer.get().getMetadata();
@ -101,6 +105,9 @@ public class CatalogueStorageHubManagement {
"Unable to set revision id {} to the file of resource with id {} because the file was NOT found on storage-hub. This could be related to an item not created via gCat. Skipping it.",
revisionID, resourceID);
}
} finally {
secretManager.endSession();
}
}
public void renameFile(String resourceID, String revisionID) throws Exception {
@ -139,8 +146,15 @@ public class CatalogueStorageHubManagement {
}
}
public FileContainer getPersistedFile() {
public FileContainer getPersistedFile() throws Exception {
SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
return storageHubManagement.getPersistedFile();
} finally {
secretManager.endSession();
}
}
}