3636import org .springframework .util .LinkedMultiValueMap ;
3737import org .springframework .util .MultiValueMap ;
3838import org .springframework .web .client .RestTemplate ;
39+ import org .springframework .web .context .request .RequestContextHolder ;
40+ import org .springframework .web .context .request .ServletRequestAttributes ;
3941
4042import com .iemr .mmu .data .syncActivity_syncLayer .Indent ;
4143import com .iemr .mmu .data .syncActivity_syncLayer .IndentIssue ;
4951import com .iemr .mmu .repo .syncActivity_syncLayer .IndentRepo ;
5052import com .iemr .mmu .repo .syncActivity_syncLayer .ItemStockEntryRepo ;
5153import com .iemr .mmu .repo .syncActivity_syncLayer .StockTransferRepo ;
54+ import com .iemr .mmu .utils .CookieUtil ;
5255import com .iemr .mmu .utils .mapper .InputMapper ;
5356
57+ import jakarta .servlet .http .HttpServletRequest ;
58+
5459@ Service
5560@ PropertySource ("classpath:application.properties" )
5661public class DownloadDataFromServerTransactionalImpl implements DownloadDataFromServerTransactional {
@@ -73,6 +78,8 @@ public class DownloadDataFromServerTransactionalImpl implements DownloadDataFrom
7378 private StockTransferRepo stockTransferRepo ;
7479 @ Autowired
7580 private ItemStockEntryRepo itemStockEntryRepo ;
81+ @ Autowired
82+ private CookieUtil cookieUtil ;
7683
7784 public int downloadTransactionalData (int vanID , String ServerAuthorization ) throws Exception {
7885 JSONObject obj ;
@@ -233,13 +240,17 @@ private JSONObject downloadDataFromCentral(String schemaName, String tableName,
233240 if (facilityID != null ) {
234241
235242 RestTemplate restTemplate = new RestTemplate ();
243+ HttpServletRequest requestHeader = ((ServletRequestAttributes ) RequestContextHolder .getRequestAttributes ())
244+ .getRequest ();
245+ String jwtTokenFromCookie = cookieUtil .getJwtTokenFromCookie (requestHeader );
236246 SyncUploadDataDigester syncUploadDataDigester = new SyncUploadDataDigester (schemaName , tableName ,
237247 facilityID );
238248
239249 // Multivalue map for headers with content-type and auth key
240250 MultiValueMap <String , String > headers = new LinkedMultiValueMap <String , String >();
241251 headers .add ("Content-Type" , "application/json" );
242252 headers .add ("AUTHORIZATION" , ServerAuthorization );
253+ headers .add ("Cookie" , "Jwttoken=" + jwtTokenFromCookie );
243254 HttpEntity <Object > request = new HttpEntity <Object >(syncUploadDataDigester , headers );
244255
245256 // Call rest-template to call API to download master data for given table
@@ -263,12 +274,16 @@ private int updateProcessedFlagToCentral(String schemaName, String tableName, Li
263274
264275 int result = 0 ;
265276 RestTemplate restTemplate = new RestTemplate ();
277+ HttpServletRequest requestHeader = ((ServletRequestAttributes ) RequestContextHolder .getRequestAttributes ())
278+ .getRequest ();
279+ String jwtTokenFromCookie = cookieUtil .getJwtTokenFromCookie (requestHeader );
266280 SyncUploadDataDigester syncUploadDataDigester = new SyncUploadDataDigester (schemaName , tableName , ids );
267281
268282 // Multivalue map for headers with content-type and auth key
269283 MultiValueMap <String , String > headers = new LinkedMultiValueMap <String , String >();
270284 headers .add ("Content-Type" , "application/json" );
271285 headers .add ("AUTHORIZATION" , ServerAuthorization );
286+ headers .add ("Cookie" , "Jwttoken=" + jwtTokenFromCookie );
272287 HttpEntity <Object > request = new HttpEntity <Object >(syncUploadDataDigester , headers );
273288
274289 // Call rest-template to call API to download master data for given table
0 commit comments