-
Notifications
You must be signed in to change notification settings - Fork 0
Omar/3 endpoints #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c26372d
Add endpoints to get orders by user ID, cancel orders, and update ord…
oaly2 da784fc
Fix linter issue
oaly2 5d20343
Resolve Comments
oaly2 8cc4b16
Adjusted lint checks
oaly2 a5423a9
Added Global Exception Handler and Endpoint to Check out an order
oaly2 71d8612
Create docker-compose.yml
oaly2 ae077b0
Add DockerFile
oaly2 5e4bb96
Removed Checkout endpoint and Adjusted OrderStatus enum
oaly2 7a36737
Merge branch 'dev' into Omar/3-endpoints
oaly2 306e5a9
Merge branch 'Crud-Operations' into Omar/3-endpoints
oaly2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| FROM openjdk:25-ea-4-jdk-oraclelinux9 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY target/order-0.0.1-SNAPSHOT.jar /app/order-0.0.1-SNAPSHOT.jar | ||
|
|
||
| ENTRYPOINT [ "java", "-jar", "/app/order-0.0.1-SNAPSHOT.jar" ] |
This file contains hidden or 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,44 @@ | ||
| services: | ||
| backend: | ||
| image: openjdk:25-ea-4-jdk-oraclelinux9 | ||
| container_name: order | ||
| ports: | ||
| - "8080:8080" | ||
| depends_on: | ||
| - order_db | ||
| environment: | ||
| - SPRING_DATASOURCE_URL=jdbc:postgresql://order_db:5432/orderDB | ||
| volumes: | ||
| - ./target:/app | ||
| - ./logs:/logs | ||
| command: [ "java", "-jar", "/app/order-0.0.1-SNAPSHOT.jar" ] | ||
|
|
||
| order_db: | ||
| image: postgres:14.17 | ||
| container_name: order_db | ||
| environment: | ||
| POSTGRES_PASSWORD: 1234 | ||
| POSTGRES_USER: postgres | ||
| POSTGRES_DB: orderDB | ||
| ports: | ||
| - "5432:5432" | ||
|
|
||
| loki: | ||
| image: grafana/loki:3.5.0 | ||
| container_name: loki | ||
| ports: | ||
| - "3100:3100" | ||
| command: -config.file=/etc/loki/local-config.yaml | ||
|
|
||
| grafana: | ||
| image: grafana/grafana:10.4.1 | ||
| container_name: grafana | ||
| ports: | ||
| - "3000:3000" | ||
| depends_on: | ||
| - loki | ||
| environment: | ||
| - GF_SECURITY_ADMIN_USER=admin | ||
| - GF_SECURITY_ADMIN_PASSWORD=admin | ||
| volumes: | ||
| - grafana_data:/var/lib/grafana |
This file contains hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/podzilla/order/exception/ErrorResponse.java
This file contains hidden or 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,19 @@ | ||
| package com.podzilla.order.exception; | ||
|
|
||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Getter | ||
| public class ErrorResponse { | ||
| private final String message; | ||
| private final HttpStatus status; | ||
| private final LocalDateTime timestamp; | ||
|
|
||
| public ErrorResponse(final String message, final HttpStatus status) { | ||
| this.message = message; | ||
| this.status = status; | ||
| this.timestamp = LocalDateTime.now(); | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
src/main/java/com/podzilla/order/exception/GlobalExceptionHandler.java
This file contains hidden or 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,62 @@ | ||
| package com.podzilla.order.exception; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.AccessDeniedException; | ||
| import org.springframework.security.core.AuthenticationException; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
| import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | ||
|
|
||
| @RestControllerAdvice | ||
| public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { | ||
|
|
||
|
|
||
| @ExceptionHandler(AccessDeniedException.class) | ||
| public ResponseEntity<ErrorResponse> handleAccessDeniedException( | ||
| final AccessDeniedException exception) { | ||
| return ResponseEntity.status(HttpStatus.FORBIDDEN) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.FORBIDDEN)); | ||
| } | ||
|
|
||
| @ExceptionHandler(AuthenticationException.class) | ||
| public ResponseEntity<ErrorResponse> handleAuthenticationException( | ||
| final AuthenticationException exception) { | ||
| return ResponseEntity.status(HttpStatus.UNAUTHORIZED) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.UNAUTHORIZED)); | ||
| } | ||
|
|
||
| @ExceptionHandler(NotFoundException.class) | ||
| public ResponseEntity<ErrorResponse> handleNotFoundException( | ||
| final NotFoundException exception) { | ||
| return ResponseEntity.status(HttpStatus.NOT_FOUND) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.NOT_FOUND)); | ||
| } | ||
|
|
||
| @ExceptionHandler(ValidationException.class) | ||
| public ResponseEntity<ErrorResponse> handleValidationException( | ||
| final ValidationException exception) { | ||
| return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.BAD_REQUEST)); | ||
| } | ||
|
|
||
| @ExceptionHandler(InvalidActionException.class) | ||
| public ResponseEntity<ErrorResponse> handleInvalidActionException( | ||
| final InvalidActionException exception) { | ||
| return ResponseEntity.status(HttpStatus.BAD_REQUEST) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.BAD_REQUEST)); | ||
| } | ||
|
|
||
| @ExceptionHandler(Exception.class) | ||
| public ResponseEntity<ErrorResponse> handleException( | ||
| final Exception exception) { | ||
| return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) | ||
| .body(new ErrorResponse(exception.getMessage(), | ||
| HttpStatus.INTERNAL_SERVER_ERROR)); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/podzilla/order/exception/InvalidActionException.java
This file contains hidden or 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,7 @@ | ||
| package com.podzilla.order.exception; | ||
|
|
||
| public class InvalidActionException extends RuntimeException { | ||
| public InvalidActionException(final String message) { | ||
| super("Invalid action: " + message); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/podzilla/order/exception/NotFoundException.java
This file contains hidden or 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,7 @@ | ||
| package com.podzilla.order.exception; | ||
|
|
||
| public class NotFoundException extends RuntimeException { | ||
| public NotFoundException(final String message) { | ||
| super("Not Found: " + message); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/podzilla/order/exception/ValidationException.java
This file contains hidden or 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,7 @@ | ||
| package com.podzilla.order.exception; | ||
|
|
||
| public class ValidationException extends RuntimeException { | ||
| public ValidationException(final String message) { | ||
| super("Validation error: " + message); | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| package com.podzilla.order.model; | ||
|
|
||
| public enum OrderStatus { | ||
| PENDING, | ||
| CONFIRMED, | ||
| PLACED, | ||
| CANCELLED, | ||
| SHIPPED, | ||
| DELIVERED, | ||
| CANCELLED | ||
| FAILED | ||
| } | ||
|
|
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.