maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r425044 - in /maven/repository-manager/trunk: maven-repository-core/src/test/maven-1.x-repository/ maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/ maven-repository-discovery/src/test/repository/
Date Mon, 24 Jul 2006 13:22:33 GMT
Author: brett
Date: Mon Jul 24 06:22:32 2006
New Revision: 425044

URL: http://svn.apache.org/viewvc?rev=425044&view=rev
Log:
[MNG-125] separate the timestamp for the metadata and the artifacts to ensure both get resolved

Modified:
    maven/repository-manager/trunk/maven-repository-core/src/test/maven-1.x-repository/  
(props changed)
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
    maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
    maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/   (props
changed)

Propchange: maven/repository-manager/trunk/maven-repository-core/src/test/maven-1.x-repository/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jul 24 06:22:32 2006
@@ -0,0 +1 @@
+maven-metadata.xml

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java?rev=425044&r1=425043&r2=425044&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractArtifactDiscoverer.java
Mon Jul 24 06:22:32 2006
@@ -18,13 +18,16 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import java.io.File;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Base class for artifact discoverers.
@@ -58,7 +61,8 @@
             throw new UnsupportedOperationException( "Only filesystem repositories are supported"
);
         }
 
-        long comparisonTimestamp = readComparisonTimestamp( repository, operation );
+        Xpp3Dom dom = getLastArtifactDiscoveryDom( readRepositoryMetadataDom( repository
) );
+        long comparisonTimestamp = readComparisonTimestamp( repository, operation, dom );
 
         // Note that last checked time is deliberately set to the start of the process so
that anything added
         // mid-discovery and missed by the scanner will get checked next time.
@@ -125,5 +129,21 @@
         }
 
         return artifact;
+    }
+
+    public void setLastCheckedTime( ArtifactRepository repository, String operation, Date
date )
+        throws IOException
+    {
+        // see notes in resetLastCheckedTime
+
+        File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+
+        Xpp3Dom dom = readDom( file );
+
+        String dateString = new SimpleDateFormat( DATE_FMT, Locale.US ).format( date );
+
+        setEntry( getLastArtifactDiscoveryDom( dom ), operation, dateString );
+
+        saveDom( file, dom );
     }
 }

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java?rev=425044&r1=425043&r2=425044&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
Mon Jul 24 06:22:32 2006
@@ -37,7 +37,6 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -142,11 +141,8 @@
         return excludedPaths.iterator();
     }
 
-    protected long readComparisonTimestamp( ArtifactRepository repository, String operation
)
+    protected long readComparisonTimestamp( ArtifactRepository repository, String operation,
Xpp3Dom dom )
     {
-        File file = new File( repository.getBasedir(), "maven-metadata.xml" );
-        Xpp3Dom dom = readDom( file );
-        dom = getLastDiscoveryDom( dom );
         Xpp3Dom entry = dom.getChild( operation );
         long comparisonTimestamp = 0;
         if ( entry != null )
@@ -194,13 +190,24 @@
         return dom;
     }
 
-    protected Xpp3Dom getLastDiscoveryDom( Xpp3Dom dom )
+    protected Xpp3Dom getLastArtifactDiscoveryDom( Xpp3Dom dom )
+    {
+        Xpp3Dom lastDiscoveryDom = dom.getChild( "lastArtifactDiscovery" );
+        if ( lastDiscoveryDom == null )
+        {
+            dom.addChild( new Xpp3Dom( "lastArtifactDiscovery" ) );
+            lastDiscoveryDom = dom.getChild( "lastArtifactDiscovery" );
+        }
+        return lastDiscoveryDom;
+    }
+
+    protected Xpp3Dom getLastMetadataDiscoveryDom( Xpp3Dom dom )
     {
-        Xpp3Dom lastDiscoveryDom = dom.getChild( "lastDiscovery" );
+        Xpp3Dom lastDiscoveryDom = dom.getChild( "lastMetadataDiscovery" );
         if ( lastDiscoveryDom == null )
         {
-            dom.addChild( new Xpp3Dom( "lastDiscovery" ) );
-            lastDiscoveryDom = dom.getChild( "lastDiscovery" );
+            dom.addChild( new Xpp3Dom( "lastMetadataDiscovery" ) );
+            lastDiscoveryDom = dom.getChild( "lastMetadataDiscovery" );
         }
         return lastDiscoveryDom;
     }
@@ -218,8 +225,26 @@
 
         Xpp3Dom dom = readDom( file );
 
-        Xpp3Dom lastDiscoveryDom = getLastDiscoveryDom( dom );
+        boolean changed = false;
 
+        if ( removeEntry( getLastArtifactDiscoveryDom( dom ), operation ) )
+        {
+            changed = true;
+        }
+
+        if ( removeEntry( getLastMetadataDiscoveryDom( dom ), operation ) )
+        {
+            changed = true;
+        }
+
+        if ( changed )
+        {
+            saveDom( file, dom );
+        }
+    }
+
+    private boolean removeEntry( Xpp3Dom lastDiscoveryDom, String operation )
+    {
         boolean changed = false;
 
         // do this in reverse so that removing doesn't affect counter
@@ -232,14 +257,10 @@
                 lastDiscoveryDom.removeChild( i );
             }
         }
-
-        if ( changed )
-        {
-            saveDom( file, dom );
-        }
+        return changed;
     }
 
-    private void saveDom( File file, Xpp3Dom dom )
+    protected void saveDom( File file, Xpp3Dom dom )
         throws IOException
     {
         FileWriter writer = new FileWriter( file );
@@ -255,25 +276,19 @@
         }
     }
 
-    public void setLastCheckedTime( ArtifactRepository repository, String operation, Date
date )
-        throws IOException
+    protected void setEntry( Xpp3Dom lastDiscoveryDom, String operation, String dateString
)
     {
-        // see notes in resetLastCheckedTime
-
-        File file = new File( repository.getBasedir(), "maven-metadata.xml" );
-
-        Xpp3Dom dom = readDom( file );
-
-        Xpp3Dom lastDiscoveryDom = getLastDiscoveryDom( dom );
-
         Xpp3Dom entry = lastDiscoveryDom.getChild( operation );
         if ( entry == null )
         {
             entry = new Xpp3Dom( operation );
             lastDiscoveryDom.addChild( entry );
         }
-        entry.setValue( new SimpleDateFormat( DATE_FMT, Locale.US ).format( date ) );
+        entry.setValue( dateString );
+    }
 
-        saveDom( file, dom );
+    protected Xpp3Dom readRepositoryMetadataDom( ArtifactRepository repository )
+    {
+        return readDom( new File( repository.getBasedir(), "maven-metadata.xml" ) );
     }
 }

Modified: maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java?rev=425044&r1=425043&r2=425044&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
(original)
+++ maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DefaultMetadataDiscoverer.java
Mon Jul 24 06:22:32 2006
@@ -25,6 +25,7 @@
 import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
 import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -34,11 +35,13 @@
 import java.io.Reader;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.StringTokenizer;
 
 /**
@@ -63,7 +66,8 @@
             throw new UnsupportedOperationException( "Only filesystem repositories are supported"
);
         }
 
-        long comparisonTimestamp = readComparisonTimestamp( repository, operation );
+        Xpp3Dom dom = getLastMetadataDiscoveryDom( readRepositoryMetadataDom( repository
) );
+        long comparisonTimestamp = readComparisonTimestamp( repository, operation, dom );
 
         // Note that last checked time is deliberately set to the start of the process so
that anything added
         // mid-discovery and missed by the scanner will get checked next time.
@@ -225,5 +229,21 @@
         }
 
         return metadata;
+    }
+
+    public void setLastCheckedTime( ArtifactRepository repository, String operation, Date
date )
+        throws IOException
+    {
+        // see notes in resetLastCheckedTime
+
+        File file = new File( repository.getBasedir(), "maven-metadata.xml" );
+
+        Xpp3Dom dom = readDom( file );
+
+        String dateString = new SimpleDateFormat( DATE_FMT, Locale.US ).format( date );
+
+        setEntry( getLastMetadataDiscoveryDom( dom ), operation, dateString );
+
+        saveDom( file, dom );
     }
 }

Propchange: maven/repository-manager/trunk/maven-repository-discovery/src/test/repository/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jul 24 06:22:32 2006
@@ -0,0 +1 @@
+maven-metadata.xml



Mime
View raw message