public class EntityBodyHandler extends Object
| Constructor and Description |
|---|
EntityBodyHandler() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addMessageDataSource(BStruct entityStruct,
MessageDataSource messageDataSource)
Associate a given message data source with a given entity.
|
static boolean |
checkEntityBodyAvailability(BStruct entityStruct)
Check whether the entity body is present.
|
static BlobDataSource |
constructBlobDataSource(BStruct entityStruct)
Construct BlobDataSource from the underneath byte channel which is associated with the entity struct.
|
static BJSON |
constructJsonDataSource(BStruct entityStruct)
Construct JsonDataSource from the underneath byte channel which is associated with the entity struct.
|
static StringDataSource |
constructStringDataSource(BStruct entityStruct)
Construct StringDataSource from the underneath byte channel which is associated with the entity struct.
|
static BXML |
constructXmlDataSource(BStruct entityStruct)
Construct XMl data source from the underneath byte channel which is associated with the entity struct.
|
static BStruct |
createNewEntity(Context context,
BStruct httpMessageStruct)
Set new entity to in/out request/response struct.
|
static void |
decodeEntityBody(Context context,
BStruct entityStruct,
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 BRefValueArray |
getBodyPartArray(BStruct entityStruct)
Extract body parts from a given entity.
|
static Channel |
getByteChannel(BStruct entityStruct) |
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 MessageDataSource |
getMessageDataSource(BStruct entityStruct)
Get the message data source associated with a given entity.
|
static void |
populateBodyContent(BStruct bodyPart,
org.jvnet.mimepull.MIMEPart mimePart)
Populate ballerina body parts with actual body content.
|
static void |
setDiscreteMediaTypeBodyContent(BStruct entityStruct,
InputStream inputStream,
int numberOfBytesRead)
Handle discrete media type content.
|
static void |
writeByteChannelToOutputStream(BStruct entityStruct,
OutputStream messageOutputStream)
Write byte channel stream directly into outputstream without converting it to a data source.
|
public static BStruct createNewEntity(Context context, BStruct httpMessageStruct)
context - ballerina context.httpMessageStruct - request/response struct.public static void setDiscreteMediaTypeBodyContent(BStruct entityStruct, InputStream inputStream, int numberOfBytesRead)
entityStruct - Represent an 'Entity'inputStream - Represent input stream coming from the request/responsenumberOfBytesRead - Number of bytes readpublic 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 MessageDataSource getMessageDataSource(BStruct entityStruct)
entityStruct - Represent a ballerina entitypublic static void addMessageDataSource(BStruct entityStruct, MessageDataSource messageDataSource)
entityStruct - Represent the ballerina entitymessageDataSource - which represent the entity body in memorypublic static BlobDataSource constructBlobDataSource(BStruct entityStruct) throws IOException
entityStruct - Represent an entity structIOException - In case an error occurred while creating blob data sourcepublic static BJSON constructJsonDataSource(BStruct entityStruct)
entityStruct - Represent an entity structpublic static BXML constructXmlDataSource(BStruct entityStruct)
entityStruct - Represent an entity structpublic static StringDataSource constructStringDataSource(BStruct entityStruct)
entityStruct - Represent an entity structpublic static boolean checkEntityBodyAvailability(BStruct entityStruct)
entityStruct - Represent an 'Entity'public static void populateBodyContent(BStruct bodyPart, org.jvnet.mimepull.MIMEPart mimePart)
bodyPart - Represent ballerina body partmimePart - Represent decoded mime partpublic static void writeByteChannelToOutputStream(BStruct entityStruct, OutputStream messageOutputStream) throws IOException
entityStruct - 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, BStruct entityStruct, Channel byteChannel)
context - Represent the ballerina contextentityStruct - Parent entity that the nested parts residebyteChannel - Represent ballerina specific byte channelpublic static BRefValueArray getBodyPartArray(BStruct entityStruct)
entityStruct - Represent a ballerina entityCopyright © 2018 WSO2. All rights reserved.