From: Olivier Lamy Date: Sat, 4 Aug 2012 06:56:52 +0000 (+0000) Subject: dependency tree with aether move beans to a separate new module to be able to reuse... X-Git-Tag: archiva-1.4-M3~464 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=664eea9e415707c40571bfc5462a6cb9af5fd7f4;p=archiva.git dependency tree with aether move beans to a separate new module to be able to reuse beans git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1369269 13f79535-47bb-0310-9956-ffa450edef68 --- 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 index 000000000..aa24b0b04 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-maven2-model/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.archiva + archiva-base + 1.4-M3-SNAPSHOT + + + archiva-maven2-model + 1.4-M3-SNAPSHOT + bundle + + Archiva Base :: Maven 2 Model + + + + org.codehaus.jackson + jackson-core-asl + + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.apache.archiva.maven2.model + ${project.version} + + javax.xml.bind.annotation, + org.codehaus.jackson.annotate, + + + org.apache.archiva.maven2.model*;version=${project.version} + + + + + + + + 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 index 000000000..cf010b309 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/Artifact.java @@ -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 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 getGoals() + { + return goals; + } + + public void setGoals( List 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 index 000000000..9cf4d9a06 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-maven2-model/src/main/java/org/apache/archiva/maven2/model/TreeEntry.java @@ -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 childs = new ArrayList(); + + 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 getChilds() + { + return childs; + } + + public void setChilds( List 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; + } +} diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml index 364bb0132..230f97828 100644 --- a/archiva-modules/archiva-base/pom.xml +++ b/archiva-modules/archiva-base/pom.xml @@ -49,5 +49,6 @@ archiva-repository-admin archiva-security-common archiva-maven2-metadata + archiva-maven2-model \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml index fc0d99471..405c90107 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml @@ -50,6 +50,11 @@ metadata-model + + org.apache.archiva + archiva-maven2-model + + org.apache.archiva archiva-repository-scanner 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 index 3baa0ce0a..000000000 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java +++ /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 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 getGoals() - { - return goals; - } - - public void setGoals( List 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/ArtifactTransferRequest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactTransferRequest.java index 4bb367f46..6385cba4e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactTransferRequest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactTransferRequest.java @@ -18,6 +18,8 @@ package org.apache.archiva.rest.api.model; * under the License. */ +import org.apache.archiva.maven2.model.Artifact; + import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; 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 index 0ac2713af..000000000 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/TreeEntry.java +++ /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 childs = new ArrayList(); - - 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 getChilds() - { - return childs; - } - - public void setChilds( List childs ) - { - this.childs = childs; - } - - @JsonIgnore - public TreeEntry getParent() - { - return parent; - } - - @JsonIgnore - public void setParent( TreeEntry parent ) - { - this.parent = parent; - } -} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java index 539a4f135..d5584ff15 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java index 406322e3a..a35ec80c6 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java index c17448f3b..d48002949 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index 9d054b565..d584e4fb2 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -85,6 +85,12 @@ org.apache.archiva archiva-repository-scanner + + + org.apache.archiva + archiva-maven2-model + + org.apache.archiva.redback redback-authorization-api diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java index 0a031ed95..38858ec0c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 061f8e87f..ff075ee2e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -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 selectedRepos = getSelectedRepos( repositoryId ); - List treeEntries = new ArrayList(); - 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 getUserRepositories() diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index 333912f1d..99dc202b9 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java index d33985117..ee2ce4cc3 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java index b569ac8e0..8e29e1d2a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java @@ -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 index 22e4b0af2..000000000 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/TreeDependencyNodeVisitor.java +++ /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 treeEntries; - - private TreeEntry currentEntry; - - private DependencyNode firstNode; - - private org.sonatype.aether.graph.DependencyNode firstDependencyNode; - - public TreeDependencyNodeVisitor( List 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; - } -} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java index 4f9c68ab5..825856f52 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java index 5198d6376..b784b29f4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java index c3a9cbc01..241d6900d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java index e836727b8..cdf446c52 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/DeleteArtifactAction.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java index 5e09669e9..bbc6bf2fb 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/ShowArtifactAction.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java index 234df6903..118ff0dc8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java @@ -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; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java index a2368ccb0..584e198c6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/action/ShowArtifactActionTest.java @@ -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; diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml index 9409084a9..3046a3ecd 100644 --- a/archiva-modules/plugins/maven2-repository/pom.xml +++ b/archiva-modules/plugins/maven2-repository/pom.xml @@ -123,10 +123,28 @@ org.apache.archiva archiva-configuration + + org.apache.archiva + archiva-maven2-model + org.apache.maven.wagon wagon-provider-api + + net.sf.beanlib + beanlib + + + cglib + cglib + + + aopalliance + aopalliance + + + org.apache.maven.wagon wagon-http @@ -164,20 +182,11 @@ test - net.sf.beanlib - beanlib + org.easytesting + fest-assert-core test - - - cglib - cglib - - - aopalliance - aopalliance - - + diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java index 023fe50ba..1e03b7dfb 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java @@ -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 repositoryIds, String groupId, String artifactId, String version, - DependencyVisitor dependencyVisitor ) + public List buildDependencyTree( List 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 treeEntries = new ArrayList(); + 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 index 000000000..49edbe5b2 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/TreeDependencyNodeVisitor.java @@ -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 treeEntries; + + private TreeEntry currentEntry; + + private org.sonatype.aether.graph.DependencyNode firstDependencyNode; + + public TreeDependencyNodeVisitor( List 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; + } +} diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java index 8669f3c41..948dab0f6 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java @@ -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(); } + } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java index 8af4ca7ce..edb3ca793 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTestMaven3.java @@ -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 nodes = new HashMap(); @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 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 4bdb298ee..6fe773519 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,11 @@ archiva-maven2-metadata ${project.version} + + org.apache.archiva + archiva-maven2-model + ${project.version} + org.apache.archiva archiva-repository-admin-api