public class MetadataStatusProvider extends java.lang.Object implements HttpStatusProvider
HttpStatusProvider
that can derive the status and text from AdaptrisMessage
metadata.
If the configured metadata key does not exist / non-numeric, then getDefaultStatus()
is
used to provide the Status.
In the adapter configuration file this class is aliased as http-metadata-status which is the preferred alternative to the fully qualified classname when building your configuration.
HttpStatusProvider.HttpStatus, HttpStatusProvider.Status
Constructor and Description |
---|
MetadataStatusProvider() |
MetadataStatusProvider(java.lang.String codeKey) |
MetadataStatusProvider(java.lang.String codeKey,
java.lang.String textKey) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCodeKey() |
HttpStatusProvider.HttpStatus |
getDefaultStatus() |
HttpStatusProvider.Status |
getStatus(AdaptrisMessage msg)
Get the method that should be used with the HTTP request.
|
java.lang.String |
getTextKey() |
void |
setCodeKey(java.lang.String key)
Set the metadata where the status code will be taken.
|
void |
setDefaultStatus(HttpStatusProvider.HttpStatus status)
Set the default status in the event that it cannot be derived from metadata.
|
void |
setTextKey(java.lang.String k)
Set the metadata where the status text will be taken.
|
public MetadataStatusProvider()
public MetadataStatusProvider(java.lang.String codeKey)
public MetadataStatusProvider(java.lang.String codeKey, java.lang.String textKey)
public HttpStatusProvider.Status getStatus(AdaptrisMessage msg)
HttpStatusProvider
getStatus
in interface HttpStatusProvider
msg
- the AdaptrisMessage
if required to derive the method.HttpStatusProvider.Status
.public java.lang.String getCodeKey()
public void setCodeKey(java.lang.String key)
key
- the metadata key.public java.lang.String getTextKey()
public void setTextKey(java.lang.String k)
Note that for StandardResponseProducer
any values associated with the key will be ignored
as that will use HttpServletResponse.setStatus(int)
method only. This is only included for
completeness.
k
- the optional key for the status textpublic HttpStatusProvider.HttpStatus getDefaultStatus()
public void setDefaultStatus(HttpStatusProvider.HttpStatus status)
status
- the default status, which defaults to HttpStatusProvider.HttpStatus.INTERNAL_ERROR_500
.