Skip to content

Commit

Permalink
feat: include MagdaServiceIdentification information in Uitzonderinge…
Browse files Browse the repository at this point in the history
…nSectionInResponseExceptions
  • Loading branch information
NielskoDesmetski committed Sep 11, 2024
1 parent a2e8338 commit d2532ed
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public ConnectorMagdaClient(MagdaConnector connector) {
@Override
protected void validateMagdaResponse(MagdaResponse response, MagdaRequest request) throws MagdaClientException {
if(!response.getUitzonderingEntries().isEmpty()) {
throw new MagdaClientException("Level 2 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getUitzonderingEntries(), request.getCorrelationId(), response.getRequestId()));
throw new MagdaClientException("Level 2 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getUitzonderingEntries(), request.magdaServiceIdentification(), request.getCorrelationId(), response.getRequestId()));
}
if(!response.getResponseUitzonderingEntries().isEmpty() && haveAtLeastOneFout(response.getResponseUitzonderingEntries())) {
throw new MagdaClientException("Level 3 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getResponseUitzonderingEntries(), request.getCorrelationId(), response.getRequestId()));
throw new MagdaClientException("Level 3 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getResponseUitzonderingEntries(), request.magdaServiceIdentification(), request.getCorrelationId(), response.getRequestId()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public LenientConnectorMagdaClient(MagdaConnector connector) {
@Override
protected void validateMagdaResponse(MagdaResponse response, MagdaRequest request) throws MagdaClientException {
if(!response.getUitzonderingEntries().isEmpty()) {
throw new MagdaClientException("Level 2 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getUitzonderingEntries(), request.getCorrelationId(), response.getRequestId()));
throw new MagdaClientException("Level 2 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getUitzonderingEntries(), request.magdaServiceIdentification(), request.getCorrelationId(), response.getRequestId()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
import lombok.Getter;
import lombok.ToString;

import java.io.Serial;
import java.io.Serializable;

/**
* An identifier of a specific service provided by MAGDA, which comprises a name and a version.
*/
@Getter
@EqualsAndHashCode
@ToString
@AllArgsConstructor
public class MagdaServiceIdentification {
public class MagdaServiceIdentification implements Serializable {

@Serial
private static final long serialVersionUID = 5966457937074564979L;

private String name;
private String version;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void validateResponse(MagdaResponse response, GeefHistoriekInschrijvingR
if(response.getResponseUitzonderingEntries().stream().anyMatch(x ->
x.getUitzonderingType().equals(UitzonderingType.FOUT) &&
!"30101".equals(x.getIdentification()))) {
throw new MagdaClientException("Level 3 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getResponseUitzonderingEntries(), request.getCorrelationId(), response.getRequestId()));
throw new MagdaClientException("Level 3 exception occurred while calling magda service", new UitzonderingenSectionInResponseException(request.getSubject(), response.getResponseUitzonderingEntries(), request.magdaServiceIdentification(), request.getCorrelationId(), response.getRequestId()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package be.vlaanderen.vip.magda.exception;

import be.vlaanderen.vip.magda.client.MagdaServiceIdentification;
import be.vlaanderen.vip.magda.client.diensten.subject.SubjectIdentificationNumber;
import be.vlaanderen.vip.magda.legallogging.model.UitzonderingEntry;
import lombok.Getter;
Expand All @@ -20,10 +21,17 @@ public class UitzonderingenSectionInResponseException extends ServerException {

private final SubjectIdentificationNumber subject;
private final transient List<UitzonderingEntry> uitzonderingEntries;
private final MagdaServiceIdentification magdaServiceIdentification;

public UitzonderingenSectionInResponseException(SubjectIdentificationNumber subject, List<UitzonderingEntry> uitzonderingEntries, UUID correlationID, UUID requestID) {
public UitzonderingenSectionInResponseException(SubjectIdentificationNumber subject, List<UitzonderingEntry> uitzonderingEntries, MagdaServiceIdentification magdaServiceIdentification, UUID correlationID, UUID requestID) {
super("Backend error '" + uitzonderingEntries.get(0).toString() + "'", correlationID, requestID);
this.subject = subject;
this.uitzonderingEntries = uitzonderingEntries;
this.magdaServiceIdentification = magdaServiceIdentification;
}

@Deprecated(forRemoval = true)
public UitzonderingenSectionInResponseException(SubjectIdentificationNumber subject, List<UitzonderingEntry> uitzonderingEntries, UUID correlationID, UUID requestID) {
this(subject, uitzonderingEntries, null, correlationID, requestID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public MagdaResponse send(MagdaRequest magdaRequest, UUID requestId) throws Serv
.log("Result of request to MAGDA service with reference [{}] ({} ms): {}", requestId, duration.toMillis(), uitzonderingenMessage1);

if(!antwoord.isHasContents() && antwoordUitzonderingen.isEmpty() && uitzonderingen.isEmpty()) {
throw new UitzonderingenSectionInResponseException(magdaRequest.getSubject(), getLevel1UitzonderingEntry(response), magdaRequest.getCorrelationId(), requestId);
throw new UitzonderingenSectionInResponseException(magdaRequest.getSubject(), getLevel1UitzonderingEntry(response), magdaRequest.magdaServiceIdentification(), magdaRequest.getCorrelationId(), requestId);
}

return antwoord;
Expand Down

0 comments on commit d2532ed

Please sign in to comment.