mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
Added DOI.RESOLVER instead of using "http://dx.doi.org" everywhere.
This commit is contained in:
@@ -22,6 +22,7 @@ public class DOI
|
||||
implements Identifier
|
||||
{
|
||||
public static final String SCHEME = "doi:";
|
||||
public static final String RESOLVER = "http://dx.doi.org";
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,10 +48,10 @@ public class DOI
|
||||
if (identifier.isEmpty())
|
||||
throw new IllegalArgumentException("Cannot format an empty identifier.");
|
||||
if (identifier.startsWith(SCHEME))
|
||||
return "http://dx.doi.org/" + identifier.substring(SCHEME.length());
|
||||
return RESOLVER + "/" + identifier.substring(SCHEME.length());
|
||||
if (identifier.startsWith("10.") && identifier.contains("/"))
|
||||
return "http://dx.doi.org/" + identifier;
|
||||
if (identifier.startsWith("http://dx.doi.org/10."))
|
||||
return RESOLVER + "/" + identifier;
|
||||
if (identifier.startsWith(RESOLVER + "/10."))
|
||||
return identifier;
|
||||
|
||||
throw new IdentifierException(identifier + "does not seem to be a DOI.");
|
||||
@@ -59,7 +60,7 @@ public class DOI
|
||||
public static String DOIFromExternalFormat(String identifier)
|
||||
throws DOIIdentifierException
|
||||
{
|
||||
Pattern pattern = Pattern.compile("^http://dx.doi.org/+(10\\..*)$");
|
||||
Pattern pattern = Pattern.compile("^" + RESOLVER + "/+(10\\..*)$");
|
||||
Matcher matcher = pattern.matcher(identifier);
|
||||
if (matcher.find())
|
||||
{
|
||||
@@ -93,7 +94,7 @@ public class DOI
|
||||
if (identifier.startsWith("10.") && identifier.contains("/")) {
|
||||
return DOI.SCHEME + identifier;
|
||||
}
|
||||
if (identifier.startsWith("http://dx.doi.org/10.")) {
|
||||
if (identifier.startsWith(RESOLVER + "/10.")) {
|
||||
return DOI.SCHEME + identifier.substring(18);
|
||||
}
|
||||
throw new DOIIdentifierException(identifier + "does not seem to be a DOI.",
|
||||
|
@@ -851,7 +851,7 @@ public class DOIIdentifierProvider
|
||||
DCValue[] metadata = item.getMetadata(MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null);
|
||||
for (DCValue id : metadata)
|
||||
{
|
||||
if (id.value.startsWith("http://dx.doi.org/10."))
|
||||
if (id.value.startsWith(DOI.RESOLVER + "/10."))
|
||||
{
|
||||
return DOI.DOIFromExternalFormat(id.value);
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ public class DOIIdentifierProviderTest
|
||||
|
||||
for (DCValue id : metadata)
|
||||
{
|
||||
if (!id.value.startsWith("http://dx.doi.org/"))
|
||||
if (!id.value.startsWith(DOI.RESOLVER))
|
||||
{
|
||||
remainder.add(id.value);
|
||||
}
|
||||
@@ -262,7 +262,8 @@ public class DOIIdentifierProviderTest
|
||||
"10.5072/123abc-lkj/kljl",
|
||||
PREFIX + "/" + NAMESPACE_SEPARATOR + "lkjljasd1234",
|
||||
DOI.SCHEME + "10.5072/123abc-lkj/kljl",
|
||||
"http://dx.doi.org/10.5072/123abc-lkj/kljl"
|
||||
"http://dx.doi.org/10.5072/123abc-lkj/kljl",
|
||||
DOI.RESOLVER + "/10.5072/123abc-lkj/kljl"
|
||||
};
|
||||
|
||||
for (String doi : validDOIs)
|
||||
|
Reference in New Issue
Block a user