Index: archiva-modules/plugins/pom.xml
===================================================================
--- archiva-modules/plugins/pom.xml	(revision 956052)
+++ archiva-modules/plugins/pom.xml	(working copy)
@@ -35,6 +35,7 @@
     <!-- TODO: eventually not a core plugin, needs to be moved to a separate tree, with it's own Selenium tests -->
     <module>npanday-support</module>
     <module>maven1-repository</module>
+      <module>stage-repository-merge</module>
     <module>generic-metadata-support</module>
   </modules>
 </project>
\ No newline at end of file
Index: archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java
===================================================================
--- archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java	(revision 0)
+++ archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java	(revision 0)
@@ -0,0 +1,134 @@
+package org.apache.archiva.stagerepository.merge.repodetails;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.junit.Test;
+
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.easymock.MockControl;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class SourceArtifactsTest
+        extends PlexusInSpringTestCase
+{
+
+    private Logger log = LoggerFactory.getLogger(SourceArtifactsTest.class);
+
+    private MockControl metadataResolverControl;
+
+    private MetadataResolver metadataResolver;
+
+    private static final String TEST_REPO_ID = "internal";
+
+    private SourceAritfacts sourceArtifacts;
+
+
+    @Override
+    protected void setUp()
+            throws Exception
+    {
+        super.setUp();
+
+        sourceArtifacts = new SourceAritfacts();
+        sourceArtifacts.setRepoId(TEST_REPO_ID);
+        metadataResolverControl = MockControl.createControl(MetadataResolver.class);
+        metadataResolver = (MetadataResolver) metadataResolverControl.getMock();
+        sourceArtifacts.setMetadataResolver(metadataResolver);
+    }
+
+
+    @Test
+    public void testSourceArtifacts()
+    {
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getRootNamespaces(TEST_REPO_ID), getRootNameSpace());
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getNamespaces(TEST_REPO_ID, "org"), getNameSpace());
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getNamespaces(TEST_REPO_ID, "org" + "." + "apache"), getProject());
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getProjectVersions(TEST_REPO_ID, "org" + "." + "apache", "archiva"), getProjectVersions());
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getArtifacts(TEST_REPO_ID, "apache", "archiva", "1.6"), getArtiFactMetaData());
+
+        metadataResolverControl.expectAndReturn(metadataResolver.getArtifacts(TEST_REPO_ID, "apache", "archiva", "1.6"), getArtiFactMetaData());
+
+        metadataResolverControl.replay();
+
+        Collection<ArchivaArtifact> list = sourceArtifacts.getSourceArtifactList();
+        assertEquals(false, list.isEmpty());
+
+        ArrayList<ArtifactMetadata> metadataList = (ArrayList) sourceArtifacts.getSourceArtifactsMetaData(list.iterator().next());
+        assertEquals(2, metadataList.size());
+
+        metadataResolverControl.verify();
+
+    }
+
+    private Collection<String> getRootNameSpace()
+    {
+        List<String> artifactList = new ArrayList<String>();
+        artifactList.add("org");
+        return artifactList;
+    }
+
+    private Collection<String> getNameSpace()
+    {
+        List<String> namespace = new ArrayList<String>();
+        namespace.add("apache");
+        return namespace;
+    }
+
+    private Collection<String> getProject() {
+        List<String> namespace = new ArrayList<String>();
+        namespace.add("archiva");
+        return namespace;
+    }
+
+    private Collection<String> getProjectVersions()
+    {
+        List<String> versionList = new ArrayList<String>();
+        versionList.add("1.6");
+        return versionList;
+    }
+
+    private Collection<ArtifactMetadata> getArtiFactMetaData()
+    {
+        List<ArtifactMetadata> metaDataList = new ArrayList<ArtifactMetadata>();
+        ArtifactMetadata metaDataOne = new ArtifactMetadata();
+        ArtifactMetadata metaDataTwo = new ArtifactMetadata();
+        metaDataList.add(metaDataOne);
+        metaDataList.add(metaDataTwo);
+        return metaDataList;
+    }
+
+}
+
+

Property changes on: archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java
___________________________________________________________________
Added: svn:executable
   + *

Index: archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java
===================================================================
--- archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java	(revision 0)
+++ archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java	(revision 0)
@@ -0,0 +1,159 @@
+package org.apache.archiva.stagerepository.merge.repodetails;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+
+import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @plexus.component role="org.apache.archiva.repodetails.SourceAritfacts"
+ */
+
+public class SourceAritfacts
+{
+
+    /**
+     * @plexus.requirement
+     */
+
+    private MetadataResolver metadataResolver;
+
+    private ArrayList<String> rootNameSpacesList;
+
+    private ArrayList<String> gruopIdList;
+
+    private ArrayList<String> artifactsList;
+
+    private ArrayList<String> artifactsVersionsList;
+
+    private List<ArchivaArtifact> artifactsListWithDetails;
+
+    private String repoId;
+
+    private static final Logger log = LoggerFactory.getLogger(SourceAritfacts.class);
+
+    public String getRepoId()
+    {
+        return repoId;
+    }
+
+    public void setRepoId(String repoId)
+    {
+        this.repoId = repoId;
+    }
+
+    // this methos returns a ArtifactMetaData List.(i guess no harm due to hardcoding the Artifact type and version)
+    public Collection<ArtifactMetadata> getSourceArtifactsMetaData(ArchivaArtifact artifact)
+    {
+
+        return metadataResolver.getArtifacts(artifact.getRepositoryId(), artifact.getGroupId(), artifact.getArtifactId(),
+                artifact.getVersion());
+    }
+
+
+    public Collection<ArchivaArtifact> getSourceArtifactList()
+    {
+        artifactsListWithDetails = new ArrayList<ArchivaArtifact>();
+
+        process();
+
+        return artifactsListWithDetails;
+    }
+
+
+    public void setMetadataResolver(MetadataResolver metadataResolver)
+    {
+        this.metadataResolver = metadataResolver;
+    }
+
+    private void process() {
+        //this will get the root name spaces eg : org, com
+        rootNameSpacesList = (ArrayList<String>) metadataResolver.getRootNamespaces(repoId);
+
+        gruopIdList = new ArrayList<String>();
+
+        artifactsList = new ArrayList<String>();
+
+        //following iterates through the  root name spaces list and get the gruo id of relavet root name spaces.
+        for (String namespace : rootNameSpacesList)
+        {
+            //this will get the gruop id list of relavant name space . eg : org > archiva(gruop id)
+            gruopIdList = (ArrayList<String>) metadataResolver.getNamespaces(repoId, namespace);
+
+            // following will iterates through the particular gruop id 's
+            for (String gruopId : gruopIdList)
+            {
+                // parse the parameters "repoId" and "namespace + gruop id "to  artifacts list. eg : params = ("internal" , "org.archiva")
+                artifactsList = (ArrayList<String>) metadataResolver.getNamespaces(repoId, namespace + "." + gruopId);
+
+                for (String artifact : artifactsList)
+                {
+                    //iterates through the artifacts and get the available versions of a particular artifact
+                    artifactsVersionsList = (ArrayList<String>) metadataResolver.getProjectVersions(repoId, namespace + "." + gruopId, artifact);
+
+                    for (String version : artifactsVersionsList)
+                    {
+                        //assign gathered attributes Artifact object and add it in to the list
+                        artifactsListWithDetails.addAll(getArtifactMetadata(repoId, gruopId, artifact, version));
+
+                    }
+                }
+            }
+        }
+
+    }
+
+    private Collection<ArchivaArtifact> getArtifactMetadata(String repoId, String gruopId, String artifactId, String version)
+    {
+        MavenArtifactFacet facet = null;
+
+        List<ArchivaArtifact> artifactList = new ArrayList<ArchivaArtifact>();
+
+        ArrayList<ArtifactMetadata> artifactMetaDataList = (ArrayList<ArtifactMetadata>) metadataResolver.getArtifacts(repoId, gruopId, artifactId, version);
+
+
+        for (ArtifactMetadata artifactMetadata : artifactMetaDataList)
+        {
+
+            facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
+
+            if (facet != null)
+            {
+                artifactList.add(new ArchivaArtifact(gruopId, artifactId, version, facet.getClassifier(), facet.getType(), repoId));
+
+            } else
+            {
+                artifactList.add(new ArchivaArtifact(gruopId, artifactId, version, "", "jar", repoId));
+            }
+
+        }
+        return artifactList;
+    }
+}

Property changes on: archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java
___________________________________________________________________
Added: svn:executable
   + *

Index: archiva-modules/plugins/stage-repository-merge/pom.xml
===================================================================
--- archiva-modules/plugins/stage-repository-merge/pom.xml	(revision 0)
+++ archiva-modules/plugins/stage-repository-merge/pom.xml	(revision 0)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>plugins</artifactId>
+        <groupId>org.apache.archiva</groupId>
+        <version>1.4-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.archiva</groupId>
+    <artifactId>stage-repository-merge</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>stage-repository-merge</name>
+    <url>http://maven.apache.org</url>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.archiva</groupId>
+            <artifactId>metadata-repository-api</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.archiva</groupId>
+            <artifactId>maven2-repository</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.archiva</groupId>
+            <artifactId>archiva-model</artifactId>
+            <version>1.4-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl104-over-slf4j</artifactId>
+            <version>1.5.8</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-component-annotations</artifactId>
+            <version>1.0-beta-3.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.5.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.5.11</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.codehaus.plexus</groupId>
+                    <artifactId>plexus-component-metadata</artifactId>
+                    <version>1.0-beta-3.0.5</version>
+                    <executions>
+                        <execution>
+                            <id>process-classes</id>
+                            <goals>
+                                <goal>generate-metadata</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>process-test-classes</id>
+                            <goals>
+                                <goal>generate-test-metadata</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>

Property changes on: archiva-modules/plugins/stage-repository-merge/pom.xml
___________________________________________________________________
Added: svn:executable
   + *

