use of net.opengis.cat.csw._3.RecordType in project openaire-cris-validator by EuroCRIS.
the class FileLoggingConnectionStreamFactory method wrapCheckOAIIdentifier.
private CheckingIterable<RecordType> wrapCheckOAIIdentifier(final CheckingIterable<RecordType> checker) {
final Optional<String> repoIdentifier = endpoint.getRepositoryIdentifer();
if (repoIdentifier.isPresent()) {
final Function<RecordType, Set<String>> expectedFunction = new Function<RecordType, Set<String>>() {
@Override
public Set<String> apply(final RecordType x) {
final MetadataType metadata = x.getMetadata();
final Set<String> results = new HashSet<>();
if (metadata != null) {
final Element el = (Element) metadata.getAny();
final String id = el.getAttribute("id");
results.add("oai:" + repoIdentifier.get() + ":" + el.getLocalName() + "s/" + id);
results.add("oai:" + repoIdentifier.get() + ":" + id);
} else {
// make the test trivially satisfied for records with no metadata
results.add(x.getHeader().getIdentifier());
}
return results;
}
};
return checker.checkForAllValueInSet(expectedFunction, ((final RecordType record) -> record.getHeader().getIdentifier()), "OAI identifier other than expected");
} else {
return checker;
}
}
Aggregations