Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow backend validation but not resolution #6946

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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