adamsaghy commented on code in PR #4825:
URL: https://github.com/apache/fineract/pull/4825#discussion_r2259529962


##########
fineract-core/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java:
##########
@@ -597,4 +599,15 @@ public void checkForUnsupportedParameters(final Type 
typeOfMap, final String jso
         this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, 
requestDataParameters);
     }
 
+    public String getClientIp() {
+        ServletRequestAttributes attrs = (ServletRequestAttributes) 
RequestContextHolder.getRequestAttributes();
+        String clientIp = "";
+        if (attrs != null) {
+            Object ipAttr = attrs.getRequest().getAttribute("IP");
+            if (ipAttr != null) {
+                clientIp = ipAttr.toString();
+            }
+        }
+        return clientIp;

Review Comment:
   @Shelaslifter Fetching data from 
`RequestContextHolder.getRequestAttributes()` has nothing to do with 
JsonCommand class. Please Move this while logic into a utility class as 
@galovics recommended.
   
   We should not mix business logics together...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to