Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Autowired
- private ErrorUpdateService errorUpdateService;
- @RequestMapping(value="/api/UpdateError", method=RequestMethod.POST)
- @ResponseBody
- public String updateError(@RequestBody Error error){
- try{
- Error retrievedError=errorUpdateService.findErrorByName((error.getName()));
- if(!retrievedError.getName().equals("NVE")){
- System.out.println("Here is error: "+retrievedError.toString());
- errorUpdateService.updateError(retrievedError);
- return retrievedError.getName() + " has been updated";
- }
- }catch(NullPointerException e){
- errorUpdateService.updateError(error);
- return "Error Name Does not Exist. Saving " +error.getName() ;
- }
- return "Failed Method";
- }
- @Autowired
- private ErrorRepository errorRepository;
- @Override
- public void updateError(Error error) {
- System.out.println("Attempting to save a error: "+error.toString());
- errorRepository.save(error);
- }
- @Override
- public Error findErrorByName(String errName){
- try{
- Error error=errorRepository.findByErrName(errName);
- return error;
- }catch(NullPointerException e){
- return new Error("NVE");
- }
- }
- public interface ErrorRepository extends JpaRepository<Error, Long>{
- Error findByErrName(String errName);
- }
- Hibernate: select error0_.id as id1_0_, error0_.documentationurl as document2_0_, error0_.err_name as err_name3_0_, error0_.error_id as error_id4_0_, error0_.has_documentation as has_docu5_0_, error0_.last_incident_time as last_inc6_0_, error0_.throttle_minutes as throttle7_0_, error0_.throttle_threshold as throttle8_0_ from error error0_ where error0_.err_name=?
- Here is error: Error [id=6, errorId=0, hasDocumentation=false, errName=Error0001, documentationURL=null, throttleThreshold=0, throttleMinutes=0, lastIncidentTime=null]
- Attempting to save a error: Error [id=6, errorId=0, hasDocumentation=false, errName=Error0001, documentationURL=null, throttleThreshold=0, throttleMinutes=0, lastIncidentTime=null]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement