mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
80218: Add BitstreamService#getThumbnail
This commit is contained in:
@@ -13,6 +13,8 @@ import java.sql.SQLException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -409,6 +411,25 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException {
|
||||||
|
Pattern pattern = Pattern.compile("^" + bitstream.getName() + ".([^.]+)$");
|
||||||
|
|
||||||
|
for (Bundle bundle : bitstream.getBundles()) {
|
||||||
|
for (Item item : bundle.getItems()) {
|
||||||
|
for (Bundle thumbnails : itemService.getBundles(item, "THUMBNAIL")) {
|
||||||
|
for (Bitstream thumbnail : thumbnails.getBitstreams()) {
|
||||||
|
if (pattern.matcher(thumbnail.getName()).matches()) {
|
||||||
|
return thumbnail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
|
@@ -209,6 +209,8 @@ public interface BitstreamService extends DSpaceObjectService<Bitstream>, DSpace
|
|||||||
|
|
||||||
public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException;
|
public Bitstream getFirstBitstream(Item item, String bundleName) throws SQLException;
|
||||||
|
|
||||||
|
public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException;
|
||||||
|
|
||||||
public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException;
|
public BitstreamFormat getFormat(Context context, Bitstream bitstream) throws SQLException;
|
||||||
|
|
||||||
public Iterator<Bitstream> findByStoreNumber(Context context, Integer storeNumber) throws SQLException;
|
public Iterator<Bitstream> findByStoreNumber(Context context, Integer storeNumber) throws SQLException;
|
||||||
|
Reference in New Issue
Block a user