Skip to content

Commit

Permalink
Don't change the case for unmanaged DOI detection
Browse files Browse the repository at this point in the history
since the unchanged form is what's in the db, e.g. from harvesting

Added test for lowercase unmanaged DOI, changed an existing test to use
a lower case shoulder (not really related to the fix/verifying no
regression for managed case).
  • Loading branch information
qqmyers committed Nov 6, 2024
1 parent e208eed commit 610f8c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,16 @@ public GlobalId parsePersistentId(String protocol, String authority, String iden
if (!PidProvider.isValidGlobalId(protocol, authority, identifier)) {
return null;
}
if(isCaseInsensitive) {
identifier = identifier.toUpperCase();
}
// Check authority/identifier if this is a provider that manages specific
// identifiers
// /is not one of the unmanaged providers that has null authority
if (getAuthority() != null) {

/*
* Check authority/identifier if this is a provider that manages specific
* identifiers/is not one of the unmanaged providers that has null authority
*/
if (getAuthority() != null) {
if(isCaseInsensitive) {
identifier = identifier.toUpperCase();
}

String cleanIdentifier = protocol + ":" + authority + getSeparator() + identifier;
/*
* Test if this provider manages this identifier - return null if it does not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
@JvmSetting(key = JvmSettings.PID_PROVIDER_LABEL, value = "FAKE 1", varArgs = "fake1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_TYPE, value = FakeDOIProvider.TYPE, varArgs = "fake1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_AUTHORITY, value = "10.5074", varArgs = "fake1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "FK", varArgs = "fake1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "fk", varArgs = "fake1")
@JvmSetting(key = JvmSettings.PID_PROVIDER_MANAGED_LIST, value = "doi:10.5073/FK3ABCDEF", varArgs ="fake1")

//HANDLE 1
Expand Down Expand Up @@ -316,6 +316,12 @@ public void testUnmanagedParsing() throws IOException {
assertEquals(pid6String, pid6.asString());
assertEquals(UnmanagedPermaLinkPidProvider.ID, pid6.getProviderId());

//Lowercase test for unmanaged DOIs
String pid7String = "doi:10.5281/zenodo.6381129";
GlobalId pid7 = PidUtil.parseAsGlobalID(pid7String);
assertEquals(UnmanagedDOIProvider.ID, pid5.getProviderId());
assertEquals(pid7String, pid7.asString());

}

@Test
Expand Down Expand Up @@ -353,15 +359,15 @@ public void testExcludedSetParsing() throws IOException {
@Test
public void testManagedSetParsing() throws IOException {

String pid1String = "doi:10.5073/FK3ABCDEF";
String pid1String = "doi:10.5073/fk3ABCDEF";
GlobalId pid2 = PidUtil.parseAsGlobalID(pid1String);
assertEquals(pid1String, pid2.asString());
assertEquals(pid1String.toUpperCase(), pid2.asString().toUpperCase());
assertEquals("fake1", pid2.getProviderId());
assertEquals("https://doi.org/" + pid2.getAuthority() + PidUtil.getPidProvider(pid2.getProviderId()).getSeparator() + pid2.getIdentifier(),pid2.asURL());
assertEquals("10.5073", pid2.getAuthority());
assertEquals(AbstractDOIProvider.DOI_PROTOCOL, pid2.getProtocol());
GlobalId pid3 = PidUtil.parseAsGlobalID(pid2.asURL());
assertEquals(pid1String, pid3.asString());
assertEquals(pid1String.toUpperCase(), pid3.asString().toUpperCase());
assertEquals("fake1", pid3.getProviderId());
assertFalse(PidUtil.getPidProvider(pid3.getProviderId()).canCreatePidsLike(pid3));

Expand Down

0 comments on commit 610f8c0

Please sign in to comment.