felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mccu...@apache.org
Subject svn commit: r810765 - in /felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin: ObrCleanRepo.java ObrUpdate.java
Date Thu, 03 Sep 2009 02:52:59 GMT
Author: mcculls
Date: Thu Sep  3 02:52:58 2009
New Revision: 810765

URL: http://svn.apache.org/viewvc?rev=810765&view=rev
Log:
FELIX-1461: make local repository updates a bit more atomic

Modified:
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrCleanRepo.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrCleanRepo.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrCleanRepo.java?rev=810765&r1=810764&r2=810765&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrCleanRepo.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrCleanRepo.java Thu
Sep  3 02:52:58 2009
@@ -20,7 +20,6 @@
 
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URI;
@@ -44,6 +43,7 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -268,13 +268,14 @@
 
         DOMSource input = new DOMSource( treeToBeWrite );
 
-        File fichier = new File( outputFilename );
+        File fichier = null;
         FileOutputStream flux = null;
         try
         {
+            fichier = File.createTempFile( "repository", ".xml" );
             flux = new FileOutputStream( fichier );
         }
-        catch ( FileNotFoundException e )
+        catch ( IOException e )
         {
             getLog().error( "Unable to write to file: " + fichier.getName() );
             throw new MojoExecutionException( "Unable to write to file: " + fichier.getName()
+ " : " + e.getMessage() );
@@ -294,6 +295,8 @@
         {
             flux.flush();
             flux.close();
+
+            FileUtils.rename( fichier, new File( outputFilename ) );
         }
         catch ( IOException e )
         {

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java?rev=810765&r1=810764&r2=810765&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrUpdate.java Thu Sep
 3 02:52:58 2009
@@ -20,7 +20,6 @@
 
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URI;
@@ -42,6 +41,7 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -477,18 +477,18 @@
 
         DOMSource input = new DOMSource( treeToBeWrite );
 
-        File fichier = new File( outputFilename );
-        fichier.getParentFile().mkdirs();
+        File fichier = null;
         FileOutputStream flux = null;
         try
         {
+            fichier = File.createTempFile( "repository", ".xml" );
             flux = new FileOutputStream( fichier );
         }
-        catch ( FileNotFoundException e )
+        catch ( IOException e )
         {
             m_logger.error( "Unable to write to file: " + fichier.getName() );
             e.printStackTrace();
-            throw new MojoExecutionException( "FileNotFoundException" );
+            throw new MojoExecutionException( "Unable to write to file: " + fichier.getName()
+ " : " + e.getMessage() );
         }
         Result output = new StreamResult( flux );
         try
@@ -505,6 +505,10 @@
         {
             flux.flush();
             flux.close();
+
+            File outputFile = new File( outputFilename );
+            outputFile.getParentFile().mkdirs();
+            FileUtils.rename( fichier, outputFile );
         }
         catch ( IOException e )
         {



Mime
View raw message