Package org.frankframework.http
Class RestListener
java.lang.Object
org.frankframework.http.PushingListenerAdapter
org.frankframework.http.RestListener
- All Implemented Interfaces:
HasSpecialDefaultValues
,HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,IListener<Message>
,INamedObject
,IPushingListener<Message>
,IScopeProvider
,ServiceClient
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public class RestListener
extends PushingListenerAdapter
implements HasPhysicalDestination, HasSpecialDefaultValues
Listener that allows a
Receiver
to receive messages as a REST webservice.
Prepends the configured URI pattern with rest/
. When you are writing a new Frank config, you are recommended
to use an ApiListener
instead. You can find all serviced URI patterns
in the Frank!Console: main menu item Webservice, heading Available REST Services.
Note:
Servlets' multipart configuration expects a Content-Type of multipart/form-data
(see http://docs.oracle.com/javaee/6/api/javax/servlet/annotation/MultipartConfig.html).
So do not use other multipart content types like multipart/related
- Author:
- Niels Meijer, Gerrit van Brakel
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.frankframework.http.PushingListenerAdapter
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetView()
boolean
boolean
boolean
boolean
boolean
boolean
processRequest
(Message message, PipeLineSession session) Method to implement for processing a request.void
setAuthRoles
(String string) Comma separated list of authorization roles which are granted for this rest servicevoid
setAutomaticallyTransformToAndFromJson
(boolean b) Uses an JsonPipe to convert the json-input to xml, and xml-output to json.void
setConsumes
(RestListener.MediaTypes consumes) Mediatype (e.g.void
setContentTypeSessionKey
(String contentTypeSessionKey) Key of Session variable that determines requested content type, overridesproduces
void
setEtagSessionKey
(String etagSessionKey) Key of session variable to store etagvoid
setGenerateEtag
(boolean b) If set to true the ibis will automatically create an etagvoid
Method (e.g.void
setProduces
(RestListener.MediaTypes produces) Mediatype (e.g.void
setRestPath
(String restPath) Can be either/rest
or/rest-public
and must correspond with the available RestListenerServlet path(s).void
setRetrieveMultipart
(boolean b) Indicates whether the parts of a multipart entity should be retrieved and put in session keys.void
setUriPattern
(String uriPattern) Uri pattern to match, the {uri} part in https://mydomain.com/ibis4something/rest/{uri}, where mydomain.com and ibis4something refer to 'your ibis'.void
setValidateEtag
(boolean b) If set to true the ibis will automatically validate and process etagsvoid
setWriteSecLogMessage
(boolean b) void
setWriteToSecLog
(boolean b) void
start()
Prepares the listener for receiving messages.void
stop()
Close all resources used for listening.transformToJson
(Message message) transformToXml
(Message message) Methods inherited from class org.frankframework.http.PushingListenerAdapter
afterMessageProcessed, configure, extractMessage, getApplicationContext, getConfigurationClassLoader, getName, isApplicationFaultsAsExceptions, isRunning, setApplicationContext, setApplicationFaultsAsExceptions, setExceptionListener, setHandler, setName, setRunning, toString, wrapRawMessage
-
Constructor Details
-
RestListener
public RestListener()
-
-
Method Details
-
start
public void start()Description copied from interface:IListener
Prepares the listener for receiving messages.open()
is called once each time the listener is started.- Specified by:
start
in interfaceIListener<Message>
- Overrides:
start
in classPushingListenerAdapter
-
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped.- Specified by:
stop
in interfaceIListener<Message>
- Overrides:
stop
in classPushingListenerAdapter
-
processRequest
Description copied from interface:ServiceClient
Method to implement for processing a request. This will usually delegate to aIListener
implementation.
TODO: We may want to add the correlationId parameter back to this method, for cleaner calling and cleaner implementation.- Specified by:
processRequest
in interfaceServiceClient
- Overrides:
processRequest
in classPushingListenerAdapter
- Parameters:
message
-Message
to processsession
-PipeLineSession
of the request. If the request has a correlation ID, it should be put into this session.- Returns:
- Resulting
Message
. - Throws:
ListenerException
- Thrown if an exception occurs.
-
transformToJson
-
transformToXml
- Throws:
PipeRunException
-
getSpecialDefaultValue
public Object getSpecialDefaultValue(String attributeName, Object defaultValue, Map<String, String> attributes) - Specified by:
getSpecialDefaultValue
in interfaceHasSpecialDefaultValues
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
getRestUriPattern
-
setUriPattern
Uri pattern to match, the {uri} part in https://mydomain.com/ibis4something/rest/{uri}, where mydomain.com and ibis4something refer to 'your ibis'. -
setMethod
Method (e.g. GET or POST) to match -
setEtagSessionKey
Key of session variable to store etag -
setContentTypeSessionKey
Key of Session variable that determines requested content type, overridesproduces
-
setRestPath
Can be either/rest
or/rest-public
and must correspond with the available RestListenerServlet path(s). -
setAuthRoles
Comma separated list of authorization roles which are granted for this rest service- Default value
- IbisAdmin,IbisDataAdmin,IbisTester,IbisObserver,IbisWebService
-
setWriteToSecLog
public void setWriteToSecLog(boolean b) -
setWriteSecLogMessage
public void setWriteSecLogMessage(boolean b) -
setRetrieveMultipart
public void setRetrieveMultipart(boolean b) Indicates whether the parts of a multipart entity should be retrieved and put in session keys. This can only be done once!- Default value
- true
-
setConsumes
Mediatype (e.g. XML, JSON, TEXT) theRestServiceDispatcher
receives as input- Default value
- XML
-
setProduces
Mediatype (e.g. XML, JSON, TEXT) theRestServiceDispatcher
sends as output, if set to json the ibis will automatically try to convert the xml message- Default value
- XML
-
setValidateEtag
public void setValidateEtag(boolean b) If set to true the ibis will automatically validate and process etags- Default value
- false
-
setGenerateEtag
public void setGenerateEtag(boolean b) If set to true the ibis will automatically create an etag- Default value
- false
-
setAutomaticallyTransformToAndFromJson
public void setAutomaticallyTransformToAndFromJson(boolean b) Uses an JsonPipe to convert the json-input to xml, and xml-output to json. Use with caution, a properly configured Input/Output-wrapper can do much more and is more robust!- Default value
- true
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getUriPattern
-
getMethod
-
getEtagSessionKey
-
getContentTypeSessionKey
-
getRestPath
-
getView
-
getAuthRoles
-
isWriteToSecLog
public boolean isWriteToSecLog() -
isWriteSecLogMessage
public boolean isWriteSecLogMessage() -
isRetrieveMultipart
public boolean isRetrieveMultipart() -
isAutomaticallyTransformToAndFromJson
public boolean isAutomaticallyTransformToAndFromJson() -
getConsumes
-
getProduces
-
isValidateEtag
public boolean isValidateEtag() -
isGenerateEtag
public boolean isGenerateEtag()
-