fixing tests
This commit is contained in:
		
							parent
							
								
									0b120a0b58
								
							
						
					
					
						commit
						6cb2f78759
					
				
					 3 changed files with 53 additions and 0 deletions
				
			
		|  | @ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
| import org.springframework.context.annotation.Lazy; | import org.springframework.context.annotation.Lazy; | ||||||
|  | import org.springframework.context.event.EventListener; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| 
 | 
 | ||||||
| import ch.ethz.seb.sebserver.gbl.Constants; | import ch.ethz.seb.sebserver.gbl.Constants; | ||||||
|  | @ -73,6 +74,23 @@ public class LmsAPIServiceImpl implements LmsAPIService { | ||||||
|         this.templateFactories = new EnumMap<>(factories); |         this.templateFactories = new EnumMap<>(factories); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** Listen to LmsSetupChangeEvent to release an affected LmsAPITemplate from cache | ||||||
|  |      * | ||||||
|  |      * @param event the event holding the changed LmsSetup */ | ||||||
|  |     @EventListener | ||||||
|  |     public void notifyLmsSetupChange(final LmsSetupChangeEvent event) { | ||||||
|  |         final LmsSetup lmsSetup = event.getLmsSetup(); | ||||||
|  |         if (lmsSetup == null) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (log.isDebugEnabled()) { | ||||||
|  |             log.debug("LmsSetup changed. Update cache by removing eventually used references"); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         this.cache.remove(new CacheKey(lmsSetup.getModelId(), 0)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void cleanup() { |     public void cleanup() { | ||||||
|         this.cache.clear(); |         this.cache.clear(); | ||||||
|  |  | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | /* | ||||||
|  |  * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET) | ||||||
|  |  * | ||||||
|  |  * This Source Code Form is subject to the terms of the Mozilla Public | ||||||
|  |  * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||
|  |  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | package ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl; | ||||||
|  | 
 | ||||||
|  | import org.springframework.context.ApplicationEvent; | ||||||
|  | 
 | ||||||
|  | import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; | ||||||
|  | 
 | ||||||
|  | public class LmsSetupChangeEvent extends ApplicationEvent { | ||||||
|  | 
 | ||||||
|  |     private static final long serialVersionUID = -7239994198026689531L; | ||||||
|  | 
 | ||||||
|  |     public LmsSetupChangeEvent(final LmsSetup source) { | ||||||
|  |         super(source); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public LmsSetup getLmsSetup() { | ||||||
|  |         return (LmsSetup) this.source; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -30,6 +30,7 @@ import ch.ethz.seb.sebserver.gbl.model.Entity; | ||||||
| import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; | import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup; | ||||||
| import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; | import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult; | ||||||
| import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; | import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile; | ||||||
|  | import ch.ethz.seb.sebserver.gbl.util.Result; | ||||||
| import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordDynamicSqlSupport; | import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.LmsSetupRecordDynamicSqlSupport; | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.PaginationService; | import ch.ethz.seb.sebserver.webservice.servicelayer.PaginationService; | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService; | import ch.ethz.seb.sebserver.webservice.servicelayer.authorization.AuthorizationService; | ||||||
|  | @ -38,6 +39,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.bulkaction.BulkActionServic | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO; | import ch.ethz.seb.sebserver.webservice.servicelayer.dao.LmsSetupDAO; | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO; | import ch.ethz.seb.sebserver.webservice.servicelayer.dao.UserActivityLogDAO; | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; | import ch.ethz.seb.sebserver.webservice.servicelayer.lms.LmsAPIService; | ||||||
|  | import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.LmsSetupChangeEvent; | ||||||
| import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService; | import ch.ethz.seb.sebserver.webservice.servicelayer.validation.BeanValidationService; | ||||||
| 
 | 
 | ||||||
| @WebServiceProfile | @WebServiceProfile | ||||||
|  | @ -132,4 +134,10 @@ public class LmsSetupController extends ActivatableEntityController<LmsSetup, Lm | ||||||
|         return new LmsSetup(null, postParams); |         return new LmsSetup(null, postParams); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     @Override | ||||||
|  |     protected Result<LmsSetup> notifySaved(final LmsSetup entity) { | ||||||
|  |         this.applicationEventPublisher.publishEvent(new LmsSetupChangeEvent(entity)); | ||||||
|  |         return super.notifySaved(entity); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti