extract bitstream thumbnail name pattern into own function

This commit is contained in:
Gantner, Florian Klaus
2023-10-19 15:44:03 +02:00
parent a9bcc0c223
commit c5466c2249

View File

@@ -403,9 +403,7 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
@Override @Override
public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException { public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException {
Pattern pattern = Pattern.compile("^" + Pattern pattern = getBitstreamNamePattern(bitstream);
(bitstream.getName() != null ? Pattern.quote(bitstream.getName()) : bitstream.getName())
+ ".([^.]+)$");
for (Bundle bundle : bitstream.getBundles()) { for (Bundle bundle : bitstream.getBundles()) {
for (Item item : bundle.getItems()) { for (Item item : bundle.getItems()) {
@@ -422,6 +420,13 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
return null; return null;
} }
protected Pattern getBitstreamNamePattern(Bitstream bitstream) {
if (bitstream.getName() != null) {
return Pattern.compile("^" + Pattern.quote(bitstream.getName()) + ".([^.]+)$");
}
return Pattern.compile("^" + bitstream.getName() + ".([^.]+)$");
}
@Override @Override
public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException { public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException {
if (bitstream.getBitstreamFormat() == null) { if (bitstream.getBitstreamFormat() == null) {