← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20930: Upgraded to staxwax 1.1.2. Replaced internal code for reading attribute values.

 

------------------------------------------------------------
revno: 20930
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-02 14:01:59 -0500
message:
  Upgraded to staxwax 1.1.2. Replaced internal code for reading attribute values.
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java
  dhis-2/pom.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-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java	2015-11-02 18:56:53 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultAdxDataService.java	2015-11-02 19:01:59 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -47,7 +45,6 @@
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
 import org.amplecode.staxwax.factory.XMLFactory;
@@ -211,7 +208,7 @@
 
         IdentifiableProperty dataElementIdScheme = importOptions.getDataElementIdScheme();
 
-        Map<String, String> groupAttributes = readAttributes( adxReader );
+        Map<String, String> groupAttributes = adxReader.readAttributes();
 
         if ( !groupAttributes.containsKey( AdxDataService.PERIOD ) )
         {
@@ -278,7 +275,7 @@
     private void parseADXDataValueToDxf( XMLReader adxReader, XMLStreamWriter dxfWriter, ImportOptions importOptions )
         throws XMLStreamException, AdxException
     {
-        Map<String, String> dvAttributes = readAttributes( adxReader );
+        Map<String, String> dvAttributes = adxReader.readAttributes();
         
         log.debug( "Processing data value: " + dvAttributes );
         
@@ -353,8 +350,8 @@
             
             if ( categoryCode == null || !XMLChar.isValidName( categoryCode ) )
             {
-                throw new AdxException( "Category code for " + category.getName() + " is missing or invalid: "
-                    + categoryCode );
+                throw new AdxException( "Category code for " + category.getName() + 
+                    " is missing or invalid: " + categoryCode );
             }
             
             categoryMap.put( category.getCode(), category );
@@ -377,7 +374,7 @@
         }
         catch ( CategoryComboMapException ex )
         {
-            log.info( "Failed to create catcomboMap from " + catcombo );
+            log.info( "Failed to create category combo map from: " + catcombo );
             throw new AdxException( ex.getMessage() );
         }
 
@@ -396,7 +393,7 @@
             
             if ( catAttribute == null )
             {
-                throw new AdxException( "Missing required attribute from catcombo: " + categoryCode );
+                throw new AdxException( "Missing required attribute from category combo: " + categoryCode );
             }
             
             compositeIdentifier += "\"" + catAttribute + "\"";
@@ -446,25 +443,4 @@
             
         log.debug( "DXF attributes: " + attributes );
     }
-
-    // TODO this should be part of staxwax library
-    protected Map<String, String> readAttributes( XMLReader staxWaxReader )
-    {
-        Map<String, String> attributes = new HashMap<>();
-
-        XMLStreamReader reader = staxWaxReader.getXmlStreamReader();
-
-        if ( reader.getEventType() != START_ELEMENT )
-        {
-            throw new IllegalArgumentException( "Trying to retrieve attributes from non START_ELEMENT node" );
-        }
-
-        // Read attributes
-        for ( int i = 0; i < reader.getAttributeCount(); i++ )
-        {
-            attributes.put( reader.getAttributeLocalName( i ), reader.getAttributeValue( i ) );
-        }
-
-        return attributes;
-    }
 }

=== modified file 'dhis-2/pom.xml'
--- dhis-2/pom.xml	2015-10-25 19:44:21 +0000
+++ dhis-2/pom.xml	2015-11-02 19:01:59 +0000
@@ -598,7 +598,7 @@
       <dependency>
         <groupId>org.amplecode</groupId>
         <artifactId>staxwax</artifactId>
-        <version>1.1.1</version>
+        <version>1.1.2</version>
       </dependency>
       <dependency>
         <groupId>com.lowagie</groupId>