Skip to content

Commit

Permalink
Merge pull request #3399 from dzhw/tvillwock/issue3303-pid-registration
Browse files Browse the repository at this point in the history
Fix verification error parsing
  • Loading branch information
tilovillwock authored Dec 11, 2024
2 parents 8df9f30 + 1ce2e7b commit a84c953
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit a84c953

Please sign in to comment.