diff options
author | Olivier Lamy <olamy@apache.org> | 2013-12-26 12:56:18 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-12-26 12:56:18 +0000 |
commit | 04d1d172a6bb67a4a10f36f2498cac22e2163f4a (patch) | |
tree | bd8833cdc9fc09316ad25f568682e0ce24b74928 /archiva-modules/archiva-web | |
parent | 3c2817d54508704f21b343dce0592b2c3b70134f (diff) | |
download | archiva-04d1d172a6bb67a4a10f36f2498cac22e2163f4a.tar.gz archiva-04d1d172a6bb67a4a10f36f2498cac22e2163f4a.zip |
fix mapping with modelmapper
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1553476 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web')
5 files changed, 40 insertions, 27 deletions
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 99e37c8ee..25e2d15ef 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 @@ -180,23 +180,10 @@ </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> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - </exclusions> + <groupId>org.modelmapper</groupId> + <artifactId>modelmapper</artifactId> </dependency> + <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>woodstox-core-asl</artifactId> 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 bd19e65b2..8e1b8a812 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 @@ -26,6 +26,7 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; import org.apache.archiva.common.utils.VersionUtil; +import org.apache.archiva.indexer.search.SearchResultHit; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.repository.RepositorySessionFactory; @@ -46,6 +47,8 @@ import org.apache.archiva.security.ArchivaSecurityException; import org.apache.archiva.security.PrincipalNotFoundException; import org.apache.archiva.security.UserRepositories; import org.apache.commons.lang.StringUtils; +import org.modelmapper.ModelMapper; +import org.modelmapper.PropertyMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; @@ -83,7 +86,7 @@ public abstract class AbstractRestService * FIXME: this could be multiple implementations and needs to be configured. */ @Inject - @Named(value = "repositorySessionFactory") + @Named( value = "repositorySessionFactory" ) protected RepositorySessionFactory repositorySessionFactory; @Inject @@ -96,7 +99,7 @@ public abstract class AbstractRestService protected RepositoryContentFactory repositoryContentFactory; @Inject - @Named(value = "archivaTaskScheduler#repository") + @Named( value = "archivaTaskScheduler#repository" ) protected DefaultRepositoryArchivaTaskScheduler repositoryTaskScheduler; @@ -312,4 +315,31 @@ public abstract class AbstractRestService } return true; } + + private static class ModelMapperHolder + { + private static ModelMapper MODEL_MAPPER = new ModelMapper(); + + static + { + MODEL_MAPPER.addMappings( new SearchResultHitMap() ); + } + } + + + private static class SearchResultHitMap + extends PropertyMap<SearchResultHit, Artifact> + { + protected void configure() + { + skip().setId( null ); + } + } + + ; + + protected ModelMapper getModelMapper() + { + return ModelMapperHolder.MODEL_MAPPER; + } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java index c43f85047..c5383bb28 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java @@ -18,7 +18,6 @@ package org.apache.archiva.rest.services; * under the License. */ -import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryCommonValidator; import org.apache.archiva.admin.model.beans.ManagedRepository; @@ -170,7 +169,7 @@ public class DefaultManagedRepositoriesService if ( stats != null ) { ArchivaRepositoryStatistics archivaRepositoryStatistics = - new BeanReplicator().replicateBean( stats, ArchivaRepositoryStatistics.class ); + getModelMapper().map( stats, ArchivaRepositoryStatistics.class ); archivaRepositoryStatistics.setDuration( archivaRepositoryStatistics.getScanEndTime().getTime() - archivaRepositoryStatistics.getScanStartTime().getTime() ); archivaRepositoryStatistics.setLastScanDate( diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index a2bca4d2f..1b214be22 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -19,16 +19,15 @@ package org.apache.archiva.rest.services; */ import org.apache.archiva.admin.model.RepositoryAdminException; -import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration; +import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin; import org.apache.archiva.redback.authentication.Authenticator; import org.apache.archiva.redback.common.ldap.connection.LdapConnection; -import org.apache.archiva.redback.common.ldap.user.LdapUserMapper; -import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory; import org.apache.archiva.redback.common.ldap.connection.LdapException; +import org.apache.archiva.redback.common.ldap.user.LdapUserMapper; import org.apache.archiva.redback.components.cache.Cache; import org.apache.archiva.redback.policy.CookieSettings; import org.apache.archiva.redback.policy.PasswordRule; @@ -40,7 +39,6 @@ import org.apache.archiva.rest.api.model.RedbackImplementationsInformations; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService; - import org.apache.commons.lang.StringUtils; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; 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 2f4fc210c..bc1f2cc57 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 @@ -19,7 +19,6 @@ package org.apache.archiva.rest.services; * under the License. */ -import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.indexer.search.RepositorySearchException; import org.apache.archiva.indexer.search.SearchFields; @@ -139,7 +138,7 @@ public class DefaultSearchService { return Collections.emptyList(); } - SearchFields searchField = new BeanReplicator().replicateBean( searchRequest, SearchFields.class ); + SearchFields searchField = getModelMapper().map( searchRequest, SearchFields.class ); SearchResultLimits limits = new SearchResultLimits( 0 ); // if no repos set we use ones available for the user @@ -219,7 +218,7 @@ public class DefaultSearchService for ( String version : hit.getVersions() ) { - Artifact versionned = new BeanReplicator().replicateBean( hit, Artifact.class ); + Artifact versionned = getModelMapper().map( hit, Artifact.class ); if ( StringUtils.isNotBlank( version ) ) { |