Skip to content
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 @@ -48,8 +48,8 @@ private X509TrustManager getDefaultTrustManager() {
trustManagerFactory.init((KeyStore) null); // Using null here initialises the TMF with the default trust store.

for (TrustManager tm : trustManagerFactory.getTrustManagers()) {
if (tm instanceof X509TrustManager) {
return (X509TrustManager) tm;
if (tm instanceof X509TrustManager x509TrustManager) {
return x509TrustManager;
}
}
throw new IllegalStateException("Cannot find trust manager");
Expand All @@ -70,8 +70,8 @@ private X509TrustManager getCustomDbTrustManager(AmazonS3URI s3URI, String trust
}

for (TrustManager tm : trustManagerFactory.getTrustManagers()) {
if (tm instanceof X509TrustManager) {
return (X509TrustManager) tm;
if (tm instanceof X509TrustManager x509TrustManager) {
return x509TrustManager;
}
}
throw new IllegalStateException("Cannot find trust manager");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class ObjectSerializer {

@SneakyThrows
public String serialize(Object object) {
if (object instanceof IBaseResource) {
return fhirParser.encodeToString((IBaseResource) object);
if (object instanceof IBaseResource iBaseResource) {
return fhirParser.encodeToString(iBaseResource);
}
if (object instanceof AmendmentBody) {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
if (object instanceof AmendmentBody amendmentBody) {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(amendmentBody);
}
throw new UnsupportedOperationException("Data type " + object.getClass().getSimpleName() + " is not supported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ private void logRequest(String type, HttpRequest request) {
LOGGER.debug("MESH '{}' request line: {}", type, request.getRequestLine());
LOGGER.debug("MESH '{}' request headers: {}", type, request.getAllHeaders());

if (request instanceof HttpEntityEnclosingRequest) {
var entity = ((HttpEntityEnclosingRequest) request).getEntity();
if (request instanceof HttpEntityEnclosingRequest httpEntityEnclosingRequest) {
var entity = httpEntityEnclosingRequest.getEntity();
if (entity != null) {
LOGGER.debug("MESH '{}' request content line: {}", type, entity);
// request content is usually not "repeatable" so we can only decode it once. Log response content separately.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class NewHealthAuthorityName extends Segment {
public static final String QUALIFIER = "NFH";
public static final String KEY_QUALIFIER = KEY + "+" + QUALIFIER;
private @NonNull String haName;
private final String code = "954";
private static final String CODE = "954";

public static NewHealthAuthorityName fromString(String edifactString) {
if (!edifactString.startsWith(NewHealthAuthorityName.KEY_QUALIFIER)) {
Expand All @@ -36,7 +36,7 @@ public String getKey() {

@Override
public String getValue() {
return QUALIFIER + "+" + haName + ":" + code;
return QUALIFIER + "+" + haName + ":" + CODE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public class PreviousHealthAuthorityName extends Segment {
public static final String QUALIFIER = "PFH";
public static final String KEY_QUALIFIER = KEY + "+" + QUALIFIER;
private @NonNull String identifier;
private final String code = "954";

private static final String CODE = "954";

@Override
public String getKey() {
Expand All @@ -27,7 +26,7 @@ public String getKey() {

@Override
public String getValue() {
return QUALIFIER + "+" + identifier + ":" + code;
return QUALIFIER + "+" + identifier + ":" + CODE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ResidentialInstituteNameAndAddress extends Segment {
public static final String KEY = "NAD";
public static final String QUALIFIER = "RIC";
public static final String KEY_QUALIFIER = KEY + "+" + QUALIFIER;
private final String code = "956";
private static final String CODE = "956";
private @NonNull String identifier;

@Override
Expand All @@ -33,7 +33,7 @@ public String getKey() {

@Override
public String getValue() {
return QUALIFIER + "+" + identifier + ":" + code;
return QUALIFIER + "+" + identifier + ":" + CODE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,17 @@ protected void recordOutboundState(T translationItems) {

protected void addSequenceNumbersToSegments(T translationItems) {
for (Segment segment : translationItems.getSegments()) {
if (segment instanceof InterchangeHeader) {
InterchangeHeader interchangeHeader = (InterchangeHeader) segment;
if (segment instanceof InterchangeHeader interchangeHeader) {
interchangeHeader.setSequenceNumber(translationItems.getSendInterchangeSequence());
} else if (segment instanceof InterchangeTrailer) {
InterchangeTrailer interchangeTrailer = (InterchangeTrailer) segment;
} else if (segment instanceof InterchangeTrailer interchangeTrailer) {
interchangeTrailer.setSequenceNumber(translationItems.getSendInterchangeSequence());
} else if (segment instanceof MessageHeader) {
MessageHeader messageHeader = (MessageHeader) segment;
} else if (segment instanceof MessageHeader messageHeader) {
messageHeader.setSequenceNumber(translationItems.getSendMessageSequence());
} else if (segment instanceof MessageTrailer) {
MessageTrailer messageTrailer = (MessageTrailer) segment;
} else if (segment instanceof MessageTrailer messageTrailer) {
messageTrailer.setSequenceNumber(translationItems.getSendMessageSequence());
} else if (segment instanceof ReferenceTransactionNumber) {
ReferenceTransactionNumber referenceTransactionNumber = (ReferenceTransactionNumber) segment;
} else if (segment instanceof ReferenceTransactionNumber referenceTransactionNumber) {
referenceTransactionNumber.setTransactionNumber(translationItems.getTransactionNumber());
} else if (segment instanceof RegistrationMessageDateTime) {
RegistrationMessageDateTime registrationMessageDateTime = (RegistrationMessageDateTime) segment;
} else if (segment instanceof RegistrationMessageDateTime registrationMessageDateTime) {
registrationMessageDateTime.setTimestamp(translationItems.getTranslationTimestamp());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ public final ResponseEntity<String> handleAllErrors(Exception ex, WebRequest req
LOGGER.error("Creating OperationOutcome response for unhandled exception", ex);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
headers.put(HttpHeaders.CONTENT_TYPE, singletonList("application/json"));
if (ex instanceof OperationOutcomeError) {
OperationOutcomeError error = (OperationOutcomeError) ex;
String content = fhirParser.encodeToString(error.getOperationOutcome());
return new ResponseEntity<>(content, headers, error.getStatusCode());
if (ex instanceof OperationOutcomeError operationOutcomeError) {
String content = fhirParser.encodeToString(operationOutcomeError.getOperationOutcome());
return new ResponseEntity<>(content, headers, operationOutcomeError.getStatusCode());
}
OperationOutcome operationOutcome = OperationOutcomeUtils.createFromMessage(ex.getMessage());
String content = fhirParser.encodeToString(operationOutcome);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
public class FhirParser {

private final IParser parser;
// private final FhirValidator validator;

/*
* TODO: Consider revisiting validation if we are able to update to FHIR 5.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ public abstract class BadRequestException extends NhaisBaseException implements

private final IBaseOperationOutcome operationOutcome;

public BadRequestException(String message) {
protected BadRequestException(String message) {
super(message);
operationOutcome = OperationOutcomeUtils.createFromMessage(message, getIssueType());
}

public BadRequestException(String message, Throwable cause) {
super(message, cause);
operationOutcome = OperationOutcomeUtils.createFromMessage(message, getIssueType());
}

public BadRequestException(Throwable cause) {
protected BadRequestException(Throwable cause) {
super(cause);
operationOutcome = OperationOutcomeUtils.createFromMessage(cause.getMessage(), getIssueType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
public class JmsReader {

public static String readMessage(Message message) throws JMSException {
if (message instanceof JmsTextMessage) {
return readTextMessage((JmsTextMessage) message);
if (message instanceof JmsTextMessage jmsTextMessage) {
return readTextMessage(jmsTextMessage);
}
if (message instanceof JmsBytesMessage) {
return readBytesMessage((JmsBytesMessage) message);
if (message instanceof JmsBytesMessage jmsBytesMessage) {
return readBytesMessage(jmsBytesMessage);
}
if (message != null) {
return message.getBody(String.class);
Expand Down