Skip to content

fix(#8852): Statistics event processor now uses oaiPrefix instead of getHost#11160

Merged
tdonohue merged 1 commit intoDSpace:mainfrom
JohnnyMendesC:fix/8852-oai-statistics-prefix
Aug 21, 2025
Merged

fix(#8852): Statistics event processor now uses oaiPrefix instead of getHost#11160
tdonohue merged 1 commit intoDSpace:mainfrom
JohnnyMendesC:fix/8852-oai-statistics-prefix

Conversation

@JohnnyMendesC
Copy link
Copy Markdown
Contributor

@JohnnyMendesC JohnnyMendesC commented Aug 14, 2025

References

Description

This pull request resolves the statistics event processor removing www prefixes from OAI identifiers.
The root cause of the bug was that the ExportEventProcessor was incorrectly using the dspace.ui.url configuration and processing it with Utils.getHostName(). This resulted in OAI identifiers being generated with the wrong hostname (e.g., localhost in test environments) or having necessary prefixes like www. stripped.
This fix ensures the processor uses the dedicated oai.identifier.prefix configuration, guaranteeing that the OAI identifier sent in statistics events is always correct and complete.

Instructions for Reviewers

This PR modifies ExportEventProcessor.java to use the correct configuration property for building the OAI identifier (rft.artnum parameter) for statistics events.

List of changes in this PR:

  • The existing logic to determine hostName from dspace.ui.url is preserved, as it is correctly used for the rfr_id parameter.
  • A new string variable, oaiPrefix, is added to fetch its value directly from the oai.identifier.prefix configuration property.
  • The rft.artnum parameter is now built using this new oaiPrefix variable, ensuring the identifier is correct.
  • Updated the related integration tests (ExportEventProcessorIT.java and ITIrusExportUsageEventListener.java) to provide the new oai.identifier.prefix configuration, ensuring they align with the new code logic and pass successfully.

How to test this PR:

1. Setup your test environment:
In your local.cfg, ensure the following properties are set:

# Enable the IRUS statistics tracker
irus.statistics.tracker.enabled = true

# Set an OAI prefix that starts with "www"
oai.identifier.prefix = www.my-dspace-repo.com

# Configure the tracker to send events to a local listener
irus.statistics.tracker.environment = test
irus.statistics.tracker.testurl = http://localhost:8000/

2. Start a local HTTP listener:
In a separate terminal, run the following command to listen for the events sent by DSpace:

python3 -m http.server 8000

3. How to reproduce the bug (on the main branch):

  • Start DSpace.
  • Confirm that the main OAI-PMH module is correctly configured by running the Identify verb. You should see the correct repository identifier as configured in oai.identifier.prefix.
image
  • Now, in the UI, navigate to an item page and download a file.
  • Observe the output in your Python listener terminal.
  • Expected Result (Buggy): Despite the main OAI module being correct, the statistics event will use the wrong identifier. In a local test environment, this will typically be oai:localhost:..., as it is derived from dspace.ui.url.
...&rft.artnum=oai%3Alocalhost%3A...
or
...&rft.artnum=oai%3Amy-dspace-repo.com%3A...

(Note how this contradicts the correct identifier shown in the Identify verb above)

4. How to verify the fix (on this PR's branch):

  • Apply this PR, recompile DSpace, and restart the backend.
  • In the UI, download a file from any item again.
  • Observe the new output in your Python listener terminal.
  • Expected Result (Fixed): The rft.artnum parameter now correctly uses the full prefix from oai.identifier.prefix.
...&rft.artnum=oai%3Awww.my-dspace-repo.com%3A...

(Note that "www." is now correctly included)

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods. (No new public methods were added)
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide. (Updated the related integration tests (ExportEventProcessorIT.java and ITIrusExportUsageEventListener.java) to provide the new oai.identifier.prefix configuration, ensuring they align with the new code logic and pass successfully.)
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@JohnnyMendesC JohnnyMendesC force-pushed the fix/8852-oai-statistics-prefix branch from 52601ff to c8fe80c Compare August 14, 2025 20:09
@tdonohue tdonohue added bug component: statistics Related to Statistics (Solr or Google Analytics) interface: OAI-PMH Related to the OAI-PMH interface (dspace-oai module) 1 APPROVAL pull request only requires a single approval to merge. labels Aug 20, 2025
@tdonohue tdonohue added port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Aug 20, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Aug 20, 2025
Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @JohnnyMendesC ! This looks very obviously correct, and it aligns with the definition of the oai.identifier.prefix in our configuration which says it should be used for all OAI-PMH identifiers here: https://github.com/DSpace/DSpace/blob/main/dspace/config/modules/oai.cfg#L32

@github-project-automation github-project-automation Bot moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 10.0 Release Aug 21, 2025
@tdonohue tdonohue added this to the 10.0 milestone Aug 21, 2025
@tdonohue tdonohue merged commit 776872f into DSpace:main Aug 21, 2025
27 checks passed
@github-project-automation github-project-automation Bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Aug 21, 2025
@dspace-bot
Copy link
Copy Markdown
Contributor

@dspace-bot
Copy link
Copy Markdown
Contributor

@dspace-bot
Copy link
Copy Markdown
Contributor

@tdonohue tdonohue removed port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release port to dspace-8_x This PR needs to be ported to `dspace-8_x` branch for next bug-fix release port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge. bug component: statistics Related to Statistics (Solr or Google Analytics) interface: OAI-PMH Related to the OAI-PMH interface (dspace-oai module)

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

The statistics event processor method in DSpace 7.5 removes the beginning of OAI identifier prefixes that start with www.

3 participants