mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Fix request a copy link token generation
Ensure DSpace URLs with extra segments are included
fully in the generated link
(cherry picked from commit 52702a23df
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
c70d6dbf2e
commit
5ca9fee2be
@@ -21,6 +21,7 @@ import java.util.UUID;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.validator.routines.EmailValidator;
|
import org.apache.commons.validator.routines.EmailValidator;
|
||||||
import org.apache.http.client.utils.URIBuilder;
|
import org.apache.http.client.utils.URIBuilder;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -287,19 +288,17 @@ public class RequestItemRepository
|
|||||||
* Generate a link back to DSpace, to act on a request.
|
* Generate a link back to DSpace, to act on a request.
|
||||||
*
|
*
|
||||||
* @param token identifies the request.
|
* @param token identifies the request.
|
||||||
* @return URL to the item request API, with the token as request parameter
|
* @return URL to the item request API, with /request-a-copy/{token} as the last URL segments
|
||||||
* "token".
|
|
||||||
* @throws URISyntaxException passed through.
|
* @throws URISyntaxException passed through.
|
||||||
* @throws MalformedURLException passed through.
|
* @throws MalformedURLException passed through.
|
||||||
*/
|
*/
|
||||||
private String getLinkTokenEmail(String token)
|
private String getLinkTokenEmail(String token)
|
||||||
throws URISyntaxException, MalformedURLException {
|
throws URISyntaxException, MalformedURLException {
|
||||||
final String base = configurationService.getProperty("dspace.ui.url");
|
final String base = configurationService.getProperty("dspace.ui.url");
|
||||||
|
URIBuilder uriBuilder = new URIBuilder(base);
|
||||||
URI link = new URIBuilder(base)
|
// Add request-a-copy/token to the existing path (without breaking /sub/dir dspace URLs)
|
||||||
.setPathSegments("request-a-copy", token)
|
URI uri = uriBuilder.setPath(StringUtils.stripEnd(uriBuilder.getPath(), "")
|
||||||
.build();
|
+ "/request-a-copy/" + token).build();
|
||||||
|
return uri.toURL().toExternalForm();
|
||||||
return link.toURL().toExternalForm();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user