Skip to content

Commit

Permalink
Fix invalid relative URL in Zenodo redirect
Browse files Browse the repository at this point in the history
Updated changelog
Bump version
Closes #32
  • Loading branch information
thebe14 committed Oct 27, 2023
1 parent 1d5c34e commit 1e09497
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
47 changes: 45 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,51 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Add OpenTelemetry support
## [1.1.65]
- Workaround Zenodo redirecting to invalid relative URL

## [1.1.63]
- Added support for S3S
- Moved Swagger-UI to the root, path is now /swagger-ui

## [1.1.58]
- Fix authentication schemes in Swagger-UI

## [1.1.53]
- API now accepts DOIs in correct canonical format
- Missing downloadUrl field for files in ESRF data records

## [1.1.52]
- Zenodo parser does not return checksum algorithm
- ESRF parser only returns first dataset in record

## [1.1.51]
- Add support for transfers to grid storage StoRM
- Implement trace sampling

## [1.1.50]
- Implement structured logging
- Upgrade to Quarkus 3

## [1.1.46]
- Parsers can now return file checksums in the form algorithm:checksum
- Parsers can mark returned files as not available, it's up to clients to decide whether or not to attempt to
transfer these
- Parsers can group returned files into collections (file sets), and/or can return the original path of a file
in the data record, allowing reconstruction of the folder hierarchy at the destination
- Documented Java17 dependency and fixed some typos

## [1.1.44]
- Endpoint /parser should accept canonical DOI format
- Added valid example DOI for endpoint /parser
- Fix accessUrl of parsed ESRF files
- Create/modified date times of parsed ESRF files incorrect

## [1.1.41]
- Implemented ESRF parsing

## [1.1.40]
- Handle (and hide) timeouts and 500 errors when registering new S3 hosts with FTS

## [1.0.18]
- Added truststore for EGI Data Transfer
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/parser/ParserHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ private String doiToUrl(String uri) {
*/
public Uni<String> checkRedirect(String uri) {

var result = client.headAbs(doiToUrl(uri))
final var url = doiToUrl(uri);
var result = client.headAbs(url)
.send()
.chain(resp -> {
var redirects = resp.followedRedirects();
Expand Down Expand Up @@ -85,7 +86,8 @@ public Uni<String> checkRedirect(String uri) {
*/
public Uni<Tuple2<String, MultiMap>> fetchHeaders(String uri) {

var result = client.headAbs(doiToUrl(uri))
final var url = doiToUrl(uri);
var result = client.headAbs(url)
.send()
.chain(resp -> {
var urlTarget = uri;
Expand Down Expand Up @@ -114,7 +116,8 @@ public Uni<Tuple2<String, MultiMap>> fetchHeaders(String uri) {
*/
public Uni<StorageContent> fetchLinkset(String uri) {

var result = client.getAbs(doiToUrl(uri))
final var url = doiToUrl(uri);
var result = client.getAbs(url)
.send()
.onItem().transform(resp -> resp.bodyAsJsonObject())
.chain(json -> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/parser/zenodo/ZenodoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ else if(!doi.equals(redirectedToUrl)) {
}

// Validate URL
Pattern p = Pattern.compile("^https?://([\\w\\.]*zenodo.org)/(record|api/records)/(\\d+)",
Pattern p = Pattern.compile("^(?:https?://[\\w\\.]*zenodo.org)?/(records?|api/records)/(\\d+)",
Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(redirectedToUrl);
boolean isSupported = m.matches();

if(isSupported) {
this.recordId = m.group(3);
this.recordId = m.group(2);
MDC.put("recordId", this.recordId);
MDC.put("doiType", this.id);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ quarkus:
urls-primary-name: default
smallrye-openapi:
path: /openapi
info-version: 1.1.63
info-version: 1.1.65
security-scheme-name: OIDC
security-scheme-description: OpenID Connect access token issued by EGI Check-In
security-scheme: jwt
Expand Down

0 comments on commit 1e09497

Please sign in to comment.