Skip to content

Lease access status on items and bitstreams (Frontend) - #6259

Open
costaluu wants to merge 1 commit into
DSpace:mainfrom
costaluu:feature/lease-access-status
Open

costaluu wants to merge 1 commit into
DSpace:mainfrom
costaluu:feature/lease-access-status

Conversation

@costaluu

@costaluu costaluu commented Sep 22, 2026 •

Copy link
Copy Markdown

References

Requires backend PR: DSpace/DSpace#13128

Description

The lease access condition (anonymous read policy with no startDate and a future endDate) was silently treated as open.access by the backend. The DefaultAccessStatusHelper.findAvailabilityDate() method called isDateValid(policy) on a lease policy, got true (the policy is currently active), and returned null — which maps to open.access. The lease expiration date was completely lost. When the lease expired, the status flipped directly to restricted/metadata.only with no indication it had ever been a lease.

This PR introduces a new lease access status across the full stack so that items and bitstreams with an active lease display a badge showing the expiration date, and appear as a distinct facet value in search filters.

Instructions for Reviewers

The bug:

PATCH /edititems/{uuid}  →  ResourcePolicy saved with startDate=null, endDate=2026-09-30

GET /core/items/{uuid}/accessStatus
  └─ DefaultAccessStatusHelper.getAccessStatusFromBitstream()
       └─ findAvailabilityDate(policies, threshold)
            └─ isDateValid(leasePolicy) == true  →  return null   ← BUG
       └─ getAccessStatusFromAvailabilityDate(null)  →  "open.access"

A lease is valid today but expires — it is not open access. The fix detects policies with endDate and no startDate as active leases and returns a dedicated "lease" status with the expiration date.

Important

Disclaimer: This PR was developed with the assistance of AI tooling. All changes were reviewed and validated by the author.

Backend changes

  • AccessStatus.java — Added leaseDate field with getter/setter and a new 3-arg constructor AccessStatus(status, availabilityDate, leaseDate).
  • DefaultAccessStatusHelper.java — Added LEASE = "lease" constant. Refactored findAvailabilityDate() to return a LocalDate[2] array [availabilityDate, leaseEndDate]. Inside the policy loop: a valid policy with endDate but no startDate is tracked as a lease (earliest endDate wins); a valid policy without endDate is truly open access. getAccessStatusFromBitstream() now checks for leaseEndDate and returns new AccessStatus(LEASE, null, leaseEndDate).
  • AccessStatusRest.java — Added leaseDate string field with Javadoc.
  • ItemAccessStatusLinkRepository.java and BitstreamAccessStatusLinkRepository.java — Added else if (status == LEASE) branch to populate leaseDate on the REST response, mirroring the existing embargoDate handling.
  • DefaultAccessStatusHelperTest.java — Two new tests: testWithLease() (active lease → status lease with correct leaseDate) and testWithExpiredLease() (past endDate → status restricted).

Frontend changes

  • access-status.model.ts — Added @autoserialize leaseDate: string to AccessStatusObject.
  • access-status-badge.component.ts — handleItem(): extracted shared accessStatusPayload$ observable, exposed leaseDate$ for template interpolation. handleBitstream(): same refactor, plus badge logic now shows lease status (not only embargo).
  • access-status-badge.component.html — Template resolves date as embargoDate ?? leaseDate, so the correct expiration date is interpolated for either status type.
  • access-status-badge.component.spec.ts — Added test cases for lease status on both items and bitstreams.
  • i18n (all 38 locale files) — Two new keys per locale:
    • access-status.lease.listelement.badge: badge label (e.g. "Lease until {{ date }}")
    • search.filters.access_status.lease: search facet label (e.g. "Temporary access (lease)")

How to test

  1. Start the REST API with the backend PR applied.
  2. Submit or edit an item, adding a bitstream with a lease access condition (endDate in the future, no startDate).
  3. Verify GET /server/api/core/items/{uuid}/accessStatus returns {"status": "lease", "leaseDate": "2026-09-30"}.
  4. On the item list page, the badge should display "Lease until {date}" (or locale equivalent).
  5. On the bitstream detail, same badge should appear.
  6. In search facets, "Temporary access (lease)" should appear and filter correctly.
  7. After the endDate passes, the status should become restricted or metadata.only — no more lease badge.
  8. An item with both a lease policy and a truly open policy (no endDate) should show open.access, not lease.

Checklist

  • My PR is created against the main branch.
  • My PR is small in size.
  • My PR follows all coding best practices based on the Code Conventions Guide.
  • My PR passes ESLint validation using npm run lint.
  • My PR doesn't introduce circular dependencies.
  • My PR includes TypeDoc/Javadoc comments for all new and modified public methods and classes.
  • My PR passes all specs/tests and includes new/updated specs.
  • My PR aligns with Accessibility guidelines.
  • My PR uses i18n keys.
  • My PR includes details on how to test it (see above).
  • No new libraries/dependencies added.
  • Basic technical documentation provided in this PR description.
  • Backend and frontend PRs are linked together.

@lgeggleston lgeggleston changed the title feat: lease access status on items and bistreams Lease access status on items and bitstreams (Frontend) Sep 25, 2026
@lgeggleston lgeggleston added authorization related to authorization, permissions or groups new feature component: Item (Archived) Item display or editing labels Sep 25, 2026
@lgeggleston lgeggleston moved this to 🙋 Needs Reviewers Assigned in DSpace 11.0 Release Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authorization related to authorization, permissions or groups component: Item (Archived) Item display or editing new feature

Projects

Status: 🙋 Needs Reviewers Assigned

Development

Successfully merging this pull request may close these issues.

2 participants