mirror of https://github.com/apache/archiva.git
fix mapping with modelmapper
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1553476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c2817d545
commit
04d1d172a6
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ) )
|
||||
{
|
||||
|
|
|
@ -141,22 +141,8 @@
|
|||
<artifactId>wagon-provider-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.beanlib</groupId>
|
||||
<artifactId>beanlib</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
|
@ -270,7 +256,7 @@
|
|||
org.sonatype.aether.repository,
|
||||
org.sonatype.aether.util,
|
||||
org.sonatype.aether.util.artifact,
|
||||
net.sf.beanlib.provider.replicator,
|
||||
org.modelmapper,
|
||||
org.apache.archiva.maven2.model,
|
||||
org.sonatype.aether.util.graph.selector,
|
||||
org.apache.archiva.metadata.model.maven2,
|
||||
|
|
|
@ -18,9 +18,9 @@ package org.apache.archiva.dependency.tree.maven2;
|
|||
* 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.modelmapper.ModelMapper;
|
||||
import org.sonatype.aether.graph.DependencyNode;
|
||||
import org.sonatype.aether.graph.DependencyVisitor;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class TreeDependencyNodeVisitor
|
|||
public boolean visitEnter( DependencyNode dependencyNode )
|
||||
{
|
||||
TreeEntry entry = new TreeEntry(
|
||||
new BeanReplicator().replicateBean( dependencyNode.getDependency().getArtifact(), Artifact.class ) );
|
||||
getModelMapper().map( dependencyNode.getDependency().getArtifact(), Artifact.class ) );
|
||||
entry.getArtifact().setScope( dependencyNode.getDependency().getScope() );
|
||||
entry.setParent( currentEntry );
|
||||
currentEntry = entry;
|
||||
|
@ -71,4 +71,14 @@ public class TreeDependencyNodeVisitor
|
|||
currentEntry = currentEntry.getParent();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class ModelMapperHolder
|
||||
{
|
||||
private static ModelMapper MODEL_MAPPER = new ModelMapper();
|
||||
}
|
||||
|
||||
protected ModelMapper getModelMapper()
|
||||
{
|
||||
return ModelMapperHolder.MODEL_MAPPER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.archiva.configuration;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
||||
import org.apache.archiva.admin.model.AuditInformation;
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
|
@ -33,6 +32,7 @@ import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorOrderComparat
|
|||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -279,7 +279,7 @@ public class MockRepoAdmin
|
|||
{
|
||||
return proxyConnectorConfiguration == null
|
||||
? null
|
||||
: new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
|
||||
: new ModelMapper().map( proxyConnectorConfiguration, ProxyConnector.class );
|
||||
}
|
||||
|
||||
public List<ProxyConnectorRule> getProxyConnectorRules()
|
||||
|
|
|
@ -69,22 +69,8 @@
|
|||
</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>
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.netflix.astyanax.entitystore.EntityManager;
|
||||
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.FacetedMetadata;
|
||||
|
@ -42,6 +41,7 @@ import org.apache.archiva.metadata.repository.cassandra.model.Project;
|
|||
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Repository;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -870,7 +870,7 @@ public class CassandraMetadataRepository
|
|||
if ( projectVersionMetadataModel == null )
|
||||
{
|
||||
projectVersionMetadataModel =
|
||||
new BeanReplicator().replicateBean( versionMetadata, ProjectVersionMetadataModel.class );
|
||||
getModelMapper().map( versionMetadata, ProjectVersionMetadataModel.class );
|
||||
projectVersionMetadataModel.setRowId( key );
|
||||
}
|
||||
projectVersionMetadataModel.setProjectId( projectId );
|
||||
|
@ -1162,7 +1162,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
for ( ArtifactMetadataModel model : artifactMetadataModels )
|
||||
{
|
||||
ArtifactMetadata artifactMetadata = new BeanReplicator().replicateBean( model, ArtifactMetadata.class );
|
||||
ArtifactMetadata artifactMetadata = getModelMapper().map( model, ArtifactMetadata.class );
|
||||
populateFacets( artifactMetadata );
|
||||
artifactMetadatas.add( artifactMetadata );
|
||||
}
|
||||
|
@ -1269,7 +1269,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
for ( ArtifactMetadataModel model : artifactMetadataModels )
|
||||
{
|
||||
ArtifactMetadata artifactMetadata = new BeanReplicator().replicateBean( model, ArtifactMetadata.class );
|
||||
ArtifactMetadata artifactMetadata = getModelMapper().map( model, ArtifactMetadata.class );
|
||||
populateFacets( artifactMetadata );
|
||||
artifactMetadatas.add( artifactMetadata );
|
||||
}
|
||||
|
@ -1380,7 +1380,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
for ( ArtifactMetadataModel model : artifactMetadataModels )
|
||||
{
|
||||
ArtifactMetadata artifactMetadata = new BeanReplicator().replicateBean( model, ArtifactMetadata.class );
|
||||
ArtifactMetadata artifactMetadata = getModelMapper().map( model, ArtifactMetadata.class );
|
||||
populateFacets( artifactMetadata );
|
||||
artifactMetadatas.add( artifactMetadata );
|
||||
}
|
||||
|
@ -1450,7 +1450,7 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
|
||||
ProjectVersionMetadata projectVersionMetadata =
|
||||
new BeanReplicator().replicateBean( projectVersionMetadataModel, ProjectVersionMetadata.class );
|
||||
getModelMapper().map( projectVersionMetadataModel, ProjectVersionMetadata.class );
|
||||
|
||||
logger.debug( "getProjectVersion repoId: '{}', namespace: '{}', projectId: '{}', projectVersion: {} -> {}",
|
||||
repoId, namespace, projectId, projectVersion, projectVersionMetadata );
|
||||
|
@ -1630,7 +1630,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
for ( ArtifactMetadataModel model : artifactMetadataModels )
|
||||
{
|
||||
ArtifactMetadata artifactMetadata = new BeanReplicator().replicateBean( model, ArtifactMetadata.class );
|
||||
ArtifactMetadata artifactMetadata = getModelMapper().map( model, ArtifactMetadata.class );
|
||||
populateFacets( artifactMetadata );
|
||||
artifactMetadatas.add( artifactMetadata );
|
||||
}
|
||||
|
@ -1751,4 +1751,15 @@ public class CassandraMetadataRepository
|
|||
throw new IllegalArgumentException(
|
||||
"Access using " + aClass + " is not supported on the cassandra metadata storage" );
|
||||
}
|
||||
|
||||
|
||||
private static class ModelMapperHolder
|
||||
{
|
||||
private static ModelMapper MODEL_MAPPER = new ModelMapper();
|
||||
}
|
||||
|
||||
protected ModelMapper getModelMapper()
|
||||
{
|
||||
return ModelMapperHolder.MODEL_MAPPER;
|
||||
}
|
||||
}
|
||||
|
|
15
pom.xml
15
pom.xml
|
@ -580,21 +580,6 @@
|
|||
<version>0.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.beanlib</groupId>
|
||||
<artifactId>beanlib</artifactId>
|
||||
<version>5.0.2beta</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>aopalliance</groupId>
|
||||
<artifactId>aopalliance</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
|
|
Loading…
Reference in New Issue