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

Skip to content

Conversation

@milanmajchrak
Copy link
Collaborator

@milanmajchrak milanmajchrak commented Apr 16, 2025

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

Problem description

This issue causes that the file preview spinner was still loading where there weren't any file.
The issue: dataquest-dev/dspace-angular#833

Summary by CodeRabbit

  • Bug Fixes
    • Improved the reliability of updating item metadata after bitstream deletions or removals, ensuring metadata is always updated at the correct time.
    • Added safeguards to prevent errors when updating metadata if item information is missing.
  • Tests
    • Enhanced bulk bitstream deletion tests to verify item metadata updates correctly reflect the absence of files.

…led after the bitstream was updated, so that items bitstream metadata wasn't correctly updated.
@coderabbitai
Copy link

coderabbitai bot commented Apr 16, 2025

Walkthrough

The changes reorganize when and how the updateItemFilesMetadata method is called during bitstream and bundle operations in the DSpace codebase. Specifically, calls to update item file metadata are moved to occur after bitstream removals rather than before, ensuring metadata reflects the final state. Additionally, a null check is added to prevent errors when updating metadata if the item is null. The bulk bitstream deletion test was enhanced to verify updated item metadata after deletions. No changes are made to public method signatures, and the overall logic of the affected methods remains the same except for the repositioning of metadata updates.

Changes

File(s) Change Summary
dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java Moved clarinItemService.updateItemFilesMetadata call to after bitstream removal loop in delete method; minor comment formatting updates.
dspace-api/src/main/java/org/dspace/content/BundleServiceImpl.java Relocated clarinItemService.updateItemFilesMetadata call to after the owning item null check in removeBitstream method.
dspace-api/src/main/java/org/dspace/content/clarin/ClarinItemServiceImpl.java Added a null check for item in updateItemFilesMetadata; logs error and returns early if null.
dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamRestRepositoryIT.java Enhanced deleteBitstreamsInBulk test to verify that item metadata reflects absence of files after bulk bitstream deletion; added JSON path assertion import.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BitstreamService
    participant BundleService
    participant ClarinItemService

    User->>BitstreamService: delete(context, bitstream)
    BitstreamService->>BitstreamService: Mark bitstream as deleted
    BitstreamService->>BitstreamService: Update bitstream
    loop For each bundle
        BitstreamService->>BundleService: Remove bitstream from bundle
    end
    BitstreamService->>ClarinItemService: updateItemFilesMetadata(context, bitstream)
Loading
sequenceDiagram
    participant User
    participant BundleService
    participant ClarinItemService

    User->>BundleService: removeBitstream(context, bundle, bitstream)
    BundleService->>BundleService: Remove bitstream from bundle
    alt owningItem is not null
        BundleService->>BundleService: Update owningItem last modified
        BundleService->>BundleService: Save owningItem
    end
    BundleService->>ClarinItemService: updateItemFilesMetadata(context, owningItem, bundle)
Loading

Suggested reviewers

  • vidiecan

Poem

In the warren of code, we hop and we shift,
Moving metadata updates, a well-timed gift.
With checks for null and logic anew,
Our bundles and bitstreams now know what to do.
No more pointer surprises, no metadata delay—
The carrot of clarity lights our way! 🥕

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.31.1)
dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamRestRepositoryIT.java

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 de0e2aa and 2251ee9.

📒 Files selected for processing (1)
  • dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamRestRepositoryIT.java (2 hunks)
⏰ 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
🔇 Additional comments (2)
dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamRestRepositoryIT.java (2)

10-10: Added necessary import for metadata verification.

This import adds support for the JsonPath matcher used in the enhanced test assertion.


2502-2510: Well-implemented test enhancement to verify files metadata update.

This additional test verification is directly addressing the core issue from PR #940, ensuring that the item's metadata correctly reflects the absence of bitstreams after deletion. The test now verifies that local.has.files is properly set to "no" when all bitstreams are removed from an item.

The verification confirms that backend changes to the updateItemFilesMetadata method call timing are working as expected, ensuring the metadata is updated only after bitstreams are fully removed.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

@milanmajchrak milanmajchrak linked an issue Apr 16, 2025 that may be closed by this pull request
2 tasks
@milanmajchrak milanmajchrak self-assigned this Apr 16, 2025
@milanmajchrak milanmajchrak requested a review from vidiecan April 16, 2025 11:52
@milanmajchrak milanmajchrak merged commit 6daa0fd 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)
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/Preview spinner is still spinning

3 participants