Skip to content

Commit

Permalink
Merge pull request #6946 from ORCID/FixValidationErrorOnIsbn
Browse files Browse the repository at this point in the history
Allow backend validation but not resolution
  • Loading branch information
amontenegro authored Dec 7, 2023
2 parents f068b83 + f40129e commit 1f320b2
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.orcid.core.utils.v3.identifiers.PIDResolverCache;
import org.orcid.jaxb.model.v3.release.record.Work;
import org.orcid.pojo.PIDResolutionResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.google.common.collect.Lists;
Expand All @@ -21,6 +22,9 @@ public class ISBNOCLCResolver implements LinkResolver {

@Resource
PIDResolverCache cache;

@Value("${org.orcid.core.utils.v3.identifiers.resolvers.ISBNOCLCResolver.disabled:true}")
private boolean disableIsbnResolution;

public List<String> canHandle() {
return Lists.newArrayList("oclc","isbn");
Expand All @@ -39,10 +43,14 @@ public PIDResolutionResult resolve(String apiTypeName, String value) {
// this assumes we're using worldcat - 303 on success, 200 on fail
String normUrl = normalizationService.generateNormalisedURL(apiTypeName, value);
if (!StringUtils.isEmpty(normUrl)) {
if (cache.isHttp303(normUrl)){
return new PIDResolutionResult(true,true,true,normUrl);
}else{
return new PIDResolutionResult(false,true,true,null);
if (disableIsbnResolution) {
// If it is a valid format, but the resolver is disabled,
// return just the valid format
return new PIDResolutionResult(false, true, true, null);
} else if (cache.isHttp303(normUrl)) {
return new PIDResolutionResult(true, true, true, normUrl);
} else {
return new PIDResolutionResult(false, true, true, null);
}
}
return new PIDResolutionResult(false,false,true,null);//unreachable?
Expand Down

0 comments on commit 1f320b2

Please sign in to comment.