Skip to content

Commit

Permalink
fix : starting problem
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Dec 8, 2024
1 parent 7de128d commit 98a7dc9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/learning/mfscreener/config/Initializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -21,7 +22,7 @@
import org.springframework.util.StringUtils;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestClient;

@Component
public class Initializer implements CommandLineRunner {
Expand All @@ -30,17 +31,17 @@ public class Initializer implements CommandLineRunner {

private final SchemeService schemeService;
private final MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper;
private final RestTemplate restTemplate;
private final RestClient restClient;
private final MFSchemeNavService mfSchemeNavService;

public Initializer(
SchemeService schemeService,
MfSchemeDtoToEntityMapper mfSchemeDtoToEntityMapper,
RestTemplate restTemplate,
RestClient restClient,
MFSchemeNavService mfSchemeNavService) {
this.schemeService = schemeService;
this.mfSchemeDtoToEntityMapper = mfSchemeDtoToEntityMapper;
this.restTemplate = restTemplate;
this.restClient = restClient;
this.mfSchemeNavService = mfSchemeNavService;
}

Expand All @@ -49,7 +50,11 @@ public void run(String... args) throws IOException {
long start = System.currentTimeMillis();
LOGGER.info("Loading All Funds...");
try {
String allNAVs = restTemplate.getForObject(AppConstants.AMFI_WEBSITE_LINK, String.class);
String allNAVs = restClient
.get()
.uri(URI.create(AppConstants.AMFI_WEBSITE_LINK))
.retrieve()
.body(String.class);
Reader inputString = new StringReader(Objects.requireNonNull(allNAVs));
List<MFSchemeDTO> chopArrayList = new ArrayList<>();
try (BufferedReader br = new BufferedReader(inputString)) {
Expand Down

0 comments on commit 98a7dc9

Please sign in to comment.