-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new fields in services' database schema
- Loading branch information
1 parent
50bb4ae
commit 866a464
Showing
24 changed files
with
237 additions
and
21 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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/smartclide/dbapi/config/MongoValidationConfig.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,14 @@ | ||
package com.smartclide.dbapi.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener; | ||
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; | ||
|
||
@Configuration | ||
public class MongoValidationConfig { | ||
@Bean | ||
public ValidatingMongoEventListener validatingMongoEventListener(LocalValidatorFactoryBean localValidatorFactoryBean) { | ||
return new ValidatingMongoEventListener(localValidatorFactoryBean); | ||
} | ||
} |
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
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/smartclide/dbapi/exception/AppExceptionHandler.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,24 @@ | ||
package com.smartclide.dbapi.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@RestControllerAdvice | ||
public class AppExceptionHandler { | ||
|
||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public Map<String, String> handleInvalidArgs(MethodArgumentNotValidException exception) { | ||
Map<String, String> errorMap = new HashMap<>(); | ||
exception.getBindingResult().getFieldErrors().forEach(fieldError -> { | ||
errorMap.put(fieldError.getField(), fieldError.getDefaultMessage()); | ||
}); | ||
return errorMap; | ||
} | ||
} |
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,32 @@ | ||
//package com.smartclide.dbapi.exception; | ||
// | ||
//public class Error { | ||
// | ||
// private String message; | ||
// private int status; | ||
// private Long timestamp; | ||
// | ||
// public String getMessage() { | ||
// return message; | ||
// } | ||
// | ||
// public void setMessage(String message) { | ||
// this.message = message; | ||
// } | ||
// | ||
// public int getStatus() { | ||
// return status; | ||
// } | ||
// | ||
// public void setStatus(int status) { | ||
// this.status = status; | ||
// } | ||
// | ||
// public Long getTimestamp() { | ||
// return timestamp; | ||
// } | ||
// | ||
// public void setTimestamp(Long timestamp) { | ||
// this.timestamp = timestamp; | ||
// } | ||
//} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/smartclide/dbapi/exception/GlobalExceptionHandlerController.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,35 @@ | ||
//package com.smartclide.dbapi.exception; | ||
// | ||
//import org.springframework.http.HttpStatus; | ||
//import org.springframework.http.ResponseEntity; | ||
//import org.springframework.web.bind.MethodArgumentNotValidException; | ||
//import org.springframework.web.bind.annotation.ControllerAdvice; | ||
//import org.springframework.web.bind.annotation.ExceptionHandler; | ||
// | ||
//import javax.servlet.http.HttpServletRequest; | ||
//import java.util.Date; | ||
// | ||
//@ControllerAdvice | ||
//public class GlobalExceptionHandlerController { | ||
// | ||
// @ExceptionHandler(ResourceNotFoundException.class) | ||
// public ResponseEntity<Object> resourceNotFound(ResourceNotFoundException ex, | ||
// HttpServletRequest request) { | ||
// Error error = new Error(); | ||
// error.setMessage(ex.getMessage()); | ||
// error.setTimestamp(new Date().getTime()); | ||
// error.setStatus(HttpStatus.NOT_FOUND.value()); | ||
// return new ResponseEntity<>(error, null, HttpStatus.NOT_FOUND); | ||
// } | ||
// | ||
// @ExceptionHandler(MethodArgumentNotValidException.class) | ||
// public ResponseEntity<Object> badRequest(MethodArgumentNotValidException ex, | ||
// HttpServletRequest request) { | ||
// Error error = new Error(); | ||
// //error.setMessage(ex.getMessage()); | ||
// error.setMessage(ex.get); | ||
// error.setTimestamp(new Date().getTime()); | ||
// error.setStatus(HttpStatus.BAD_REQUEST.value()); | ||
// return new ResponseEntity<>(error, null, HttpStatus.BAD_REQUEST); | ||
// } | ||
//} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/smartclide/dbapi/exception/ResourceNotFoundException.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,10 @@ | ||
//package com.smartclide.dbapi.exception; | ||
// | ||
//public class ResourceNotFoundException extends RuntimeException { | ||
// | ||
// private static final long serialVersionUID = 1L; | ||
// | ||
// public ResourceNotFoundException(String message) { | ||
// super(message); | ||
// } | ||
//} |
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
Oops, something went wrong.