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

Fix verification error parsing #3399

Merged
merged 3 commits into from
Dec 11, 2024
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 @@ -6,7 +6,6 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import eu.dzhw.fdz.metadatamanagement.common.config.MetadataManagementProperties;
import eu.dzhw.fdz.metadatamanagement.datapackagemanagement.domain.DataPackage;
import eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.DataAcquisitionProject;
Expand All @@ -33,7 +32,6 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

/**
* A client service that's solely responsible for
Expand Down Expand Up @@ -122,9 +120,13 @@ RegistrationResponse register(List<VariableMetadata> variables) throws Registrat
this.config.getDaraPid().getEndpoint() + PATH_VERIFY, entity, String.class);
var responseNode = this.objectMapper.readTree(response.getBody());
if (responseNode.path("constraintViolation").isArray()) {
var violations = Stream.of((ArrayNode) responseNode.path("constraintViolation"))
.map(JsonNode::toPrettyString).toList();
throw new VerificationException(violations);
var violations = new ArrayList<String>();
for (JsonNode jsonNode : responseNode.get("constraintViolation")) {
violations.add(jsonNode.toPrettyString());
}
if (!violations.isEmpty()) {
throw new VerificationException(violations);
}
}
// register variables
response = this.restTemplate.postForEntity(this.getRegistationEndpoint(), entity, String.class);
Expand Down