From a25c7c6565991fc6f1a9b95d8ab944efee576aa7 Mon Sep 17 00:00:00 2001 From: vanitha1822 Date: Fri, 24 Apr 2026 15:11:07 +0530 Subject: [PATCH] fix: build issue --- .../controller/version/VersionController.java | 28 ------------------- .../utils/JwtUserIdValidationFilter.java | 23 +-------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/main/java/com/iemr/admin/controller/version/VersionController.java b/src/main/java/com/iemr/admin/controller/version/VersionController.java index 1da6fb1..dd46670 100644 --- a/src/main/java/com/iemr/admin/controller/version/VersionController.java +++ b/src/main/java/com/iemr/admin/controller/version/VersionController.java @@ -23,14 +23,11 @@ package com.iemr.admin.controller.version; -import java.util.Map; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import io.swagger.v3.oas.annotations.Operation; import java.io.IOException; @@ -46,14 +43,7 @@ public class VersionController { private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); private static final String UNKNOWN_VALUE = "unknown"; - private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - private static final String UNKNOWN_VALUE = "unknown"; - - @Operation(summary = "Get version information") - @GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> versionInformation() { - Map response = new LinkedHashMap<>(); @Operation(summary = "Get version information") @GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> versionInformation() { @@ -65,34 +55,17 @@ public ResponseEntity> versionInformation() { response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE)); response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE)); response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE)); - Properties gitProperties = loadGitProperties(); - response.put("buildTimestamp", gitProperties.getProperty("git.build.time", UNKNOWN_VALUE)); - response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE)); - response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE)); - response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE)); } catch (Exception e) { logger.error("Failed to load version information", e); response.put("buildTimestamp", UNKNOWN_VALUE); response.put("version", UNKNOWN_VALUE); response.put("branch", UNKNOWN_VALUE); response.put("commitHash", UNKNOWN_VALUE); - logger.error("Failed to load version information", e); - response.put("buildTimestamp", UNKNOWN_VALUE); - response.put("version", UNKNOWN_VALUE); - response.put("branch", UNKNOWN_VALUE); - response.put("commitHash", UNKNOWN_VALUE); } logger.info("version Controller End"); return ResponseEntity.ok(response); - return ResponseEntity.ok(response); } - private Properties loadGitProperties() throws IOException { - Properties properties = new Properties(); - try (InputStream input = getClass().getClassLoader() - .getResourceAsStream("git.properties")) { - if (input != null) { - properties.load(input); private Properties loadGitProperties() throws IOException { Properties properties = new Properties(); try (InputStream input = getClass().getClassLoader() @@ -102,6 +75,5 @@ private Properties loadGitProperties() throws IOException { } } return properties; - return properties; } } diff --git a/src/main/java/com/iemr/admin/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/admin/utils/JwtUserIdValidationFilter.java index 889e542..fc94da1 100644 --- a/src/main/java/com/iemr/admin/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/admin/utils/JwtUserIdValidationFilter.java @@ -22,9 +22,6 @@ public class JwtUserIdValidationFilter implements Filter { private static final String HEALTH_ENDPOINT = "/health"; private static final String VERSION_ENDPOINT = "/version"; - private static final String HEALTH_ENDPOINT = "/health"; - private static final String VERSION_ENDPOINT = "/version"; - private final JwtAuthenticationUtil jwtAuthenticationUtil; private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); private final String allowedOrigins; @@ -52,17 +49,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo return; } - String path = request.getRequestURI(); - String contextPath = request.getContextPath(); - - // FIRST: Check for health and version endpoints - skip ALL processing - if (path.equals(HEALTH_ENDPOINT) || path.equals(VERSION_ENDPOINT) || - path.equals(contextPath + HEALTH_ENDPOINT) || path.equals(contextPath + VERSION_ENDPOINT)) { - logger.info("Skipping JWT validation for monitoring endpoint: {}", path); - filterChain.doFilter(servletRequest, servletResponse); - return; - } - String origin = request.getHeader("Origin"); String method = request.getMethod(); String uri = request.getRequestURI(); @@ -91,11 +77,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo return; } } - - // Determine request path/context for later checks - String path = request.getRequestURI(); - String contextPath = request.getContextPath(); - + // Set CORS headers and handle OPTIONS request only if origin is valid and allowed if (origin != null && isOriginAllowed(origin)) { addCorsHeaders(response, origin); @@ -141,9 +123,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo || path.startsWith(contextPath + "/user/refreshToken") || path.startsWith(contextPath + "/public") || path.equals(contextPath + HEALTH_ENDPOINT) - || path.equals(contextPath + VERSION_ENDPOINT)) { - || path.startsWith(contextPath + "/public") - || path.equals(contextPath + HEALTH_ENDPOINT) || path.equals(contextPath + VERSION_ENDPOINT)) { logger.info("Skipping filter for path: " + path); filterChain.doFilter(servletRequest, servletResponse);