Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.dspace.content.service.PreviewContentService;
import org.dspace.core.Context;
import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
import org.dspace.util.FileInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
Expand All @@ -58,6 +59,9 @@ public class MetadataBitstreamRestRepository extends DSpaceRestRepository<Metada
@Autowired
PreviewContentService previewContentService;

@Autowired
ConfigurationService configurationService;

@SearchRestMethod(name = "byHandle")
public Page<MetadataBitstreamWrapperRest> findByHandle(@Parameter(value = "handle", required = true) String handle,
@Parameter(value = "fileGrpType") String fileGrpType,
Expand Down Expand Up @@ -109,12 +113,16 @@ public Page<MetadataBitstreamWrapperRest> findByHandle(@Parameter(value = "handl
List<PreviewContent> prContents = previewContentService.hasPreview(context, bitstream);
// Generate new content if we didn't find any
if (prContents.isEmpty()) {
fileInfos = previewContentService.getFilePreviewContent(context, bitstream);
// Do not store HTML content in the database because it could be longer than the limit
// of the database column
if (!StringUtils.equals("text/html", bitstream.getFormat(context).getMIMEType())) {
for (FileInfo fi : fileInfos) {
previewContentService.createPreviewContent(context, bitstream, fi);
boolean allowComposePreviewContent = configurationService.getBooleanProperty
("create.file-preview.on-item-page-load", false);
if (allowComposePreviewContent) {
fileInfos = previewContentService.getFilePreviewContent(context, bitstream);
// Do not store HTML content in the database because it could be longer than the limit
// of the database column
if (!StringUtils.equals("text/html", bitstream.getFormat(context).getMIMEType())) {
for (FileInfo fi : fileInfos) {
previewContentService.createPreviewContent(context, bitstream, fi);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public void setup() throws Exception {
.withMimeType("application/x-gzip")
.build();

// Allow composing of file preview in the config
configurationService.setProperty("create.file-preview.on-item-page-load", true);

context.restoreAuthSystemState();

if (StringUtils.isBlank(url)) {
Expand Down
4 changes: 4 additions & 0 deletions dspace/config/clarin-dspace.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,7 @@ autocomplete.custom.allowed = solr-author_ac,solr-publisher_ac,solr-dataProvider
#### name || id
### these collections allow submitters to edit metadata of their items
#allow.edit.metadata =

#### FILE-PREVIEW ####
# Create file preview when item page is loading
create.file-preview.on-item-page-load = false