From 2d840d9ffe0ebfe949a09638ebf0d81f4a2c8f21 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 7 Jan 2014 09:28:05 +0000 Subject: [PATCH] use strict matching for model mapper git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1556158 13f79535-47bb-0310-9956-ffa450edef68 --- ...faultRedbackRuntimeConfigurationAdmin.java | 23 +++++++++++-------- .../plugins/maven2-repository/pom.xml | 3 +++ .../maven2/TreeDependencyNodeVisitor.java | 10 ++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index 6373a3427..677517898 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -52,7 +52,7 @@ import java.util.Set; * @author Olivier Lamy * @since 1.4-M4 */ -@Service( "redbackRuntimeConfigurationAdmin#default" ) +@Service("redbackRuntimeConfigurationAdmin#default") public class DefaultRedbackRuntimeConfigurationAdmin extends AbstractRepositoryAdmin implements RedbackRuntimeConfigurationAdmin, UserConfiguration @@ -64,13 +64,19 @@ public class DefaultRedbackRuntimeConfigurationAdmin private ArchivaConfiguration archivaConfiguration; @Inject - @Named( value = "userConfiguration#redback" ) + @Named(value = "userConfiguration#redback") private UserConfiguration userConfiguration; @Inject - @Named( value = "cache#users" ) + @Named(value = "cache#users") private Cache usersCache; + @Inject + public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration ) + { + this.archivaConfiguration = archivaConfiguration; + } + @PostConstruct public void initialize() throws UserConfigurationException @@ -383,19 +389,16 @@ public class DefaultRedbackRuntimeConfigurationAdmin { redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() ); } - res.setLdapConfiguration( - getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(), - org.apache.archiva.configuration.LdapConfiguration.class ) ); + res.setLdapConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(), + org.apache.archiva.configuration.LdapConfiguration.class ) ); if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null ) { redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() ); } - - res.setUsersCacheConfiguration( - getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(), - org.apache.archiva.configuration.CacheConfiguration.class ) ); + res.setUsersCacheConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(), + org.apache.archiva.configuration.CacheConfiguration.class ) ); List ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings(); diff --git a/archiva-modules/plugins/maven2-repository/pom.xml b/archiva-modules/plugins/maven2-repository/pom.xml index 0d04e7ae9..b321f1dbb 100644 --- a/archiva-modules/plugins/maven2-repository/pom.xml +++ b/archiva-modules/plugins/maven2-repository/pom.xml @@ -263,6 +263,9 @@ org.sonatype.aether.util, org.sonatype.aether.util.artifact, org.modelmapper, + org.modelmapper.config, + org.modelmapper.convention, + org.modelmapper.spi, org.apache.archiva.maven2.model, org.sonatype.aether.util.graph.selector, org.apache.archiva.metadata.model.maven2, 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 index 82c8aa873..56ab172d3 100644 --- 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 @@ -21,6 +21,7 @@ package org.apache.archiva.dependency.tree.maven2; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.maven2.model.TreeEntry; import org.modelmapper.ModelMapper; +import org.modelmapper.convention.MatchingStrategies; import org.sonatype.aether.graph.DependencyNode; import org.sonatype.aether.graph.DependencyVisitor; @@ -48,8 +49,8 @@ public class TreeDependencyNodeVisitor public boolean visitEnter( DependencyNode dependencyNode ) { - TreeEntry entry = new TreeEntry( - getModelMapper().map( dependencyNode.getDependency().getArtifact(), Artifact.class ) ); + TreeEntry entry = + new TreeEntry( getModelMapper().map( dependencyNode.getDependency().getArtifact(), Artifact.class ) ); entry.getArtifact().setScope( dependencyNode.getDependency().getScope() ); entry.setParent( currentEntry ); currentEntry = entry; @@ -75,6 +76,11 @@ public class TreeDependencyNodeVisitor private static class ModelMapperHolder { private static ModelMapper MODEL_MAPPER = new ModelMapper(); + + static + { + MODEL_MAPPER.getConfiguration().setMatchingStrategy( MatchingStrategies.STRICT ); + } } protected ModelMapper getModelMapper() -- 2.39.5