Skip to content

Commit

Permalink
fixes added
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-b-7 committed Feb 4, 2021
1 parent c97be6b commit e85661b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class OpsmxVisibilityController {
@Autowired
OpsmxVisibilityService opsmxVisibilityService

Gson gson = new Gson()

@ApiOperation(value = "Endpoint for visibility rest services")
@RequestMapping(value = "/v1/approvalGates/{id}/trigger", method = RequestMethod.POST)
@ResponseBody Object triggerV1ApprovalGate(@PathVariable("id") Integer id,
Expand Down Expand Up @@ -94,12 +96,14 @@ class OpsmxVisibilityController {

Response response = opsmxVisibilityService.triggerV2ApprovalGate(id, data)
InputStream inputStream = null

try {
HttpHeaders headers = new HttpHeaders()
headers.add("Location", response.getHeaders().stream().filter({ header -> header.getName().trim().equalsIgnoreCase("Location") }).collect(Collectors.toList()).get(0).value)
inputStream = response.getBody().in()
String responseBody = new String(IOUtils.toByteArray(inputStream))
return new ResponseEntity(responseBody, headers, HttpStatus.valueOf(response.getStatus()))
ApprovalGateTriggerResponseModel approvalGateTriggerResponseModel = gson.fromJson(responseBody, ApprovalGateTriggerResponseModel.class)
return new ResponseEntity(approvalGateTriggerResponseModel, headers, HttpStatus.valueOf(response.getStatus()))

} finally{
if (inputStream!=null){
Expand Down

0 comments on commit e85661b

Please sign in to comment.