stackroute / boeing-wave4-knowledgehub

0 stars 10 forks source link

Incorrect httpstatus #160

Open sushmitha007 opened 5 years ago

sushmitha007 commented 5 years ago
@PostMapping("/addKnowledge")
public ResponseEntity<String> addKnowledge(@RequestBody Knowledge knowledge) {
    ResponseEntity<String> responseEntity;
    try {
        knowledgeIndexerServiceImpl.saveKnowledgeToDb(knowledge);
        responseEntity = new ResponseEntity<>("Knowledge saved sucessfully", HttpStatus.OK);
    } catch (Exception e) {
        responseEntity = new ResponseEntity<>("Error while saving knowledge", HttpStatus.BAD_GATEWAY);
    }
    return responseEntity;
}

//Code used for testing the methods
@PostMapping("addRelationship/{name}/{paragraphId}/{intentLevel}/{confidenceScore}")
public ResponseEntity<String> addRelationship(@PathVariable("name") String name,
                                              @PathVariable("paragraphId")String paragraphId,
                                              @PathVariable("intentLevel") String intentLevel,
                                              @PathVariable("confidenceScore") double confidenceScore)
{
    ResponseEntity<String> responseEntity;
    try {
        knowledgeIndexerServiceImpl.addRelationship(name,paragraphId,intentLevel,confidenceScore);
        responseEntity = new ResponseEntity<>("Relationship saved sucessfully", HttpStatus.OK);
    } catch (Exception e) {
        responseEntity = new ResponseEntity<>("Error while saving relationship", HttpStatus.BAD_GATEWAY);
    }
    return responseEntity;
}

boeing-wave4-knowledgehub/knowledge-indexer/src/main/java/com/stackroute/controller/KnowledgeIndexerController.java