Skip to content

UFAL/Embargo info check - #1033

Merged
milanmajchrak merged 5 commits into
dtq-devfrom
embargo-check
Aug 21, 2025
Merged

milanmajchrak merged 5 commits into
dtq-devfrom
embargo-check

Conversation

@Kasinhou

@Kasinhou Kasinhou commented Aug 6, 2025

Copy link
Copy Markdown

Added embargo check to health report.
This is the output
image

Summary by CodeRabbit

  • New Features

    • Added a health check that scans items, bitstreams, bundles, communities, and collections for resource policies with start/end dates and produces a summarized report (counts and detailed listings).
  • Chores

    • Enabled the new embargo health check in the active health checks configuration.
  • Tests

    • One integration test marked as ignored/skipped for the current version.

@Kasinhou
Kasinhou requested a review from milanmajchrak August 6, 2025 10:31
@coderabbitai

coderabbitai Bot commented Aug 6, 2025

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds a new health check class org.dspace.health.EmbargoInfoCheck that scans Items, Bundles, Bitstreams, Collections, and Communities for resource policies with start/end dates and produces a formatted report; registers the check in the healthcheck configuration; and marks one integration test as ignored.

Changes

Cohort / File(s) Change Summary
Embargo Info Health Check Implementation
dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java
New class added to traverse Items, Bundles, Bitstreams, Collections, and Communities, collect embargo-related ResourcePolicy start/end dates into EmbargoInfo records, and generate a formatted report. Handles DSpace Context lifecycle and exception wrapping.
Healthcheck Configuration
dspace/config/modules/healthcheck.cfg
Added plugin declaration mapping org.dspace.health.EmbargoInfoCheck to the label "Embargo check" and included it in the active checks list.
Test Adjustment
dspace-api/src/test/java/org/dspace/identifier/VersionedHandleIdentifierProviderIT.java
Test import and annotation added to mark testDefaultVersionedHandleProvider as ignored (skips the test in current DSpace version).

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Healthcheck Admin
    participant Healthcheck as Healthcheck System
    participant EmbargoCheck as EmbargoInfoCheck
    participant DSpace as DSpace Repository

    Admin->>Healthcheck: Run "Embargo check"
    Healthcheck->>EmbargoCheck: invoke run(ReportInfo)
    Note over EmbargoCheck,DSpace: initialize Context
    EmbargoCheck->>DSpace: list Items / Collections / Communities
    loop per Item
        EmbargoCheck->>DSpace: fetch Bundles & Bitstreams
        EmbargoCheck->>DSpace: fetch ResourcePolicies
        EmbargoCheck->>EmbargoCheck: filter policies with start/end dates
        EmbargoCheck->>EmbargoCheck: add EmbargoInfo entries
    end
    loop per Collection/Community
        EmbargoCheck->>DSpace: fetch ResourcePolicies
        EmbargoCheck->>EmbargoCheck: filter & add EmbargoInfo entries
    end
    EmbargoCheck->>EmbargoCheck: build formatted report (truncate >50 per type)
    EmbargoCheck->>Healthcheck: return report string
    Note over EmbargoCheck: close Context
    Healthcheck->>Admin: present report
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit dug through metadata rows,
Counting dates where embargoes doze.
With nibble and note it logged each sign,
UUIDs and dates in tidy line.
Now the meadow's clear — one hop, one find. 🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch embargo-check

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java (1)

74-76: Consider more specific exception handling.

While catching all exceptions prevents the health check from failing completely, it might mask specific issues that could be valuable for debugging.

Consider handling specific exceptions separately:

-        } catch (Exception e) {
-            throw new RuntimeException("Error while processing embargo check", e);
+        } catch (SQLException e) {
+            throw new RuntimeException("Database error while processing embargo check", e);
+        } catch (AuthorizeException e) {
+            throw new RuntimeException("Authorization error while processing embargo check", e);
+        } catch (Exception e) {
+            throw new RuntimeException("Unexpected error while processing embargo check", e);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cbfde27 and 153bde6.

📒 Files selected for processing (2)
  • dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java (1 hunks)
  • dspace/config/modules/healthcheck.cfg (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: dspace / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: dspace-cli / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: dspace-test / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: Run Integration Tests
  • GitHub Check: Run Unit Tests
🔇 Additional comments (10)
dspace/config/modules/healthcheck.cfg (2)

10-11: LGTM! Configuration properly integrates the new embargo check.

The addition to the healthcheck.checks list follows the correct format and integrates well with existing checks.


17-17: Plugin registration follows proper naming convention.

The plugin declaration correctly maps the EmbargoInfoCheck class to the "Embargo check" label, maintaining consistency with other health check plugins.

dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java (8)

1-41: Well-structured class with appropriate imports and fields.

The class follows good practices with:

  • Proper package declaration and imports
  • Clear documentation explaining the check's purpose
  • Appropriate field declarations with meaningful names
  • Reasonable display threshold constant

52-64: Efficient iteration over items and nested objects.

The logic correctly processes all items and their associated bundles and bitstreams, collecting embargo information at each level. The nesting structure appropriately reflects the DSpace object hierarchy.


66-72: Consistent processing of collections and communities.

The iteration over collections and communities follows the same pattern as items, maintaining consistency in the embargo info collection approach.


78-89: Clear and comprehensive reporting structure.

The report generation provides both detailed listings and summary counts, making it easy to understand the embargo status across different object types. The distinction between objects that include parent references (bitstreams, bundles) and those that don't is appropriate.


98-105: Efficient embargo detection logic.

The method correctly identifies resource policies with start or end dates, which indicates embargo restrictions. The logic is straightforward and handles both embargo start and end scenarios.


107-134: Well-formatted report output with appropriate limits.

The appendReport method creates clear, tabular output with:

  • Proper column headers and formatting
  • Configurable display limits to prevent overwhelming output
  • Consistent handling of optional parent item references

The use of String.repeat() for the separator line is clean and readable.


136-148: Simple and effective data structure.

The EmbargoInfo inner class is well-designed with:

  • Appropriate fields for capturing embargo information
  • Clean constructor that initializes all fields
  • Package-private accessibility which is suitable for this use case

118-118: Java 11 minimum confirmed; String.repeat() compatibility OK

  • pom.xml (line 21) defines <java.version>11>.
  • String.repeat() was introduced in Java 11, matching the project’s minimum version.

No further changes needed.

Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
@milanmajchrak
milanmajchrak requested a review from Copilot August 6, 2025 11:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new health check feature that provides detailed reporting on embargo information across different DSpace objects. The embargo check identifies items, bitstreams, bundles, communities, and collections that have start or end dates defined in their resource policies.

  • Implemented a new EmbargoInfoCheck class that scans all DSpace objects for embargo-related resource policies
  • Added the new embargo check to the health check configuration to make it available in the system
  • Provides tabular output showing embargo details with counts and object UUIDs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
dspace/config/modules/healthcheck.cfg Adds the new embargo check to the list of available health checks and plugin configuration
dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Implements the embargo information health check that scans DSpace objects for embargo policies

Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java Outdated
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java
Comment thread dspace-api/src/main/java/org/dspace/health/EmbargoInfoCheck.java
@Kasinhou
Kasinhou requested a review from milanmajchrak August 21, 2025 07:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
dspace-api/src/test/java/org/dspace/identifier/VersionedHandleIdentifierProviderIT.java (1)

69-83: Add a descriptive reason to the @ignore and track it

We currently have 73 ignored tests across the codebase—blanket ignores without a clear link to an issue or feature flag make it hard to know when and why to re-enable them. For this test, please:

  • Replace the inline comment with a formal reason in the annotation, pointing to a tracking ticket or PR.
  • Optionally, guard the test at runtime using JUnit’s Assume so it only runs when versioning is enabled.
  • Open a follow-up issue (e.g., DS-XXXX) to revisit and re-enable this test once the provider is supported.

Locations to update:

  • dspace-api/src/test/java/org/dspace/identifier/VersionedHandleIdentifierProviderIT.java:69

Minimal change:

-    @Ignore // This test is ignored because it is not applicable to the current version of DSpace.
+    @Ignore("VersionedHandleIdentifierProvider not active under current configuration; see DS-XXXX")

Optional conditional skip (add import near other imports):

import static org.junit.Assume.assumeTrue;

Inside the test method:

assumeTrue("Skip when identifier.versioning.enabled==false",
    DSpaceServicesFactory.getInstance()
        .getConfigurationService()
        .getBooleanProperty("identifier.versioning.enabled", false));
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f0fa0e0 and b346393.

📒 Files selected for processing (1)
  • dspace-api/src/test/java/org/dspace/identifier/VersionedHandleIdentifierProviderIT.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: dspace / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: dspace-test / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: dspace-cli / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: Run Integration Tests
  • GitHub Check: Run Unit Tests
🔇 Additional comments (1)
dspace-api/src/test/java/org/dspace/identifier/VersionedHandleIdentifierProviderIT.java (1)

27-27: Confirmed JUnit 4–only usage—no mixed JUnit 5 annotations detected
I ran the provided grep across the repository and found no references to org.junit.jupiter (JUnit 5) while JUnit 4 annotations (@Test, @Before, @Ignore) are used consistently—including in VersionedHandleIdentifierProviderIT.java. It’s safe to keep using org.junit.Ignore here.

@milanmajchrak
milanmajchrak merged commit 9e6d709 into dtq-dev Aug 21, 2025
12 checks passed
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.

3 participants