-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FR-#4.2] Add User, Group and Script controllers
User, group and script controllers created and documented with swagger. Requsted processed in Services. Hibernate repositories used to interract with postgresDB. Robot table added to createDB file. Gradle build files have minor fixes. Root project removed.
- Loading branch information
Showing
55 changed files
with
1,861 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
modules/harmonist/src/main/java/com/RPA/controller/ExceptionHandleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.RPA.controller; | ||
|
||
import com.RPA.exception.ConflictException; | ||
import com.RPA.exception.ForbiddenException; | ||
import com.RPA.exception.NotFoundException; | ||
import io.swagger.v3.oas.annotations.Hidden; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Hidden | ||
@RestControllerAdvice | ||
public class ExceptionHandleController { | ||
@ExceptionHandler(ConflictException.class) | ||
@ResponseStatus(HttpStatus.CONFLICT) | ||
public ResponseEntity handleConflictException(ConflictException ex) { | ||
return createBody(ex.getMessage(), HttpStatus.CONFLICT); | ||
} | ||
|
||
@ExceptionHandler(NotFoundException.class) | ||
@ResponseStatus(HttpStatus.NOT_FOUND) | ||
public ResponseEntity handleNotFoundException(NotFoundException ex) { | ||
return createBody(ex.getMessage(), HttpStatus.NOT_FOUND); | ||
} | ||
|
||
@ExceptionHandler(ForbiddenException.class) | ||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | ||
public ResponseEntity handleRuntimeException(ForbiddenException ex) { | ||
return createBody(ex.getMessage(), HttpStatus.FORBIDDEN); | ||
} | ||
|
||
@ExceptionHandler(RuntimeException.class) | ||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) | ||
public ResponseEntity handleRuntimeException(RuntimeException ex) { | ||
return createBody("Internal Server Error", HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
private ResponseEntity createBody(String error, HttpStatus status) { | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("timestamp", new Date().toString()); | ||
map.put("status", status.toString()); | ||
map.put("error", error); | ||
return new ResponseEntity(map, status); | ||
} | ||
} |
Oops, something went wrong.