Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 4 additions & 1 deletion src/main/environment/ecd_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ logging.file.name=@env.ECD_API_LOGGING_FILE_NAME@
springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@
springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@

spring.redis.host=@env.REDIS_HOST@
spring.redis.host=@env.REDIS_HOST@

cors.allowed-origins=@CORS_ALLOWED_ORIGINS@

4 changes: 3 additions & 1 deletion src/main/environment/ecd_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ springdoc.swagger-ui.enabled=true
jwt.secret=my-32-character-ultra-secure-and-ultra-long-secret
#If both properties are set, only logging.file.name takes effect.
logging.path=logs/
logging.file.name=logs/ecd-api.log
logging.file.name=logs/ecd-api.log

cors.allowed-origins=http://localhost:*
Comment thread
vishwab1 marked this conversation as resolved.
24 changes: 22 additions & 2 deletions src/main/java/com/iemr/ecd/config/WebConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,33 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
import org.springframework.beans.factory.annotation.Value;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Configuration
public class WebConfiguration implements WebMvcConfigurer {

private static final Logger logger = LoggerFactory.getLogger(WebConfiguration.class);

@Value("${cors.allowed-origins}")
private String allowedOrigins;

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
String[] originPatterns = Arrays.stream(allowedOrigins.split(","))
.map(String::trim)
.toArray(String[]::new);

logger.info("Initializing CORS configuration with allowed origins: {}", Arrays.toString(originPatterns));

registry.addMapping("/**")
.allowedOriginPatterns(originPatterns)
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.exposedHeaders("Authorization", "Jwttoken")
.allowCredentials(true)
.maxAge(3600);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -47,7 +47,6 @@

@RestController
@RequestMapping(value = "/autoPreviewDialing", headers = "Authorization")
@CrossOrigin()
public class AutoPreviewDialingController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -46,7 +46,6 @@

@RestController
@RequestMapping(value = "/callHistory", headers = "Authorization")
@CrossOrigin()
public class BeneficiaryCallHistoryController {
@Autowired
private BeneficiaryCallHistoryImpl beneficiaryCallHistoryImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
Expand All @@ -43,14 +43,12 @@

@RestController
@RequestMapping(value = "/beneficary", headers = "Authorization")
@CrossOrigin()

public class BeneficiaryRegistrationController {

@Autowired
private BeneficiaryRegistrationServiceImpl beneficiaryRegistrationServiceImpl;

@CrossOrigin()
@PostMapping(value = "/registration", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Create beneficiary registration", description = "Desc - Create Beneficiary registration")
@ApiResponses(value = {
Expand All @@ -67,7 +65,6 @@ public ResponseEntity<Object> beneficiaryRegistration(@RequestBody RequestBenefi
HttpStatus.OK);
}

@CrossOrigin()
@PostMapping(value = "/updateBeneficiaryDetails", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Update beneficiary details", description = "Desc - Update Beneficiary details")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -42,12 +42,10 @@

@RestController
@RequestMapping(value = "/closure", headers = "Authorization")
@CrossOrigin()
public class CallClosureController {
@Autowired
private CallClosureImpl callClosureImpl;

@CrossOrigin()
@PostMapping(value = "/closeCall", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Call closure", description = "Desc - Call closure")
@ApiResponses(value = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -50,7 +50,6 @@

@RestController
@RequestMapping(value = "/callAllocation", headers = "Authorization")
@CrossOrigin()
public class CallAllocationController {

@Autowired
Expand Down Expand Up @@ -127,7 +126,7 @@ public ResponseEntity<Object> reAllocateCalls(@RequestBody RequestCallAllocation
public ResponseEntity<String> updateAlerts(@RequestBody RequestCallAllocationDTO callAllocationDto) {
return new ResponseEntity<>(callAllocationImpl.moveAllocatedCallsToBin(callAllocationDto), HttpStatus.OK);
}

@PostMapping(value = "/insertRecordsInOutboundCalls", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Insert Records In OutboundCalls", description = "Desc - Insert Records In OutboundCalls")
@ApiResponses(value = {
Expand All @@ -141,7 +140,7 @@ public ResponseEntity<String> insertRecordsInOutboundCalls(@RequestBody Outbound
return new ResponseEntity<>(callAllocationImpl.insertRecordsInOutboundCalls(outboundCallsDTO), HttpStatus.OK);

}

@GetMapping(value = "/getEligibleRecordsLanguageInfo/{psmId}/{phoneNoType}/{recordType}/{fDate}/{tDate}/{preferredLanguage}/{role}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Fetch eligible Language records for allocation", description = "Desc - Fetch eligible records for allocation")
@ApiResponses(value = {
Expand All @@ -153,9 +152,12 @@ public ResponseEntity<String> insertRecordsInOutboundCalls(@RequestBody Outbound
@ApiResponse(responseCode = CustomExceptionResponse.BAD_REQUEST_SC_V, description = CustomExceptionResponse.BAD_REQUEST_SC) })
public ResponseEntity<ResponseEligibleCallRecordsDTO> getEligibleRecordsLanguageInfo(@PathVariable int psmId,
@PathVariable String phoneNoType, @PathVariable String recordType, @PathVariable String fDate,
@PathVariable String tDate, @PathVariable String preferredLanguage,@PathVariable String role) throws ECDException {
@PathVariable String tDate, @PathVariable String preferredLanguage, @PathVariable String role)
throws ECDException {
return new ResponseEntity<>(
callAllocationImpl.getEligibleRecordsLanguageInfo(psmId, phoneNoType, recordType, fDate, tDate, preferredLanguage,role), HttpStatus.OK);
callAllocationImpl.getEligibleRecordsLanguageInfo(psmId, phoneNoType, recordType, fDate, tDate,
preferredLanguage, role),
HttpStatus.OK);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -48,7 +48,6 @@

@RestController
@RequestMapping(value = "/callConfiguration", headers = "Authorization")
@CrossOrigin()
public class CallConfigurationController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -48,7 +48,6 @@

@RestController
@RequestMapping(value = "/dataTemplate", headers = "Authorization")
@CrossOrigin()
public class DataTemplateController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
Expand All @@ -41,7 +41,6 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;

@RestController
@CrossOrigin()
public class DataUploadController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
Expand Down Expand Up @@ -60,7 +60,6 @@

@RestController
@RequestMapping(value = "/master", headers = "Authorization")
@CrossOrigin()
public class MastersController {
@Autowired
private MasterServiceImpl masterServiceImpl;
Expand Down Expand Up @@ -234,11 +233,14 @@ public ResponseEntity<List<Gender>> getGender() {
return new ResponseEntity<>(masterServiceImpl.getGenders(), HttpStatus.OK);

}

@Operation(summary = "Get agents by role id and preferred language", description = "Fetches agents filtered by both role ID and their preferred language setting")
@GetMapping("/getAgentsByRoleIdAndPreferredLanguage/{roleId}/{preferredLanguage}")
public ResponseEntity<List<AgentsViewMaster>> getAgentsByRoleIdAndLanguage(
@RequestHeader(value = "Authorization") String authorization, @PathVariable Integer roleId, @PathVariable String preferredLanguage) {
return new ResponseEntity<>(masterServiceImpl.getAgentByRoleIdAndLanguage(roleId, preferredLanguage), HttpStatus.OK);
@RequestHeader(value = "Authorization") String authorization, @PathVariable Integer roleId,
@PathVariable String preferredLanguage) {
return new ResponseEntity<>(masterServiceImpl.getAgentByRoleIdAndLanguage(roleId, preferredLanguage),
HttpStatus.OK);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -42,7 +42,6 @@

@RestController
@RequestMapping(value = "/agent", headers = "Authorization")
@CrossOrigin()
public class CallStatisticsController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -48,7 +48,6 @@

@RestController
@RequestMapping(value = "/outbound-worklist", headers = "Authorization")
@CrossOrigin()
public class OutBoundWorklistController {

@Autowired
Expand All @@ -68,7 +67,7 @@ public ResponseEntity<String> getMotherWorklist(@PathVariable int userId) throws
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
String resp = objectMapper.writeValueAsString(motherWorkList);
return new ResponseEntity<>(resp,HttpStatus.OK);
return new ResponseEntity<>(resp, HttpStatus.OK);
}

@GetMapping(value = "/get-child-data/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -47,7 +47,6 @@

@RestController
@RequestMapping(value = "/agentQualityAuditorMap", headers = "Authorization")
@CrossOrigin()
public class AgentQualityAuditorMappingController {
@Autowired
private AgentQualityAuditorMappingImpl agentQualityAuditorMappingImpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -44,7 +44,6 @@

@RestController
@RequestMapping(value = "/charts", headers = "Authorization")
@CrossOrigin()
public class ChartsController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -47,7 +47,6 @@

@RestController
@RequestMapping(value = "/gradeConfiguration", headers = "Authorization")
@CrossOrigin()
public class GradeConfigurationController {

@Autowired
Expand Down
Loading
Loading