Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SELC-6155] feat: Added new method into SDK Azure #631

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions libs/onboarding-sdk-azure-storage/pom.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.5.1</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.6.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>

<artifactId>onboarding-sdk-azure-storage</artifactId>
<artifactId>onboarding-sdk-azure-storage</artifactId>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<azure-storage-blob-version>12.24.0</azure-storage-blob-version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<azure-storage-blob-version>12.24.0</azure-storage-blob-version>
<commons-lang3.version>3.12.0</commons-lang3.version>
</properties>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>${azure-storage-blob-version}</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>${azure-storage-blob-version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package it.pagopa.selfcare.azurestorage;

import com.azure.storage.blob.models.BlobProperties;

import java.io.File;
import java.util.List;

public interface AzureBlobClient {

Expand All @@ -17,4 +17,6 @@ public interface AzureBlobClient {
void removeFile(String fileName);

BlobProperties getProperties(String filePath);

List<String> getFiles(String path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.models.BlobListDetails;
import com.azure.storage.blob.models.BlobProperties;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.models.ListBlobsOptions;
import it.pagopa.selfcare.azurestorage.error.SelfcareAzureStorageError;
import it.pagopa.selfcare.azurestorage.error.SelfcareAzureStorageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class AzureBlobClientDefault implements AzureBlobClient {
Expand Down Expand Up @@ -151,4 +155,26 @@ public BlobProperties getProperties(String filePath) {
}
}

@Override
public List<String> getFiles(String path) {
log.debug("START - getFiles by given path: {}", path);
List<String> listOfResource = new ArrayList<>();
final BlobContainerClient blobContainer = blobClient.getBlobContainerClient(containerName);

if (StringUtils.isNotEmpty(path)) {

ListBlobsOptions options = new ListBlobsOptions()
.setPrefix(path)
.setDetails(new BlobListDetails()
.setRetrieveDeletedBlobs(true)
.setRetrieveSnapshots(true));

blobContainer.listBlobs(options, null).forEach(blob -> listOfResource.add(blob.getName()));
}

log.debug("Results: {}", listOfResource.size());
log.debug("END - getFiles");
return listOfResource;
}

}
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.5.1</version>
<version>0.6.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion libs/onboarding-sdk-crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.5.1</version>
<version>0.6.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-crypto</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions libs/onboarding-sdk-pom/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<project>
<modelVersion>4.0.0</modelVersion>


<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<packaging>pom</packaging>
<name>onboarding-sdk-pom</name>
<version>0.5.1</version>
<version>0.6.0</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
4 changes: 2 additions & 2 deletions libs/onboarding-sdk-product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-pom</artifactId>
<version>0.5.1</version>
<version>0.6.0</version>
<relativePath>../onboarding-sdk-pom</relativePath>
</parent>
<artifactId>onboarding-sdk-product</artifactId>
<name>onboarding-sdk-product</name>
<version>0.5.1</version>
<version>0.6.0</version>

<properties>
<jackson.version>2.15.2</jackson.version>
Expand Down
Loading