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

Bug fix/update pid resolution issue #81

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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 @@ -73,7 +73,7 @@ public JsonApiWrapperWrite updateRecords(List<JsonNode> requests, boolean increm
var types = requests.stream()
.map(request -> request.get(NODE_DATA).get(NODE_TYPE).asText())
.filter(type -> !type.equals(MEDIA_OBJECT.toString())
|| !type.equals(DIGITAL_SPECIMEN.toString()))
&& !type.equals(DIGITAL_SPECIMEN.toString()))
.collect(Collectors.toSet());

if (!types.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public class FdoRecordService {
private static final String DOI_DOMAIN = "https://doi.org/";
private static final String ROR_API_DOMAIN = "https://api.ror.org/organizations/";
private static final String ROR_DOMAIN = "https://ror.org/";
private static final String WIKIDATA_DOMAIN = "https://wikidata.org";
private static final String WIKIDATA_API = "https://wikidata.org/w/rest.php/wikibase/v0/entities/items/";
private static final String PROXY_ERROR = "Invalid attribute: %s must contain proxy: %s";
private static final String PID_KERNEL_METADATA_LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/";
Expand Down Expand Up @@ -574,7 +575,8 @@ private HandleAttribute setHostName(String hostName, String hostId, byte[] handl
}
return new HandleAttribute(targetAttribute, handle, hostNameResolved);
} else {
throw new PidResolutionException("Specimen host ID {} is neither QID nor ROR.");
log.error("Specimen host ID {} is neither QID nor ROR.", hostId);
throw new PidResolutionException("Invalid host id: " + hostId);
}
} catch (UnprocessableEntityException | InvalidRequestException |
PidResolutionException e) {
Expand All @@ -587,7 +589,7 @@ private HandleAttribute setHostName(String hostName, String hostId, byte[] handl
}

private boolean isAcceptedSpecimenHostId(String id) {
return (id.contains(ROR_DOMAIN) || id.toLowerCase().charAt(0) == 'q');
return (id.contains(ROR_DOMAIN) || id.contains(WIKIDATA_DOMAIN));
}

public List<HandleAttribute> prepareUpdateAttributes(byte[] handle, JsonNode requestAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void testPrepareDigitalSpecimenRecordMandatoryAttributes() throws Exception {
@Test
void testPrepareDigitalSpecimenRecordMandatoryAttributesQNumber() throws Exception {
// Given
String qid = "Q12345";
String qid = "https://wikidata.org/Q12345";
String qidUrl = "https://wikidata.org/w/rest.php/wikibase/v0/entities/items/" + qid;
given(pidResolver.getObjectName(any())).willReturn("placeholder");
given(pidResolver.resolveQid(any())).willReturn("placeholder");
Expand Down
Loading