|
|
|
|
@@ -129,16 +129,62 @@ public class AppointmentDao {
|
|
|
|
|
|
|
|
|
|
public NdgResponse checkNdgForAppointment(Long applicationId) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
NdgResponse ndgResponseToReturn = new NdgResponse();
|
|
|
|
|
// Validate application, company, and hub
|
|
|
|
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
|
|
|
|
NdgResponse ndgResponse = new NdgResponse();
|
|
|
|
|
if (application.getNdgStatus() != null && application.getNdgStatus().equalsIgnoreCase(GepafinConstant.NDG_IN_PROGRESS)) {
|
|
|
|
|
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
|
|
|
|
|
}
|
|
|
|
|
//cloned for old application data
|
|
|
|
|
ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
|
|
|
|
|
|
|
|
|
if (application.getNdgStatus() != null && application.getNdgStatus().equalsIgnoreCase(GepafinConstant.NDG_GENERATED) && application.getNdg() != null) {
|
|
|
|
|
ndgResponse.setNdg(application.getNdg());
|
|
|
|
|
return ndgResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update application status
|
|
|
|
|
application.setNdgStatus(GepafinConstant.NDG_IN_PROGRESS);
|
|
|
|
|
applicationRepository.save(application);
|
|
|
|
|
|
|
|
|
|
// Start async processing
|
|
|
|
|
startAsyncNdgProcessing(applicationId);
|
|
|
|
|
|
|
|
|
|
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void startAsyncNdgProcessing(Long applicationId) {
|
|
|
|
|
// Check if a thread is already running for this application
|
|
|
|
|
if (executorMap.containsKey(applicationId)) {
|
|
|
|
|
log.warn("Async processing already running for applicationId: {}", applicationId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a dedicated thread for asynchronous processing
|
|
|
|
|
ExecutorService executor = Executors.newSingleThreadExecutor(runnable -> {
|
|
|
|
|
Thread thread = new Thread(runnable);
|
|
|
|
|
thread.setName("AsyncNdgProcessing-" + applicationId);
|
|
|
|
|
return thread;
|
|
|
|
|
});
|
|
|
|
|
executorMap.put(applicationId, executor);
|
|
|
|
|
|
|
|
|
|
executor.submit(() -> {
|
|
|
|
|
try {
|
|
|
|
|
log.info("Starting async processing for applicationId: {}", applicationId);
|
|
|
|
|
processNdgGeneration(applicationId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("Error in async NDG processing for applicationId: {}", applicationId, e);
|
|
|
|
|
} finally {
|
|
|
|
|
// Cleanup resources
|
|
|
|
|
ExecutorService executorToShutdown = executorMap.remove(applicationId);
|
|
|
|
|
if (executorToShutdown != null) {
|
|
|
|
|
executorToShutdown.shutdown();
|
|
|
|
|
}
|
|
|
|
|
log.info("Async processing completed for applicationId: {}", applicationId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void processNdgGeneration(Long applicationId) {
|
|
|
|
|
// Validate application, company, and hub
|
|
|
|
|
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
|
|
|
|
CompanyEntity company = companyService.validateCompany(application.getCompanyId());
|
|
|
|
|
HubEntity hub = hubRepository.findByHubId(application.getHubId());
|
|
|
|
|
|
|
|
|
|
@@ -147,133 +193,82 @@ public class AppointmentDao {
|
|
|
|
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.NO_NDG_FOR_ANOTHER_HUB));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if NDG and idVisura are already present
|
|
|
|
|
if (isNdgAndIdVisuraPresent(application)) {
|
|
|
|
|
log.info("NDG already exist for applicationId: {}", applicationId);
|
|
|
|
|
ndgResponseToReturn.setNdg(application.getNdg());
|
|
|
|
|
return ndgResponseToReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Authenticate and fetch token if required
|
|
|
|
|
if (hub.getAppointmentAuthTokenId() == null && hub.getAreaCode() == null) {
|
|
|
|
|
hub = authenticateAndSaveToken(hub);
|
|
|
|
|
if (hub.getAppointmentAuthTokenId() == null || hub.getAreaCode() == null) {
|
|
|
|
|
authenticateAndSaveToken(hub);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String authorizationToken = getBearerToken(hub);
|
|
|
|
|
|
|
|
|
|
// Try retrieving NDG by VAT number
|
|
|
|
|
AppointmentLoginResponse ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
|
|
|
|
//For testing purpose Commenting it
|
|
|
|
|
if (isNdgValid(ndgResponse.getNdg())) {
|
|
|
|
|
saveNdgAndIdVisura(application, company, ndgResponse.getNdg(), null);
|
|
|
|
|
ndgResponseToReturn.setNdg(application.getNdg());
|
|
|
|
|
return ndgResponseToReturn;
|
|
|
|
|
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
|
|
|
|
} else {
|
|
|
|
|
// If NDG isn't immediately available, start polling
|
|
|
|
|
handleNdgPolling(application, company, hub, authorizationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getNdgResponse(company, authorizationToken, hub, application, ndgResponseToReturn, oldApplicationData);
|
|
|
|
|
} catch (FeignException e) {
|
|
|
|
|
log.error("Error in feign client call during NDG handling: {}", e.getMessage(), e);
|
|
|
|
|
Utils.callException(e.status(), e);
|
|
|
|
|
} catch (CustomValidationException e) {
|
|
|
|
|
log.info("Custom validation exception: {}", e.getMessage());
|
|
|
|
|
throw e;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("Error during NDG handling: {}", e.getMessage(), e);
|
|
|
|
|
throw new RuntimeException("Error during fetching NDG.");
|
|
|
|
|
log.error("Error during NDG generation for applicationId: {}", applicationId, e);
|
|
|
|
|
}
|
|
|
|
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private NdgResponse getNdgResponse(CompanyEntity company, String authorizationToken, HubEntity hub, ApplicationEntity application, NdgResponse ndgResponseToReturn,
|
|
|
|
|
ApplicationEntity oldApplicationData) {
|
|
|
|
|
// Create Visura if NDG is not found
|
|
|
|
|
AppointmentLoginResponse visuraResponse = createVisura(company, authorizationToken, hub);
|
|
|
|
|
if (isNdgValid(visuraResponse.getNdg())) {
|
|
|
|
|
saveNdgAndIdVisura(application, company, visuraResponse.getNdg(), visuraResponse.getIdVisura());
|
|
|
|
|
ndgResponseToReturn.setNdg(application.getNdg());
|
|
|
|
|
} else if (visuraResponse.getIdVisura() != null) {
|
|
|
|
|
application.setNdgStatus(GepafinConstant.NDG_IN_PROGRESS);
|
|
|
|
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
|
|
|
|
applicationRepository.save(application);
|
|
|
|
|
private void handleNdgPolling(ApplicationEntity application, CompanyEntity company, HubEntity hub, String authorizationToken) {
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "Updating ndg status in application" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(
|
|
|
|
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
|
|
|
|
|
|
|
|
|
|
startNdgPollingTask(application, company, hub);
|
|
|
|
|
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ndgResponseToReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getBearerToken(HubEntity hub) {
|
|
|
|
|
|
|
|
|
|
return "Bearer " + hub.getAppointmentAuthTokenId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void startNdgPollingTask(ApplicationEntity application, CompanyEntity company, HubEntity hub) {
|
|
|
|
|
//cloned for all data
|
|
|
|
|
ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
|
|
|
|
CompanyEntity oldCompanyData = Utils.getClonedEntityForData(company);
|
|
|
|
|
|
|
|
|
|
// Check if a thread is already running for this application
|
|
|
|
|
if (executorMap.containsKey(application.getId())) {
|
|
|
|
|
log.warn("Polling task already running for applicationId: {}", application.getId());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a dedicated thread (single-threaded executor) for this application
|
|
|
|
|
ExecutorService executor = Executors.newSingleThreadExecutor(runnable -> {
|
|
|
|
|
Thread thread = new Thread(runnable);
|
|
|
|
|
thread.setName(GepafinConstant.POLLING_THREAD_NAME + application.getId());
|
|
|
|
|
return thread;
|
|
|
|
|
});
|
|
|
|
|
executorMap.put(application.getId(), executor);
|
|
|
|
|
|
|
|
|
|
// Submit polling task to this thread
|
|
|
|
|
executor.submit(() -> {
|
|
|
|
|
try {
|
|
|
|
|
log.info("Polling task started for applicationId: {} on thread: {}", application.getId(), Thread.currentThread().getName());
|
|
|
|
|
log.info("Starting NDG polling for applicationId: {}", application.getId());
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
if (application.getNdg() != null)
|
|
|
|
|
if (application.getNdg() != null) {
|
|
|
|
|
log.info("NDG retrieved for applicationId: {}", application.getId());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String visuraListJson = getVisuraList(application.getIdVisura(), hub.getAppointmentAuthTokenId(), application, hub);
|
|
|
|
|
// Fetch Visura list and attempt to parse NDG
|
|
|
|
|
String visuraListJson = getVisuraList(application.getIdVisura(), authorizationToken, application, hub);
|
|
|
|
|
String ndg = parseNdgFromVisuraListResponse(visuraListJson);
|
|
|
|
|
|
|
|
|
|
if (isNdgValid(ndg)) {
|
|
|
|
|
// CompanyEntity oldCompanyData = Utils.getClonedEntityForData(company);
|
|
|
|
|
// ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
|
|
|
|
|
|
|
|
|
company.setNdg(ndg);
|
|
|
|
|
application.setNdg(ndg);
|
|
|
|
|
application.setNdgStatus(GepafinConstant.NDG_GENERATED);
|
|
|
|
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
|
|
|
|
application.setNdg(ndg);
|
|
|
|
|
applicationRepository.save(application);
|
|
|
|
|
companyRepository.save(company);
|
|
|
|
|
log.info("NDG saved successfully for applicationId: {}", application.getId());
|
|
|
|
|
|
|
|
|
|
log.info("NDG obtained for applicationId: {} and saved successfully.", application.getId());
|
|
|
|
|
break; // Exit the loop after successful NDG retrieval
|
|
|
|
|
} else {
|
|
|
|
|
log.warn("NDG not found for applicationId: {} in Visura List API response.", application.getId());
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "update application ndg code, status, and Id visura"
|
|
|
|
|
// operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(
|
|
|
|
|
// VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData)
|
|
|
|
|
// .newData(application).build());
|
|
|
|
|
//
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "update company ndg code" operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(
|
|
|
|
|
// VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyData)
|
|
|
|
|
// .newData(company).build());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if polling time has exceeded the limit
|
|
|
|
|
// Check if polling has timed out
|
|
|
|
|
if (System.currentTimeMillis() - startTime > TimeUnit.HOURS.toMillis(2)) {
|
|
|
|
|
log.warn("Polling timed out for applicationId: {}", application.getId());
|
|
|
|
|
// Mark NDG status as FAILED for this application
|
|
|
|
|
log.warn("NDG polling timed out for applicationId: {}", application.getId());
|
|
|
|
|
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
|
|
|
|
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
|
|
|
|
applicationRepository.save(application);
|
|
|
|
|
log.info("NDG status marked as FAILED for applicationId: {}", application.getId());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wait before the next polling attempt
|
|
|
|
|
Thread.sleep(TimeUnit.MINUTES.toMillis(15));
|
|
|
|
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
log.warn("Polling task interrupted for applicationId: {}", application.getId());
|
|
|
|
|
log.warn("NDG polling interrupted for applicationId: {}", application.getId());
|
|
|
|
|
Thread.currentThread().interrupt();
|
|
|
|
|
break;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
@@ -281,31 +276,13 @@ public class AppointmentDao {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
// Cleanup: Shut down the thread for this application
|
|
|
|
|
executor.shutdown();
|
|
|
|
|
executorMap.remove(application.getId());
|
|
|
|
|
log.info("Polling task completed and thread shut down for applicationId: {}", application.getId());
|
|
|
|
|
log.info("NDG polling completed for applicationId: {}", application.getId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
/** This code is responsible for adding a version history log for the "Update application ndgCode and ndgStatus" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(
|
|
|
|
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "Update company ndgCode" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyData).newData(company).build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isNdgAndIdVisuraPresent(ApplicationEntity application) {
|
|
|
|
|
private static String getBearerToken(HubEntity hub) {
|
|
|
|
|
|
|
|
|
|
String ndg = application.getNdg();
|
|
|
|
|
String idVisura = application.getIdVisura();
|
|
|
|
|
|
|
|
|
|
if (ndg != null && idVisura == null) {
|
|
|
|
|
return true;
|
|
|
|
|
} else if (ndg == null && idVisura != null) {
|
|
|
|
|
return false;
|
|
|
|
|
} else
|
|
|
|
|
return ndg != null;
|
|
|
|
|
return "Bearer " + hub.getAppointmentAuthTokenId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isNdgValid(String ndg) {
|
|
|
|
|
@@ -316,8 +293,8 @@ public class AppointmentDao {
|
|
|
|
|
private void saveNdgAndIdVisura(ApplicationEntity application, CompanyEntity company, String ndg, String idVisura) {
|
|
|
|
|
|
|
|
|
|
//cloned for old application and company data
|
|
|
|
|
ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
|
|
|
|
CompanyEntity oldCompanyData = Utils.getClonedEntityForData(company);
|
|
|
|
|
// ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(application);
|
|
|
|
|
// CompanyEntity oldCompanyData = Utils.getClonedEntityForData(company);
|
|
|
|
|
|
|
|
|
|
application.setNdg(ndg);
|
|
|
|
|
application.setIdVisura(idVisura);
|
|
|
|
|
@@ -327,12 +304,13 @@ public class AppointmentDao {
|
|
|
|
|
companyRepository.save(company);
|
|
|
|
|
applicationRepository.save(application);
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "update application ndg code, status, and Id visura" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(
|
|
|
|
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "update company ndg code" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyData).newData(company).build());
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "update application ndg code, status, and Id visura" operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(
|
|
|
|
|
// VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationData).newData(application).build());
|
|
|
|
|
//
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "update company ndg code" operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldCompanyData).newData
|
|
|
|
|
// (company).build());
|
|
|
|
|
|
|
|
|
|
log.info("NDG saved for applicationId: {}, {}", application.getId(), application.getNdg());
|
|
|
|
|
}
|
|
|
|
|
@@ -361,7 +339,7 @@ public class AppointmentDao {
|
|
|
|
|
|
|
|
|
|
private HubEntity authenticateAndSaveToken(HubEntity hub) {
|
|
|
|
|
|
|
|
|
|
HubEntity oldHubData = Utils.getClonedEntityForData(hub);
|
|
|
|
|
// HubEntity oldHubData = Utils.getClonedEntityForData(hub);
|
|
|
|
|
try {
|
|
|
|
|
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
|
|
|
|
String authJwtToken = Utils.generateAuthTokenForLoginToOdessa();
|
|
|
|
|
@@ -369,8 +347,9 @@ public class AppointmentDao {
|
|
|
|
|
hub.setAuthToken(authJwtToken);
|
|
|
|
|
hubRepository.save(hub);
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "Updating auth token for login api in hub" operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldHubData).newData(hub).build());
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "Updating auth token for login api in hub" operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldHubData).newData
|
|
|
|
|
// (hub).build());
|
|
|
|
|
|
|
|
|
|
// Prepare the request body (adjust if necessary for login API)
|
|
|
|
|
Map<String, Object> body = Collections.emptyMap();
|
|
|
|
|
@@ -389,10 +368,12 @@ public class AppointmentDao {
|
|
|
|
|
hub.setAreaCode(parsedResponse.getAreaCode());
|
|
|
|
|
hubRepository.save(hub);
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for the "inserting token and areaCode from login odessa response for appointment flow api's"
|
|
|
|
|
* operation. **/
|
|
|
|
|
loggingUtil.addVersionHistory(
|
|
|
|
|
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldHubData).newData(hub).build());
|
|
|
|
|
// /** This code is responsible for adding a version history log for the "inserting token and areaCode from login odessa response for
|
|
|
|
|
// appointment flow api's"
|
|
|
|
|
// * operation. **/
|
|
|
|
|
// loggingUtil.addVersionHistory(
|
|
|
|
|
// VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldHubData).newData(hub)
|
|
|
|
|
// .build());
|
|
|
|
|
|
|
|
|
|
log.info("Saved new authToken and areaCode for Hub.");
|
|
|
|
|
return hub;
|
|
|
|
|
@@ -419,7 +400,7 @@ public class AppointmentDao {
|
|
|
|
|
// Parse and return the NDG response
|
|
|
|
|
return parseNdgResponse(responseJson);
|
|
|
|
|
} catch (FeignException.Forbidden forbiddenException) {
|
|
|
|
|
log.error("403 Forbidden received while retrieving NDG. Regenerating token...");
|
|
|
|
|
logForbiddenError();
|
|
|
|
|
// Regenerate the token and retry
|
|
|
|
|
String newAuthorizationToken = regenerateTokenAndSave(hub);
|
|
|
|
|
return retrieveNdgByVatNumber(vatNumber, newAuthorizationToken, hub, application);
|
|
|
|
|
@@ -448,7 +429,7 @@ public class AppointmentDao {
|
|
|
|
|
String responseJson = Utils.convertObjectToJson(response.getBody());
|
|
|
|
|
return parseVisuraResponse(responseJson);
|
|
|
|
|
} catch (FeignException.Forbidden forbiddenException) {
|
|
|
|
|
log.error("403 Forbidden received while retrieving NDG. Regenerating token...");
|
|
|
|
|
logForbiddenError();
|
|
|
|
|
// Regenerate the token and retry
|
|
|
|
|
String newAuthorizationToken = regenerateTokenAndSave(hub);
|
|
|
|
|
return createVisura(company, newAuthorizationToken, hub);
|
|
|
|
|
@@ -458,6 +439,11 @@ public class AppointmentDao {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void logForbiddenError() {
|
|
|
|
|
|
|
|
|
|
log.error("403 Forbidden received while retrieving NDG. Regenerating token...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static AppointmentNdgRequest getAppointmentNdgRequest(String vatNumber) {
|
|
|
|
|
|
|
|
|
|
AppointmentNdgRequest request = new AppointmentNdgRequest();
|
|
|
|
|
|