public class EntityBodyHandler extends Object
Constructor and Description |
---|
EntityBodyHandler() |
Modifier and Type | Method and Description |
---|---|
static void |
addMessageDataSource(BMap<String,BValue> entityObj,
BValue messageDataSource)
Associate a given message data source with a given entity.
|
static boolean |
checkEntityBodyAvailability(BMap<String,BValue> entityObj)
Check whether the entity body is present.
|
static BValueArray |
constructBlobDataSource(BMap<String,BValue> entityObj)
Construct BlobDataSource from the underneath byte channel which is associated with the entity object.
|
static BValueArray |
constructBlobDataSource(InputStream inputStream)
Construct BlobDataSource from the underneath byte channel which is associated with the entity object.
|
static BRefType<?> |
constructJsonDataSource(BMap<String,BValue> entityObj)
Construct JsonDataSource from the underneath byte channel which is associated with the entity object.
|
static BRefType<?> |
constructJsonDataSource(BMap<String,BValue> entity,
InputStream inputStream)
Construct JsonDataSource from the given input stream.
|
static BString |
constructStringDataSource(BMap<String,BValue> entityObj)
Construct StringDataSource from the underneath byte channel which is associated with the entity object.
|
static BString |
constructStringDataSource(BMap<String,BValue> entity,
InputStream inputStream)
Construct StringDataSource from the given input stream.
|
static BXML |
constructXmlDataSource(BMap<String,BValue> entityObj)
Construct XML data source from the underneath byte channel which is associated with the entity object.
|
static BXML |
constructXmlDataSource(BMap<String,BValue> entityObj,
InputStream inputStream)
Construct XML data source from the given input stream.
|
static void |
decodeEntityBody(Context context,
BMap<String,BValue> entityObj,
Channel byteChannel)
Decode a given entity body to get a set of child parts and set them to parent entity's multipart data field.
|
static BValueArray |
getBodyPartArray(BMap<String,BValue> entityObj)
Extract body parts from a given entity.
|
static Channel |
getByteChannel(BMap<String,BValue> entityObj) |
static TempFileIOChannel |
getByteChannelForTempFile(String temporaryFilePath)
Given a temp file location, create a byte channel.
|
static EntityWrapper |
getEntityWrapper(String textPayload)
Get a byte channel for a given text data.
|
static BValue |
getMessageDataSource(BMap<String,BValue> entityObj)
Get the message data source associated with a given entity.
|
static boolean |
isStreamingRequired(BMap<String,BValue> entity)
Check whether the streaming is required as data source should be constructed using byte channel if entity
contains body parts or byte channel.
|
static void |
populateBodyContent(BMap<String,BValue> bodyPart,
org.jvnet.mimepull.MIMEPart mimePart)
Populate ballerina body parts with actual body content.
|
static void |
writeByteChannelToOutputStream(BMap<String,BValue> entityObj,
OutputStream messageOutputStream)
Write byte channel stream directly into outputstream without converting it to a data source.
|
public static EntityWrapper getEntityWrapper(String textPayload)
textPayload
- Text data that needs to be wrapped in a byte channelpublic static TempFileIOChannel getByteChannelForTempFile(String temporaryFilePath)
temporaryFilePath
- Temporary file pathpublic static BValue getMessageDataSource(BMap<String,BValue> entityObj)
entityObj
- Represent a ballerina entitypublic static void addMessageDataSource(BMap<String,BValue> entityObj, BValue messageDataSource)
entityObj
- Represent the ballerina entitymessageDataSource
- which represent the entity body in memorypublic static BValueArray constructBlobDataSource(BMap<String,BValue> entityObj) throws IOException
entityObj
- Represent an entity objectIOException
- In case an error occurred while creating blob data sourcepublic static BValueArray constructBlobDataSource(InputStream inputStream)
inputStream
- Represent the input streampublic static BRefType<?> constructJsonDataSource(BMap<String,BValue> entityObj)
entityObj
- Represent an entity objectpublic static BRefType<?> constructJsonDataSource(BMap<String,BValue> entity, InputStream inputStream)
entity
- Represent an entity objectinputStream
- Represent the input streampublic static BXML constructXmlDataSource(BMap<String,BValue> entityObj)
entityObj
- Represent an entity objectpublic static BXML constructXmlDataSource(BMap<String,BValue> entityObj, InputStream inputStream)
entityObj
- Represent an entity objectinputStream
- Represent the input streampublic static BString constructStringDataSource(BMap<String,BValue> entityObj)
entityObj
- Represent an entity objectpublic static BString constructStringDataSource(BMap<String,BValue> entity, InputStream inputStream)
entity
- Represent an entity objectinputStream
- Represent the input streampublic static boolean checkEntityBodyAvailability(BMap<String,BValue> entityObj)
entityObj
- Represent an 'Entity'public static boolean isStreamingRequired(BMap<String,BValue> entity)
entity
- Represent an 'Entity'public static void populateBodyContent(BMap<String,BValue> bodyPart, org.jvnet.mimepull.MIMEPart mimePart)
bodyPart
- Represent ballerina body partmimePart
- Represent decoded mime partpublic static void writeByteChannelToOutputStream(BMap<String,BValue> entityObj, OutputStream messageOutputStream) throws IOException
entityObj
- Represent a ballerina entitymessageOutputStream
- Represent the outputstream that the message should be written toIOException
- When an error occurs while writing inputstream to outputstreampublic static void decodeEntityBody(Context context, BMap<String,BValue> entityObj, Channel byteChannel)
context
- Represent the ballerina contextentityObj
- Parent entity that the nested parts residebyteChannel
- Represent ballerina specific byte channelpublic static BValueArray getBodyPartArray(BMap<String,BValue> entityObj)
entityObj
- Represent a ballerina entityCopyright © 2019 WSO2. All rights reserved.