Skip to content

Commit 30ba66c

Browse files
vins01-4scienceAdamF42
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2304 (pull request DSpace#5122)
fix(DOI): Fixes NULLPointer during discard of submission with DOI. Adds doi configuration for submissions and edits the datacite template Approved-by: Fapohunda, Adamo
2 parents 1c582c5 + d608b8c commit 30ba66c

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,16 +1040,20 @@ public String getDOIOutOfObject(Context context, DSpaceObject dso) throws DOIIde
10401040
List<MetadataValue> metadata = itemService.getMetadata(item, MD_SCHEMA, DOI_ELEMENT, DOI_QUALIFIER, null);
10411041
String resolverBaseUrl = getResolverBaseUrl(context, item);
10421042
for (MetadataValue id : metadata) {
1043-
if (id.getValue().startsWith(resolverBaseUrl)) {
1043+
if (resolverBaseUrl != null && id.getValue().startsWith(resolverBaseUrl)) {
10441044
return doiService.DOIFromExternalFormat(id.getValue());
10451045
}
10461046
}
10471047
return null;
10481048
}
10491049

10501050
private String getResolverBaseUrl(Context context, Item item) {
1051-
return DoiGenerationStrategy.getApplicableStrategy(context, doiGenerationStrategies, item)
1052-
.getDOIResolverAndPrefix(context, item, getPrefix());
1051+
DoiGenerationStrategy applicableStrategy =
1052+
DoiGenerationStrategy.getApplicableStrategy(context, doiGenerationStrategies, item);
1053+
if (applicableStrategy != null) {
1054+
return applicableStrategy.getDOIResolverAndPrefix(context, item, getPrefix());
1055+
}
1056+
return null;
10531057
}
10541058

10551059
/**

dspace/config/crosswalks/template/publication-datacite-xml.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<titles>
3232
<title>@dc.title@</title>
3333
</titles>
34+
@if.not.metadata.dc-publisher.start@
35+
<publisher>(:unav)</publisher>
36+
@if.not.metadata.dc-publisher.end@
3437
@if.metadata.dc-publisher.start@
3538
<publisher
3639
@relation.dc-publisher.start@

dspace/config/dspace.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ org.dspace.app.batchitemimport.work.dir = ${dspace.dir}/imports
992992
# Following are configuration values for the EZID DOI provider, with appropriate
993993
# values for testing. Replace the values with your assigned "shoulder" and
994994
# credentials.
995+
doi.datacite.host = mds.test.datacite.org
995996
#identifier.doi.ezid.shoulder = 10.5072/FK2/
996997
#identifier.doi.ezid.user = apitest
997998
#identifier.doi.ezid.password = apitest
@@ -1988,6 +1989,16 @@ system-event.thread.size = 2
19881989
#------------------------------------------------------------------#
19891990
orchestrator.ignore-script = process-cleaner, item-export, bulk-item-export, cris-layout-tool, export-cris-layout-tool, deduplication-merge-items, bulk-access-control, export-schema, dspace-object-deletion
19901991

1992+
#------------------------------------------------------------------#
1993+
#----------------DOI GENERATOR CONFIGURATIONS-----------------------#
1994+
#------------------------------------------------------------------#
1995+
# #
1996+
# Configurations for the DOI Generator Module #
1997+
# #
1998+
#------------------------------------------------------------------#
1999+
# Handle of the pulication collection where DOIs will be registered during submission
2000+
# doi.generator.collection.publication.handle = 123456789/xxxx
2001+
19912002
# Load default module configs
19922003
# ----------------------------
19932004
# To exclude a module configuration, simply comment out its "include" statement.

dspace/config/spring/api/identifier-service.xml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
-->
1010
<bean id="org.dspace.identifier.service.IdentifierService"
1111
class="org.dspace.identifier.IdentifierServiceImpl"
12-
autowire="byType"
13-
scope="singleton">
12+
autowire="byType">
1413
</bean>
1514

1615
<!-- If you disable versioning, you need to use the default HandleIdentifierProvider. -->
@@ -20,11 +19,11 @@
2019
</bean>
2120
-->
2221

23-
<!-- If you enabled versioning, you should use one of the versioned
24-
handle identifier provider instead of the default one.
25-
The VersionedHandleIdentifierProvider creates a new versioned
26-
handle for every new version.
27-
-->
22+
<!-- If you enabled versioning, you should use one of the versioned
23+
handle identifier provider instead of the default one.
24+
The VersionedHandleIdentifierProvider creates a new versioned
25+
handle for every new version.
26+
-->
2827
<bean id="org.dspace.identifier.HandleIdentifierProvider" class="org.dspace.identifier.VersionedHandleIdentifierProvider" scope="singleton">
2928
<property name="configurationService" ref="org.dspace.services.ConfigurationService"/>
3029
</bean>
@@ -101,10 +100,10 @@
101100
-->
102101
<!-- Uncomment this to use the DataCite API directly as DOIConnector.
103102
<bean id="org.dspace.identifier.doi.DOIConnector"
104-
class="org.dspace.identifier.doi.DataCiteConnector"
105-
scope="singleton">
103+
class="org.dspace.identifier.doi.DataCiteConnector"
104+
scope="singleton">
106105
<property name='DATACITE_SCHEME' value='https'/>
107-
<property name='DATACITE_HOST' value='mds.test.datacite.org'/>
106+
<property name='DATACITE_HOST' value='${doi.datacite.host}'/>
108107
<property name='DATACITE_DOI_PATH' value='/doi/' />
109108
<property name='DATACITE_METADATA_PATH' value='/metadata/' />
110109
<property name='disseminationCrosswalkByEntityType'>
@@ -165,9 +164,7 @@
165164
<property name="configurationValue" value="${identifier.doi.namespaceseparator}" />
166165
</bean>
167166
168-
&lt;!&ndash; Below there are defined the generation strategy &ndash;&gt;
169167
<bean id="defaultDoiGenerationStrategy" class="org.dspace.identifier.generators.ConfigurableDoiGenerationStrategy">
170-
&lt;!&ndash; Filter configured in item-filters.xml file &ndash;&gt;
171168
<constructor-arg name="filter" ref="always_true_filter" />
172169
<constructor-arg name="doiNamespaceGenerator" ref="defaultValueNamespace" />
173170
<constructor-arg name="generationType" value="DEFAULT" />
@@ -181,7 +178,7 @@
181178
<map>
182179
<entry key="collections">
183180
<list>
184-
<value>123456789/6</value>
181+
<value>${doi.generator.collection.publication.handle:-}</value>
185182
</list>
186183
</entry>
187184
</map>
@@ -190,17 +187,19 @@
190187
<bean id="publicationFilter" class="org.dspace.content.logic.DefaultFilter">
191188
<property name="statement" ref="publicationCollectionCond"/>
192189
</bean>
190+
<bean id="publicationDOIGenerationStrategy" class="org.dspace.identifier.generators.ConfigurableDoiGenerationStrategy">
191+
<constructor-arg name="filter" ref="publicationFilter" />
192+
<constructor-arg name="doiNamespaceGenerator" ref="defaultValueNamespace" />
193+
<constructor-arg name="generationType" value="CUSTOM" />
194+
</bean>
195+
-->
196+
<!--
193197
194198
<bean id="publicationGenerator" class="org.dspace.identifier.generators.FixedConfigurationValueNamespaceGenerator">
195199
<property name="configurationValue" value="publications/dspace-local/" />
196200
</bean>
197201
198-
<bean id="thesisDoiGenerationStrategy" class="org.dspace.identifier.generators.ConfigurableDoiGenerationStrategy">
199-
<constructor-arg name="filter" ref="publicationFilter" />
200-
<constructor-arg name="doiNamespaceGenerator" ref="publicationGenerator" />
201-
<constructor-arg name="generationType" value="CUSTOM" />
202-
</bean>
203-
-->
202+
-->
204203
<!-- CUSTOM GENERATORS -->
205204

206205
</beans>

dspace/config/spring/api/item-filters.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<property name="parameters">
9595
<map>
9696
<entry key="field" value="dc.identifier.uri" />
97-
<entry key="pattern" value="10.12345/" />
97+
<entry key="pattern" value="${identifier.doi.prefix:10\.12345}\/" />
9898
</map>
9999
</property>
100100
</bean>

0 commit comments

Comments
 (0)