]> source.dussan.org Git - archiva.git/commitdiff
Cleaned up code so that we are always writing a zip file. Might be a good idea to...
authorJames William Dumay <jdumay@apache.org>
Thu, 18 Dec 2008 12:07:01 +0000 (12:07 +0000)
committerJames William Dumay <jdumay@apache.org>
Thu, 18 Dec 2008 12:07:01 +0000 (12:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-obr-repository@727703 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/pom.xml
archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/main/java/org/apache/archiva/consumers/OBRRepositoryConsumer.java
archiva-modules/archiva-base/archiva-consumers/archiva-obr-consumer/src/test/java/org/apache/archiva/consumers/OBRRepositoryConsumerTest.java

index 7798090ea0ffb855869c9a1ec42f24840c39f9e9..015bacc66e31f8a419311ae3c3955570adf8deda 100644 (file)
           <artifactId>plexus-spring</artifactId>
           <scope>test</scope>
         </dependency>
-        <dependency>
-           <groupId>ant</groupId>
-           <artifactId>ant</artifactId>
-           <version>1.6.1</version>
-        </dependency>
         <dependency>
             <groupId>org.osgi.impl.bundle.bindex</groupId>
             <artifactId>bindex</artifactId>
             <version>2.2</version>
         </dependency>
     </dependencies>
-</project>
\ No newline at end of file
+</project>
index 8994ae002b4f8add38cbb81b45c0d10cb089e6f3..f382b84eb18370db680d3692ce685fc4be60fafe 100644 (file)
@@ -35,6 +35,7 @@ import org.apache.maven.archiva.consumers.ConsumerException;
 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.codehaus.plexus.util.FileUtils;
 import org.osgi.impl.bundle.obr.resource.BundleInfo;
 import org.osgi.impl.bundle.obr.resource.RepositoryImpl;
 import org.osgi.impl.bundle.obr.resource.ResourceImpl;
@@ -120,21 +121,23 @@ public class OBRRepositoryConsumer
         pw.close();
         byte buffer[] = out.toByteArray();
         String name = "repository.xml";
-        FileOutputStream fout = new FileOutputStream(repositoryXml);
 
-        if (repositoryXml.getAbsolutePath().endsWith(".zip"))
-        {
-            ZipOutputStream zip = new ZipOutputStream(fout);
-            CRC32 checksum = new CRC32();
-            checksum.update(buffer);
-            ZipEntry ze = new ZipEntry(name);
-            ze.setSize(buffer.length);
-            ze.setCrc(checksum.getValue());
-            zip.putNextEntry(ze);
-            zip.write(buffer, 0, buffer.length);
-            zip.closeEntry();
-            zip.close();
-        }
+        //Write file out of place
+        File tmpFile = File.createTempFile("repository.zip", null);
+        FileOutputStream fout = new FileOutputStream(tmpFile);
+        ZipOutputStream zip = new ZipOutputStream(fout);
+        CRC32 checksum = new CRC32();
+        checksum.update(buffer);
+        ZipEntry ze = new ZipEntry(name);
+        ze.setSize(buffer.length);
+        ze.setCrc(checksum.getValue());
+        zip.putNextEntry(ze);
+        zip.write(buffer, 0, buffer.length);
+        zip.closeEntry();
+        zip.close();
         fout.close();
+
+        //Copy into place
+        FileUtils.copyFile(tmpFile, repositoryXml);
        }
 }
index f173cf917874539473cced970e020a1d64a4dbb6..225ea20bcf0e3c1f61871c91f850cf25ef06a603 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.consumers.ConsumerException;
 import org.osgi.impl.bundle.obr.resource.RepositoryImpl;
-import org.osgi.impl.bundle.obr.resource.ResourceImpl;
 
 /**
  *