Class NakFactory<AuditDatasetType extends MllpAuditDataset>
java.lang.Object
org.openehealth.ipf.commons.ihe.hl7v2.NakFactory<AuditDatasetType>
- Direct Known Subclasses:
QpdAwareNakFactory
Basic ACK and NAK factory for HL7v2-based transactions.
- Author:
- Dmytro Rud
-
Constructor Summary
ConstructorDescriptionShort constructor which corresponds toNakFactory(config, false, "ACK")
.NakFactory
(Hl7v2TransactionConfiguration<AuditDatasetType> config, boolean useCAckTypeCodes, String defaultNakMsh9) Generic constructor. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a transaction-specific HL7v2 ACK response message on the basis of the original HAPI request message.Generates a "default" HL7v2 NAK message on the basis of the thrown exception.createNak
(Message originalMessage, HL7Exception exception, AcknowledgmentCode ackTypeCode) Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.static String
Formats and returns error message of an exception.protected AcknowledgmentCode
Returns a HL7v2 acknowledgement type code that corresponds to the given instance ofThrowable
.protected Hl7v2TransactionConfiguration<AuditDatasetType>
Returns configuration of the transaction served by this factory.protected HL7Exception
Returns a HL7v2 exception that corresponds to the given instance ofThrowable
.
-
Constructor Details
-
NakFactory
public NakFactory(Hl7v2TransactionConfiguration<AuditDatasetType> config, boolean useCAckTypeCodes, String defaultNakMsh9) Generic constructor.- Parameters:
config
- Configuration of the transaction served by this factory.useCAckTypeCodes
- iftrue
, HL7v2 acknowledgement codes CA, CE, CR will be used instead of the default AA, AE, AR.defaultNakMsh9
- desired contents of MSH-9 in this transaction's default NAKs.
-
NakFactory
Short constructor which corresponds toNakFactory(config, false, "ACK")
.- Parameters:
config
- Configuration of the transaction served by this factory.
-
-
Method Details
-
createAck
Generates a transaction-specific HL7v2 ACK response message on the basis of the original HAPI request message.- Parameters:
originalMessage
- original HAPI request message.- Throws:
HL7Exception
IOException
-
createNak
public Message createNak(Message originalMessage, HL7Exception exception, AcknowledgmentCode ackTypeCode) throws HL7Exception, IOException Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.- Parameters:
exception
- thrown exception.originalMessage
- original HAPI request message.ackTypeCode
- HL7v2 acknowledgement type code.- Throws:
HL7Exception
IOException
-
createNak
Generates an HL7v2 NAK response message on the basis of the thrown exception and the original HAPI request message.- Parameters:
t
- thrown exception.originalMessage
- original HAPI request message.- Throws:
HL7Exception
IOException
-
createDefaultNak
Generates a "default" HL7v2 NAK message on the basis of the thrown exception.- Parameters:
e
- thrown exception.
-
getHl7Exception
Returns a HL7v2 exception that corresponds to the given instance ofThrowable
. -
getAckTypeCode
Returns a HL7v2 acknowledgement type code that corresponds to the given instance ofThrowable
. -
formatErrorMessage
Formats and returns error message of an exception.In particular, all line break characters must be removed, otherwise they will break the structure of an HL7 NAK.
- Parameters:
t
- thrown exception.- Returns:
- formatted error message from the given exception.
-
getConfig
Returns configuration of the transaction served by this factory.
-