]> source.dussan.org Git - archiva.git/commitdiff
dependency tree with aether move beans to a separate new module to be able to reuse...
authorOlivier Lamy <olamy@apache.org>
Sat, 4 Aug 2012 06:56:52 +0000 (06:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 4 Aug 2012 06:56:52 +0000 (06:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1369269 13f79535-47bb-0310-9956-ffa450edef68

31 files changed:
archiva-modules/archiva-base/archiva-maven2-model/pom.xml [new file with mode: 0644]
archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/Artifact.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/TreeEntry.java [new file with mode: 0644]
archiva-modules/archiva-base/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java [deleted file]
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactTransferRequest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/TreeEntry.java [deleted file]
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/TreeDependencyNodeVisitor.java [deleted file]
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java
archiva-modules/plugins/maven2-repository/pom.xml
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java [new file with mode: 0644]
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java
pom.xml

diff --git a/archiva-modules/archiva-base/archiva-maven2-model/pom.xml b/archiva-modules/archiva-base/archiva-maven2-model/pom.xml
new file mode 100644 (file)
index 0000000..aa24b0b
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  ~ Licensed to the Apache Software Foundation (ASF) under one\r
+  ~ or more contributor license agreements.  See the NOTICE file\r
+  ~ distributed with this work for additional information\r
+  ~ regarding copyright ownership.  The ASF licenses this file\r
+  ~ to you under the Apache License, Version 2.0 (the\r
+  ~ "License"); you may not use this file except in compliance\r
+  ~ with the License.  You may obtain a copy of the License at\r
+  ~\r
+  ~   http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing,\r
+  ~ software distributed under the License is distributed on an\r
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
+  ~ KIND, either express or implied.  See the License for the\r
+  ~ specific language governing permissions and limitations\r
+  ~ under the License.\r
+  -->\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+  <modelVersion>4.0.0</modelVersion>\r
+  <parent>\r
+    <groupId>org.apache.archiva</groupId>\r
+    <artifactId>archiva-base</artifactId>\r
+    <version>1.4-M3-SNAPSHOT</version>\r
+  </parent>\r
+\r
+  <artifactId>archiva-maven2-model</artifactId>\r
+  <version>1.4-M3-SNAPSHOT</version>\r
+  <packaging>bundle</packaging>\r
+\r
+  <name>Archiva Base :: Maven 2 Model</name>\r
+\r
+  <dependencies>\r
+    <dependency>\r
+      <groupId>org.codehaus.jackson</groupId>\r
+      <artifactId>jackson-core-asl</artifactId>\r
+    </dependency>\r
+\r
+  </dependencies>\r
+\r
+  <build>\r
+    <plugins>\r
+      <plugin>\r
+        <groupId>org.apache.felix</groupId>\r
+        <artifactId>maven-bundle-plugin</artifactId>\r
+        <configuration>\r
+          <instructions>\r
+            <Bundle-SymbolicName>org.apache.archiva.maven2.model</Bundle-SymbolicName>\r
+            <Bundle-Version>${project.version}</Bundle-Version>\r
+            <Import-Package>\r
+              javax.xml.bind.annotation,\r
+              org.codehaus.jackson.annotate,\r
+            </Import-Package>\r
+            <Export-Package>\r
+              org.apache.archiva.maven2.model*;version=${project.version}\r
+            </Export-Package>\r
+          </instructions>\r
+        </configuration>\r
+      </plugin>\r
+    </plugins>\r
+  </build>\r
+\r
+</project>\r
diff --git a/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/Artifact.java b/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/Artifact.java
new file mode 100644 (file)
index 0000000..cf010b3
--- /dev/null
@@ -0,0 +1,659 @@
+package org.apache.archiva.maven2.model;
+
+/*
+ * 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 javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement( name = "artifact" )
+public class Artifact
+    implements Serializable
+{
+    // The (optional) context for this result.
+    private String context;
+
+    // Basic hit, direct to non-artifact resource.
+    private String url;
+
+    // Advanced hit, reference to groupId.
+    private String groupId;
+
+    //  Advanced hit, reference to artifactId.
+    private String artifactId;
+
+    private String repositoryId;
+
+    private String version;
+
+    /**
+     * Plugin goal prefix (only if packaging is "maven-plugin")
+     */
+    private String prefix;
+
+    /**
+     * Plugin goals (only if packaging is "maven-plugin")
+     */
+    private List<String> goals;
+
+    /**
+     * contains osgi metadata Bundle-Version if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleVersion;
+
+    /**
+     * contains osgi metadata Bundle-SymbolicName if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleSymbolicName;
+
+    /**
+     * contains osgi metadata Export-Package if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleExportPackage;
+
+    /**
+     * contains osgi metadata Export-Service if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleExportService;
+
+    /**
+     * contains osgi metadata Bundle-Description if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleDescription;
+
+    /**
+     * contains osgi metadata Bundle-Name if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleName;
+
+    /**
+     * contains osgi metadata Bundle-License if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleLicense;
+
+    /**
+     * contains osgi metadata Bundle-DocURL if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleDocUrl;
+
+    /**
+     * contains osgi metadata Import-Package if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleImportPackage;
+
+    /**
+     * contains osgi metadata Require-Bundle if available
+     *
+     * @since 1.4-M1
+     */
+    private String bundleRequireBundle;
+
+    private String classifier;
+
+    private String packaging;
+
+    /**
+     * file extension of the artifact
+     *
+     * @since 1.4-M2
+     */
+    private String fileExtension;
+
+    /**
+     * human readable size : not available for all services
+     *
+     * @since 1.4-M3
+     */
+    private String size;
+
+    /**
+     * @since 1.4-M3
+     */
+    private String type;
+
+
+    /**
+     * @since 1.4-M3
+     */
+    private String path;
+
+    /**
+     * concat of artifactId+'-'+version+'.'+type
+     *
+     * @since 1.4-M3
+     */
+    private String id;
+
+    /**
+     * @since 1.4-M3
+     */
+    private String scope;
+
+
+    public Artifact()
+    {
+        // no op
+    }
+
+    public Artifact( String groupId, String artifactId, String version )
+    {
+        this.artifactId = artifactId;
+        this.groupId = groupId;
+        this.version = version;
+    }
+
+    /**
+     * @since 1.4-M3
+     */
+    public Artifact( String groupId, String artifactId, String version, String scope )
+    {
+        this( groupId, artifactId, version );
+        this.scope = scope;
+    }
+
+    /**
+     * @since 1.4-M3
+     */
+    public Artifact( String groupId, String artifactId, String version, String scope, String classifier )
+    {
+        this( groupId, artifactId, version );
+        this.scope = scope;
+        this.classifier = classifier;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public String getRepositoryId()
+    {
+        return repositoryId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public void setRepositoryId( String repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+
+    public String getContext()
+    {
+        return context;
+    }
+
+    public void setContext( String context )
+    {
+        this.context = context;
+    }
+
+    public String getUrl()
+    {
+        return url;
+    }
+
+    public void setUrl( String url )
+    {
+        this.url = url;
+    }
+
+    public String getPrefix()
+    {
+        return prefix;
+    }
+
+    public void setPrefix( String prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    public List<String> getGoals()
+    {
+        return goals;
+    }
+
+    public void setGoals( List<String> goals )
+    {
+        this.goals = goals;
+    }
+
+    public String getBundleVersion()
+    {
+        return bundleVersion;
+    }
+
+    public void setBundleVersion( String bundleVersion )
+    {
+        this.bundleVersion = bundleVersion;
+    }
+
+    public String getBundleSymbolicName()
+    {
+        return bundleSymbolicName;
+    }
+
+    public void setBundleSymbolicName( String bundleSymbolicName )
+    {
+        this.bundleSymbolicName = bundleSymbolicName;
+    }
+
+    public String getBundleExportPackage()
+    {
+        return bundleExportPackage;
+    }
+
+    public void setBundleExportPackage( String bundleExportPackage )
+    {
+        this.bundleExportPackage = bundleExportPackage;
+    }
+
+    public String getBundleExportService()
+    {
+        return bundleExportService;
+    }
+
+    public void setBundleExportService( String bundleExportService )
+    {
+        this.bundleExportService = bundleExportService;
+    }
+
+    public String getBundleDescription()
+    {
+        return bundleDescription;
+    }
+
+    public void setBundleDescription( String bundleDescription )
+    {
+        this.bundleDescription = bundleDescription;
+    }
+
+    public String getBundleName()
+    {
+        return bundleName;
+    }
+
+    public void setBundleName( String bundleName )
+    {
+        this.bundleName = bundleName;
+    }
+
+    public String getBundleLicense()
+    {
+        return bundleLicense;
+    }
+
+    public void setBundleLicense( String bundleLicense )
+    {
+        this.bundleLicense = bundleLicense;
+    }
+
+    public String getBundleDocUrl()
+    {
+        return bundleDocUrl;
+    }
+
+    public void setBundleDocUrl( String bundleDocUrl )
+    {
+        this.bundleDocUrl = bundleDocUrl;
+    }
+
+    public String getBundleImportPackage()
+    {
+        return bundleImportPackage;
+    }
+
+    public void setBundleImportPackage( String bundleImportPackage )
+    {
+        this.bundleImportPackage = bundleImportPackage;
+    }
+
+    public String getBundleRequireBundle()
+    {
+        return bundleRequireBundle;
+    }
+
+    public void setBundleRequireBundle( String bundleRequireBundle )
+    {
+        this.bundleRequireBundle = bundleRequireBundle;
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public void setClassifier( String classifier )
+    {
+        this.classifier = classifier;
+    }
+
+
+    public String getPackaging()
+    {
+        return packaging;
+    }
+
+    public void setPackaging( String packaging )
+    {
+        this.packaging = packaging;
+    }
+
+    public String getFileExtension()
+    {
+        return fileExtension;
+    }
+
+    public void setFileExtension( String fileExtension )
+    {
+        this.fileExtension = fileExtension;
+    }
+
+    public String getSize()
+    {
+        return size;
+    }
+
+    public void setSize( String size )
+    {
+        this.size = size;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath( String path )
+    {
+        this.path = path;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+
+    public String getScope()
+    {
+        return scope;
+    }
+
+    public void setScope( String scope )
+    {
+        this.scope = scope;
+    }
+
+    @Override
+    public String toString()
+    {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "Artifact" );
+        sb.append( "{context='" ).append( context ).append( '\'' );
+        sb.append( ", url='" ).append( url ).append( '\'' );
+        sb.append( ", groupId='" ).append( groupId ).append( '\'' );
+        sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
+        sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
+        sb.append( ", version='" ).append( version ).append( '\'' );
+        sb.append( ", prefix='" ).append( prefix ).append( '\'' );
+        sb.append( ", goals=" ).append( goals );
+        sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
+        sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
+        sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
+        sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
+        sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
+        sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
+        sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
+        sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
+        sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
+        sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
+        sb.append( ", classifier='" ).append( classifier ).append( '\'' );
+        sb.append( ", packaging='" ).append( packaging ).append( '\'' );
+        sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
+        sb.append( ", size='" ).append( size ).append( '\'' );
+        sb.append( ", type='" ).append( type ).append( '\'' );
+        sb.append( ", path='" ).append( path ).append( '\'' );
+        sb.append( ", id='" ).append( id ).append( '\'' );
+        sb.append( '}' );
+        return sb.toString();
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( !( o instanceof Artifact ) )
+        {
+            return false;
+        }
+
+        Artifact artifact = (Artifact) o;
+
+        if ( !artifactId.equals( artifact.artifactId ) )
+        {
+            return false;
+        }
+        if ( bundleDescription != null
+            ? !bundleDescription.equals( artifact.bundleDescription )
+            : artifact.bundleDescription != null )
+        {
+            return false;
+        }
+        if ( bundleDocUrl != null ? !bundleDocUrl.equals( artifact.bundleDocUrl ) : artifact.bundleDocUrl != null )
+        {
+            return false;
+        }
+        if ( bundleExportPackage != null
+            ? !bundleExportPackage.equals( artifact.bundleExportPackage )
+            : artifact.bundleExportPackage != null )
+        {
+            return false;
+        }
+        if ( bundleExportService != null
+            ? !bundleExportService.equals( artifact.bundleExportService )
+            : artifact.bundleExportService != null )
+        {
+            return false;
+        }
+        if ( bundleImportPackage != null
+            ? !bundleImportPackage.equals( artifact.bundleImportPackage )
+            : artifact.bundleImportPackage != null )
+        {
+            return false;
+        }
+        if ( bundleLicense != null ? !bundleLicense.equals( artifact.bundleLicense ) : artifact.bundleLicense != null )
+        {
+            return false;
+        }
+        if ( bundleName != null ? !bundleName.equals( artifact.bundleName ) : artifact.bundleName != null )
+        {
+            return false;
+        }
+        if ( bundleRequireBundle != null
+            ? !bundleRequireBundle.equals( artifact.bundleRequireBundle )
+            : artifact.bundleRequireBundle != null )
+        {
+            return false;
+        }
+        if ( bundleSymbolicName != null
+            ? !bundleSymbolicName.equals( artifact.bundleSymbolicName )
+            : artifact.bundleSymbolicName != null )
+        {
+            return false;
+        }
+        if ( bundleVersion != null ? !bundleVersion.equals( artifact.bundleVersion ) : artifact.bundleVersion != null )
+        {
+            return false;
+        }
+        if ( classifier != null ? !classifier.equals( artifact.classifier ) : artifact.classifier != null )
+        {
+            return false;
+        }
+        if ( context != null ? !context.equals( artifact.context ) : artifact.context != null )
+        {
+            return false;
+        }
+        if ( fileExtension != null ? !fileExtension.equals( artifact.fileExtension ) : artifact.fileExtension != null )
+        {
+            return false;
+        }
+        if ( goals != null ? !goals.equals( artifact.goals ) : artifact.goals != null )
+        {
+            return false;
+        }
+        if ( !groupId.equals( artifact.groupId ) )
+        {
+            return false;
+        }
+        if ( id != null ? !id.equals( artifact.id ) : artifact.id != null )
+        {
+            return false;
+        }
+        if ( packaging != null ? !packaging.equals( artifact.packaging ) : artifact.packaging != null )
+        {
+            return false;
+        }
+        if ( path != null ? !path.equals( artifact.path ) : artifact.path != null )
+        {
+            return false;
+        }
+        if ( prefix != null ? !prefix.equals( artifact.prefix ) : artifact.prefix != null )
+        {
+            return false;
+        }
+        if ( repositoryId != null ? !repositoryId.equals( artifact.repositoryId ) : artifact.repositoryId != null )
+        {
+            return false;
+        }
+        if ( scope != null ? !scope.equals( artifact.scope ) : artifact.scope != null )
+        {
+            return false;
+        }
+        if ( size != null ? !size.equals( artifact.size ) : artifact.size != null )
+        {
+            return false;
+        }
+        if ( type != null ? !type.equals( artifact.type ) : artifact.type != null )
+        {
+            return false;
+        }
+        if ( url != null ? !url.equals( artifact.url ) : artifact.url != null )
+        {
+            return false;
+        }
+        if ( !version.equals( artifact.version ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int result = context != null ? context.hashCode() : 0;
+        result = 31 * result + ( url != null ? url.hashCode() : 0 );
+        result = 31 * result + groupId.hashCode();
+        result = 31 * result + artifactId.hashCode();
+        result = 31 * result + ( repositoryId != null ? repositoryId.hashCode() : 0 );
+        result = 31 * result + version.hashCode();
+        result = 31 * result + ( prefix != null ? prefix.hashCode() : 0 );
+        result = 31 * result + ( goals != null ? goals.hashCode() : 0 );
+        result = 31 * result + ( bundleVersion != null ? bundleVersion.hashCode() : 0 );
+        result = 31 * result + ( bundleSymbolicName != null ? bundleSymbolicName.hashCode() : 0 );
+        result = 31 * result + ( bundleExportPackage != null ? bundleExportPackage.hashCode() : 0 );
+        result = 31 * result + ( bundleExportService != null ? bundleExportService.hashCode() : 0 );
+        result = 31 * result + ( bundleDescription != null ? bundleDescription.hashCode() : 0 );
+        result = 31 * result + ( bundleName != null ? bundleName.hashCode() : 0 );
+        result = 31 * result + ( bundleLicense != null ? bundleLicense.hashCode() : 0 );
+        result = 31 * result + ( bundleDocUrl != null ? bundleDocUrl.hashCode() : 0 );
+        result = 31 * result + ( bundleImportPackage != null ? bundleImportPackage.hashCode() : 0 );
+        result = 31 * result + ( bundleRequireBundle != null ? bundleRequireBundle.hashCode() : 0 );
+        result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
+        result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
+        result = 31 * result + ( fileExtension != null ? fileExtension.hashCode() : 0 );
+        result = 31 * result + ( size != null ? size.hashCode() : 0 );
+        result = 31 * result + ( type != null ? type.hashCode() : 0 );
+        result = 31 * result + ( path != null ? path.hashCode() : 0 );
+        result = 31 * result + ( id != null ? id.hashCode() : 0 );
+        result = 31 * result + ( scope != null ? scope.hashCode() : 0 );
+        return result;
+    }
+}
diff --git a/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/TreeEntry.java b/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/TreeEntry.java
new file mode 100644 (file)
index 0000000..9cf4d9a
--- /dev/null
@@ -0,0 +1,113 @@
+package org.apache.archiva.maven2.model;
+/*
+ * 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.codehaus.jackson.annotate.JsonIgnore;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+@XmlRootElement( name = "treeEntry" )
+public class TreeEntry
+    implements Serializable
+{
+
+    private List<TreeEntry> childs = new ArrayList<TreeEntry>();
+
+    private Artifact artifact;
+
+    @JsonIgnore
+    private TreeEntry parent;
+
+    public TreeEntry()
+    {
+        // no op
+    }
+
+    public TreeEntry( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+
+
+    public Artifact getArtifact()
+    {
+        return artifact;
+    }
+
+    public void setArtifact( Artifact artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    public List<TreeEntry> getChilds()
+    {
+        return childs;
+    }
+
+    public void setChilds( List<TreeEntry> childs )
+    {
+        this.childs = childs;
+    }
+
+    @JsonIgnore
+    public TreeEntry getParent()
+    {
+        return parent;
+    }
+
+    @JsonIgnore
+    public void setParent( TreeEntry parent )
+    {
+        this.parent = parent;
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( !( o instanceof TreeEntry ) )
+        {
+            return false;
+        }
+
+        TreeEntry treeEntry = (TreeEntry) o;
+
+        if ( artifact != null ? !artifact.equals( treeEntry.artifact ) : treeEntry.artifact != null )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return artifact != null ? artifact.hashCode() : 0;
+    }
+}
index 364bb01320de5ce4fbbc980c1bd2608a0d24834b..230f9782880558429849bc7f1a3fa7abc6b7b05c 100644 (file)
@@ -49,5 +49,6 @@
     <module>archiva-repository-admin</module>
     <module>archiva-security-common</module>
     <module>archiva-maven2-metadata</module>
+    <module>archiva-maven2-model</module>
   </modules>
 </project>
\ No newline at end of file
index fc0d99471c3bdc1464c63b22bbf32fd7f4d45dd7..405c90107bf0eabfc824ccc860666b04bbe2f6b3 100644 (file)
       <artifactId>metadata-model</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-maven2-model</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-repository-scanner</artifactId>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
deleted file mode 100644 (file)
index 3baa0ce..0000000
+++ /dev/null
@@ -1,458 +0,0 @@
-package org.apache.archiva.rest.api.model;
-
-/*
- * 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 javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.List;
-
-@XmlRootElement( name = "artifact" )
-public class Artifact
-    implements Serializable
-{
-    // The (optional) context for this result.
-    private String context;
-
-    // Basic hit, direct to non-artifact resource.
-    private String url;
-
-    // Advanced hit, reference to groupId.
-    private String groupId;
-
-    //  Advanced hit, reference to artifactId.
-    private String artifactId;
-
-    private String repositoryId;
-
-    private String version;
-
-    /**
-     * Plugin goal prefix (only if packaging is "maven-plugin")
-     */
-    private String prefix;
-
-    /**
-     * Plugin goals (only if packaging is "maven-plugin")
-     */
-    private List<String> goals;
-
-    /**
-     * contains osgi metadata Bundle-Version if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleVersion;
-
-    /**
-     * contains osgi metadata Bundle-SymbolicName if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleSymbolicName;
-
-    /**
-     * contains osgi metadata Export-Package if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleExportPackage;
-
-    /**
-     * contains osgi metadata Export-Service if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleExportService;
-
-    /**
-     * contains osgi metadata Bundle-Description if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleDescription;
-
-    /**
-     * contains osgi metadata Bundle-Name if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleName;
-
-    /**
-     * contains osgi metadata Bundle-License if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleLicense;
-
-    /**
-     * contains osgi metadata Bundle-DocURL if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleDocUrl;
-
-    /**
-     * contains osgi metadata Import-Package if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleImportPackage;
-
-    /**
-     * contains osgi metadata Require-Bundle if available
-     *
-     * @since 1.4-M1
-     */
-    private String bundleRequireBundle;
-
-    private String classifier;
-
-    private String packaging;
-
-    /**
-     * file extension of the artifact
-     *
-     * @since 1.4-M2
-     */
-    private String fileExtension;
-
-    /**
-     * human readable size : not available for all services
-     * @since 1.4-M3
-     */
-    private String size;
-
-    /**
-     * @since 1.4-M3
-     */
-    private String type;
-
-
-    /**
-     * @since 1.4-M3
-     */
-    private String path;
-
-    /**
-     * concat of artifactId+'-'+version+'.'+type
-     * @since 1.4-M3
-     */
-    private String id;
-
-
-    public Artifact()
-    {
-        // no op
-    }
-
-    public Artifact( String groupId, String artifactId, String version )
-    {
-        this.artifactId = artifactId;
-        this.groupId = groupId;
-        this.version = version;
-    }
-
-    public String getGroupId()
-    {
-        return groupId;
-    }
-
-    public String getArtifactId()
-    {
-        return artifactId;
-    }
-
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public String getRepositoryId()
-    {
-        return repositoryId;
-    }
-
-    public void setGroupId( String groupId )
-    {
-        this.groupId = groupId;
-    }
-
-    public void setArtifactId( String artifactId )
-    {
-        this.artifactId = artifactId;
-    }
-
-    public void setVersion( String version )
-    {
-        this.version = version;
-    }
-
-    public void setRepositoryId( String repositoryId )
-    {
-        this.repositoryId = repositoryId;
-    }
-
-    public String getContext()
-    {
-        return context;
-    }
-
-    public void setContext( String context )
-    {
-        this.context = context;
-    }
-
-    public String getUrl()
-    {
-        return url;
-    }
-
-    public void setUrl( String url )
-    {
-        this.url = url;
-    }
-
-    public String getPrefix()
-    {
-        return prefix;
-    }
-
-    public void setPrefix( String prefix )
-    {
-        this.prefix = prefix;
-    }
-
-    public List<String> getGoals()
-    {
-        return goals;
-    }
-
-    public void setGoals( List<String> goals )
-    {
-        this.goals = goals;
-    }
-
-    public String getBundleVersion()
-    {
-        return bundleVersion;
-    }
-
-    public void setBundleVersion( String bundleVersion )
-    {
-        this.bundleVersion = bundleVersion;
-    }
-
-    public String getBundleSymbolicName()
-    {
-        return bundleSymbolicName;
-    }
-
-    public void setBundleSymbolicName( String bundleSymbolicName )
-    {
-        this.bundleSymbolicName = bundleSymbolicName;
-    }
-
-    public String getBundleExportPackage()
-    {
-        return bundleExportPackage;
-    }
-
-    public void setBundleExportPackage( String bundleExportPackage )
-    {
-        this.bundleExportPackage = bundleExportPackage;
-    }
-
-    public String getBundleExportService()
-    {
-        return bundleExportService;
-    }
-
-    public void setBundleExportService( String bundleExportService )
-    {
-        this.bundleExportService = bundleExportService;
-    }
-
-    public String getBundleDescription()
-    {
-        return bundleDescription;
-    }
-
-    public void setBundleDescription( String bundleDescription )
-    {
-        this.bundleDescription = bundleDescription;
-    }
-
-    public String getBundleName()
-    {
-        return bundleName;
-    }
-
-    public void setBundleName( String bundleName )
-    {
-        this.bundleName = bundleName;
-    }
-
-    public String getBundleLicense()
-    {
-        return bundleLicense;
-    }
-
-    public void setBundleLicense( String bundleLicense )
-    {
-        this.bundleLicense = bundleLicense;
-    }
-
-    public String getBundleDocUrl()
-    {
-        return bundleDocUrl;
-    }
-
-    public void setBundleDocUrl( String bundleDocUrl )
-    {
-        this.bundleDocUrl = bundleDocUrl;
-    }
-
-    public String getBundleImportPackage()
-    {
-        return bundleImportPackage;
-    }
-
-    public void setBundleImportPackage( String bundleImportPackage )
-    {
-        this.bundleImportPackage = bundleImportPackage;
-    }
-
-    public String getBundleRequireBundle()
-    {
-        return bundleRequireBundle;
-    }
-
-    public void setBundleRequireBundle( String bundleRequireBundle )
-    {
-        this.bundleRequireBundle = bundleRequireBundle;
-    }
-
-    public String getClassifier()
-    {
-        return classifier;
-    }
-
-    public void setClassifier( String classifier )
-    {
-        this.classifier = classifier;
-    }
-
-
-    public String getPackaging()
-    {
-        return packaging;
-    }
-
-    public void setPackaging( String packaging )
-    {
-        this.packaging = packaging;
-    }
-
-    public String getFileExtension()
-    {
-        return fileExtension;
-    }
-
-    public void setFileExtension( String fileExtension )
-    {
-        this.fileExtension = fileExtension;
-    }
-
-    public String getSize()
-    {
-        return size;
-    }
-
-    public void setSize( String size )
-    {
-        this.size = size;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
-    public String getPath()
-    {
-        return path;
-    }
-
-    public void setPath( String path )
-    {
-        this.path = path;
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-
-    public void setId( String id )
-    {
-        this.id = id;
-    }
-
-    @Override
-    public String toString()
-    {
-        final StringBuilder sb = new StringBuilder();
-        sb.append( "Artifact" );
-        sb.append( "{context='" ).append( context ).append( '\'' );
-        sb.append( ", url='" ).append( url ).append( '\'' );
-        sb.append( ", groupId='" ).append( groupId ).append( '\'' );
-        sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
-        sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
-        sb.append( ", version='" ).append( version ).append( '\'' );
-        sb.append( ", prefix='" ).append( prefix ).append( '\'' );
-        sb.append( ", goals=" ).append( goals );
-        sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
-        sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
-        sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' );
-        sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' );
-        sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
-        sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
-        sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
-        sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
-        sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' );
-        sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' );
-        sb.append( ", classifier='" ).append( classifier ).append( '\'' );
-        sb.append( ", packaging='" ).append( packaging ).append( '\'' );
-        sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' );
-        sb.append( ", size='" ).append( size ).append( '\'' );
-        sb.append( ", type='" ).append( type ).append( '\'' );
-        sb.append( ", path='" ).append( path ).append( '\'' );
-        sb.append( ", id='" ).append( id ).append( '\'' );
-        sb.append( '}' );
-        return sb.toString();
-    }
-
-}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/TreeEntry.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/TreeEntry.java
deleted file mode 100644 (file)
index 0ac2713..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.apache.archiva.rest.api.model;
-/*
- * 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.codehaus.jackson.annotate.JsonIgnore;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-@XmlRootElement( name = "treeEntry" )
-public class TreeEntry
-    implements Serializable
-{
-
-    private List<TreeEntry> childs = new ArrayList<TreeEntry>();
-
-    private Artifact artifact;
-
-    @JsonIgnore
-    private TreeEntry parent;
-
-    public TreeEntry()
-    {
-        // no op
-    }
-
-    public TreeEntry( Artifact artifact )
-    {
-        this.artifact = artifact;
-    }
-
-
-    public Artifact getArtifact()
-    {
-        return artifact;
-    }
-
-    public void setArtifact( Artifact artifact )
-    {
-        this.artifact = artifact;
-    }
-
-    public List<TreeEntry> getChilds()
-    {
-        return childs;
-    }
-
-    public void setChilds( List<TreeEntry> childs )
-    {
-        this.childs = childs;
-    }
-
-    @JsonIgnore
-    public TreeEntry getParent()
-    {
-        return parent;
-    }
-
-    @JsonIgnore
-    public void setParent( TreeEntry parent )
-    {
-        this.parent = parent;
-    }
-}
index 539a4f13577d9da3ab7d52ffa19adf352fff33b5..d5584ff1535b2d8a3d3bcd55ff9b22dc83d66e62 100644 (file)
@@ -21,12 +21,12 @@ package org.apache.archiva.rest.api.services;
 import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.redback.authorization.RedbackAuthorization;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactContent;
 import org.apache.archiva.rest.api.model.ArtifactContentEntry;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.Entry;
-import org.apache.archiva.rest.api.model.TreeEntry;
+import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.archiva.rest.api.model.VersionsList;
 
 import javax.ws.rs.DELETE;
index 406322e3ac8df6816ec19ce6e49d279a21f6f336..a35ec80c6c2fa9d137bf3f4fd5ce99ce5f35af17 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.archiva.rest.api.services;
 
 import org.apache.archiva.redback.authorization.RedbackAuthorization;
 import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
 
index c17448f3b134cbfab97a3d4879f015a7eee77594..d48002949a78203f0abfb4de82641f564237edf6 100644 (file)
@@ -20,7 +20,7 @@ package org.apache.archiva.rest.api.services;
  */
 
 
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.GroupIdList;
 import org.apache.archiva.rest.api.model.SearchRequest;
 import org.apache.archiva.rest.api.model.StringList;
index 9d054b565a099cdadeae1baee9caed6f2ae4d256..d584e4fb2a0ae46a4cb1afe60dc0b912dd586046 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-repository-scanner</artifactId>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-maven2-model</artifactId>
+    </dependency>
+
     <dependency>
       <groupId>org.apache.archiva.redback</groupId>
       <artifactId>redback-authorization-api</artifactId>
index 0a031ed953c5626bd55b23aa9cd878e7e888d072..38858ec0c1f223b73615cb1cae56b5b48ac7fd0d 100644 (file)
@@ -30,7 +30,7 @@ import org.apache.archiva.redback.rest.services.RedbackAuthenticationThreadLocal
 import org.apache.archiva.redback.rest.services.RedbackRequestInformation;
 import org.apache.archiva.redback.users.User;
 import org.apache.archiva.redback.users.UserManager;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.security.AccessDeniedException;
 import org.apache.archiva.security.ArchivaSecurityException;
index 061f8e87f9cf8a8eedfc0590bce330b470c7d0a9..ff075ee2e212e2a63e2ead9ddb07c394a981ba6c 100644 (file)
@@ -22,6 +22,8 @@ import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.VersionComparator;
 import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
 import org.apache.archiva.dependency.tree.maven2.Maven3DependencyTreeBuilder;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.archiva.metadata.generic.GenericMetadataFacet;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.model.MetadataFacet;
@@ -39,19 +41,16 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.RepositoryContentFactory;
 import org.apache.archiva.repository.RepositoryException;
 import org.apache.archiva.repository.RepositoryNotFoundException;
-import org.apache.archiva.rest.api.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactContent;
 import org.apache.archiva.rest.api.model.ArtifactContentEntry;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.BrowseResultEntry;
 import org.apache.archiva.rest.api.model.Entry;
-import org.apache.archiva.rest.api.model.TreeEntry;
 import org.apache.archiva.rest.api.model.VersionsList;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.BrowseService;
 import org.apache.archiva.rest.services.utils.ArtifactContentEntryComparator;
 import org.apache.archiva.rest.services.utils.ArtifactDownloadInfoBuilder;
-import org.apache.archiva.rest.services.utils.TreeDependencyNodeVisitor;
 import org.apache.archiva.security.ArchivaSecurityException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.FileUtils;
@@ -427,25 +426,10 @@ public class DefaultBrowseService
     {
         List<String> selectedRepos = getSelectedRepos( repositoryId );
 
-        List<TreeEntry> treeEntries = new ArrayList<TreeEntry>();
-        TreeDependencyNodeVisitor treeDependencyNodeVisitor = new TreeDependencyNodeVisitor( treeEntries );
-        /*
-        try
-        {
-            dependencyTreeBuilder.buildDependencyTree( selectedRepos, groupId, artifactId, version,
-                                                       treeDependencyNodeVisitor );
-        }
-        catch ( DependencyTreeBuilderException e )
-        {
-            throw new ArchivaRestServiceException( e.getMessage(),
-                                                   Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e );
-        }
-        */
         try
         {
 
-            maven3DependencyTreeBuilder.buildDependencyTree( selectedRepos, groupId, artifactId, version,
-                                                             treeDependencyNodeVisitor );
+            return maven3DependencyTreeBuilder.buildDependencyTree( selectedRepos, groupId, artifactId, version );
 
         }
         catch ( Exception e )
@@ -453,8 +437,7 @@ public class DefaultBrowseService
             log.error( e.getMessage(), e );
         }
 
-        log.debug( "treeEntrie: {}", treeEntries );
-        return treeEntries;
+        return Collections.emptyList();
     }
 
     public List<ManagedRepository> getUserRepositories()
index 333912f1d03cb8cf58ea501bd0026dc979974ee8..99dc202b900cb92a4054247044ff59e42e8b1435 100644 (file)
@@ -61,7 +61,7 @@ import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
 import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
 import org.apache.archiva.repository.scanner.RepositoryScanner;
 import org.apache.archiva.repository.scanner.RepositoryScannerException;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.RepositoriesService;
index d33985117dfdaa0a038f728cb53ea14e6303513a..ee2ce4cc30d4b8b149c1f10ef9dd3d027e8276a6 100644 (file)
@@ -26,7 +26,7 @@ import org.apache.archiva.indexer.search.SearchFields;
 import org.apache.archiva.indexer.search.SearchResultHit;
 import org.apache.archiva.indexer.search.SearchResultLimits;
 import org.apache.archiva.indexer.search.SearchResults;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.Dependency;
 import org.apache.archiva.rest.api.model.GroupIdList;
 import org.apache.archiva.rest.api.model.SearchRequest;
index b569ac8e015603207f9b8cfbd482a7f0c6ef4963..8e29e1d2a2aca179a39254c1657e2cbbe1740e71 100644 (file)
@@ -22,7 +22,7 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
 import org.apache.archiva.model.ArtifactReference;
 import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.commons.io.FilenameUtils;
 
 import java.io.File;
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/TreeDependencyNodeVisitor.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/TreeDependencyNodeVisitor.java
deleted file mode 100644 (file)
index 22e4b0a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.apache.archiva.rest.services.utils;
-/*
- * 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 net.sf.beanlib.provider.replicator.BeanReplicator;
-import org.apache.archiva.rest.api.model.Artifact;
-import org.apache.archiva.rest.api.model.TreeEntry;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.sonatype.aether.graph.DependencyVisitor;
-
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- * @since 1.4-M3
- */
-public class TreeDependencyNodeVisitor
-    implements DependencyNodeVisitor, DependencyVisitor
-{
-
-    final List<TreeEntry> treeEntries;
-
-    private TreeEntry currentEntry;
-
-    private DependencyNode firstNode;
-
-    private org.sonatype.aether.graph.DependencyNode firstDependencyNode;
-
-    public TreeDependencyNodeVisitor( List<TreeEntry> treeEntries )
-    {
-        this.treeEntries = treeEntries;
-    }
-
-    public boolean visit( DependencyNode node )
-    {
-        TreeEntry entry = new TreeEntry( new BeanReplicator().replicateBean( node.getArtifact(), Artifact.class ) );
-        entry.setParent( currentEntry );
-        currentEntry = entry;
-
-        if ( firstNode == null )
-        {
-            firstNode = node;
-            treeEntries.add( currentEntry );
-        }
-        else
-        {
-            currentEntry.getParent().getChilds().add( currentEntry );
-        }
-        return true;
-    }
-
-    public boolean endVisit( DependencyNode node )
-    {
-        currentEntry = currentEntry.getParent();
-        return true;
-    }
-
-    public boolean visitEnter( org.sonatype.aether.graph.DependencyNode dependencyNode )
-    {
-        TreeEntry entry = new TreeEntry( new BeanReplicator().replicateBean( dependencyNode.getDependency().getArtifact(), Artifact.class ) );
-        entry.setParent( currentEntry );
-        currentEntry = entry;
-
-        if ( firstDependencyNode == null )
-        {
-            firstDependencyNode = dependencyNode;
-            treeEntries.add( currentEntry );
-        }
-        else
-        {
-            currentEntry.getParent().getChilds().add( currentEntry );
-        }
-        return true;
-    }
-
-    public boolean visitLeave( org.sonatype.aether.graph.DependencyNode dependencyNode )
-    {
-        currentEntry = currentEntry.getParent();
-        return true;
-    }
-}
index 4f9c68ab5c41ca002ba5d14cabe371ec5b7dd103..825856f52d53e840ca0886c0d6c9b85365b85184 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.archiva.rest.services;
  */
 
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactContentEntry;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.BrowseResultEntry;
index 5198d6376ac685c8fdf2d7ae6f11aa656112ec17..b784b29f4c52968cb7226c5bbb99f782a6511ad9 100644 (file)
@@ -21,7 +21,7 @@ package org.apache.archiva.rest.services;
 
 import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.FileUtil;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.BrowseResultEntry;
 import org.apache.archiva.rest.api.model.VersionsList;
index c3a9cbc01ab17fa08d9152c9f73221eb92ba355e..241d6900d1f4c176b557368f4731a531811d1f02 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.archiva.rest.services;
  */
 
 import org.apache.archiva.admin.model.beans.UiConfiguration;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.SearchRequest;
 import org.apache.archiva.rest.api.services.SearchService;
 import org.fest.assertions.api.Assertions;
index e836727b85795431e54d1bea5aefb7d7cb83bb7e..cdf446c52b27ca5ff5cb9d8d336e0c9baef55168 100644 (file)
@@ -25,7 +25,7 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.common.utils.VersionUtil;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.RepositoriesService;
 import org.apache.archiva.security.AccessDeniedException;
index 5e09669e9a86c87c75376249916b62476cd78a8b..bbc6bf2fbdc60ad9fcf74f31a70c10c229d8bab5 100644 (file)
@@ -37,7 +37,7 @@ import org.apache.archiva.reports.RepositoryProblemFacet;
 import org.apache.archiva.repository.RepositoryContentFactory;
 import org.apache.archiva.repository.RepositoryException;
 import org.apache.archiva.repository.RepositoryNotFoundException;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.services.utils.ArtifactDownloadInfoBuilder;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.context.annotation.Scope;
index 234df690316b86495c0a9aa9c697fc102344ef9e..118ff0dc883eb99460d080e5838e8e8e0d523a05 100644 (file)
@@ -22,7 +22,7 @@ import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.admin.model.beans.ProxyConnector;
 import org.apache.archiva.admin.model.beans.RemoteRepository;
 import org.apache.archiva.admin.model.beans.RepositoryGroup;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.rest.api.model.SearchRequest;
 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
 import org.apache.archiva.rest.api.services.ProxyConnectorService;
index a2368ccb0ac283cec39c0ba5421152bb4724cb4c..584e198c6140ceec14e83283ff91ea06696c2f69 100644 (file)
@@ -29,7 +29,7 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionReference;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.webtest.memory.TestMetadataResolver;
 import org.apache.archiva.webtest.memory.TestRepositorySessionFactory;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
index 9409084a9e2742032238770c68ce45824e321ed5..3046a3ecdddad9096180238182b572f99cb36e09 100644 (file)
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-configuration</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-maven2-model</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-provider-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>net.sf.beanlib</groupId>
+      <artifactId>beanlib</artifactId>
+        <exclusions>
+          <exclusion>
+            <groupId>cglib</groupId>
+            <artifactId>cglib</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+          </exclusion>
+        </exclusions>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-http</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>net.sf.beanlib</groupId>
-      <artifactId>beanlib</artifactId>
+      <groupId>org.easytesting</groupId>
+      <artifactId>fest-assert-core</artifactId>
       <scope>test</scope>
-        <exclusions>
-          <exclusion>
-            <groupId>cglib</groupId>
-            <artifactId>cglib</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>aopalliance</groupId>
-            <artifactId>aopalliance</artifactId>
-          </exclusion>
-        </exclusions>
     </dependency>
+
   </dependencies>
   <build>
     <plugins>
index 023fe50ba1a01fd6dcf04ab3cc3999a3faa16003..1e03b7dfb91c72528476566884a061b287f67748 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
 import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
 import org.apache.archiva.proxy.common.WagonFactory;
 import org.apache.maven.artifact.Artifact;
@@ -67,6 +68,7 @@ import javax.inject.Inject;
 import javax.inject.Named;
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -120,8 +122,8 @@ public class Maven3DependencyTreeBuilder
         builder = defaultModelBuilderFactory.newInstance();
     }
 
-    public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
-                                     DependencyVisitor dependencyVisitor )
+    public List<TreeEntry> buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId,
+                                                String version )
         throws Exception
     {
         Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
@@ -139,7 +141,7 @@ public class Maven3DependencyTreeBuilder
         if ( repository == null )
         {
             // metadata could not be resolved
-            return;
+            return Collections.emptyList();
         }
 
         // MRM-1411
@@ -166,9 +168,14 @@ public class Maven3DependencyTreeBuilder
             }
         }
 
+        List<TreeEntry> treeEntries = new ArrayList<TreeEntry>();
+        TreeDependencyNodeVisitor treeDependencyNodeVisitor = new TreeDependencyNodeVisitor( treeEntries );
+
         // FIXME take care of relative path
-        resolve( repository.getLocation(), groupId, artifactId, version, dependencyVisitor );
+        resolve( repository.getLocation(), groupId, artifactId, version, treeDependencyNodeVisitor );
 
+        log.debug( "treeEntrie: {}", treeEntries );
+        return treeEntries;
     }
 
 
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java
new file mode 100644 (file)
index 0000000..49edbe5
--- /dev/null
@@ -0,0 +1,74 @@
+package org.apache.archiva.dependency.tree.maven2;
+/*
+ * 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 net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.maven2.model.TreeEntry;
+import org.sonatype.aether.graph.DependencyNode;
+import org.sonatype.aether.graph.DependencyVisitor;
+
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public class TreeDependencyNodeVisitor
+    implements DependencyVisitor
+{
+
+    final List<TreeEntry> treeEntries;
+
+    private TreeEntry currentEntry;
+
+    private org.sonatype.aether.graph.DependencyNode firstDependencyNode;
+
+    public TreeDependencyNodeVisitor( List<TreeEntry> treeEntries )
+    {
+        this.treeEntries = treeEntries;
+    }
+
+
+    public boolean visitEnter( DependencyNode dependencyNode )
+    {
+        TreeEntry entry = new TreeEntry(
+            new BeanReplicator().replicateBean( dependencyNode.getDependency().getArtifact(), Artifact.class ) );
+        entry.getArtifact().setScope( dependencyNode.getDependency().getScope() );
+        entry.setParent( currentEntry );
+        currentEntry = entry;
+
+        if ( firstDependencyNode == null )
+        {
+            firstDependencyNode = dependencyNode;
+            treeEntries.add( currentEntry );
+        }
+        else
+        {
+            currentEntry.getParent().getChilds().add( currentEntry );
+        }
+        return true;
+    }
+
+    public boolean visitLeave( DependencyNode dependencyNode )
+    {
+        currentEntry = currentEntry.getParent();
+        return true;
+    }
+}
index 8669f3c41b854db694e288fd14b5faec018543c0..948dab0f6b990c5ca91a62edd08dbb62a81dae50 100644 (file)
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.versioning.VersionRange;
@@ -279,4 +280,5 @@ public class DependencyTreeBuilderTest
 
         control.verify();
     }
+
 }
index 8af4ca7ce1d2c7a6a0347647df017a6351c33c82..edb3ca793fe023a504352dd92f659ede672a9634 100644 (file)
@@ -24,27 +24,20 @@ import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.configuration.Configuration;
 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.archiva.maven2.model.Artifact;
+import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.easymock.MockControl;
+import org.fest.assertions.api.Assertions;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.graph.DependencyVisitor;
-import org.sonatype.aether.impl.internal.DefaultRepositorySystem;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
-import org.sonatype.aether.util.graph.DefaultDependencyNode;
 import org.springframework.test.context.ContextConfiguration;
 
 import javax.inject.Inject;
 import javax.inject.Named;
 import java.io.File;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
 
 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@@ -66,10 +59,6 @@ public class DependencyTreeBuilderTestMaven3
 
     private static final String TEST_GROUP_ID = "org.apache.archiva";
 
-    private DefaultRepositorySystem defaultRepositorySystem;
-
-
-    final Map<String, DependencyNode> nodes = new HashMap<String, DependencyNode>();
 
     @Inject
     @Named( value = "archivaConfiguration#test" )
@@ -81,8 +70,6 @@ public class DependencyTreeBuilderTestMaven3
     {
         super.setUp();
 
-        defaultRepositorySystem = (DefaultRepositorySystem) plexusSisuBridge.lookup( RepositorySystem.class );
-
         Configuration configuration = new Configuration();
         ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
         repoConfig.setId( TEST_REPO_ID );
@@ -96,7 +83,7 @@ public class DependencyTreeBuilderTestMaven3
 
     private Artifact createArtifact( String groupId, String artifactId, String version )
     {
-        return new DefaultArtifact( groupId, artifactId, "jar", version );
+        return new Artifact( groupId, artifactId, version );
     }
 
     private String getId( Artifact artifact )
@@ -109,321 +96,40 @@ public class DependencyTreeBuilderTestMaven3
         throws Exception
     {
 
-        DependencyNode springContext = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.springframework", "spring-context", "2.5.6" ), "compile" ) );
-
-        //springContext.setPremanagedVersion( "2.5.5" );
-
-        nodes.put( getId( springContext.getDependency().getArtifact() ), springContext );
-
-        DependencyNode springTest = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.springframework", "spring-test", "2.5.5" ), "test" ) );
-
-        nodes.put( getId( springTest.getDependency().getArtifact() ), springTest );
-
-        DependencyNode plexusUtils = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus", "plexus-utils", "1.4.5" ), "compile" ) );
-
-        //plexusUtils.setPremanagedVersion( "1.5.1" );
-
-        nodes.put( getId( plexusUtils.getDependency().getArtifact() ), plexusUtils );
-
-        DependencyNode slf4jLog4j12 = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.slf4j", "slf4j-log4j12", "1.5.0" ), "runtime" ) );
-
-        //slf4jLog4j12.setPremanagedScope( "test" );
-
-        nodes.put( getId( slf4jLog4j12.getDependency().getArtifact() ), slf4jLog4j12 );
-
-        DependencyNode plexusLog4j = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus", "plexus-log4j-logging", "1.1-alpha-3" ), "test" ) );
-
-        nodes.put( getId( plexusLog4j.getDependency().getArtifact() ), plexusLog4j );
-
-        DependencyNode log4j =
-            new DefaultDependencyNode( new Dependency( createArtifact( "log4j", "log4j", "1.2.14" ), "test" ) );
-
-        nodes.put( getId( log4j.getDependency().getArtifact() ), log4j );
-
-        DependencyNode mavenArtifact = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.apache.maven", "maven-artifact", "2.0.8" ), "test" ) );
-
-        nodes.put( getId( mavenArtifact.getDependency().getArtifact() ), mavenArtifact );
-
-        DependencyNode mavenProject = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.apache.maven", "maven-project", "2.0.8" ), "test" ) );
-
-        nodes.put( getId( mavenProject.getDependency().getArtifact() ), mavenProject );
-
-        DependencyNode mavenCore = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.apache.maven", "maven-core", "2.0.8" ), "test" ) );
-
-        nodes.put( getId( mavenCore.getDependency().getArtifact() ), mavenCore );
-
-        DependencyNode mavenSettings = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.apache.maven", "maven-settings", "2.0.8" ), "test" ) );
-
-        nodes.put( getId( mavenSettings.getDependency().getArtifact() ), mavenSettings );
-
-        DependencyNode mavenModel = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.apache.maven", "maven-model", "2.0.8" ), "test" ) );
-
-        nodes.put( getId( mavenModel.getDependency().getArtifact() ), mavenModel );
-
-        DependencyNode plexusCommandLine = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus", "plexus-command-line", "1.0-alpha-2" ), "test" ) );
-
-        nodes.put( getId( plexusCommandLine.getDependency().getArtifact() ), plexusCommandLine );
-
-        DependencyNode plexusRegistryCommons = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus.registry", "plexus-registry-commons", "1.0-alpha-2" ),
-                            "test" ) );
-
-        nodes.put( getId( plexusRegistryCommons.getDependency().getArtifact() ), plexusRegistryCommons );
-
-        //plexusRegistryCommons.setPremanagedVersion( "1.0-alpha-3" );
-
-        DependencyNode plexusRegistryApi = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus.registry", "plexus-registry-api", "1.0-alpha-2" ),
-                            "test" ) );
-
-        nodes.put( getId( plexusRegistryApi.getDependency().getArtifact() ), plexusRegistryApi );
-
-        //plexusRegistryApi.setPremanagedVersion( "1.0-alpha-3" );
-
-        DependencyNode plexusSpring = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2" ), "test" ) );
-
-        nodes.put( getId( plexusSpring.getDependency().getArtifact() ), plexusSpring );
-
-        plexusSpring.getChildren().add( springContext );
-        plexusSpring.getChildren().add( springTest );
-        plexusSpring.getChildren().add( plexusUtils );
-        plexusSpring.getChildren().add( slf4jLog4j12 );
-        plexusSpring.getChildren().add( plexusLog4j );
-        plexusSpring.getChildren().add( log4j );
-        plexusSpring.getChildren().add( mavenArtifact );
-        plexusSpring.getChildren().add( mavenProject );
-        plexusSpring.getChildren().add( mavenCore );
-        plexusSpring.getChildren().add( mavenSettings );
-        plexusSpring.getChildren().add( mavenModel );
-        plexusSpring.getChildren().add( plexusCommandLine );
-        plexusSpring.getChildren().add( plexusRegistryCommons );
-        plexusSpring.getChildren().add( plexusRegistryApi );
-
-        DependencyNode commonsLang = new DefaultDependencyNode(
-            new Dependency( createArtifact( "commons-lang", "commons-lang", "2.2" ), "compile" ) );
-
-        nodes.put( getId( commonsLang.getDependency().getArtifact() ), commonsLang );
-
-        DependencyNode commonsIO = new DefaultDependencyNode(
-            new Dependency( createArtifact( "commons-io", "commons-io", "1.4" ), "compile" ) );
-
-        nodes.put( getId( commonsIO.getDependency().getArtifact() ), commonsIO );
-
-        DependencyNode slf4j = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.slf4j", "slf4j-api", "1.5.0" ), "compile" ) );
-
-        nodes.put( getId( slf4j.getDependency().getArtifact() ), slf4j );
-
-        DependencyNode plexusAPI = new DefaultDependencyNode(
-            new Dependency( createArtifact( "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22" ),
-                            "compile" ) );
-
-        nodes.put( getId( plexusAPI.getDependency().getArtifact() ), plexusAPI );
-
-        DependencyNode xalan =
-            new DefaultDependencyNode( new Dependency( createArtifact( "xalan", "xalan", "2.7.0" ), "compile" ) );
-
-        nodes.put( getId( xalan.getDependency().getArtifact() ), xalan );
-
-        DependencyNode dom4j =
-            new TestDefaultDependencyNode( new Dependency( createArtifact( "dom4j", "dom4j", "1.6.1" ), "test" ) );
+        List<TreeEntry> treeEntries =
+            builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
+                                         TEST_VERSION );
 
-        nodes.put( getId( dom4j.getDependency().getArtifact() ), dom4j );
-
-        //dom4j.setFailedUpdateScope("compile");
-
-        DependencyNode junit =
-            new TestDefaultDependencyNode( new Dependency( createArtifact( "junit", "junit", "3.8.1" ), "test" ) );
-
-        nodes.put( getId( junit.getDependency().getArtifact() ), junit );
-
-        DependencyNode easymock = new TestDefaultDependencyNode(
-            new Dependency( createArtifact( "easymock", "easymock", "1.2_Java1.3" ), "test" ) );
-
-        nodes.put( getId( easymock.getDependency().getArtifact() ), easymock );
-
-        DependencyNode easymockExt = new TestDefaultDependencyNode(
-            new Dependency( createArtifact( "easymock", "easymockclassextension", "1.2" ), "test" ) );
-
-        nodes.put( getId( easymockExt.getDependency().getArtifact() ), easymockExt );
-
-        DependencyNode mainNode = new TestDefaultDependencyNode(
-            new Dependency( createArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ), "" ) );
-
-        nodes.put( getId( mainNode.getDependency().getArtifact() ), mainNode );
-
-        mainNode.getChildren().add( commonsLang );
-        mainNode.getChildren().add( commonsIO );
-        mainNode.getChildren().add( slf4j );
-        mainNode.getChildren().add( plexusAPI );
-        mainNode.getChildren().add( plexusSpring );
-        mainNode.getChildren().add( xalan );
-        mainNode.getChildren().add( dom4j );
-        mainNode.getChildren().add( junit );
-        mainNode.getChildren().add( easymock );
-        mainNode.getChildren().add( easymockExt );
-
-        /*defaultRepositorySystem.setDependencyCollector( new DependencyCollector()
-        {
-
-            public CollectResult collectDependencies( RepositorySystemSession session, CollectRequest request )
-                throws DependencyCollectionException
-            {
-                CollectResult collectResult = new CollectResult( request );
-                collectResult.setRoot( new DefaultDependencyNode() );
-                for ( Dependency dependency : request.getDependencies() )
-                {
-                    DependencyNode node = nodes.get( getId( dependency.getArtifact() ) );
-                    if ( node != null )
-                    {
-                        collectResult.getRoot().getChildren().add( node );
-                    }
-                }
-                return collectResult;
-            }
-        } );
-        */
-
-        MockControl control = MockControl.createStrictControl( DependencyVisitor.class );
-        DependencyVisitor visitor = (DependencyVisitor) control.getMock();
-
-        control.expectAndReturn( visitor.visitEnter( mainNode ), true );
-
-        control.expectAndReturn( visitor.visitEnter( commonsLang ), true );
-        control.expectAndReturn( visitor.visitLeave( commonsLang ), true );
-
-        control.expectAndReturn( visitor.visitEnter( commonsIO ), true );
-        control.expectAndReturn( visitor.visitLeave( commonsIO ), true );
-
-        control.expectAndReturn( visitor.visitEnter( slf4j ), true );
-        control.expectAndReturn( visitor.visitLeave( slf4j ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusAPI ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusAPI ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusSpring ), true );
-
-        control.expectAndReturn( visitor.visitEnter( springContext ), true );
-        control.expectAndReturn( visitor.visitLeave( springContext ), true );
-
-        control.expectAndReturn( visitor.visitEnter( springTest ), true );
-        control.expectAndReturn( visitor.visitLeave( springTest ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusUtils ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusUtils ), true );
-
-        control.expectAndReturn( visitor.visitEnter( slf4jLog4j12 ), true );
-        control.expectAndReturn( visitor.visitLeave( slf4jLog4j12 ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusLog4j ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusLog4j ), true );
-
-        control.expectAndReturn( visitor.visitEnter( log4j ), true );
-        control.expectAndReturn( visitor.visitLeave( log4j ), true );
-
-        control.expectAndReturn( visitor.visitEnter( mavenArtifact ), true );
-        control.expectAndReturn( visitor.visitLeave( mavenArtifact ), true );
-
-        control.expectAndReturn( visitor.visitEnter( mavenProject ), true );
-        control.expectAndReturn( visitor.visitLeave( mavenProject ), true );
-
-        control.expectAndReturn( visitor.visitEnter( mavenCore ), true );
-        control.expectAndReturn( visitor.visitLeave( mavenCore ), true );
-
-        control.expectAndReturn( visitor.visitEnter( mavenSettings ), true );
-        control.expectAndReturn( visitor.visitLeave( mavenSettings ), true );
-
-        control.expectAndReturn( visitor.visitEnter( mavenModel ), true );
-        control.expectAndReturn( visitor.visitLeave( mavenModel ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusCommandLine ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusCommandLine ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusRegistryCommons ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusRegistryCommons ), true );
-
-        control.expectAndReturn( visitor.visitEnter( plexusRegistryApi ), true );
-        control.expectAndReturn( visitor.visitLeave( plexusRegistryApi ), true );
-
-        control.expectAndReturn( visitor.visitLeave( plexusSpring ), true );
-
-        control.expectAndReturn( visitor.visitEnter( xalan ), true );
-        control.expectAndReturn( visitor.visitLeave( xalan ), true );
-
-        control.expectAndReturn( visitor.visitEnter( dom4j ), true );
-        control.expectAndReturn( visitor.visitLeave( dom4j ), true );
-
-        control.expectAndReturn( visitor.visitEnter( junit ), true );
-        control.expectAndReturn( visitor.visitLeave( junit ), true );
-
-        control.expectAndReturn( visitor.visitEnter( easymock ), true );
-        control.expectAndReturn( visitor.visitLeave( easymock ), true );
-
-        control.expectAndReturn( visitor.visitEnter( easymockExt ), true );
-        control.expectAndReturn( visitor.visitLeave( easymockExt ), true );
-
-        control.expectAndReturn( visitor.visitLeave( mainNode ), true );
-
-        control.replay();
-
-        visitor = new DependencyVisitor()
-        {
-            public boolean visitEnter( DependencyNode dependencyNode )
-            {
-                return true;
-            }
-
-            public boolean visitLeave( DependencyNode dependencyNode )
-            {
-                return true;
-            }
-        };
-
-        builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                     TEST_VERSION, visitor );
-
-        control.verify();
+        Assertions.assertThat( treeEntries ).isNotNull().isNotEmpty().contains(
+            new TreeEntry( new Artifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION, "", "" ) ) );
 
+        Assertions.assertThat( treeEntries.get( 0 ).getChilds() ).isNotNull().isNotEmpty().contains(
+            new TreeEntry( new Artifact( "commons-lang", "commons-lang", "2.2", "compile", "" ) ) );
     }
 
-    public static class TestDefaultDependencyNode
-        extends DefaultDependencyNode
+
+    public static class TestTreeEntry
+        extends TreeEntry
     {
+        Artifact a;
 
-        private TestDefaultDependencyNode( Dependency dependency )
+        public TestTreeEntry( Artifact a )
         {
-            super( dependency );
+            this.a = a;
         }
 
         @Override
         public int hashCode()
         {
-            return super.hashCode();
+            return this.a.hashCode();
         }
 
         @Override
         public boolean equals( Object o )
         {
-            DependencyNode node = (DependencyNode) o;
-            boolean equals = this.getDependency().getArtifact().getGroupId().equals(
-                node.getDependency().getArtifact().getGroupId() ) &&
-                this.getDependency().getArtifact().getArtifactId().equals(
-                    node.getDependency().getArtifact().getArtifactId() ) &&
-                this.getDependency().getArtifact().getVersion().equals(
-                    node.getDependency().getArtifact().getVersion() );
-            return equals;
+            Artifact artifact = ( (TreeEntry) o ).getArtifact();
+            return artifact.equals( this.a );
         }
     }
+
 }
diff --git a/pom.xml b/pom.xml
index 4bdb298ee34d7d0bf94c8da379ef0607ea644801..6fe77351983c886e580cd2837bfcf0c9e00ef6a0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <artifactId>archiva-maven2-metadata</artifactId>
         <version>${project.version}</version>
       </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-maven2-model</artifactId>
+        <version>${project.version}</version>
+      </dependency>
       <dependency>
         <groupId>org.apache.archiva</groupId>
         <artifactId>archiva-repository-admin-api</artifactId>