Use handle.original.prefixes

This commit is contained in:
Terry Brady
2016-08-16 13:17:38 -07:00
parent c061898b07
commit 351b03a87b
3 changed files with 18 additions and 13 deletions

View File

@@ -58,7 +58,7 @@ public class HandleIdentifierProvider extends IdentifierProvider {
return false; return false;
} }
// return true if handle has valid starting pattern // return true if handle has valid starting pattern
if (identifier.startsWith(prefix) if (identifier.startsWith(prefix + "/")
|| identifier.startsWith(canonicalPrefix) || identifier.startsWith(canonicalPrefix)
|| identifier.startsWith("hdl:") || identifier.startsWith("hdl:")
|| identifier.startsWith("info:hdl") || identifier.startsWith("info:hdl")
@@ -71,10 +71,11 @@ public class HandleIdentifierProvider extends IdentifierProvider {
//Check additional prefixes supported in the config file //Check additional prefixes supported in the config file
String[] additionalPrefixes = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("handle.additional.prefixes"); String[] additionalPrefixes = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("handle.additional.prefixes");
for(String additionalPrefix: additionalPrefixes) { for(String additionalPrefix: additionalPrefixes) {
if (identifier.startsWith(additionalPrefix)) { if (identifier.startsWith(additionalPrefix + "/")) {
return true; return true;
} }
} }
return false; return false;
} }

View File

@@ -78,7 +78,7 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
return false; return false;
} }
// return true if handle has valid starting pattern // return true if handle has valid starting pattern
if (identifier.startsWith(prefix) if (identifier.startsWith(prefix + "/")
|| identifier.startsWith(canonicalPrefix) || identifier.startsWith(canonicalPrefix)
|| identifier.startsWith("hdl:") || identifier.startsWith("hdl:")
|| identifier.startsWith("info:hdl") || identifier.startsWith("info:hdl")
@@ -87,13 +87,15 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
{ {
return true; return true;
} }
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
if(prefix.contains(".")) { //Check additional prefixes supported in the config file
String[] splitPrefix = prefix.split("\\."); String[] additionalPrefixes = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("handle.additional.prefixes");
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) { for(String additionalPrefix: additionalPrefixes) {
if (identifier.startsWith(additionalPrefix + "/")) {
return true; return true;
} }
} }
// otherwise, assume invalid handle // otherwise, assume invalid handle
return false; return false;
} }

View File

@@ -74,7 +74,7 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
return false; return false;
} }
// return true if handle has valid starting pattern // return true if handle has valid starting pattern
if (identifier.startsWith(prefix) if (identifier.startsWith(prefix + "/")
|| identifier.startsWith(canonicalPrefix) || identifier.startsWith(canonicalPrefix)
|| identifier.startsWith("hdl:") || identifier.startsWith("hdl:")
|| identifier.startsWith("info:hdl") || identifier.startsWith("info:hdl")
@@ -83,13 +83,15 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
{ {
return true; return true;
} }
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
if(prefix.contains(".")) { //Check additional prefixes supported in the config file
String[] splitPrefix = prefix.split("\\."); String[] additionalPrefixes = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("handle.additional.prefixes");
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) { for(String additionalPrefix: additionalPrefixes) {
if (identifier.startsWith(additionalPrefix + "/")) {
return true; return true;
} }
} }
// otherwise, assume invalid handle // otherwise, assume invalid handle
return false; return false;
} }