Class ResponseEntityHelper
java.lang.Object
com.flowable.core.common.rest.response.ResponseEntityHelper
public class ResponseEntityHelper
extends java.lang.Object
Helper class for working with
ResponseEntity
.- Author:
- Filip Hrisafov
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Collection<org.springframework.http.MediaType>
autoInlineMediaTypes
-
Constructor Summary
Constructors Constructor Description ResponseEntityHelper(java.util.Collection<org.springframework.http.MediaType> autoInlineMediaTypes)
-
Method Summary
Modifier and Type Method Description org.springframework.http.ResponseEntity<byte[]>
asByteArrayResponseEntity(java.io.InputStream inputStream, java.lang.String mimeType, java.lang.String name, java.lang.Boolean download)
Create aResponseEntity
with abyte[]
body based on theinputStream
.protected java.lang.String
dispositionType(java.lang.Boolean download, org.springframework.http.MediaType mediaType)
-
Field Details
-
autoInlineMediaTypes
protected java.util.Collection<org.springframework.http.MediaType> autoInlineMediaTypes
-
-
Constructor Details
-
ResponseEntityHelper
public ResponseEntityHelper(java.util.Collection<org.springframework.http.MediaType> autoInlineMediaTypes)
-
-
Method Details
-
asByteArrayResponseEntity
public org.springframework.http.ResponseEntity<byte[]> asByteArrayResponseEntity(java.io.InputStream inputStream, java.lang.String mimeType, java.lang.String name, java.lang.Boolean download) throws java.io.IOExceptionCreate aResponseEntity
with abyte[]
body based on theinputStream
.When the
mimeType
is provided and is a knownMediaType
then it would be used as theContent-Type
header for theResponseEntity
. Otherwise,application/octet-stream
would be used.If the
name
is provided then aContent-Disposition
header would be added with that as a file name.The
download
flag is used to indicate whether theinputStream
should be displayed inside the Web page (inline
whendownload
isfalse
) or downloaded (attachment
whendownload
istrue
). In case it isnull
the value would be created based on themimeType
.NB: Callers of this method are responsible for appropriately closing the
inputStream
- Parameters:
inputStream
- The input stream that should be used as the body (the caller is responsible for closing it)mimeType
- the mime type for theContent-Type
headername
- the filename for theContent-Disposition
headerdownload
- flag indicating the type for theContent-Disposition
header- Returns:
- the
ResponseEntity
with a statusHttpStatus.OK
- Throws:
java.io.IOException
- in case of I/O errors
-
dispositionType
protected java.lang.String dispositionType(java.lang.Boolean download, org.springframework.http.MediaType mediaType)
-