From 2378031cdc4f30ead287fb17104c273ef20d57d8 Mon Sep 17 00:00:00 2001 From: rdodiya Date: Sat, 30 May 2026 23:00:06 +0530 Subject: [PATCH] Resolve Runtime Errors and set default values in properties and update SecurityConfig --- .../admin/dashboard/service/DashboardServiceImpl.java | 5 +---- .../com/restroly/qrmenu/auth/controller/AuthController.java | 4 ++-- .../restroly/qrmenu/auth/controller/AuthControllerTest.java | 2 +- .../com/restroly/qrmenu/auth/service/GoogleAuthService.java | 2 +- .../java/com/restroly/qrmenu/config/SecurityConfig.java | 6 +++--- .../controller/DashboardNotificationController.java | 2 +- .../com/restroly/qrmenu/user/service/UserServiceImpl.java | 1 + RestroHub/src/main/resources/application-dev.properties | 6 +++--- .../restroly/qrmenu/auth/service/GoogleAuthServiceTest.java | 1 - 9 files changed, 13 insertions(+), 16 deletions(-) diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/admin/dashboard/service/DashboardServiceImpl.java b/RestroHub/src/main/java/com/restroly/qrmenu/admin/dashboard/service/DashboardServiceImpl.java index 08d08639..e036e32e 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/admin/dashboard/service/DashboardServiceImpl.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/admin/dashboard/service/DashboardServiceImpl.java @@ -2,14 +2,11 @@ import com.restroly.qrmenu.admin.dashboard.dto.DashboardStatDTO; -import com.restroly.qrmenu.branch.repository.BranchRepository; import com.restroly.qrmenu.common.enums.OrderStatus; import com.restroly.qrmenu.order.repository.OrderRepository; -import com.restroly.qrmenu.order.service.OrderNotificationService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import java.math.BigDecimal; import java.text.NumberFormat; @@ -35,7 +32,7 @@ public List getDashboardStats() { // Today's Revenue BigDecimal todayRevenue = orderRepository.getTodayRevenue(startOfDay, endOfDay); - NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); + @SuppressWarnings("deprecation") NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); String formattedRevenue = formatter.format(todayRevenue); // Live Orders (Active statuses) diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthController.java b/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthController.java index 4eaca40e..0f467cf4 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthController.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthController.java @@ -153,7 +153,7 @@ public ResponseEntity> login( description = "Invalid request - token missing or invalid", content = @Content( mediaType = "application/json", - schema = @Schema(implementation = ErrorResponse.class) + schema = @Schema(implementation = ApiErrorResponse.class) ) ), @io.swagger.v3.oas.annotations.responses.ApiResponse( @@ -161,7 +161,7 @@ public ResponseEntity> login( description = "Google token verification failed", content = @Content( mediaType = "application/json", - schema = @Schema(implementation = ErrorResponse.class) + schema = @Schema(implementation = ApiErrorResponse.class) ) ) }) diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthControllerTest.java b/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthControllerTest.java index 564c21a2..1e981aa0 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthControllerTest.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/auth/controller/AuthControllerTest.java @@ -5,7 +5,7 @@ //import com.restroly.qrmenu.auth.dto.LoginRequest; //import com.restroly.qrmenu.auth.dto.RefreshTokenRequest; //import com.restroly.qrmenu.auth.service.AuthService; -//import com.restroly.qrmenu.common.exception.BusinessException; +//import com.restroly.qrmenu.exception.BusinessException; //import org.junit.jupiter.api.BeforeEach; //import org.junit.jupiter.api.DisplayName; //import org.junit.jupiter.api.Test; diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/auth/service/GoogleAuthService.java b/RestroHub/src/main/java/com/restroly/qrmenu/auth/service/GoogleAuthService.java index c6c35588..18d17f2e 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/auth/service/GoogleAuthService.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/auth/service/GoogleAuthService.java @@ -4,7 +4,7 @@ import com.google.api.client.json.webtoken.JsonWebSignature; import com.restroly.qrmenu.auth.dto.AuthResponse; import com.restroly.qrmenu.auth.dto.GoogleAuthRequest; -import com.restroly.qrmenu.common.exception.BusinessException; +import com.restroly.qrmenu.exception.BusinessException; import com.restroly.qrmenu.security.JwtTokenProvider; import com.restroly.qrmenu.user.entity.Role; import com.restroly.qrmenu.user.entity.User; diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/config/SecurityConfig.java b/RestroHub/src/main/java/com/restroly/qrmenu/config/SecurityConfig.java index 87efac58..c5770f40 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/config/SecurityConfig.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/config/SecurityConfig.java @@ -63,9 +63,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .authorizeHttpRequests(auth -> auth .requestMatchers(PUBLIC_URLS).permitAll() .requestMatchers(HttpMethod.GET, PUBLIC_GET_URLS).permitAll() - .requestMatchers(HttpMethod.POST, "/secure/api/**").hasAnyRole("ADMIN", "RESTAURANT_OWNER") - .requestMatchers(HttpMethod.PUT, "/secure/api/**").hasAnyRole("ADMIN", "RESTAURANT_OWNER") - .requestMatchers(HttpMethod.DELETE, "/secure/api/**").hasAnyRole("ADMIN", "RESTAURANT_OWNER") + .requestMatchers(HttpMethod.POST, "/secure/api/**").hasAnyAuthority("ADMIN", "RESTAURANT_OWNER") + .requestMatchers(HttpMethod.PUT, "/secure/api/**").hasAnyAuthority("ADMIN", "RESTAURANT_OWNER") + .requestMatchers(HttpMethod.DELETE, "/secure/api/**").hasAnyAuthority("ADMIN", "RESTAURANT_OWNER") // All other requests require authentication .anyRequest().authenticated() ) diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/notifications/controller/DashboardNotificationController.java b/RestroHub/src/main/java/com/restroly/qrmenu/notifications/controller/DashboardNotificationController.java index be07664e..7ec5d0cd 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/notifications/controller/DashboardNotificationController.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/notifications/controller/DashboardNotificationController.java @@ -12,7 +12,7 @@ import com.restroly.qrmenu.branch.dto.BranchResponseDTO; import com.restroly.qrmenu.branch.service.BranchService; -import com.restroly.qrmenu.common.exception.ResourceNotFoundException; +import com.restroly.qrmenu.exception.ResourceNotFoundException; import com.restroly.qrmenu.order.service.OrderNotificationService; import lombok.RequiredArgsConstructor; diff --git a/RestroHub/src/main/java/com/restroly/qrmenu/user/service/UserServiceImpl.java b/RestroHub/src/main/java/com/restroly/qrmenu/user/service/UserServiceImpl.java index 612d4df7..14b9c45c 100644 --- a/RestroHub/src/main/java/com/restroly/qrmenu/user/service/UserServiceImpl.java +++ b/RestroHub/src/main/java/com/restroly/qrmenu/user/service/UserServiceImpl.java @@ -1,5 +1,6 @@ package com.restroly.qrmenu.user.service; +import com.restroly.qrmenu.exception.ResourceAlreadyExistsException; import com.restroly.qrmenu.user.dto.RoleResponse; import com.restroly.qrmenu.user.dto.UserRequest; import com.restroly.qrmenu.user.dto.UserResponse; diff --git a/RestroHub/src/main/resources/application-dev.properties b/RestroHub/src/main/resources/application-dev.properties index f17457c2..4fefd091 100644 --- a/RestroHub/src/main/resources/application-dev.properties +++ b/RestroHub/src/main/resources/application-dev.properties @@ -67,9 +67,9 @@ google.oauth.client-id=${GOOGLE_OAUTH_CLIENT_ID:YOUR_GOOGLE_OAUTH_CLIENT_ID_HERE # Cloudinary # =============================== # Set these environment variables locally. Blank values fail startup validation. -cloudinary.cloud-name=${CLOUDINARY_CLOUD_NAME:} -cloudinary.api-key=${CLOUDINARY_API_KEY:} -cloudinary.api-secret=${CLOUDINARY_API_SECRET:} +cloudinary.cloud-name=${CLOUDINARY_CLOUD_NAME:test} +cloudinary.api-key=${CLOUDINARY_API_KEY:test} +cloudinary.api-secret=${CLOUDINARY_API_SECRET:test} # =============================== # Service Requests Configuration diff --git a/RestroHub/src/test/java/com/restroly/qrmenu/auth/service/GoogleAuthServiceTest.java b/RestroHub/src/test/java/com/restroly/qrmenu/auth/service/GoogleAuthServiceTest.java index 547bfcaf..e4b15848 100644 --- a/RestroHub/src/test/java/com/restroly/qrmenu/auth/service/GoogleAuthServiceTest.java +++ b/RestroHub/src/test/java/com/restroly/qrmenu/auth/service/GoogleAuthServiceTest.java @@ -2,7 +2,6 @@ import com.restroly.qrmenu.auth.dto.AuthResponse; import com.restroly.qrmenu.auth.dto.GoogleAuthRequest; -import com.restroly.qrmenu.common.exception.BusinessException; import com.restroly.qrmenu.security.JwtTokenProvider; import com.restroly.qrmenu.user.entity.Role; import com.restroly.qrmenu.user.entity.User;