Skip to content
Snippets Groups Projects

fix: check deposit is not completely null after importing from a DOI after verifying all services

Merged Alicia.DeDiosFuente requested to merge adf-import-doi into master
All threads resolved!
@@ -126,6 +126,10 @@ public class MetadataImportWorkFlowService {
} catch (SolidifyRuntimeException e) {
try {
depositDoc = this.doiCrossrefImportService.searchDoi(cleanedDoi, depositDoc);
// Check that first step properties have been recovered.
if (this.isDepositDataNull(depositDoc)) {
throw new SolidifyRuntimeException("The doi has not been found neither in crossref.");
}
} catch (SolidifyRuntimeException exception) {
try {
depositDoc = this.dataCiteImportService.searchDoi(cleanedDoi, depositDoc);
@@ -148,6 +152,12 @@ public class MetadataImportWorkFlowService {
log.warn("Unable to import from PMID with the DOI '{}'", cleanedDoi, e);
}
// Check that first step properties have been recovered.
if (this.isDepositDataNull(depositDoc)) {
throw new SolidifyHttpErrorException(HttpStatus.NOT_FOUND,
this.messageService.get("deposit.error.identifiers.doi.not_found", new Object[] { cleanedDoi }));
}
this.checkForIndirectDuplicate(Publication.ImportSource.DOI, depositDoc);
if (isXmlFormat) {
@@ -360,6 +370,15 @@ public class MetadataImportWorkFlowService {
}
}
private boolean isDepositDataNull(DepositDoc depositDoc) {
return depositDoc.getTitle() == null
&& depositDoc.getType() == null
&& depositDoc.getOriginalTitle() == null
&& depositDoc.getSubtype() == null
&& depositDoc.getSubsubtype() == null;
}
private void throwExistingPublicationInfoExceptionIfExists(ExistingPublicationInfo existingPublicationInfo, String message) {
final Map<Object, Object> params = this.duplicateService.getParamsFromExistingPublicationInfo(existingPublicationInfo);
if (params != null) {
Loading