diff --git a/src/Storage/Altinn.Platform.Storage.csproj b/src/Storage/Altinn.Platform.Storage.csproj index e93d24e6..a1b4b5d4 100644 --- a/src/Storage/Altinn.Platform.Storage.csproj +++ b/src/Storage/Altinn.Platform.Storage.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Storage/Controllers/CleanupController.cs b/src/Storage/Controllers/CleanupController.cs index 104d3d64..f88e7430 100644 --- a/src/Storage/Controllers/CleanupController.cs +++ b/src/Storage/Controllers/CleanupController.cs @@ -142,7 +142,7 @@ public async Task CleanupDataelements() app = await applicationRepository.FindOne(instance.AppId, instance.Org); } - if (!await blobRepository.DeleteBlob(dataElement.BlobStoragePath.Split('/')[0], dataElement.BlobStoragePath, app.StorageContainerNumber)) + if (!await blobRepository.DeleteBlob(dataElement.BlobStoragePath.Split('/')[0], dataElement.BlobStoragePath, app.StorageAccountNumber)) { _logger.LogError( "CleanupController // CleanupDataelements // Blob not found for dataElement Id: {dataElement.Id} Blobstoragepath: {blobStoragePath}", @@ -192,7 +192,7 @@ private async Task CleanupInstancesInternal(List instances, List< try { Application app = await applicationRepository.FindOne(instance.AppId, instance.Org); - blobsNoException = await blobRepository.DeleteDataBlobs(instance, app.StorageContainerNumber); + blobsNoException = await blobRepository.DeleteDataBlobs(instance, app.StorageAccountNumber); if (blobsNoException) { diff --git a/src/Storage/Controllers/ContentOnDemandController.cs b/src/Storage/Controllers/ContentOnDemandController.cs index 9edc1341..f34ee645 100644 --- a/src/Storage/Controllers/ContentOnDemandController.cs +++ b/src/Storage/Controllers/ContentOnDemandController.cs @@ -81,7 +81,7 @@ public async Task GetSignatureAsHtml([FromRoute] string org, [From await _blobRepository.ReadBlob( $"{(_generalSettings.A2UseTtdAsServiceOwner ? "ttd" : instance.Org)}", $"{instance.Org}/{app}/{instanceGuid}/data/{signatureElement.Id}", - application.StorageContainerNumber)); + application.StorageAccountNumber)); return View("Signature", view); } @@ -106,7 +106,7 @@ public async Task GetPaymentAsHtml([FromRoute] string org, [FromRo await _blobRepository.ReadBlob( $"{(_generalSettings.A2UseTtdAsServiceOwner ? "ttd" : instance.Org)}", $"{instance.Org}/{app}/{instanceGuid}/data/{paymentElement.Id}", - application.StorageContainerNumber)); + application.StorageAccountNumber)); return View("Payment", view); } @@ -234,7 +234,7 @@ private async Task GetFormdataAsHtmlInternal(string org, string app, Gui return _a2OndemandFormattingService.GetFormdataHtml( xsls, - await _blobRepository.ReadBlob($"{(_generalSettings.A2UseTtdAsServiceOwner ? "ttd" : instance.Org)}", $"{instance.Org}/{app}/{instanceGuid}/data/{xmlElement.Id}", application.StorageContainerNumber), + await _blobRepository.ReadBlob($"{(_generalSettings.A2UseTtdAsServiceOwner ? "ttd" : instance.Org)}", $"{instance.Org}/{app}/{instanceGuid}/data/{xmlElement.Id}", application.StorageAccountNumber), xmlElement.Created.ToString()); } } diff --git a/src/Storage/Controllers/DataController.cs b/src/Storage/Controllers/DataController.cs index f2ef3054..9f651374 100644 --- a/src/Storage/Controllers/DataController.cs +++ b/src/Storage/Controllers/DataController.cs @@ -140,7 +140,7 @@ public async Task> Delete(int instanceOwnerPartyId, Gu } dataElement.LastChangedBy = User.GetUserOrOrgId(); - return await DeleteImmediately(instance, dataElement, application.StorageContainerNumber); + return await DeleteImmediately(instance, dataElement, application.StorageAccountNumber); } /// @@ -199,7 +199,7 @@ public async Task Get(int instanceOwnerPartyId, Guid instanceGuid, if (string.Equals(dataElement.BlobStoragePath, storageFileName)) { - Stream dataStream = await _blobRepository.ReadBlob(instance.Org, storageFileName, app.StorageContainerNumber); + Stream dataStream = await _blobRepository.ReadBlob(instance.Org, storageFileName, app.StorageAccountNumber); if (dataStream == null) { @@ -312,11 +312,11 @@ public async Task> CreateAndUploadData( } newData.Filename = HttpUtility.UrlDecode(newData.Filename); - (long length, DateTimeOffset blobTimestamp) = await _blobRepository.WriteBlob(instance.Org, theStream, newData.BlobStoragePath, appInfo.StorageContainerNumber); + (long length, DateTimeOffset blobTimestamp) = await _blobRepository.WriteBlob(instance.Org, theStream, newData.BlobStoragePath, appInfo.StorageAccountNumber); if (length == 0L) { - await _blobRepository.DeleteBlob(instance.Org, newData.BlobStoragePath, appInfo.StorageContainerNumber); + await _blobRepository.DeleteBlob(instance.Org, newData.BlobStoragePath, appInfo.StorageAccountNumber); return BadRequest("Empty stream provided. Cannot persist data."); } @@ -330,7 +330,7 @@ public async Task> CreateAndUploadData( DataElement dataElement = await _dataRepository.Create(newData, instanceInternalId); dataElement.SetPlatformSelfLinks(_storageBaseAndHost, instanceOwnerPartyId); - await _dataService.StartFileScan(instance, dataTypeDefinition, dataElement, blobTimestamp, appInfo.StorageContainerNumber, CancellationToken.None); + await _dataService.StartFileScan(instance, dataTypeDefinition, dataElement, blobTimestamp, appInfo.StorageAccountNumber, CancellationToken.None); await _instanceEventService.DispatchEvent(InstanceEventType.Created, instance, dataElement); @@ -418,7 +418,7 @@ public async Task> OverwriteData( DateTime changedTime = DateTime.UtcNow; - (long blobSize, DateTimeOffset blobTimestamp) = await _blobRepository.WriteBlob(instance.Org, theStream, blobStoragePathName, appInfo.StorageContainerNumber); + (long blobSize, DateTimeOffset blobTimestamp) = await _blobRepository.WriteBlob(instance.Org, theStream, blobStoragePathName, appInfo.StorageAccountNumber); var updatedProperties = new Dictionary() { @@ -446,7 +446,7 @@ public async Task> OverwriteData( updatedElement.SetPlatformSelfLinks(_storageBaseAndHost, instanceOwnerPartyId); - await _dataService.StartFileScan(instance, dataTypeDefinition, dataElement, blobTimestamp, appInfo.StorageContainerNumber, CancellationToken.None); + await _dataService.StartFileScan(instance, dataTypeDefinition, dataElement, blobTimestamp, appInfo.StorageAccountNumber, CancellationToken.None); await _instanceEventService.DispatchEvent(InstanceEventType.Saved, instance, updatedElement); diff --git a/src/Storage/Controllers/MigrationController.cs b/src/Storage/Controllers/MigrationController.cs index 4d17c49d..62e6c1dd 100644 --- a/src/Storage/Controllers/MigrationController.cs +++ b/src/Storage/Controllers/MigrationController.cs @@ -208,7 +208,7 @@ public async Task> CreateDataElement( $"{(_generalSettings.A2UseTtdAsServiceOwner ? "ttd" : instance.Org)}", theStream, dataElement.BlobStoragePath, - app.StorageContainerNumber); + app.StorageAccountNumber); } else { @@ -489,7 +489,7 @@ private async Task CleanupOldMigrationInternal(string instanceId) } instance.Id = instanceId; - await _blobRepository.DeleteDataBlobs(instance, app.StorageContainerNumber); + await _blobRepository.DeleteDataBlobs(instance, app.StorageAccountNumber); await _dataRepository.DeleteForInstance(instanceId); await _instanceEventRepository.DeleteAllInstanceEvents(instanceId); await _instanceRepository.Delete(instance); diff --git a/src/Storage/Models/FileScanRequest.cs b/src/Storage/Models/FileScanRequest.cs index 25e0988b..06171ec0 100644 --- a/src/Storage/Models/FileScanRequest.cs +++ b/src/Storage/Models/FileScanRequest.cs @@ -42,8 +42,8 @@ public class FileScanRequest public string Org { get; set; } /// - /// Gets or sets an optional container number for when the application owner have more than one storage container + /// Gets or sets an optional account number for when the application owner have more than one storage account /// - public int? StorageContainerNumber { get; set; } + public int? StorageAccountNumber { get; set; } } } diff --git a/src/Storage/Services/DataService.cs b/src/Storage/Services/DataService.cs index e6295800..72773ab7 100644 --- a/src/Storage/Services/DataService.cs +++ b/src/Storage/Services/DataService.cs @@ -45,7 +45,7 @@ public async Task StartFileScan(Instance instance, DataType dataType, DataElemen BlobStoragePath = dataElement.BlobStoragePath, Filename = dataElement.Filename, Org = instance.Org, - StorageContainerNumber = storageAccountNumber + StorageAccountNumber = storageAccountNumber }; string serialisedRequest = JsonSerializer.Serialize( diff --git a/src/Storage/Services/InstanceService.cs b/src/Storage/Services/InstanceService.cs index 1eebb642..fa2c134b 100644 --- a/src/Storage/Services/InstanceService.cs +++ b/src/Storage/Services/InstanceService.cs @@ -54,7 +54,7 @@ public InstanceService(IInstanceRepository instanceRepository, IDataService data foreach (SignRequest.DataElementSignature dataElementSignature in signRequest.DataElementSignatures) { - (string base64Sha256Hash, serviceError) = await _dataService.GenerateSha256Hash(instance.Org, instanceGuid, Guid.Parse(dataElementSignature.DataElementId), app.StorageContainerNumber); + (string base64Sha256Hash, serviceError) = await _dataService.GenerateSha256Hash(instance.Org, instanceGuid, Guid.Parse(dataElementSignature.DataElementId), app.StorageAccountNumber); if (string.IsNullOrEmpty(base64Sha256Hash)) { return (false, serviceError); @@ -83,7 +83,7 @@ public InstanceService(IInstanceRepository instanceRepository, IDataService data using (MemoryStream fileStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(signDocument, Formatting.Indented)))) { - await _dataService.UploadDataAndCreateDataElement(instance.Org, fileStream, dataElement, instanceInternalId, app.StorageContainerNumber); + await _dataService.UploadDataAndCreateDataElement(instance.Org, fileStream, dataElement, instanceInternalId, app.StorageAccountNumber); } await _instanceEventService.DispatchEvent(InstanceEventType.Signed, instance);