diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/MetadataBitstreamRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/MetadataBitstreamRestRepository.java index aebb260cd438..3eb2ee46185e 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/MetadataBitstreamRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/MetadataBitstreamRestRepository.java @@ -173,7 +173,6 @@ public Page findByHandle(@Parameter(value = "handl for (FileInfo fi : fileInfos) { createPreviewContent(context, bitstream, fi); } - context.commit(); } else { for (PreviewContent pc : prContents) { fileInfos.add(createFileInfo(pc)); @@ -186,6 +185,7 @@ public Page findByHandle(@Parameter(value = "handl metadataValueWrappers.add(bts); rs.add(metadataBitstreamWrapperConverter.convert(bts, utils.obtainProjection())); } + context.commit(); } return new PageImpl<>(rs, pageable, rs.size()); @@ -318,7 +318,11 @@ private List processInputStreamToFilePreview(Context context, Bitstrea String data = ""; if (bitstream.getFormat(context).getMIMEType().equals("application/zip")) { data = extractFile(inputStream, "zip"); - fileInfos = FileTreeViewGenerator.parse(data); + try { + fileInfos = FileTreeViewGenerator.parse(data); + } catch (Exception e) { + log.error("Cannot extract file content because: {}", e.getMessage()); + } } else if (bitstream.getFormat(context).getMIMEType().equals("application/x-tar")) { ArchiveInputStream is = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, inputStream);