Commit 98e7e1be authored by Aman Verma's avatar Aman Verma
Browse files

removing DPSHeaders

parent 96569f63
Pipeline #4836 passed with stages
in 9 minutes and 4 seconds
......@@ -20,7 +20,6 @@ import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.specialized.BlockBlobClient;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
......@@ -29,7 +28,8 @@ import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;;
import java.nio.charset.StandardCharsets;
import java.util.Collections;;
/**
* A simpler interface to interact with Azure blob storage.
......@@ -69,9 +69,6 @@ public class BlobStore {
@Autowired
private ILogger logger;
@Autowired
private DpsHeaders headers;
private static final String LOG_PREFIX = "azure-core-lib";
/**
......@@ -89,20 +86,20 @@ public class BlobStore {
} catch (BlobStorageException ex) {
if (ex.getErrorCode().equals(BlobErrorCode.BLOB_NOT_FOUND)) {
String errorMessage = "Specified blob was not found";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(404, errorMessage, ex.getMessage(), ex);
} else {
String errorMessage = "Failed to read specified blob";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
}
} catch (UnsupportedEncodingException ex) {
String errorMessage = String.format("Encoding was not correct for item with name=%s", filePath);
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(400, errorMessage, ex.getMessage(), ex);
} catch (IOException ex) {
String errorMessage = String.format("Malformed document for item with name=%s", filePath);
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
}
}
......@@ -122,11 +119,11 @@ public class BlobStore {
} catch (BlobStorageException ex) {
if (ex.getErrorCode().equals(BlobErrorCode.BLOB_NOT_FOUND)) {
String errorMessage = "Specified blob was not found";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(404, errorMessage, ex.getMessage(), ex);
} else {
String errorMessage = "Failed to delete blob";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
}
}
......@@ -149,11 +146,11 @@ public class BlobStore {
blockBlobClient.upload(dataStream, bytesSize, true);
} catch (BlobStorageException ex) {
String errorMessage = "Failed to upload file content.";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
} catch (IOException ex) {
String errorMessage = String.format("Malformed document for item with name=%s", filePath);
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
}
}
......@@ -168,7 +165,7 @@ public class BlobStore {
return blobContainerClientFactory.getClient(dataPartitionId);
} catch (Exception ex) {
String errorMessage = "Error creating creating blob container client.";
logger.warning(LOG_PREFIX, errorMessage, headers.getHeaders());
logger.warning(LOG_PREFIX, errorMessage, Collections.<String, String>emptyMap());
throw new AppException(500, errorMessage, ex.getMessage(), ex);
}
}
......
......@@ -66,9 +66,6 @@ public class BlobStoreTest {
@Mock
ILogger logger;
@Mock
DpsHeaders headers;
@BeforeEach
void init() {
initMocks(this);
......@@ -76,7 +73,6 @@ public class BlobStoreTest {
lenient().doReturn(blobClient).when(blobContainerClient).getBlobClient(FILE_PATH);
lenient().doReturn(blockBlobClient).when(blobClient).getBlockBlobClient();
lenient().doNothing().when(logger).warning(eq("azure-core-lib"), any(), anyMap());
lenient().doReturn(new HashMap<String, String>()).when(headers).getHeaders();
}
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment