133552: AIP packager bitstream url fix

(cherry picked from commit 11da562ea4)
This commit is contained in:
Kristof De Langhe
2025-09-03 11:35:05 +02:00
committed by github-actions[bot]
parent ff6afd4d0b
commit 9674bc05be

View File

@@ -224,29 +224,17 @@ public class PREMISCrosswalk
// c. made-up name based on sequence ID and extension. // c. made-up name based on sequence ID and extension.
String sid = String.valueOf(bitstream.getSequenceID()); String sid = String.valueOf(bitstream.getSequenceID());
String baseUrl = configurationService.getProperty("dspace.ui.url"); String baseUrl = configurationService.getProperty("dspace.ui.url");
String handle = null;
// get handle of parent Item of this bitstream, if there is one:
List<Bundle> bn = bitstream.getBundles();
if (bn.size() > 0) {
List<Item> bi = bn.get(0).getItems();
if (bi.size() > 0) {
handle = bi.get(0).getHandle();
}
}
// get or make up name for bitstream: // get or make up name for bitstream:
String bsName = bitstream.getName(); String bsName = bitstream.getName();
if (bsName == null) { if (bsName == null) {
List<String> ext = bitstream.getFormat(context).getExtensions(); List<String> ext = bitstream.getFormat(context).getExtensions();
bsName = "bitstream_" + sid + (ext.size() > 0 ? ext.get(0) : ""); bsName = "bitstream_" + sid + (ext.size() > 0 ? ext.get(0) : "");
} }
if (handle != null && baseUrl != null) { if (baseUrl != null) {
oiv.setText(baseUrl oiv.setText(baseUrl
+ "/bitstream/" + "/bitstreams/"
+ URLEncoder.encode(handle, "UTF-8") + bitstream.getID()
+ "/" + "/download");
+ sid
+ "/"
+ URLEncoder.encode(bsName, "UTF-8"));
} else { } else {
oiv.setText(URLEncoder.encode(bsName, "UTF-8")); oiv.setText(URLEncoder.encode(bsName, "UTF-8"));
} }