Usecase: Here, we will create a reusable integration for example say OIC_FILE_Handler which will do move and delete file from a specified directory of AWS S3 bucket using rest feature.
It will perform the following operations:
- Write file
- Delete file
- Move file (mixed option 1 and option2)
REST trigger Request JSON:
{
"base64FileRef":"",
"sourceFileName":"",
"sourceDirectory":"",
"moveFileFlag":"",
"targetDirectory":"",
"targetFileName":"",
"deleteSourceFileFlag";"",
"deleteDirectory":""
}
REST Response JSON:
{
"jobStatus":"SUCCEEDED",
"fileMoved":"Y",
"fileDeleted":"N",
"exceptionCode":"",
"exceptionReason":"",
"exceptionDetails":""
}
Implemetation logic steps:
- Create a AWS S3 rest connection
- Create a App driven orchestration pattern and configure rest to accept the base64 encoded file, source path, delete path, source and delete directories and different flags.
- Assign globals:
- varBasePathAndFile : Concat(deleteDirectory sourceFileName)
- varMovePathAndFile : concat(targetDirectory, targetFileName)
- varFileref: ""
- varMoveComplete : N
- varDeletecomplete: N
- varFileStatus : "error"
- varCounter : 0.0
- IF base64FileRef != empty, then decode base64 to file reference using decodebase64ToReference().
- If moveFileFlag = Y, call S3 rest service to place the file to the specified directory and map the decoded file ref to stream reference.
- Resource path: /{pathAndFileName}
- VERB: put
- Request payload as Binary - application/zip
- Also, put a retry logic to place the files to S3 3 times
- Take a scope
- While conditon: varFileStatus ="error" and varCounter <3.0
- If success, assign varFileStaus ="success"
- Under scope > default fault handler > increment counter +1
- Update that varMoveComplete = Y if it is success
- IF deleteSourceFileFlag = Y , Call S3 rest service nad configure below:
- Resource path: /{pathAndFileName}
- Verb: Delete
- Map the varBasePathandFileName
- If it is success, assign deleteComplete =Y
- Update the response of the rest - fileMoved, fileDeleted and jobStatus.
- Update the exception scope fault status from main scope fault handler
Screenshots:
No comments:
Post a Comment