From 86044b1a1dc47d1f63ac63e097062d2fb750ba1f Mon Sep 17 00:00:00 2001 From: Julius Lee Date: Wed, 18 Sep 2024 14:04:45 -0700 Subject: [PATCH] LPD-36650 In LPD-34342 (d8ee37e5514d3808e97d492c2e1cf24d8dcd5a00), azure bom was upgraded from 1.2.20 to 1.2.26. azure-storage-blob version was upgraded from 12.25.1 to 12.27.0. In 12.26.0, there is a breaking change about URLEncoding the blob names. See: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/storage/azure-storage-blob/CHANGELOG.md BlobContainerClient.getBlobClient(String blobName) method no longer require us to do url encoding before we pass it in. --- .../portal/store/azure/AzureStore.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/modules/apps/portal-store/portal-store-azure/src/main/java/com/liferay/portal/store/azure/AzureStore.java b/modules/apps/portal-store/portal-store-azure/src/main/java/com/liferay/portal/store/azure/AzureStore.java index 3b3a44eaef2ed7..ea1104f99c20fd 100644 --- a/modules/apps/portal-store/portal-store-azure/src/main/java/com/liferay/portal/store/azure/AzureStore.java +++ b/modules/apps/portal-store/portal-store-azure/src/main/java/com/liferay/portal/store/azure/AzureStore.java @@ -24,7 +24,6 @@ import com.azure.storage.blob.models.BlobItem; import com.azure.storage.blob.models.BlobProperties; import com.azure.storage.blob.models.ListBlobsOptions; -import com.azure.storage.common.Utility; import com.liferay.document.library.kernel.exception.NoSuchFileException; import com.liferay.document.library.kernel.store.Store; @@ -78,7 +77,7 @@ public void addFile( throws PortalException { BlobClient blobClient = _blobContainerClient.getBlobClient( - _getBlobItemName(companyId, repositoryId, fileName, versionLabel)); + _getAzurePath(companyId, repositoryId, fileName, versionLabel)); File tempFile = null; @@ -158,7 +157,7 @@ public void deleteFile( String versionLabel) { BlobClient blobClient = _blobContainerClient.getBlobClient( - _getBlobItemName(companyId, repositoryId, fileName, versionLabel)); + _getAzurePath(companyId, repositoryId, fileName, versionLabel)); if (blobClient.exists()) { blobClient.delete(); @@ -177,7 +176,7 @@ public InputStream getFileAsStream( } BlobClient blobClient = _blobContainerClient.getBlobClient( - _getBlobItemName(companyId, repositoryId, fileName, versionLabel)); + _getAzurePath(companyId, repositoryId, fileName, versionLabel)); if (!blobClient.exists()) { throw new NoSuchFileException( @@ -220,7 +219,7 @@ public long getFileSize( } BlobClient blobClient = _blobContainerClient.getBlobClient( - _getBlobItemName(companyId, repositoryId, fileName, versionLabel)); + _getAzurePath(companyId, repositoryId, fileName, versionLabel)); if (!blobClient.exists()) { throw new NoSuchFileException( @@ -281,7 +280,7 @@ public boolean hasFile( } BlobClient blobClient = _blobContainerClient.getBlobClient( - _getBlobItemName(companyId, repositoryId, fileName, versionLabel)); + _getAzurePath(companyId, repositoryId, fileName, versionLabel)); return blobClient.exists(); } @@ -375,14 +374,6 @@ private String _getAzurePath( return sb.toString(); } - private String _getBlobItemName( - long companyId, long repositoryId, String fileName, - String versionLabel) { - - return Utility.urlEncode( - _getAzurePath(companyId, repositoryId, fileName, versionLabel)); - } - private String _getFileName( long companyId, long repositoryId, String blobItemName) {