Skip to content

Commit

Permalink
UFAL/The files are not rendered in the Item UI (#752)
Browse files Browse the repository at this point in the history
* Do not commit a session during processing the previews. Catch the error when the ZIP is broken because it wont render files in the UI.

* Fixed checkstyle issues
  • Loading branch information
milanmajchrak authored Sep 12, 2024
1 parent 47b45b6 commit 218f7f2
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public Page<MetadataBitstreamWrapperRest> findByHandle(@Parameter(value = "handl
for (FileInfo fi : fileInfos) {
createPreviewContent(context, bitstream, fi);
}
context.commit();
} else {
for (PreviewContent pc : prContents) {
fileInfos.add(createFileInfo(pc));
Expand All @@ -186,6 +185,7 @@ public Page<MetadataBitstreamWrapperRest> findByHandle(@Parameter(value = "handl
metadataValueWrappers.add(bts);
rs.add(metadataBitstreamWrapperConverter.convert(bts, utils.obtainProjection()));
}
context.commit();
}

return new PageImpl<>(rs, pageable, rs.size());
Expand Down Expand Up @@ -318,7 +318,11 @@ private List<FileInfo> 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);
Expand Down

0 comments on commit 218f7f2

Please sign in to comment.