Skip to content

Commit

Permalink
Merge pull request DSpace#9671 from atmire/w2p-115693_DataCite-DOI-fix
Browse files Browse the repository at this point in the history
DataCite DOI error fixes
  • Loading branch information
bram-atmire authored Aug 23, 2024
2 parents cbea61c + 9e11e1f commit 7ff6d55
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
package org.dspace.identifier.doi;

import static org.dspace.identifier.DOIIdentifierProvider.DOI_ELEMENT;
import static org.dspace.identifier.DOIIdentifierProvider.DOI_QUALIFIER;
import static org.dspace.identifier.DOIIdentifierProvider.MD_SCHEMA;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -15,6 +19,7 @@
import java.util.Iterator;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
Expand Down Expand Up @@ -383,6 +388,10 @@ public void reserveDOI(Context context, DSpaceObject dso, String doi)
parameters.put("hostinginstitution",
configurationService.getProperty(CFG_HOSTINGINSTITUTION));
}
parameters.put("mdSchema", MD_SCHEMA);
parameters.put("mdElement", DOI_ELEMENT);
// Pass an empty string for qualifier if the metadata field doesn't have any
parameters.put("mdQualifier", DOI_QUALIFIER);

Element root = null;
try {
Expand Down Expand Up @@ -410,7 +419,7 @@ public void reserveDOI(Context context, DSpaceObject dso, String doi)
}

String metadataDOI = extractDOI(root);
if (null == metadataDOI) {
if (StringUtils.isBlank(metadataDOI)) {
// The DOI will be saved as metadata of dso after successful
// registration. To register a doi it has to be part of the metadata
// sent to DataCite. So we add it to the XML we'll send to DataCite
Expand Down
24 changes: 15 additions & 9 deletions dspace/config/crosswalks/DIM2DataCite.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<xsl:param name="hostinginstitution"><xsl:value-of select="$publisher" /></xsl:param>
<!-- Please take a look into the DataCite schema documentation if you want to know how to use these elements.
http://schema.datacite.org -->
<!-- Metadata-field to retrieve DOI from items -->
<xsl:param name="mdSchema">dc</xsl:param>
<xsl:param name="mdElement">identifier</xsl:param>
<xsl:param name="mdQualifier">uri</xsl:param>

<xsl:output method="xml" indent="yes" encoding="utf-8" />

Expand Down Expand Up @@ -333,15 +337,17 @@
company as well. We have to ensure to use URIs of our prefix
as primary identifiers only.
-->
<xsl:template match="dspace:field[@mdschema='dc' and @element='identifier' and @qualifier and (contains(., $prefix))]">
<identifier identifierType="DOI">
<xsl:if test="starts-with(string(text()), 'https://doi.org/')">
<xsl:value-of select="substring(., 17)"/>
</xsl:if>
<xsl:if test="starts-with(string(text()), 'http://dx.doi.org/')">
<xsl:value-of select="substring(., 19)"/>
</xsl:if>
</identifier>
<xsl:template match="dspace:field[@mdschema=$mdSchema and @element=$mdElement and (contains(., $prefix))]">
<xsl:if test="(($mdQualifier and $mdQualifier != '') and @qualifier=$mdQualifier) or ((not($mdQualifier) or $mdQualifier = '') and not(@qualifier))">
<identifier identifierType="DOI">
<xsl:if test="starts-with(string(text()), 'https://doi.org/')">
<xsl:value-of select="substring(., 17)"/>
</xsl:if>
<xsl:if test="starts-with(string(text()), 'http://dx.doi.org/')">
<xsl:value-of select="substring(., 19)"/>
</xsl:if>
</identifier>
</xsl:if>
</xsl:template>

<!-- DataCite (2) :: Creator -->
Expand Down

0 comments on commit 7ff6d55

Please sign in to comment.