------------------------------------------------------------ revno: 17542 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Wed 2014-11-19 21:06:13 +0100 message: Event import, fixed bug. Removed guava cache for now. Guava caches do not like null values and throw exceptions for nulls. The cache was used for the outer program on events object, which is not required, and a null is hence valid, causing valid events to crash. The catch-all exceptions solution discriminating between bulk and single event import is also not good since it hides real exceptions. modified: dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JacksonEventService.java
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-11-15 13:56:50 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-11-19 20:06:13 +0000 @@ -40,9 +40,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -88,8 +85,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; /** * @author Morten Olav Hansen <morte...@gmail.com> @@ -211,9 +206,9 @@ @Override public ImportSummary addEvent( Event event, ImportOptions importOptions ) { - Program program = getProgram( event.getProgram() ); + Program program = programService.getProgram( event.getProgram() ); ProgramInstance programInstance; - ProgramStage programStage = getProgramStage( event.getProgramStage() ); + ProgramStage programStage = programStageService.getProgramStage( event.getProgramStage() ); ProgramStageInstance programStageInstance = null; if ( importOptions == null ) @@ -982,35 +977,4 @@ return organisationUnit; } - - private static Cache<String, Program> programCache = CacheBuilder.newBuilder() - .expireAfterAccess( 30, TimeUnit.SECONDS ) - .initialCapacity( 10 ) - .maximumSize( 50 ) - .build(); - - private Program getProgram( final String id ) - { - try - { - return programCache.get( id, new Callable<Program>() - { - @Override - public Program call() throws Exception - { - return programService.getProgram( id ); - } - } ); - } - catch ( ExecutionException ignored ) - { - } - - return null; - } - - private ProgramStage getProgramStage( String id ) - { - return programStageService.getProgramStage( id ); - } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JacksonEventService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JacksonEventService.java 2014-10-19 08:42:32 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JacksonEventService.java 2014-11-19 20:06:13 +0000 @@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dxf2.importsummary.ImportSummaries; @@ -38,6 +39,7 @@ import org.hisp.dhis.dxf2.metadata.ImportOptions; import org.hisp.dhis.system.timer.SystemTimer; import org.hisp.dhis.system.timer.Timer; +import org.hisp.dhis.system.util.DebugUtils; import org.hisp.dhis.scheduling.TaskId; import org.hisp.dhis.system.notification.NotificationLevel; import org.springframework.transaction.annotation.Transactional; @@ -191,6 +193,8 @@ } catch ( Exception ex ) { + log.debug( ex ); + Event event = fromJson( input, Event.class ); importSummaries.addImportSummary( addEvent( event, importOptions ) ); }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp