]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1025] write more information out
authorBrett Porter <brett@apache.org>
Tue, 2 Dec 2008 00:37:27 +0000 (00:37 +0000)
committerBrett Porter <brett@apache.org>
Tue, 2 Dec 2008 00:37:27 +0000 (00:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@722312 13f79535-47bb-0310-9956-ffa450edef68

MRM-1025/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectBuildMetadata.java
MRM-1025/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectMetadata.java
MRM-1025/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java

index 57b9f4d0c17702dc33ba2b8d48aa224b5dd96848..650871c4c289d0faa5bb2e2dd0bca128ca4e6b1c 100644 (file)
@@ -1,5 +1,6 @@
 package org.apache.archiva.metadata.model;
 
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -42,4 +43,9 @@ public class ProjectBuildMetadata
     {
         this.artifacts.put( artifact.getId(), artifact );
     }
+
+    public Collection<ArtifactMetadata> getArtifacts()
+    {
+        return artifacts.values();
+    }
 }
index 783c91313958836a0edd26214c5fa9aaea02c7d2..107fd373cdd5c8a33bec2d3152de200dd7c689ed 100644 (file)
@@ -1,5 +1,6 @@
 package org.apache.archiva.metadata.model;
 
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -42,4 +43,9 @@ public class ProjectMetadata
     {
         this.builds.put( build.getId(), build );
     }
+
+    public Collection<ProjectBuildMetadata> getBuilds()
+    {
+        return builds.values();
+    }
 }
index 9241ad31664b2c0784582aace80043afb908b06c..c39f8f0e37b43884bb52fbf6d8ccc3bd7a94ccea 100644 (file)
@@ -25,6 +25,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Properties;
 
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.model.ProjectBuildMetadata;
 import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.commons.io.IOUtils;
@@ -32,8 +34,8 @@ import org.apache.commons.io.IOUtils;
 public class FileMetadataRepository
     implements MetadataRepository
 {
-    private File directory; 
-    
+    private File directory;
+
     public FileMetadataRepository( File directory )
     {
         this.directory = directory;
@@ -41,9 +43,16 @@ public class FileMetadataRepository
 
     public void update( ProjectMetadata project )
     {
+        // TODO: this is a more braindead implementation than we would normally expect, for prototyping purposes
         try
         {
-            store( project );
+            File projectDirectory = new File( this.directory, project.getId() );
+            store( project, projectDirectory );
+
+            for ( ProjectBuildMetadata build : project.getBuilds() )
+            {
+                store( build, projectDirectory );
+            }
         }
         catch ( IOException e )
         {
@@ -52,14 +61,33 @@ public class FileMetadataRepository
         }
     }
 
-    private void store( ProjectMetadata project )
+    private void store( ProjectBuildMetadata build, File directory )
         throws FileNotFoundException, IOException
     {
-        // TODO: this is a more braindead implementation than we would normally expect, for prototyping purposes
+        Properties properties = new Properties();
+        properties.setProperty( "id", build.getId() );
         
+        for ( ArtifactMetadata artifact : build.getArtifacts() )
+        {
+            properties.setProperty( artifact.getId() + ".updated", Long.toString( artifact.getUpdated().getTime() ) );
+            properties.setProperty( artifact.getId() + ".size", Long.toString( artifact.getSize() ) );
+        }
+        
+        writeProperties( properties, new File( directory, build.getId() ) );
+    }
+
+    private void store( ProjectMetadata project, File directory )
+        throws FileNotFoundException, IOException
+    {
+
         Properties properties = new Properties();
-        properties.put( "id", project.getId() );
-        File directory = new File( this.directory, project.getId() );
+        properties.setProperty( "id", project.getId() );
+        writeProperties( properties, directory );
+    }
+
+    private void writeProperties( Properties properties, File directory )
+        throws FileNotFoundException, IOException
+    {
         directory.mkdirs();
         FileOutputStream os = new FileOutputStream( new File( directory, "metadata.xml" ) );
         try