← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2068: Some improvement in logging/error handling

 

------------------------------------------------------------
revno: 2068
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2010-07-02 13:53:57 +0100
message:
  Some improvement in logging/error handling
  Modified dxf converter to parse dxf root element
  Fixed bug in resetting buffered stream
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportException.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryOptionComboConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/PeriodConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/zip/SingleStreamImporter.java
  dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java
  dhis-2/dhis-services/dhis-service-importexport/src/test/resources/transforms.xml


--
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-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java	2010-06-08 08:14:55 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/DefaultImportService.java	2010-07-02 12:53:57 +0000
@@ -123,8 +123,7 @@
 
             } catch ( Exception ex )
             {
-                log.info( ex );
-                throw new ImportException( "Failed to import data in zip package" );
+                throw new ImportException( "Failed to import data in zip package", ex );
             } finally
             {
                 if (tempFile != null) {
@@ -144,8 +143,7 @@
                     xmlDataStream = new BufferedInputStream( new GZIPInputStream( bufin ) );
                 } catch ( IOException ex )
                 {
-                    log.info( ex );
-                    throw new ImportException("Corrupt gzip stream");
+                    throw new ImportException("Corrupt gzip stream", ex);
                 }
             } else
             {
@@ -153,7 +151,7 @@
                 xmlDataStream = bufin;
             }
 
-            XMLReader dxfReader = preConverter.transform( xmlDataStream, params, state );
+            XMLReader dxfReader = preConverter.processStream( xmlDataStream, params, state );
 
             converter.read( dxfReader, params, state );
 

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportException.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportException.java	2010-06-04 17:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportException.java	2010-07-02 12:53:57 +0000
@@ -34,15 +34,23 @@
 public class ImportException extends Exception
 {
 
-    private String message;
+    private String message = null;
+
+    private Exception wrappedEx = null;
 
     public ImportException( String message )
     {
         this.message = message;
     }
 
+    public ImportException( String message, Exception ex )
+    {
+        this.message = message;
+        wrappedEx = ex;
+    }
+
     public String toString()
     {
-        return message;
+        return (wrappedEx==null) ? message : message + ": " + wrappedEx.toString();
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java	2010-06-04 17:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportParams.java	2010-07-02 12:53:57 +0000
@@ -36,11 +36,6 @@
 public class ImportParams
 {
     public static final String ATTRIBUTE_NAMESPACE = "xmlns";
-    public static final String ATTRIBUTE_MINOR_VERSION = "minorVersion";
-    public static final String ATTRIBUTE_EXPORTED = "exported";
-    public static final String NAMESPACE_10 = "http://dhis2.org/schema/dxf/1.0";;
-    public static final String MINOR_VERSION_10 = "1.0";
-    public static final String MINOR_VERSION_11 = "1.1";
     
     private ImportType type;
     

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java	2010-06-18 15:21:28 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java	2010-07-02 12:53:57 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import javax.xml.namespace.QName;
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
 import org.amplecode.staxwax.reader.XMLReader;
@@ -113,6 +114,7 @@
 import org.hisp.dhis.source.Source;
 import org.hisp.dhis.validation.ValidationRuleService;
 import org.springframework.beans.factory.annotation.Autowired;
+import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
 
 /**
  * DXFConverter class
@@ -124,6 +126,14 @@
  */
 public class DXFConverter 
 {
+
+    public static final String DXFROOT = "dxf";
+    public static final String ATTRIBUTE_MINOR_VERSION = "minorVersion";
+    public static final String ATTRIBUTE_EXPORTED = "exported";
+    public static final String NAMESPACE_10 = "http://dhis2.org/schema/dxf/1.0";;
+    public static final String MINOR_VERSION_10 = "1.0";
+    public static final String MINOR_VERSION_11 = "1.1";
+
     private final Log log = LogFactory.getLog( DXFConverter.class );
 
     // -------------------------------------------------------------------------
@@ -269,6 +279,17 @@
             log.info( "Deleted previewed objects" );
         }
 
+        
+        if (!reader.moveToStartElement( DXFROOT, DXFROOT)) {
+            throw new RuntimeException("Couldn't find dxf root element");
+        }
+        QName rootName = reader.getElementQName();
+
+        params.setNamespace( defaultIfEmpty( rootName.getNamespaceURI(), NAMESPACE_10 ) );
+        String version = reader.getAttributeValue( ATTRIBUTE_MINOR_VERSION  );
+        params.setMinorVersion( version != null ? version : MINOR_VERSION_10 );
+        log.debug( "Importing dxf1 minor version " + version );
+
         while ( reader.next() )
         {
             if ( reader.isStartElement( DataElementCategoryOptionConverter.COLLECTION_NAME ) )

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryOptionComboConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryOptionComboConverter.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementCategoryOptionComboConverter.java	2010-07-02 12:53:57 +0000
@@ -166,6 +166,7 @@
             reader.moveToStartElement( FIELD_NAME );
             String categoryComboName = reader.getElementValue();
 
+            log.debug( categoryComboName + ": " + categoryComboId + "-" + categoryOptionCombo.getId());
             // -----------------------------------------------------------------
             // Setting the persisted CategoryCombo on the CategoryOptionCombo
             // if not in preview

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java	2010-06-01 08:53:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java	2010-07-02 12:53:57 +0000
@@ -189,14 +189,22 @@
             final DataElementCategoryOptionCombo categoryOptionCombo = new DataElementCategoryOptionCombo();
             value.setOptionCombo( categoryOptionCombo );
             
+            log.debug( "Reading Datavalue");
             value.getDataElement().setId( dataElementMapping.get( Integer.parseInt( values.get( FIELD_DATAELEMENT ) ) ) );
+            log.debug( "id: " + value.getDataElement().getId());
             value.getPeriod().setId( periodMapping.get( Integer.parseInt( values.get( FIELD_PERIOD ) ) ) );
+            log.debug( "period: " + value.getPeriod().getId());
             value.getSource().setId( sourceMapping.get( Integer.parseInt( values.get( FIELD_SOURCE ) ) ) );
+            log.debug( "src: " + value.getSource().getId());
             value.setValue( values.get( FIELD_VALUE ) );
             value.setStoredBy( values.get( FIELD_STOREDBY ) );
             value.setTimestamp( DateUtils.getMediumDate( values.get( FIELD_TIMESTAMP ) ) );
             value.setComment( values.get( FIELD_COMMENT ) );
+            log.debug( "reading optioncombo ...");
             value.getOptionCombo().setId( categoryOptionComboMapping.get( Integer.parseInt( values.get( FIELD_CATEGORY_OPTION_COMBO ) ) ) );
+            log.debug( "optionCombo: " + value.getOptionCombo().getId());
+
+            log.debug( "Datavalue read");
             
             importObject( value, params );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java	2010-06-03 17:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java	2010-07-02 12:53:57 +0000
@@ -27,7 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.importexport.ImportParams.MINOR_VERSION_11;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.*;
 
 import java.util.ArrayList;
 import java.util.Collection;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/PeriodConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/PeriodConverter.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/PeriodConverter.java	2010-07-02 12:53:57 +0000
@@ -138,7 +138,9 @@
             period.getPeriodType().setId( periodTypeMapping.get( values.get( FIELD_PERIOD_TYPE ) ) );
             period.setStartDate( DateUtils.getMediumDate( values.get( FIELD_START_DATE ) ) );
             period.setEndDate( DateUtils.getMediumDate( values.get( FIELD_END_DATE ) ) );
-            
+
+            log.info( "Period: " + period.getId() + ' ' + ' ' + period.getPeriodType()
+                + ' ' + period.getStartDate() + ' ' + period.getEndDate());
             importObject( period, params );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java	2010-06-01 11:04:02 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/exporter/DefaultDXFExportService.java	2010-07-02 12:53:57 +0000
@@ -99,6 +99,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 
 import static org.hisp.dhis.importexport.ImportParams.*;
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.*;
+
 
 /**
  * @author Lars Helge Overland
@@ -108,7 +110,6 @@
     implements ExportService
 {
     private static final String ZIP_ENTRY_NAME = "Export.xml";
-    private static final String ROOT_NAME = "dxf";
         
     // -------------------------------------------------------------------------
     // Dependencies
@@ -245,7 +246,7 @@
             thread.setZipOutputStream( zipOut );
             thread.setParams( params );
             thread.setWriter( writer );
-            thread.setRootName( ROOT_NAME );
+            thread.setRootName( DXFROOT );
             thread.setRootProperties( rootProperties );
             
             thread.registerXMLConverter( new DataElementCategoryOptionConverter( categoryService ) );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java	2010-06-08 08:14:55 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/LocManagerXSLTLocator.java	2010-07-02 12:53:57 +0000
@@ -75,14 +75,12 @@
                 result = locationManager.getInputStream( "transform/" + transformerNode.getTextContent() );
             } else
             {
-                log.info( "xpath search returned no result - no stylsheet configured for " + identifier );
                 throw new ImportException( "No transformer configured for this format" );
             }
 
         } catch ( LocationManagerException ex )
         {
-            log.info( "File error locating transform:" + ex.getCause() );
-            throw new ImportException( "Missing transformer for this format" );
+            throw new ImportException( "Missing transformer for this format", ex );
         }
         return result;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java	2010-06-24 11:50:08 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XMLPreConverter.java	2010-07-02 12:53:57 +0000
@@ -52,22 +52,22 @@
 import org.hisp.dhis.common.ProcessState;
 import org.hisp.dhis.importexport.ImportException;
 import org.hisp.dhis.importexport.ImportParams;
-import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import static org.hisp.dhis.importexport.dxf.converter.DXFConverter.*;
+
 /**
  * GenericXMLConvertor transforms imported foreign XML to dxf.
  * 
  * @author bobj
  */
-@Component( "preConverter" )
+@Component("preConverter")
 public class XMLPreConverter
 {
+
     private final Log log = LogFactory.getLog( XMLPreConverter.class );
 
-    public static final String DXF_ROOT = "dxf";
-
     public static final int BUFFER_SIZE = 2000;
 
     public static final String TRANSFORMERS_CONFIG = "transform/transforms.xml";
@@ -83,7 +83,7 @@
 
     /**
      * This method is called for an anonymous xml stream ie. we don't yet know
-     * if or how to transform it
+     * if or how to processStream it
      * 
      * @param xmlDataStream
      * @param params
@@ -91,7 +91,7 @@
      * @return
      * @throws ImportException
      */
-    public XMLReader transform( InputStream xmlDataStream, ImportParams params, ProcessState state )
+    public XMLReader processStream( InputStream xmlDataStream, ImportParams params, ProcessState state )
         throws ImportException
     {
         XMLReader dxfReader = null;
@@ -107,11 +107,11 @@
 
         try
         {
+            // buffer enough space to read root elemen
+            bufin.mark( BUFFER_SIZE );
+
             XMLInputFactory2 factory = (XMLInputFactory2) XMLInputFactory.newInstance();
-            XMLStreamReader2 streamReader = (XMLStreamReader2) factory.createXMLStreamReader( xmlDataStream );
-
-            // buffer enough space to read root element
-            bufin.mark( BUFFER_SIZE );
+            XMLStreamReader2 streamReader = (XMLStreamReader2) factory.createXMLStreamReader( bufin );
 
             // move to document root
             streamReader.nextTag();
@@ -123,32 +123,25 @@
                 String value = streamReader.getAttributeValue( i );
                 attributes.put( attribute, value );
             }
-            
+
             bufin.reset();
 
+            // recreate stream reader to reclaim root element
+            streamReader = (XMLStreamReader2) factory.createXMLStreamReader( bufin );
+
+
             log.info( "Importing " + rootName.toString() );
 
             // first test if its a dxf stream
-            if ( rootName.getLocalPart().equals( DXF_ROOT ) )
+            if ( rootName.getLocalPart().equals( DXFROOT ) )
             {
                 // Native DXF stream - no transform required
 
-                // -----------------------------------------------------------------
-                // Retrieve namespace and minor version from root element and
-                // set on
-                // import params. Use default if not found.
-                // -----------------------------------------------------------------
-
-                params.setNamespace( defaultIfEmpty( rootName.getNamespaceURI(), ImportParams.NAMESPACE_10 ) );
-                String version = attributes.get( new QName( ImportParams.ATTRIBUTE_MINOR_VERSION ) );
-                params.setMinorVersion( version != null ? version : ImportParams.MINOR_VERSION_10 );
-
-                log.info( "Using DXF namespace '" + params.getNamespace() + "' version '" + params.getMinorVersion() + "'" );
-
-                // no transform required
+                log.info( "Importing dxf native stream" );
+
+                // no processStream required
                 dxfReader = XMLFactory.getXMLReader( streamReader );
-            }
-            else
+            } else
             {
                 // use the stringified form of the qname as an id
                 xsltIdentifierTag = rootName.toString();
@@ -156,13 +149,11 @@
 
                 dxfReader = this.transform( streamReader, params, state, xsltParams, xsltIdentifierTag );
             }
-        }
-        catch ( Exception ex )
+        } catch ( Exception ex )
         {
-            log.info( ex );
-            throw new ImportException( "Failed to transform xml stream" );
+            throw new ImportException( "Failed to transform xml stream", ex );
         }
-        
+
         return dxfReader;
     }
 
@@ -174,33 +165,40 @@
      * @param xsltParams
      * @param xsltTag
      * @return
-     * @throws Exception
+     * @throws ImportException
      */
     public DefaultXMLEventReader transform( XMLStreamReader2 streamReader, ImportParams params, ProcessState state,
-        Map<String, String> xsltParams, String xsltTag )
-        throws Exception
+        Map<String, String> xsltParams, String xsltTag ) throws ImportException
     {
         DefaultXMLEventReader dxfReader;
         InputStream sheetStream = xsltLocator.getTransformerByTag( xsltTag );
         Source sheet = new StreamSource( sheetStream );
-        TransformerTask tt = new TransformerTask( sheet, xsltParams );
-
-        Source source = new StAXSource( streamReader );
-
-        XMLPipe pipe = new XMLPipe(); // Make a pipe to capture output of transform
-        XMLEventWriter pipeinput = pipe.getInput();
-        XMLEventReader2 pipeoutput = pipe.getOutput();
-
-        StAXResult result = new StAXResult( pipeinput ); // Set result of transform to input of pipe
-        // tt.transform( source, result, resolver );
-        tt.transform( source, result, null );
-        log.info( "Transform successful" );
-
-        // Set dxfReader to output of pipe
-        dxfReader = new DefaultXMLEventReader( (XMLEventReader2) pipeoutput );
-
-        streamReader.close();
+
+        try
+        {
+            TransformerTask tt = new TransformerTask( sheet, xsltParams );
+
+
+            Source source = new StAXSource( streamReader );
+
+            XMLPipe pipe = new XMLPipe(); // Make a pipe to capture output of processStream
+            XMLEventWriter pipeinput = pipe.getInput();
+            XMLEventReader2 pipeoutput = pipe.getOutput();
+
+            StAXResult result = new StAXResult( pipeinput ); // Set result of processStream to input of pipe
+            // tt.processStream( source, result, resolver );
+            tt.transform( source, result, null );
+            log.info( "Transform successful" );
+
+            // Set dxfReader to output of pipe
+            dxfReader = new DefaultXMLEventReader( (XMLEventReader2) pipeoutput );
+
+            streamReader.close();
+        } catch ( Exception ex )
+        {
+            throw new ImportException( "Failed to transform stream", ex );
+        }
 
         return dxfReader;
     }
-}
\ No newline at end of file
+}

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java	2010-06-23 17:50:25 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/xml/XSLTLocator.java	2010-07-02 12:53:57 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.io.InputStream;
+import org.hisp.dhis.importexport.ImportException;
 
 /**
  * 
@@ -45,5 +46,5 @@
      * 
      */
     public InputStream getTransformerByTag( String identifier )
-        throws Exception;
+        throws ImportException;
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/zip/SingleStreamImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/zip/SingleStreamImporter.java	2010-06-19 15:32:24 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/zip/SingleStreamImporter.java	2010-07-02 12:53:57 +0000
@@ -63,7 +63,7 @@
     @Override
     public void importData( ImportParams params, ProcessState state, ZipFile zipFile ) throws Exception
     {
-        XMLReader dxfReader = preConverter.transform( getXMLStream(zipFile), params, state);
+        XMLReader dxfReader = preConverter.processStream( getXMLStream(zipFile), params, state);
         converter.read( dxfReader, params, state );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java	2010-06-04 17:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/java/org/hisp/dhis/importexport/dxf/DXFImportServiceTest.java	2010-07-02 12:53:57 +0000
@@ -121,22 +121,28 @@
 
     private InputStream inputStreamH;
 
-    private InputStream inputStreamSDMX;
-
     private InputStream inputStreamTransforms;
 
     private InputStream inputStreamSimpleXsl;
 
     private InputStream inputStreamExcelx;
 
+    private InputStream inputStreamSdmx;
+
     private InputStream inputStreamXL2DXF;
 
+    private InputStream inputStreamSdmxCross2DXF;
+
     private final static String TRANSFORMS = "transforms.xml";
 
     private final static String SIMPLEXSL = "changeroot.xsl";
 
     private final static String XL2DXF = "xl2dxf.xsl";
 
+    private final static String SDMXCROSS2DXF = "cross2dxf.xsl";
+
+    private final static String METADATA = "ExportMetaData.xml";
+
     private ImportObjectService importObjectService;
 
     private ImportDataValueService importDataValueService;
@@ -163,12 +169,13 @@
         inputStreamF = classLoader.getResourceAsStream( "dxfF.zip" );
         inputStreamG = classLoader.getResourceAsStream( "dxfG.zip" );
         inputStreamH = classLoader.getResourceAsStream( "changeroot.xml" );
-        inputStreamSDMX = classLoader.getResourceAsStream( "formattedCSDS2.xml" );
         inputStreamExcelx = classLoader.getResourceAsStream( "orgunits.xlsx" );
+        inputStreamSdmx = classLoader.getResourceAsStream( "sdmx_cross.zip" );
 
         inputStreamTransforms = classLoader.getResourceAsStream( TRANSFORMS );
         inputStreamSimpleXsl = classLoader.getResourceAsStream( SIMPLEXSL );
         inputStreamXL2DXF = classLoader.getResourceAsStream( XL2DXF );
+        inputStreamSdmxCross2DXF = classLoader.getResourceAsStream( SDMXCROSS2DXF );
 
         importService = (ImportService) getBean( "org.hisp.dhis.importexport.ImportService" );
 
@@ -206,15 +213,21 @@
             OutputStream transforms = null;
             OutputStream simplexsl = null;
             OutputStream xl2dxf = null;
+            OutputStream cross2dxf = null;
             String transformPath = extDir.getPath() + "/transform";
+            String metadataPath = extDir.getPath() + "/metadata";
             File transformDir = new File( transformPath );
+            File metadataDir = new File( metadataPath );
             transformDir.mkdir();
+            metadataDir.mkdir();
             transforms = new FileOutputStream( transformPath + "/" + TRANSFORMS );
             simplexsl = new FileOutputStream( transformPath + "/" + SIMPLEXSL );
             xl2dxf = new FileOutputStream( transformPath + "/" + XL2DXF );
+            cross2dxf = new FileOutputStream( transformPath + "/" + SDMXCROSS2DXF );
             copy( inputStreamTransforms, transforms );
             copy( inputStreamSimpleXsl, simplexsl );
             copy( inputStreamXL2DXF, xl2dxf );
+            copy( inputStreamSdmxCross2DXF, cross2dxf );
             transforms.close();
             simplexsl.close();
         }
@@ -234,13 +247,12 @@
         inputStreamE.close();
         inputStreamF.close();
         inputStreamH.close();
-        inputStreamSDMX.close();
-
+        inputStreamSdmx.close();
         inputStreamTransforms.close();
         inputStreamSimpleXsl.close();
 
         // clean up the mess ...
-        removeExternalTestDir();
+        //removeExternalTestDir();
     }
 
     @Override
@@ -280,13 +292,9 @@
     {
         ImportParams importParams = ImportExportUtils.getImportParams( ImportStrategy.NEW_AND_UPDATES, false, false, false );
 
-        importService.importData( importParams, inputStreamSDMX );
-
-        assertEquals( dataElementService.getAllDataElements().size(), 1546 );
-
-        assertEquals( organisationUnitService.getAllOrganisationUnits().size(), 1 );
-
-        assertEquals( dataValueService.getAllDataValues().size(), 64 );
+        importService.importData( importParams, inputStreamSdmx );
+
+        assertEquals( dataValueService.getAllDataValues().size(), 20 );
     }
 
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/test/resources/transforms.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/test/resources/transforms.xml	2010-06-08 08:14:55 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/test/resources/transforms.xml	2010-07-02 12:53:57 +0000
@@ -9,7 +9,7 @@
         <description>Excel template import</description>
     </transform>
     <transform tag="SDMX_CSD">
-        <xslt>sdmx_csd2dxf.xsl</xslt>
+        <xslt>cross2dxf.xsl</xslt>
         <description>SDMX-HD Cross Sectional Data Import</description>
     </transform>
 </transforms>