Resolved conflicts
This commit is contained in:
@@ -52,6 +52,8 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
@@ -160,6 +162,8 @@ public class AppointmentDao {
|
||||
public NdgResponse checkNdgForAppointment(Long applicationId) {
|
||||
log.info("Starting NDG check for appointment. applicationId: {}", applicationId);
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||
|
||||
NdgResponse ndgResponse = new NdgResponse();
|
||||
if (application.getNdgStatus() != null && application.getNdgStatus().equalsIgnoreCase(GepafinConstant.NDG_IN_PROGRESS)) {
|
||||
log.warn("NDG generation already in progress. applicationId: {}", applicationId);
|
||||
@@ -176,6 +180,10 @@ public class AppointmentDao {
|
||||
application.setNdgStatus(GepafinConstant.NDG_IN_PROGRESS);
|
||||
applicationRepository.save(application);
|
||||
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(application).build());
|
||||
|
||||
|
||||
// Start async processing
|
||||
HubEntity hub = hubRepository.findByHubId(application.getHubId());
|
||||
loginToOdessa(hub, application);
|
||||
@@ -409,6 +417,7 @@ public class AppointmentDao {
|
||||
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
applicationRepository.save(application);
|
||||
}
|
||||
log.warn("Detected PASSWORD_EXPIRED error during Odessa login. ApplicationId: {}", application.getId());
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
|
||||
@@ -427,10 +436,7 @@ public class AppointmentDao {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
log.error("Unexpected exception during Odessa login.Error: {}",e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,6 +446,7 @@ public class AppointmentDao {
|
||||
log.warn("Async processing already running for applicationId: {}", applicationId);
|
||||
return;
|
||||
}
|
||||
ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request);
|
||||
|
||||
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> {
|
||||
Thread t = new Thread(runnable);
|
||||
@@ -457,6 +464,8 @@ public class AppointmentDao {
|
||||
AtomicReference<ScheduledFuture<?>> futureRef = new AtomicReference<>();
|
||||
|
||||
Runnable pollingTask = () -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes, true);
|
||||
Utils.setHttpServletRequestForThread(request,HttpMethodEnum.POST.getValue(),GepafinConstant.CREATE_NDG, (Long) request.getAttribute(GepafinConstant.USER_ACTION_ID));
|
||||
try {
|
||||
// 1) If 2 hours have already passed, mark as FAILED and shut down:
|
||||
if (System.currentTimeMillis() - startTime > twoHoursMs) {
|
||||
@@ -558,7 +567,8 @@ public class AppointmentDao {
|
||||
private void handleNdgPolling(ApplicationEntity application, CompanyEntity company, HubEntity hub, String authorizationToken) {
|
||||
|
||||
log.info("Starting single‐shot NDG polling attempt for applicationId: {}, CompanyId: {}, HubId: {}", application.getId(), company.getId(), hub.getId());
|
||||
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||
CompanyEntity oldCompanyEntity=Utils.getClonedEntityForData(company);
|
||||
long startTime = System.currentTimeMillis();
|
||||
long twoHoursMs = TimeUnit.HOURS.toMillis(2);
|
||||
|
||||
@@ -585,6 +595,10 @@ public class AppointmentDao {
|
||||
|
||||
companyRepository.save(company);
|
||||
applicationRepository.save(application);
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(application).build());
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyEntity).newData(company).build());
|
||||
|
||||
ApplicationEvaluationEntity eval = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
@@ -613,6 +627,10 @@ public class AppointmentDao {
|
||||
|
||||
companyRepository.save(company);
|
||||
applicationRepository.save(application);
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(application).build());
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyEntity).newData(company).build());
|
||||
|
||||
ApplicationEvaluationEntity eval = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
@@ -663,6 +681,7 @@ public class AppointmentDao {
|
||||
private void saveNdgAndIdVisura(ApplicationEntity application, CompanyEntity company, String ndg) {
|
||||
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||
CompanyEntity oldCompanyEntity=Utils.getClonedEntityForData(company);
|
||||
application.setNdg(ndg);
|
||||
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
||||
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
||||
@@ -671,6 +690,9 @@ public class AppointmentDao {
|
||||
applicationRepository.save(application);
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(application).build());
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyEntity).newData(company).build());
|
||||
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
@@ -1185,6 +1207,7 @@ public class AppointmentDao {
|
||||
}
|
||||
|
||||
private void uploadDocumentToExternalSystemSync(Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest, ApplicationEntity application) {
|
||||
log.info("Starting sync document upload for documentId: {}", documentId);
|
||||
// Synchronous upload logic
|
||||
DocumentEntity systemDoc = documentDao.validateDocument(documentId);
|
||||
|
||||
|
||||
@@ -1043,15 +1043,17 @@ public class Utils {
|
||||
return new ArrayList<>(responseMap.values());
|
||||
}
|
||||
|
||||
public static void setHttpServletRequestForThread(String redirectURI, String methodType,HttpServletRequest request,String remoteUser) {
|
||||
|
||||
public static void setHttpServletRequestForThread(HttpServletRequest request,String methodType, String remoteUser, Long userActionId) {
|
||||
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
|
||||
mockRequest.setRequestURI(redirectURI);
|
||||
mockRequest.setRequestURI(request.getRequestURI());
|
||||
mockRequest.setMethod(methodType);
|
||||
mockRequest.setRemoteUser(remoteUser);
|
||||
Long userActionId = (Long) request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
mockRequest.setRemoteUser(remoteUser); // or pass it in if needed
|
||||
mockRequest.setAttribute(GepafinConstant.USER_ACTION_ID, userActionId);
|
||||
|
||||
ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
|
||||
RequestContextHolder.setRequestAttributes(attributes, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user