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