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

Skip to content

Conversation

@Paurikova2
Copy link
Collaborator

@Paurikova2 Paurikova2 commented Apr 15, 2025

Phases MP MM MB MR JM Total
ETA 0 0 0 0 0 0
Developing 0.5 0 0 0 0 0
Review 0 0 0 0 0 0
Total - - - - - 0
ETA est. 0
ETA cust. - - - - - 0

Problem description

We want to prevent users from triggering file preview generation when opening an item if a specific configuration property is not enabled. Allowing this behavior can lead to issues, especially when items contain large files—generating previews may take too long, and opening the same item multiple times could trigger concurrent preview generation processes before the first one has completed.

Summary by CodeRabbit

  • New Features
    • Added a configurable option to enable or disable file preview generation for bitstreams. By default, this feature is turned off and can be activated through a new setting in the configuration file.

@coderabbitai
Copy link

coderabbitai bot commented Apr 15, 2025

Walkthrough

A new configuration property, create.file-preview.on-item-page-load, has been introduced to control whether file preview content is generated and stored for bitstreams when an item page loads. The main repository logic now checks this property via ConfigurationService before proceeding with preview generation. The configuration is set to false by default in the clarin-dspace.cfg file. Corresponding test code has been updated to explicitly enable the create.file-preview.on-item-page-load property during test setup to ensure preview content is generated as expected.

Changes

File(s) Change Summary
dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/MetadataBitstreamRestRepository.java Added a conditional check using ConfigurationService for create.file-preview.on-item-page-load before generating file preview content; autowired the configuration service.
dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java Modified test setup to enable the create.file-preview.on-item-page-load property for testing preview content generation.
dspace/config/clarin-dspace.cfg Added new configuration property create.file-preview.on-item-page-load (default: false) under a new "FILE-PREVIEW" section.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MetadataBitstreamRestRepository
    participant ConfigurationService

    Client->>MetadataBitstreamRestRepository: Request bitstream metadata
    MetadataBitstreamRestRepository->>ConfigurationService: Get create.file-preview.on-item-page-load
    ConfigurationService-->>MetadataBitstreamRestRepository: Return true/false
    alt create.file-preview.on-item-page-load is true
        MetadataBitstreamRestRepository->>MetadataBitstreamRestRepository: Generate and store preview content
    else create.file-preview.on-item-page-load is false
        MetadataBitstreamRestRepository->>MetadataBitstreamRestRepository: Skip preview content generation
    end
    MetadataBitstreamRestRepository-->>Client: Return response
Loading

Possibly related PRs

Poem

🐇
A switch in config, a quiet new gate,
To preview or not, it now decides fate.
If true, bits bloom with preview delight,
If false, they rest hidden from sight.
Tests set the stage, the code takes its cue,
Hopping through logic, fresh and anew!
🎉📄✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1a2745 and f55f43d.

📒 Files selected for processing (1)
  • dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamRestRepositoryIT.java
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Integration Tests
  • GitHub Check: dspace-dependencies / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: Run Unit Tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Paurikova2 Paurikova2 self-assigned this Apr 15, 2025
@Paurikova2
Copy link
Collaborator Author

@milanmajchrak Maybe I’ll change the message, because currently the file preview is not being generated at all — it’s not that it's generating unsuccessfully, they don't need to contact administrator.

@milanmajchrak milanmajchrak requested a review from vidiecan April 15, 2025 12:01
@milanmajchrak milanmajchrak merged commit 242a405 into dtq-dev Apr 16, 2025
11 checks passed
milanmajchrak added a commit that referenced this pull request Apr 22, 2025
* Enhanced file preview feature - Run file preview as authenticated user (#936), Property to allow composing file previews (#935), Do not create temp file during generating preview (#921)

* Use the handle url instead of the items url with the UUID (#938)

* Items file metadata not correctly updated (#940)

* Remove duplicate dependency element with identical content (warnings in build)

* Anonymous users should be able to use shortener

* Fixed internal server error, when context.commit() was called multiple times in search request

* Catch DSpaceBadRequestException rather than BadRequestException

* Fixed security issue for downloading file with non anonymous license

* Fixed Clarinuserregistration nullpoint exception (#941)
kosarko added a commit to ufal/clarin-dspace that referenced this pull request May 5, 2025
pulling changes from latest (lindat-2025.04.14600125143) dataquest release

This contains the following changes:

- UFAL/Run file preview as authenticated user (dataquest-dev#936)
- Property to allow composing file previews (dataquest-dev#935)
- File preview is not loaded properly for big zip file (dataquest-dev#921)
- UFAL/Clarinuserregistration nullpoint exception (dataquest-dev#941)
- UFAL/Use the handle url instead of the items url with the UUID (dataquest-dev#938)
- UFAL/Items file metadata not correctly updated (dataquest-dev#940)
- Synchronize ufal and dataquest main branches (dataquest-dev#939)
@coderabbitai coderabbitai bot mentioned this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UFAL/Add config property to disable generating file preview by opening item

4 participants