-
Notifications
You must be signed in to change notification settings - Fork 1
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
Pivotal ID # 184975504: S3 submission resubmission #702
Merged
Juan-EBI
merged 8 commits into
master
from
feature/pivotal-184975504-S3-submission-resubmission
May 2, 2023
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66339e5
added s3 re submission support
Juan-EBI 51edc20
code review changes
Juan-EBI 9489ab3
code review changes
Juan-EBI b78fda7
code review changes
Juan-EBI f46d327
code review changes
Juan-EBI 6b23ece
Merge branch 'master' of github.com:EBIBioStudies/biostudies-backend-…
Juan-EBI a309177
code review changes
Juan-EBI ac29534
code review changes
Juan-EBI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
client/fire-webclient/src/main/kotlin/uk/ac/ebi/fire/client/api/S3Client.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package uk.ac.ebi.fire.client.api | ||
|
||
import com.amazonaws.services.s3.AmazonS3 | ||
import com.amazonaws.services.s3.model.GetObjectRequest | ||
import com.amazonaws.services.s3.model.S3Object | ||
import uk.ac.ebi.fire.client.integration.web.FireS3Client | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.StandardCopyOption | ||
|
||
class S3Client( | ||
private val amazonS3Client: AmazonS3, | ||
private val bucketName: String, | ||
) : FireS3Client { | ||
override fun downloadByPath(path: String): File? { | ||
val stream = getFireObjectByPath(path).objectContent | ||
val tmp = File.createTempFile(DEFAULT_PREFIX, path.substringAfterLast("/")) | ||
Files.copy(stream, tmp.toPath(), StandardCopyOption.REPLACE_EXISTING) | ||
return tmp | ||
} | ||
|
||
private fun getFireObjectByPath(path: String?): S3Object { | ||
val getObjectRequest = GetObjectRequest(bucketName, path) | ||
return amazonS3Client.getObject(getObjectRequest) | ||
} | ||
|
||
companion object { | ||
const val DEFAULT_PREFIX = "tmp_s3_file" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ import java.io.File | |
|
||
@Suppress("TooManyFunctions") | ||
internal class RetryWebClient( | ||
private val fireClient: FireClient, | ||
private val fireClient: FireWebClient, | ||
private val fireS3Client: FireS3Client, | ||
private val template: RetryTemplate, | ||
) : FireClient { | ||
override fun save(file: File, md5: String, size: Long): FireApiFile { | ||
|
@@ -25,11 +26,6 @@ internal class RetryWebClient( | |
template.execute(opt) { fireClient.unsetPath(fireOid) } | ||
} | ||
|
||
override fun downloadByPath(path: String): File? { | ||
val opt = "Download file path='$path'" | ||
return template.execute(opt) { fireClient.downloadByPath(path) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're removing this, I think we should also remove the http client method and the related tests since it won't be required anymore |
||
} | ||
|
||
override fun findByMd5(md5: String): List<FireApiFile> { | ||
val opt = "Find file md5='$md5'" | ||
return template.execute(opt) { fireClient.findByMd5(md5) } | ||
|
@@ -59,4 +55,9 @@ internal class RetryWebClient( | |
val opt = "Delete file fireOid='$fireOid'" | ||
template.execute(opt) { fireClient.delete(fireOid) } | ||
} | ||
|
||
override fun downloadByPath(path: String): File? { | ||
val opt = "Dowload file path='$path'" | ||
return template.execute(opt) { fireS3Client.downloadByPath(path) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing unit tests for this client