Skip to content
Snippets Groups Projects
Commit c4769a87 authored by Bruce Jin's avatar Bruce Jin
Browse files

Merge branch 'aws-code-smell-fix' into 'master'

code smell fix

See merge request !866
parents ebd67352 6b006bab
No related branches found
No related tags found
1 merge request!866code smell fix
Pipeline #253634 failed
......@@ -49,6 +49,12 @@ public class S3RecordClient {
@Value("${aws.s3.recordsBucket.ssm.relativePath}")
private String s3RecordsBucketParameterRelativePath;
private final static String RECORD_DELETE_ERROR_MSG = "Error deleting record";
private final static String RECORD_FIND_ERROR_MSG = "Error finding record";
private final static String RECORD_GET_ERROR_MSG = "Error getting record";
private S3ClientWithBucket getS3ClientWithBucket(String dataPartition) {
return s3ClientFactory.getS3ClientForPartition(dataPartition, s3RecordsBucketParameterRelativePath);
}
......@@ -105,7 +111,7 @@ public class S3RecordClient {
try {
s3.deleteObject(new DeleteObjectRequest(recordsBucketName, keyName));
} catch (SdkClientException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error deleting record", e.getMessage(), e);
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, RECORD_DELETE_ERROR_MSG, e.getMessage(), e);
}
}
......@@ -119,7 +125,7 @@ public class S3RecordClient {
try {
s3.deleteObject(new DeleteObjectRequest(recordsBucketName, keyName));
} catch (SdkClientException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error deleting record", e.getMessage(), e);
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, RECORD_DELETE_ERROR_MSG, e.getMessage(), e);
}
}
......@@ -131,7 +137,7 @@ public class S3RecordClient {
try {
s3.deleteObject(new DeleteObjectRequest(recordsBucketName, versionPath));
} catch (SdkClientException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error deleting record", e.getMessage(), e);
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, RECORD_DELETE_ERROR_MSG, e.getMessage(), e);
}
}
......@@ -147,7 +153,7 @@ public class S3RecordClient {
ListObjectsV2Result result = s3.listObjectsV2(recordsBucketName, keyName);
exists = result.getKeyCount() > 0;
} catch (SdkClientException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error finding record", e.getMessage(), e);
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, RECORD_FIND_ERROR_MSG, e.getMessage(), e);
}
return exists;
}
......@@ -162,7 +168,7 @@ public class S3RecordClient {
try {
recordStr = s3.getObjectAsString(recordsBucketName, keyName);
} catch (SdkClientException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error getting record", e.getMessage(), e);
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, RECORD_GET_ERROR_MSG, e.getMessage(), e);
}
return recordStr;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment