Skip to content

Commit fc7f351

Browse files
authored
fix: build issue (#130)
1 parent 9fb367a commit fc7f351

2 files changed

Lines changed: 1 addition & 50 deletions

File tree

src/main/java/com/iemr/admin/controller/version/VersionController.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323

2424
package com.iemr.admin.controller.version;
2525

26-
import java.util.Map;
2726
import java.util.Map;
2827
import org.slf4j.Logger;
2928
import org.slf4j.LoggerFactory;
3029
import org.springframework.http.ResponseEntity;
3130
import org.springframework.web.bind.annotation.GetMapping;
32-
import org.springframework.http.ResponseEntity;
33-
import org.springframework.web.bind.annotation.GetMapping;
3431
import org.springframework.web.bind.annotation.RestController;
3532
import io.swagger.v3.oas.annotations.Operation;
3633
import java.io.IOException;
@@ -46,14 +43,7 @@ public class VersionController {
4643
private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
4744

4845
private static final String UNKNOWN_VALUE = "unknown";
49-
private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
5046

51-
private static final String UNKNOWN_VALUE = "unknown";
52-
53-
@Operation(summary = "Get version information")
54-
@GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
55-
public ResponseEntity<Map<String, String>> versionInformation() {
56-
Map<String, String> response = new LinkedHashMap<>();
5747
@Operation(summary = "Get version information")
5848
@GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
5949
public ResponseEntity<Map<String, String>> versionInformation() {
@@ -65,34 +55,17 @@ public ResponseEntity<Map<String, String>> versionInformation() {
6555
response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE));
6656
response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE));
6757
response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE));
68-
Properties gitProperties = loadGitProperties();
69-
response.put("buildTimestamp", gitProperties.getProperty("git.build.time", UNKNOWN_VALUE));
70-
response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE));
71-
response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE));
72-
response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE));
7358
} catch (Exception e) {
7459
logger.error("Failed to load version information", e);
7560
response.put("buildTimestamp", UNKNOWN_VALUE);
7661
response.put("version", UNKNOWN_VALUE);
7762
response.put("branch", UNKNOWN_VALUE);
7863
response.put("commitHash", UNKNOWN_VALUE);
79-
logger.error("Failed to load version information", e);
80-
response.put("buildTimestamp", UNKNOWN_VALUE);
81-
response.put("version", UNKNOWN_VALUE);
82-
response.put("branch", UNKNOWN_VALUE);
83-
response.put("commitHash", UNKNOWN_VALUE);
8464
}
8565
logger.info("version Controller End");
8666
return ResponseEntity.ok(response);
87-
return ResponseEntity.ok(response);
8867
}
8968

90-
private Properties loadGitProperties() throws IOException {
91-
Properties properties = new Properties();
92-
try (InputStream input = getClass().getClassLoader()
93-
.getResourceAsStream("git.properties")) {
94-
if (input != null) {
95-
properties.load(input);
9669
private Properties loadGitProperties() throws IOException {
9770
Properties properties = new Properties();
9871
try (InputStream input = getClass().getClassLoader()
@@ -102,6 +75,5 @@ private Properties loadGitProperties() throws IOException {
10275
}
10376
}
10477
return properties;
105-
return properties;
10678
}
10779
}

src/main/java/com/iemr/admin/utils/JwtUserIdValidationFilter.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ public class JwtUserIdValidationFilter implements Filter {
2222
private static final String HEALTH_ENDPOINT = "/health";
2323
private static final String VERSION_ENDPOINT = "/version";
2424

25-
private static final String HEALTH_ENDPOINT = "/health";
26-
private static final String VERSION_ENDPOINT = "/version";
27-
2825
private final JwtAuthenticationUtil jwtAuthenticationUtil;
2926
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
3027
private final String allowedOrigins;
@@ -52,17 +49,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
5249
return;
5350
}
5451

55-
String path = request.getRequestURI();
56-
String contextPath = request.getContextPath();
57-
58-
// FIRST: Check for health and version endpoints - skip ALL processing
59-
if (path.equals(HEALTH_ENDPOINT) || path.equals(VERSION_ENDPOINT) ||
60-
path.equals(contextPath + HEALTH_ENDPOINT) || path.equals(contextPath + VERSION_ENDPOINT)) {
61-
logger.info("Skipping JWT validation for monitoring endpoint: {}", path);
62-
filterChain.doFilter(servletRequest, servletResponse);
63-
return;
64-
}
65-
6652
String origin = request.getHeader("Origin");
6753
String method = request.getMethod();
6854
String uri = request.getRequestURI();
@@ -91,11 +77,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
9177
return;
9278
}
9379
}
94-
95-
// Determine request path/context for later checks
96-
String path = request.getRequestURI();
97-
String contextPath = request.getContextPath();
98-
80+
9981
// Set CORS headers and handle OPTIONS request only if origin is valid and allowed
10082
if (origin != null && isOriginAllowed(origin)) {
10183
addCorsHeaders(response, origin);
@@ -141,9 +123,6 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
141123
|| path.startsWith(contextPath + "/user/refreshToken")
142124
|| path.startsWith(contextPath + "/public")
143125
|| path.equals(contextPath + HEALTH_ENDPOINT)
144-
|| path.equals(contextPath + VERSION_ENDPOINT)) {
145-
|| path.startsWith(contextPath + "/public")
146-
|| path.equals(contextPath + HEALTH_ENDPOINT)
147126
|| path.equals(contextPath + VERSION_ENDPOINT)) {
148127
logger.info("Skipping filter for path: " + path);
149128
filterChain.doFilter(servletRequest, servletResponse);

0 commit comments

Comments
 (0)