Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/release-notes/11592-HandleParsing_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A bug introduced in v6.5 broken Handle parsing when using a lower-case shoulder. This is now fixed.
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,13 @@ public GlobalId parsePersistentId(String protocol, String authority, String iden
if (!PidProvider.isValidGlobalId(protocol, authority, identifier)) {
return null;
}
String comparableShoulder = getShoulder();

if(isCaseInsensitive) {
identifier = identifier.toUpperCase();
if(comparableShoulder != null) {
comparableShoulder = comparableShoulder.toUpperCase();
}
}
// Check authority/identifier if this is a provider that manages specific
// identifiers
Expand All @@ -362,7 +367,7 @@ public GlobalId parsePersistentId(String protocol, String authority, String iden
logger.fine("managed in " + getId() + ": " + getManagedSet().contains(cleanIdentifier));
logger.fine("excluded from " + getId() + ": " + getExcludedSet().contains(cleanIdentifier));

if (!(((authority.equals(getAuthority()) && identifier.startsWith(getShoulder().toUpperCase()))
if (!(((authority.equals(getAuthority()) && identifier.startsWith(comparableShoulder))
|| getManagedSet().contains(cleanIdentifier)) && !getExcludedSet().contains(cleanIdentifier))) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
@JvmSetting(key = JvmSettings.PID_PROVIDER_LABEL, value = "HDL 1", varArgs = "hdl1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_TYPE, value = HandlePidProvider.TYPE, varArgs = "hdl1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_AUTHORITY, value = "20.500.1234", varArgs = "hdl1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "", varArgs = "hdl1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "test", varArgs = "hdl1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_MANAGED_LIST, value = "hdl:20.20.20/FK2ABCDEF", varArgs ="hdl1")
@JvmSetting(key = JvmSettings.HANDLENET_AUTH_HANDLE, value = "20.500.1234/ADMIN", varArgs ="hdl1")
@JvmSetting(key = JvmSettings.HANDLENET_INDEPENDENT_SERVICE, value = "true", varArgs ="hdl1")
Expand Down Expand Up @@ -294,16 +294,22 @@ public void testDOIParsing() throws IOException {
@Test
public void testHandleParsing() throws IOException {

String pid1String = "hdl:20.500.1234/10052";
String pid1String = "hdl:20.500.1234/test10052";
GlobalId pid2 = PidUtil.parseAsGlobalID(pid1String);
assertEquals(pid1String, pid2.asString());
assertEquals("hdl1", pid2.getProviderId());
assertEquals("https://hdl.handle.net/" + pid2.getAuthority() + PidUtil.getPidProvider(pid2.getProviderId()).getSeparator() + pid2.getIdentifier(),pid2.asURL());
assertEquals("https://hdl.handle.net/" + pid2.getAuthority() + PidUtil.getPidProvider(pid2.getProviderId()).getSeparator() + pid2.getIdentifier(), pid2.asURL());
assertEquals("20.500.1234", pid2.getAuthority());
assertEquals(HandlePidProvider.HDL_PROTOCOL, pid2.getProtocol());
GlobalId pid3 = PidUtil.parseAsGlobalID(pid2.asURL());
assertEquals(pid1String, pid3.asString());
assertEquals("hdl1", pid3.getProviderId());

// Test case sensitivity - a handle with uppercase "TEST" should not match the hdl1 provider
Copy link
Copy Markdown
Contributor

@stevenwinship stevenwinship Sep 2, 2025

Choose a reason for hiding this comment

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

This comment leads me to believe you will be comparing the uppercase "TEST" of pid4 to the lowercase "test" in pid1String showing they are not equal.

Maybe add:
assertNotEquals(pid4.asString(), pid1String);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

? - this test has nothing to do with pid1 other than all 4 tests use the hdl1 provider defined around line 110. Line 110 itself defines the hdl1 provider as having the lower case 'test' shoulder, so hdl4 which uses upper case won't match it. In this case, pid4String should still be recognized as a Handle, so the assertEquals on 311 should work (the string form of the pid equals the original string), but it won't be recognized by the hdl1 provider, only the UnmanagedHandlePidProvider (tested on line 312).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My point was there should be a negative test showing that "test" isn't equal to "TEST"

String pid4String = "hdl:20.500.1234/TEST10052";
GlobalId pid4 = PidUtil.parseAsGlobalID(pid4String);
assertEquals(pid4String, pid4.asString());
assertEquals(UnmanagedHandlePidProvider.ID, pid4.getProviderId());
}

@Test
Expand Down