SEBSERV-417 better connection init
This commit is contained in:
		
							parent
							
								
									b1e4f50a1a
								
							
						
					
					
						commit
						fc7ac4c4e0
					
				
					 3 changed files with 14 additions and 16 deletions
				
			
		|  | @ -166,9 +166,11 @@ public class FullLmsIntegrationServiceImpl implements FullLmsIntegrationService | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (lmsSetup.active) { |         if (lmsSetup.active) { | ||||||
|             applyFullLmsIntegration(lmsSetup.id) |             if (!lmsSetup.integrationActive) { | ||||||
|                     .onError(error -> log.warn("Failed to update LMS integration for: {}", lmsSetup, error)) |                 applyFullLmsIntegration(lmsSetup.id) | ||||||
|                     .onSuccess(data -> log.debug("Successfully updated LMS integration for: {} data: {}", lmsSetup, data)); |                         .onError(error -> log.warn("Failed to update LMS integration for: {}", lmsSetup, error)) | ||||||
|  |                         .onSuccess(data -> log.debug("Successfully updated LMS integration for: {} data: {}", lmsSetup, data)); | ||||||
|  |             } | ||||||
|         } else if (lmsSetup.integrationActive) { |         } else if (lmsSetup.integrationActive) { | ||||||
|             deleteFullLmsIntegration(lmsSetup.id) |             deleteFullLmsIntegration(lmsSetup.id) | ||||||
|                     .onError(error -> log.warn("Failed to delete LMS integration for: {}", lmsSetup, error)) |                     .onError(error -> log.warn("Failed to delete LMS integration for: {}", lmsSetup, error)) | ||||||
|  |  | ||||||
|  | @ -53,7 +53,7 @@ public class LmsAPIServiceImpl implements LmsAPIService { | ||||||
|     private final ClientCredentialService clientCredentialService; |     private final ClientCredentialService clientCredentialService; | ||||||
|     private final QuizLookupService quizLookupService; |     private final QuizLookupService quizLookupService; | ||||||
|     private final EnumMap<LmsType, LmsAPITemplateFactory> templateFactories; |     private final EnumMap<LmsType, LmsAPITemplateFactory> templateFactories; | ||||||
|     private final ApplicationEventPublisher applicationEventPublisher; |     private final FullLmsIntegrationService fullLmsIntegrationService; | ||||||
| 
 | 
 | ||||||
|     private final Map<CacheKey, LmsAPITemplate> cache = new ConcurrentHashMap<>(); |     private final Map<CacheKey, LmsAPITemplate> cache = new ConcurrentHashMap<>(); | ||||||
| 
 | 
 | ||||||
|  | @ -62,14 +62,14 @@ public class LmsAPIServiceImpl implements LmsAPIService { | ||||||
|             final LmsSetupDAO lmsSetupDAO, |             final LmsSetupDAO lmsSetupDAO, | ||||||
|             final ClientCredentialService clientCredentialService, |             final ClientCredentialService clientCredentialService, | ||||||
|             final QuizLookupService quizLookupService, |             final QuizLookupService quizLookupService, | ||||||
|             final ApplicationEventPublisher applicationEventPublisher, |             final FullLmsIntegrationService fullLmsIntegrationService, | ||||||
|             final Collection<LmsAPITemplateFactory> lmsAPITemplateFactories) { |             final Collection<LmsAPITemplateFactory> lmsAPITemplateFactories) { | ||||||
| 
 | 
 | ||||||
|         this.webserviceInfo = webserviceInfo; |         this.webserviceInfo = webserviceInfo; | ||||||
|         this.lmsSetupDAO = lmsSetupDAO; |         this.lmsSetupDAO = lmsSetupDAO; | ||||||
|         this.clientCredentialService = clientCredentialService; |         this.clientCredentialService = clientCredentialService; | ||||||
|         this.quizLookupService = quizLookupService; |         this.quizLookupService = quizLookupService; | ||||||
|         this.applicationEventPublisher = applicationEventPublisher; |         this.fullLmsIntegrationService = fullLmsIntegrationService; | ||||||
| 
 | 
 | ||||||
|         final Map<LmsType, LmsAPITemplateFactory> factories = lmsAPITemplateFactories |         final Map<LmsType, LmsAPITemplateFactory> factories = lmsAPITemplateFactories | ||||||
|                 .stream() |                 .stream() | ||||||
|  | @ -170,15 +170,11 @@ public class LmsAPIServiceImpl implements LmsAPIService { | ||||||
|                         .onError(er -> log.error("Failed to mark LMS integration inactive", er)); |                         .onError(er -> log.error("Failed to mark LMS integration inactive", er)); | ||||||
|                 return lmsSetupTestResult; |                 return lmsSetupTestResult; | ||||||
|             } else { |             } else { | ||||||
|                 // try to apply full integration with a change LMSSetup notification | 
 | ||||||
|                 try { |                 final Result<FullLmsIntegrationService.IntegrationData> integrationDataResult = fullLmsIntegrationService | ||||||
|                     applicationEventPublisher.publishEvent(new LmsSetupChangeEvent(template.lmsSetup())); |                         .applyFullLmsIntegration(template.lmsSetup().id); | ||||||
|                     return lmsSetupTestResult; | 
 | ||||||
|                 } catch (final Exception e) { |                 if (integrationDataResult.hasError()) { | ||||||
|                     log.warn( |  | ||||||
|                             "Failed to apply full LMS integration on test attempt: lms: {} error: {}", |  | ||||||
|                             template.lmsSetup(), |  | ||||||
|                             e.getMessage()); |  | ||||||
|                     return LmsSetupTestResult.ofFullIntegrationAPIError( |                     return LmsSetupTestResult.ofFullIntegrationAPIError( | ||||||
|                             template.lmsSetup().lmsType, |                             template.lmsSetup().lmsType, | ||||||
|                             "Failed to apply full LMS integration"); |                             "Failed to apply full LMS integration"); | ||||||
|  |  | ||||||
|  | @ -111,7 +111,7 @@ public class MoodlePluginFullIntegration implements FullLmsIntegrationAPI { | ||||||
|                 log.warn( |                 log.warn( | ||||||
|                         "Failed to apply SEB Server connection details to Moodle for full integration. Moodle error {}, lmsSetup: {} data: {}", |                         "Failed to apply SEB Server connection details to Moodle for full integration. Moodle error {}, lmsSetup: {} data: {}", | ||||||
|                         response, |                         response, | ||||||
|                         lmsSetup, |                         lmsSetup.name, | ||||||
|                         data |                         data | ||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti