From ccca6ab5d24c1c303bcd320350e3e5f35fd68476 Mon Sep 17 00:00:00 2001 From: Bella Luz Quintero Date: Fri, 20 Dec 2024 10:32:21 -0700 Subject: [PATCH] stub out filter for organizing and fetching azure files Co-authored-by: James Herr Co-authored-by: Sylvie --- .../rse2e/AzureBlobFileFetcher.java | 15 ++++++++++++++- .../rse2e/AzureBlobOrganizer.java | 13 ++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobFileFetcher.java b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobFileFetcher.java index 4d9a3a478..d6d950916 100644 --- a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobFileFetcher.java +++ b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobFileFetcher.java @@ -47,12 +47,25 @@ public static FileFetcher getInstance() { return INSTANCE; } + // TODO - we need to modify the guts to only grab the golden or automated path @Override public List fetchFiles() { + String files_path = System.getenv("LOCAL_FILE_PATH"); + if (files_path == null || files_path.isEmpty()) { + throw new IllegalArgumentException("Environment variable LOCAL_FILE_PATH is not set"); + } + List relevantFiles = new ArrayList<>(); LocalDate today = LocalDate.now(TIME_ZONE); - String pathPrefix = AzureBlobHelper.buildDatePathPrefix(today); + String datePrefix = AzureBlobHelper.buildDatePathPrefix(today); + + // TODO - update base on AzureBlobOrganizer + String pathPrefix = datePrefix + "Automated/"; + if (files_path.contains("GoldenCopy")) { + pathPrefix += datePrefix + "GoldenCopy/"; + } + ListBlobsOptions options = new ListBlobsOptions().setPrefix(pathPrefix); for (BlobItem blobItem : blobContainerClient.listBlobs(options, null)) { BlobClient blobClient = blobContainerClient.getBlobClient(blobItem.getName()); diff --git a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobOrganizer.java b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobOrganizer.java index 3a7345216..11a0be79e 100644 --- a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobOrganizer.java +++ b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/AzureBlobOrganizer.java @@ -47,14 +47,17 @@ public void organizeAndCleanupBlobsByDate(int retentionDays, ZoneId timeZone) { } // TODO - separate the content by golden or automated so it can be distinguished - // when its pulled down - // modify destinationName to be test folder specific - // possibly read blob and modify parseAndMapMessageByControlId or use its parts to - // get a different MSH header like getIdentifier + // when its pulled down and modify destinationName to be test folder specific // possibly use a different receiver and filter on that + String testTypeAndSourceName = "Automated/" + sourceName; + if (sourceBlob.getBlobName().contains("golden")) { + testTypeAndSourceName = "GoldenCopy/" + sourceName; + } + String destinationName = - AzureBlobHelper.createDateBasedPath(sourceCreationDate, sourceName); + AzureBlobHelper.createDateBasedPath( + sourceCreationDate, testTypeAndSourceName); BlobClient destinationBlob = blobContainerClient.getBlobClient(destinationName); destinationBlob