public abstract class AbstractHl7OverHttpDecoder extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_READ_TIMEOUT
Default amount of time that the decoder will attempt to read before
timing out and throwing an IOException (30000ms)
|
static String |
HTTP_HEADER_HL7_SIGNATURE |
static String |
HTTP_HEADER_HL7_SIGNATURE_LC |
protected static Charset |
ourDefaultCharset |
Constructor and Description |
---|
AbstractHl7OverHttpDecoder() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
authorize() |
void |
decode() |
Charset |
getCharset()
Returns the charset associated with this message.
|
List<String> |
getConformanceProblems() |
String |
getContentType() |
byte[] |
getData() |
static Charset |
getDefaultCharset() |
EncodingStyle |
getEncodingStyle()
Returns the
EncodingStyle associated with the incoming message,
or null . |
Map<String,String> |
getHeaders() |
String |
getMessage() |
String |
getPassword() |
String |
getPath() |
String |
getPathRaw() |
String |
getResponseName() |
Integer |
getResponseStatus() |
ISigner |
getSigner() |
String |
getUsername() |
boolean |
isCharsetExplicitlySet() |
protected boolean |
isConnectionCloseHeaderPresent()
Protected because this doesn't make sense for a sender
|
protected abstract String |
readActionLineAndDecode(InputStream theInputStream) |
void |
readContentsFromInputStreamAndDecode(InputStream theInputStream)
Read in the contents of the raw message from the input stream and decode
entire the message.
|
protected String |
readFirstLine(InputStream theInputStream) |
void |
readHeadersAndContentsFromInputStreamAndDecode(InputStream theInputStream)
Note that if
setPath(String) is called, this method will assume
that the first line of the HTTP request has already been read from the
input stream. |
void |
setCharset(Charset theCharset)
Deprecated.
The HL7 over HTTP specification now mandates the use of UTF-8. Using this method to set a value other than UTF-8 will lead to a non-conformant application
|
protected void |
setData(byte[] theData) |
void |
setHeaders(LinkedHashMap<String,String> theHeaders) |
void |
setMessage(String theMessage) |
void |
setPassword(String thePassword) |
void |
setPath(String thePath) |
void |
setReadTimeout(long theReadTimeout)
Sets the number of milliseconds that the decoder will attempt to read
from an InputStream before timing out and throwing an exception
|
void |
setResponseName(String theResponseName) |
void |
setResponseStatus(Integer theResponseStatus) |
void |
setSigner(ISigner theSigner)
Optionally may be used to provide a signer implementation which signs HL7
content.
|
void |
setUsername(String theUsername) |
protected void |
verifyNotUsed()
Throws an
IllegalStateException if called more than once |
public static final int DEFAULT_READ_TIMEOUT
setReadTimeout(long)
,
Constant Field Valuespublic static final String HTTP_HEADER_HL7_SIGNATURE
public static final String HTTP_HEADER_HL7_SIGNATURE_LC
protected static final Charset ourDefaultCharset
public AbstractHl7OverHttpDecoder()
protected abstract void authorize() throws AuthorizationFailureException
AuthorizationFailureException
public void decode() throws DecodeException, SignatureVerificationException
protected boolean isConnectionCloseHeaderPresent()
public EncodingStyle getEncodingStyle()
EncodingStyle
associated with the incoming message,
or null
. This will be set automatically based on the value
of the Content-Type
header, and will be set to
null
if the content type is not provided, or if the content
type does not correspond to an HL7 type.EncodingStyle} for a list of appropriate content types
public List<String> getConformanceProblems()
public String getContentType()
public String getResponseName()
public Integer getResponseStatus()
protected abstract String readActionLineAndDecode(InputStream theInputStream) throws IOException, NoMessageReceivedException, DecodeException
public void readContentsFromInputStreamAndDecode(InputStream theInputStream) throws AuthorizationFailureException, DecodeException, IOException, SignatureVerificationException
setHeaders(LinkedHashMap)
theInputStream
- The inputstream to read the raw message fromAuthorizationFailureException
- If the authorization check fails. This will only be thrown if
this decoder is decoding a request message, and an
authorization callback has been provided, and the
authorization fails.DecodeException
- If the message can not be decoded for any reasonIOException
- If there is a failure while reading from the inputstreamSignatureVerificationException
- If the signature verification fails. This will only occur if
a signer
has been provided.protected String readFirstLine(InputStream theInputStream) throws IOException, NoMessageReceivedException
public void readHeadersAndContentsFromInputStreamAndDecode(InputStream theInputStream) throws IOException, DecodeException, NoMessageReceivedException, SignatureVerificationException
setPath(String)
is called, this method will assume
that the first line of the HTTP request has already been read from the
input stream. If setHeaders(java.util.LinkedHashMap)
has been
called, this method will assume that the HTTP headers have already been
read from the input stream as well as the double-LF (ASCII-10) that
proceeds the headers.theInputStream
- The inputstream to read the raw message fromAuthorizationFailureException
- If the authorization check fails. This will only be thrown if
this decoder is decoding a request message, and an
authorization callback has been provided, and the
authorization fails.DecodeException
- If the message can not be decoded for any reasonIOException
- If there is a failure while reading from the inputstreamSignatureVerificationException
- If the signature verification fails. This will only occur if
a signer
has been provided.NoMessageReceivedException
public void setReadTimeout(long theReadTimeout)
public void setResponseName(String theResponseName)
theResponseName
- the responseName to setpublic void setResponseStatus(Integer theResponseStatus)
theResponseStatus
- the responseStatus to setpublic Charset getCharset()
null
.public byte[] getData()
public Map<String,String> getHeaders()
public String getMessage()
public String getPassword()
public String getPathRaw()
public String getUsername()
public boolean isCharsetExplicitlySet()
true
if the charset was explicitly set using
setCharset(Charset)
@Deprecated public void setCharset(Charset theCharset)
theCharset
- The encoding charset to use (default is UTF-8)protected void setData(byte[] theData)
theData
- the data to setpublic void setHeaders(LinkedHashMap<String,String> theHeaders)
theHeaders
- the headers to setpublic void setMessage(String theMessage)
theMessage
- The raw message textpublic void setPassword(String thePassword)
thePassword
- The authorization passwordpublic void setSigner(ISigner theSigner)
ISigner
,
StandardMessageSigner
public void setUsername(String theUsername)
theUsername
- The authorization usernameprotected void verifyNotUsed()
IllegalStateException
if called more than oncepublic static Charset getDefaultCharset()
Copyright © 2012–2017 University Health Network. All rights reserved.