More restrictive handle definitions

As per request by pnbecker and tdonahue, reworking supports() method to
be more restrictive in its handle validation while also still allowing
support for multi-instance environments with derived handles. Now, if a
handle does not match one of the currently known DSpace handle provider
formats, it will be rejected.
This commit is contained in:
mjmarttila
2016-08-03 14:02:16 -04:00
parent 12649fe1fe
commit f6bfc491d3
3 changed files with 33 additions and 30 deletions

View File

@@ -82,19 +82,20 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
|| identifier.startsWith(canonicalPrefix)
|| identifier.startsWith("hdl:")
|| identifier.startsWith("info:hdl")
|| identifier.matches("^https?://hdl.handle.net/")
|| identifier.matches("^https?://.+/handle/"))
|| identifier.matches("^https?://hdl\\.handle\\.net/.*")
|| identifier.matches("^https?://.+/handle/.*"))
{
return true;
}
// return false if identifier starts with DOI prefix
if(identifier.startsWith("10.") || identifier.matches("^https?://dx.doi.org") || identifier.startsWith("doi:"))
return false;
// return false if identifier does not contain a '/' or is a URL that does not match above patterns
if(! identifier.contains("/") || identifier.matches("^https?://.+"))
return false;
// otherwise, assumed a valid handle
return true;
// return true if base prefix matches in case of multi-instance deployment with derived prefixes demarcated by a dot "."
if(prefix.contains(".")) {
String[] splitPrefix = prefix.split("\\.");
if(splitPrefix.length > 1 && identifier.startsWith(splitPrefix[0])) {
return true;
}
}
// otherwise, assume invalid handle
return false;
}
@Override