From 057268bd56cbfb07ffbd089f8595140862c67d46 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Mon, 12 Sep 2005 17:06:59 +0000 Subject: [PATCH] fix metadata parsing in mboot git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280372 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/download/RepositoryMetadata.java | 107 ++++++++---------- 1 file changed, 49 insertions(+), 58 deletions(-) diff --git a/maven-mboot2/src/main/java/download/RepositoryMetadata.java b/maven-mboot2/src/main/java/download/RepositoryMetadata.java index 4ef634be8d..90be3e6586 100644 --- a/maven-mboot2/src/main/java/download/RepositoryMetadata.java +++ b/maven-mboot2/src/main/java/download/RepositoryMetadata.java @@ -196,53 +196,13 @@ public class RepositoryMetadata { if ( insideVersioning ) { - if ( insideSnapshot ) + if ( "snapshot".equals( rawName ) ) { - if ( "buildNumber".equals( rawName ) ) - { - try - { - metadata.setSnapshotBuildNumber( Integer.valueOf( getBodyText() ).intValue() ); - } - catch ( NumberFormatException e ) - { - // Ignore - } - } - else if ( "timestamp".equals( rawName ) ) - { - metadata.setSnapshotTimestamp( getBodyText() ); - } - else if ( "localCopy".equals( rawName ) ) - { - metadata.setLocalCopy( Boolean.valueOf( getBodyText() ).booleanValue() ); - } + insideSnapshot = true; } - else if ( insideVersions ) + else if ( "versions".equals( rawName ) ) { - if ( "version".equals( rawName ) ) - { - metadata.addVersion( getBodyText() ); - } - } - else - { - if ( "snapshot".equals( rawName ) ) - { - insideSnapshot = true; - } - else if ( "versions".equals( rawName ) ) - { - insideVersions = true; - } - else if ( "latest".equals( rawName ) ) - { - metadata.setLatestVersion( getBodyText() ); - } - else if ( "release".equals( rawName ) ) - { - metadata.setReleaseVersion( getBodyText() ); - } + insideVersions = true; } } else @@ -252,18 +212,6 @@ public class RepositoryMetadata { insideVersioning = true; } - else if ( "groupId".equals( rawName ) ) - { - metadata.setGroupId( getBodyText() ); - } - else if ( "artifactId".equals( rawName ) ) - { - metadata.setArtifactId( getBodyText() ); - } - else if ( "version".equals( rawName ) ) - { - metadata.setVersion( getBodyText() ); - } } } @@ -286,14 +234,57 @@ public class RepositoryMetadata { insideVersioning = false; } - if ( "snapshot".equals( rawName ) ) + else if ( insideSnapshot && "snapshot".equals( rawName ) ) { + if ( "buildNumber".equals( rawName ) ) + { + try + { + metadata.setSnapshotBuildNumber( Integer.valueOf( getBodyText() ).intValue() ); + } + catch ( NumberFormatException e ) + { + // Ignore + } + } + else if ( "timestamp".equals( rawName ) ) + { + metadata.setSnapshotTimestamp( getBodyText() ); + } + else if ( "localCopy".equals( rawName ) ) + { + metadata.setLocalCopy( Boolean.valueOf( getBodyText() ).booleanValue() ); + } insideSnapshot = false; } - if ( "versions".equals( rawName ) ) + else if ( insideVersions && "versions".equals( rawName ) ) { + if ( "version".equals( rawName ) ) + { + metadata.addVersion( getBodyText() ); + } insideVersions = false; } + else if ( "latest".equals( rawName ) ) + { + metadata.setLatestVersion( getBodyText() ); + } + else if ( "release".equals( rawName ) ) + { + metadata.setReleaseVersion( getBodyText() ); + } + } + else if ( "groupId".equals( rawName ) ) + { + metadata.setGroupId( getBodyText() ); + } + else if ( "artifactId".equals( rawName ) ) + { + metadata.setArtifactId( getBodyText() ); + } + else if ( "version".equals( rawName ) ) + { + metadata.setVersion( getBodyText() ); } bodyText = new StringBuffer(); }