Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
81fc4b0
sameSite strict for production change (#172)
indraniBan Mar 17, 2025
5ccc278
Feature/grievence/changes (#175)
ravishanigarapu Mar 20, 2025
73ee64c
Fix .java-version, add plugins for successful build (#176)
drtechie Mar 21, 2025
21593ef
Scheduler changes
ravishanigarapu Mar 24, 2025
b7eeeb9
Scheduler changes
ravishanigarapu Mar 24, 2025
482f441
AMM-1301 : ActionTakenBy and comments saving as null in working (#177)
ravishanigarapu Mar 25, 2025
7d7340b
GrieVANCE WORKLIST Changes
ravishanigarapu Mar 25, 2025
0563e98
Grievance changes
ravishanigarapu Mar 29, 2025
75e5f18
Generate a JWT token in the response body for mobile users instead of…
kevalkanp1011 Mar 31, 2025
f33b2ae
unnecessary code removed
kevalkanp1011 Mar 31, 2025
f864587
Update src/main/java/com/iemr/common/controller/users/IEMRAdminContro…
kevalkanp1011 Mar 31, 2025
dbcc0ab
Update src/main/java/com/iemr/common/controller/users/IEMRAdminContro…
kevalkanp1011 Mar 31, 2025
067bf71
review changes: added doc for refresh token access and added jwt.acce…
kevalkanp1011 Mar 31, 2025
a4236c2
Merge remote-tracking branch 'origin/develop' into develop
kevalkanp1011 Mar 31, 2025
adba41e
Update src/main/java/com/iemr/common/controller/users/IEMRAdminContro…
kevalkanp1011 Apr 1, 2025
5f382bf
review changes
kevalkanp1011 Apr 1, 2025
9a94bee
Merge remote-tracking branch 'origin/develop' into develop
kevalkanp1011 Apr 1, 2025
d288ed1
review changes
kevalkanp1011 Apr 1, 2025
c16bf0c
Grievance repo condition added
ravishanigarapu Apr 1, 2025
0b7922e
completed grievance API change
ravishanigarapu Apr 1, 2025
1e4eea6
Merge branch 'develop' into develop
ravishanigarapu Apr 1, 2025
0698e6b
Merge pull request #178 from ravishanigarapu/develop
devikasuresh20 Apr 1, 2025
08fd1b8
review changes
kevalkanp1011 Apr 4, 2025
b807305
duplicate description removed
kevalkanp1011 Apr 5, 2025
cd4a707
unnecssary comments are removed
kevalkanp1011 Apr 10, 2025
3f5a727
Merge pull request #181 from kevalkanp1011/develop
drtechie Apr 10, 2025
72715a7
firebase setup
SauravBizbRolly Apr 11, 2025
121928c
firebase setup
SauravBizbRolly Apr 11, 2025
396359d
firebase setup
SauravBizbRolly Apr 11, 2025
0e24515
firebase setup
SauravBizbRolly Apr 11, 2025
70a4256
firebase setup
SauravBizbRolly Apr 14, 2025
8df1a0f
firebase setup
SauravBizbRolly Apr 17, 2025
7222cbd
Firebase Configuration in ci
SauravBizbRolly Apr 17, 2025
ede0339
Firebase Configuration in ci
SauravBizbRolly Apr 17, 2025
e3a177e
firebase notification setup
SauravBizbRolly May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8
17.0
22 changes: 20 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<java.version>17</java.version>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
<org.projectlombok.version>1.16.18</org.projectlombok.version>
<org.projectlombok.version>1.18.36</org.projectlombok.version>
<final-name>commonapi-v1.0</final-name>
<environment>${ENV_VAR}</environment>
<target-properties>target/classes/application.properties</target-properties>
Expand Down Expand Up @@ -107,6 +107,12 @@

</exclusions>
</dependency>

<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>9.4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand Down Expand Up @@ -511,12 +517,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>17</source>
<target>17</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
Expand Down
15 changes: 14 additions & 1 deletion src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ send-message-url=@env.SMS_MESSAGE_URL@
start-sms-scheduler=false
cron-scheduler-sms=0 0/1 * * * ? *

# Firebase Configuration
firebase.enabled=@env.FIREBASE_ENABLE@
# if using file
firebase.credential-file=@env.FIREBASE_CREDENTIAL@
# for CI/CD
firebase.credential-base64=@env.CREDENTIAL_BASE64@

#### Email Configuration
send-email=@env.SEND_EMAIL@
spring.mail.host=@env.MAIL_HOST@
Expand Down Expand Up @@ -148,7 +155,7 @@ logging.file.name=@env.COMMON_API_LOGGING_FILE_NAME@


##grievance API call
updateGrievanceDetails = @env.GRIEVANCE_API_BASE_URL@/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list
updateGrievanceDetails = @env.GRIEVANCE_API_BASE_URL@/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list?page=PageNumber&currentpage=1
updateGrievanceTransactionDetails=@env.GRIEVANCE_API_BASE_URL@/grsbepro/igemr1097/public/api/v1/grievance_details/
## grievance variables

Expand All @@ -160,6 +167,12 @@ grievanceDataSyncDuration = @env.GRIEVANCE_DATA_SYNC_DURATION@
springdoc.api-docs.enabled=false
springdoc.swagger-ui.enabled=false


isProduction=false
grievanceAllocationRetryConfiguration=3

start-grievancedatasync-scheduler=false
cron-scheduler-grievancedatasync=0 0/2 * * * ?



6 changes: 4 additions & 2 deletions src/main/environment/common_dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ nhm.agent.real.time.data.cron.flag=true
##----------------------------------------------------#grievance data sync-----------------------------------------------------------

start-grievancedatasync-scheduler=false
cron-scheduler-grievancedatasync=0 0/5 * * * ? *
cron-scheduler-grievancedatasync=0 0/2 * * * ?

carestream_socket_ip = 192.168.43.39
carestream_socket_port = 1235
Expand Down Expand Up @@ -173,7 +173,7 @@ fileBasePath =<Enter your required basepath here>/Doc
jwt.secret=

##grievance API call
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list?page=PageNumber&currentpage=1
updateGrievanceTransactionDetails=<ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/grievance_details/

## grievance variables
Expand All @@ -186,4 +186,6 @@ grievanceDataSyncDuration = <Enter Grievience Data Sync Duration>
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

isProduction=false
grievanceAllocationRetryConfiguration=3

6 changes: 3 additions & 3 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ cron-scheduler-nhmdashboard=0 1 * * * ? *
##----------------------------------------------------#grievance data sync-----------------------------------------------------------

start-grievancedatasync-scheduler=false
cron-scheduler-grievancedatasync=0 0/5 * * * ? *
cron-scheduler-grievancedatasync=0 0/2 * * * ?

### Redis IP
spring.redis.host=localhost
Expand Down Expand Up @@ -173,7 +173,7 @@ jwt.secret=

fileBasePath =<Enter your required basepath here>/Doc
##grievance API call
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list?page=PageNumber&currentpage=1
updateGrievanceTransactionDetails=<ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/grievance_details/

## grievance variables
Expand All @@ -186,7 +186,7 @@ grievanceDataSyncDuration = <Enter Grievience Data Sync Duration>
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

isProduction=false
grievanceAllocationRetryConfiguration=3



6 changes: 3 additions & 3 deletions src/main/environment/common_test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ cron-scheduler-everwelldatasync=0 0/5 * * * ? *
##----------------------------------------------------#grievance data sync-----------------------------------------------------------

start-grievancedatasync-scheduler=false
cron-scheduler-grievancedatasync=0 0/5 * * * ? *
cron-scheduler-grievancedatasync=0 0/2 * * * ?
##-----------------------------------------------#NHM data dashboard schedular----------------------------------------------------------------
# run at everyday 12:01AM
start-nhmdashboard-scheduler=true
Expand Down Expand Up @@ -175,7 +175,7 @@ jwt.secret=


##grievance API call
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list?page=PageNumber&currentpage=1
updateGrievanceTransactionDetails=<ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/grievance_details/

## grievance variables
Expand All @@ -187,5 +187,5 @@ grievanceDataSyncDuration = <Enter Grievience Data Sync Duration>

springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

isProduction=false
grievanceAllocationRetryConfiguration=3
6 changes: 3 additions & 3 deletions src/main/environment/common_uat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cron-scheduler-ctidatacheck=0 10 00 * * *
##----------------------------------------------------#grievance data sync-----------------------------------------------------------

start-grievancedatasync-scheduler=false
cron-scheduler-grievancedatasync=0 0/5 * * * ? *
cron-scheduler-grievancedatasync=0 0/2 * * * ?

### generate Beneficiary IDs URL
genben-api=<Enter your socket address here>/bengenapi-v1.0
Expand Down Expand Up @@ -146,7 +146,7 @@ fileBasePath =<Enter your required basepath here>/Doc
jwt.secret=

##grievance API call
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list
updateGrievanceDetails = <ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/state-wise/grievance-list?page=PageNumber&currentpage=1
updateGrievanceTransactionDetails=<ENTER GRIEVANCE_API_BASE_URL>/grsbepro/igemr1097/public/api/v1/grievance_details/

## grievance variables
Expand All @@ -158,5 +158,5 @@ grievanceDataSyncDuration = <Enter Grievience Data Sync Duration>

springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

isProduction=false
grievanceAllocationRetryConfiguration=3
9 changes: 9 additions & 0 deletions src/main/java/com/iemr/common/CommonApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
*/
package com.iemr.common;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
Expand All @@ -36,6 +41,8 @@
import com.iemr.common.data.users.User;
import com.iemr.common.utils.IEMRApplBeans;

import java.io.IOException;

@SpringBootApplication
@EnableScheduling
public class CommonApplication extends SpringBootServletInitializer {
Expand Down Expand Up @@ -73,4 +80,6 @@ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factor
return template;
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.iemr.common.config.firebase;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Base64;

@Configuration
public class FirebaseMessagingConfig {

@Value("${firebase.enabled:false}")
private boolean firebaseEnabled;

@Value("${firebase.credential-file:}")
private String firebaseCredentialFile;

@Value("${firebase.credential-base64:}")
private String firebaseCredentialBase64;

@Bean
public FirebaseMessaging firebaseMessaging() throws IOException {
if (!firebaseEnabled) {
throw new IllegalStateException("Firebase is disabled");
}

GoogleCredentials credentials;

if (!firebaseCredentialBase64.isBlank()) {
byte[] decoded = Base64.getDecoder().decode(firebaseCredentialBase64);
credentials = GoogleCredentials.fromStream(new ByteArrayInputStream(decoded));
} else if (!firebaseCredentialFile.isBlank()) {
credentials = GoogleCredentials.fromStream(
new ClassPathResource(firebaseCredentialFile).getInputStream()
);
} else {
throw new IllegalStateException("No Firebase credentials provided");
}

FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(credentials)
.build();

FirebaseApp firebaseApp = FirebaseApp.getApps().isEmpty()
? FirebaseApp.initializeApp(options)
: FirebaseApp.getInstance();

return FirebaseMessaging.getInstance(firebaseApp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.iemr.common.controller.firebaseNotification;

import com.iemr.common.model.notification.NotificationMessage;
import com.iemr.common.service.firebaseNotification.FirebaseNotificationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value= "/firebaseNotification",headers = "Authorization")
public class FirebaseNotificationController {
final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

@Autowired
FirebaseNotificationService firebaseNotificationService;

@RequestMapping(value = "sendNotification",method = RequestMethod.POST)
public String sendNotificationByToken(@RequestBody NotificationMessage notificationMessage){
return firebaseNotificationService.sendNotification(notificationMessage);
Comment on lines +12 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Verification agent

🧩 Analysis chain

Missing service implementation details.

I cannot find the implementation of FirebaseNotificationService that this controller depends on. The service would need to handle the actual Firebase messaging operations.


🌐 Web query:

What are best practices for implementing Firebase Cloud Messaging on the server-side with Java?

πŸ’‘ Result:

To implement Firebase Cloud Messaging (FCM) effectively on the server-side with Java, follow these best practices:


Token Management

  • Store tokens securely with timestamps using Firestore or your backend database. Track token freshness by updating timestamps regularly (e.g., monthly) to identify stale tokens[4][5].

    // Store token with server timestamp
    Map<String, Object> tokenData = new HashMap<>();
    tokenData.put("token", registrationToken);
    tokenData.put("timestamp", FieldValue.serverTimestamp());
    
    FirebaseFirestore.getInstance()
        .collection("fcmTokens")
        .document(userId)
        .set(tokenData);
  • Refresh tokens periodically using WorkManager to ensure validity[4]:

    // Periodic token refresh (e.g., monthly)
    PeriodicWorkRequest refreshRequest = new PeriodicWorkRequest.Builder(
        UpdateTokenWorker.class, 30, TimeUnit.DAYS
    ).build();
    WorkManager.getInstance(context).enqueue(refreshRequest);
  • Prune stale tokens by checking timestamps. Remove tokens older than a defined threshold (e.g., 30 days)[5]:

    // Delete tokens older than 30 days
    FirebaseFirestore.getInstance()
        .collection("fcmTokens")
        .whereLessThan("timestamp", Timestamp.now().toDate().getTime() - 30 * 86_400_000L)
        .get()
        .addOnSuccessListener(queryDocumentSnapshots -> {
            for (DocumentSnapshot doc : queryDocumentSnapshots) {
                doc.getReference().delete();
            }
        });

Message Handling

  • Use the Firebase Admin SDK for built-in authentication and message validation[1][3]:

    // Send a multicast message
    MulticastMessage message = MulticastMessage.builder()
        .putData("score", "850")
        .addAllTokens(registrationTokens)
        .build();
    
    BatchResponse response = FirebaseMessaging.getInstance().sendMulticast(message);
  • Prefer data messages for app-controlled behavior. Use notification messages only for UI alerts[7]:

    // Data message example
    Message dataMsg = Message.builder()
        .setToken(registrationToken)
        .putData("action", "REFRESH")
        .build();
  • Limit message size to under 4,000 bytes and avoid sending redundant keys like from or message_id[8].


Error Handling and Retries

  • Check for failures in multicast sends and log invalid tokens[1]:

    if (response.getFailureCount() > 0) {
        List<SendResponse> responses = response.getResponses();
        List<String> failedTokens = new ArrayList<>();
        for (int i = 0; i < responses.size(); i++) {
            if (!responses.get(i).isSuccessful()) {
                failedTokens.add(registrationTokens.get(i));
            }
        }
        System.out.println("Failed tokens: " + failedTokens);
    }
  • Implement exponential backoff for retries. The Admin SDK handles this automatically, but custom implementations should wait at least 10 seconds between attempts[8].


Scaling and Performance

  • Throttle send rates to avoid spikes. Gradually ramp up from 0 to maximum requests per second (RPS) over 60 seconds[8].
  • Avoid "on-the-hour" traffic to prevent congestion during common scheduling windows[8].
  • Monitor FCM quotas and contact Firebase Support if nearing limits (e.g., 100,000 RPS globally)[8].

Security

  • Protect server credentials (e.g., serviceAccountKey.json) using environment variables or secret management tools[3].
  • Validate client tokens before sending messages to prevent abuse[5].

By following these practices, you ensure efficient, reliable, and scalable FCM integration in Java server environments[1][3][5][8].

Citations:


Action Required: Implement FirebaseNotificationService

The controller currently delegates to FirebaseNotificationService without any visible implementation details. Based on best practices for Firebase Cloud Messaging with Java, please ensure that the service:

  • Implements FCM Messaging: Leverage the Firebase Admin SDK to build and send messages (e.g., using multicast or data messages) and properly handle messaging errors.
  • Manages Tokens Effectively: Include secure token storage with timestamps, implement periodic token refresh, and prune stale tokens.
  • Handles Errors and Scaling: Implement error logging, retries with exponential backoff, and throttle messaging requests as needed.
  • Secures Sensitive Information: Ensure server credentials (like serviceAccountKey.json) are protected via environment variables or secret management tools.

Addressing these points will strengthen the reliability and security of FCM operations.

}
Comment on lines +18 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Method name inconsistent with implementation.

The method is named sendNotificationByToken suggesting token-based messaging, but the implementation doesn't show explicit token handling. Also, there's no input validation or error handling.

Consider these improvements:

@RequestMapping(value = "sendNotification",method = RequestMethod.POST)
-public String sendNotificationByToken(@RequestBody NotificationMessage notificationMessage){
-    return firebaseNotificationService.sendNotification(notificationMessage);
+public ResponseEntity<String> sendNotificationByToken(@RequestBody @Valid NotificationMessage notificationMessage){
+    try {
+        String result = firebaseNotificationService.sendNotification(notificationMessage);
+        return ResponseEntity.ok(result);
+    } catch (Exception e) {
+        logger.error("Error sending notification: ", e);
+        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+                .body("Failed to send notification: " + e.getMessage());
+    }
}

Don't forget to add the required imports:

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import javax.validation.Valid;



}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.iemr.common.controller.grievance;

import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -12,13 +15,17 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.iemr.common.data.grievance.UnallocationRequest;
import com.iemr.common.dto.grivance.GrievanceWorklistDTO;
import com.iemr.common.service.grievance.GrievanceDataSync;
Expand Down Expand Up @@ -130,11 +137,12 @@ public String moveToBin(@RequestBody String request) {

@Operation(summary = "get grievance outbound worklist)")
@PostMapping(value = "/getGrievanceOutboundWorklist", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public ResponseEntity<Map<String, Object>> getGrievanceOutboundWorklist(@Param(value = "{\"providerServiceMapId\":\" called service ID integer\", "
+ "\"userId\":\"Optional - Integer ID of user that is assigned to\"}") @RequestBody String request) {
public String getGrievanceOutboundWorklist(@Param(value = "{\"providerServiceMapId\":\" called service ID integer\", "
+ "\"userId\":\"Optional - Integer ID of user that is assigned to\"}") @RequestBody String request) throws JsonProcessingException {
logger.info("Request received for grievance worklist");
List<GrievanceWorklistDTO> response = new ArrayList<>();
Map<String, Object> responseMap = new HashMap<>();
ObjectMapper objectMapper = new ObjectMapper();

try {
response = grievanceHandlingService.getFormattedGrievanceData(request);
Expand All @@ -160,9 +168,17 @@ public ResponseEntity<Map<String, Object>> getGrievanceOutboundWorklist(@Param(v
responseMap.put("errorMessage", e.getMessage());
responseMap.put("status", "Error");
}


return ResponseEntity.ok(responseMap);
Gson gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@Override
public JsonElement serialize(Date date, Type typeOfSrc, JsonSerializationContext context) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return context.serialize(sdf.format(date)); // Format date
}
})
.create();

return gson.toJson(responseMap);
}


Expand Down
Loading
Loading