use model mapper

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1553475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-26 12:55:56 +00:00
parent ec6548f9ff
commit 3c2817d545
10 changed files with 62 additions and 81 deletions

View File

@ -46,21 +46,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!--
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.indexer</groupId>
<artifactId>indexer-core</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
-->
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>

View File

@ -66,22 +66,8 @@
<artifactId>spring-taskqueue</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>
@ -254,7 +240,7 @@
<Import-Package>
javax.annotation,
javax.inject,
net.sf.beanlib.provider.replicator,
org.modelmapper,
org.apache.archiva.admin.model*;version=${project.version},
org.apache.archiva.audit;version=${project.version},
org.apache.archiva.common.plexusbridge;version=${project.version},

View File

@ -28,6 +28,7 @@ import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.redback.users.User;
import org.apache.archiva.redback.components.registry.Registry;
import org.modelmapper.ModelMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -91,6 +92,16 @@ public abstract class AbstractRepositoryAdmin
}
}
private static class ModelMapperHolder
{
private static ModelMapper MODEL_MAPPER = new ModelMapper();
}
protected ModelMapper getModelMapper()
{
return ModelMapperHolder.MODEL_MAPPER;
}
public List<AuditListener> getAuditListeners()
{
return auditListeners;

View File

@ -18,7 +18,6 @@ package org.apache.archiva.admin.repository.admin;
* 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.admin.ArchivaAdministration;
@ -81,7 +80,7 @@ public class DefaultArchivaAdministration
for ( org.apache.archiva.configuration.LegacyArtifactPath legacyArtifactPath : getArchivaConfiguration().getConfiguration().getLegacyArtifactPaths() )
{
legacyArtifactPaths.add(
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
getModelMapper().map( legacyArtifactPath, LegacyArtifactPath.class ) );
}
return legacyArtifactPaths;
}
@ -91,8 +90,8 @@ public class DefaultArchivaAdministration
{
Configuration configuration = getArchivaConfiguration().getConfiguration();
configuration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
org.apache.archiva.configuration.LegacyArtifactPath.class ) );
configuration.addLegacyArtifactPath( getModelMapper().map( legacyArtifactPath,
org.apache.archiva.configuration.LegacyArtifactPath.class ) );
saveConfiguration( configuration );
triggerAuditEvent( "", "", AuditEvent.ADD_LEGACY_PATH, auditInformation );
@ -160,7 +159,7 @@ public class DefaultArchivaAdministration
{
return null;
}
return new BeanReplicator().replicateBean( fileType, FileType.class );
return getModelMapper().map( fileType, FileType.class );
}
public void addFileType( FileType fileType, AuditInformation auditInformation )
@ -174,7 +173,7 @@ public class DefaultArchivaAdministration
}
configuration.getRepositoryScanning().addFileType(
new BeanReplicator().replicateBean( fileType, org.apache.archiva.configuration.FileType.class ) );
getModelMapper().map( fileType, org.apache.archiva.configuration.FileType.class ) );
saveConfiguration( configuration );
}
@ -272,7 +271,7 @@ public class DefaultArchivaAdministration
List<FileType> fileTypes = new ArrayList<FileType>( configFileTypes.size() );
for ( org.apache.archiva.configuration.FileType fileType : configFileTypes )
{
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
fileTypes.add( getModelMapper().map( fileType, FileType.class ) );
}
return fileTypes;
}
@ -300,7 +299,7 @@ public class DefaultArchivaAdministration
{
return null;
}
return new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
return getModelMapper().map( organisationInformation, OrganisationInformation.class );
}
public void setOrganisationInformation( OrganisationInformation organisationInformation )
@ -310,8 +309,8 @@ public class DefaultArchivaAdministration
if ( organisationInformation != null )
{
org.apache.archiva.configuration.OrganisationInformation organisationInformationModel =
new BeanReplicator().replicateBean( organisationInformation,
org.apache.archiva.configuration.OrganisationInformation.class );
getModelMapper().map( organisationInformation,
org.apache.archiva.configuration.OrganisationInformation.class );
configuration.setOrganisationInfo( organisationInformationModel );
}
else
@ -334,7 +333,7 @@ public class DefaultArchivaAdministration
{
return null;
}
return new BeanReplicator().replicateBean( userInterfaceOptions, UiConfiguration.class );
return getModelMapper().map( userInterfaceOptions, UiConfiguration.class );
}
public void updateUiConfiguration( UiConfiguration uiConfiguration )
@ -345,7 +344,7 @@ public class DefaultArchivaAdministration
{
UserInterfaceOptions userInterfaceOptions =
new BeanReplicator().replicateBean( uiConfiguration, UserInterfaceOptions.class );
getModelMapper().map( uiConfiguration, UserInterfaceOptions.class );
configuration.getWebapp().setUi( userInterfaceOptions );
}
else
@ -366,7 +365,7 @@ public class DefaultArchivaAdministration
{
return null;
}
return new BeanReplicator().replicateBean( networkConfiguration, NetworkConfiguration.class );
return getModelMapper().map( networkConfiguration, NetworkConfiguration.class );
}
public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
@ -379,8 +378,8 @@ public class DefaultArchivaAdministration
}
else
{
configuration.setNetworkConfiguration( new BeanReplicator().replicateBean( networkConfiguration,
org.apache.archiva.configuration.NetworkConfiguration.class ) );
configuration.setNetworkConfiguration( getModelMapper().map( networkConfiguration,
org.apache.archiva.configuration.NetworkConfiguration.class ) );
}
setupWagon( networkConfiguration );
saveConfiguration( configuration );

View File

@ -27,10 +27,7 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ConfigurationEvent;
import org.apache.archiva.configuration.ConfigurationListener;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.redback.components.registry.RegistryListener;
import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;

View File

@ -18,7 +18,6 @@ package org.apache.archiva.admin.repository.networkproxy;
* 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.NetworkProxy;
@ -143,13 +142,13 @@ public class DefaultNetworkProxyAdmin
{
return networkProxyConfiguration == null
? null
: new BeanReplicator().replicateBean( networkProxyConfiguration, NetworkProxy.class );
: getModelMapper().map( networkProxyConfiguration, NetworkProxy.class );
}
protected NetworkProxyConfiguration getNetworkProxyConfiguration( NetworkProxy networkProxy )
{
return networkProxy == null
? null
: new BeanReplicator().replicateBean( networkProxy, NetworkProxyConfiguration.class );
: getModelMapper().map( networkProxy, NetworkProxyConfiguration.class );
}
}

View File

@ -18,7 +18,6 @@ package org.apache.archiva.admin.repository.proxyconnector;
* 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.ProxyConnector;
@ -211,14 +210,14 @@ public class DefaultProxyConnectorAdmin
{
return proxyConnector == null
? null
: new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
: getModelMapper().map( proxyConnector, ProxyConnectorConfiguration.class );
}
protected ProxyConnector getProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
{
return proxyConnectorConfiguration == null
? null
: new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
: getModelMapper().map( proxyConnectorConfiguration, ProxyConnector.class );
}
protected void validateProxyConnector( ProxyConnector proxyConnector )

View File

@ -18,12 +18,12 @@ package org.apache.archiva.admin.repository.runtime;
* under the License.
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.CacheConfiguration;
import org.apache.archiva.admin.model.beans.FileLockConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
@ -41,6 +41,7 @@ import javax.inject.Named;
*/
@Service( "archivaRuntimeConfigurationAdmin#default" )
public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin
{
@ -151,22 +152,22 @@ public class DefaultArchivaRuntimeConfigurationAdmin
}
ArchivaRuntimeConfiguration res =
new BeanReplicator().replicateBean( archivaRuntimeConfiguration, ArchivaRuntimeConfiguration.class );
getModelMapper().map( archivaRuntimeConfiguration, ArchivaRuntimeConfiguration.class );
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() != null )
{
res.setUrlFailureCacheConfiguration(
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration(),
CacheConfiguration.class ) );
getModelMapper().map( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration(),
CacheConfiguration.class ) );
}
if ( archivaRuntimeConfiguration.getFileLockConfiguration() != null )
{
res.setFileLockConfiguration(
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getFileLockConfiguration(),
FileLockConfiguration.class ) );
getModelMapper().map( archivaRuntimeConfiguration.getFileLockConfiguration(),
FileLockConfiguration.class ) );
}
return res;
@ -181,23 +182,23 @@ public class DefaultArchivaRuntimeConfigurationAdmin
}
org.apache.archiva.configuration.ArchivaRuntimeConfiguration res =
new BeanReplicator().replicateBean( archivaRuntimeConfiguration,
org.apache.archiva.configuration.ArchivaRuntimeConfiguration.class );
getModelMapper().map( archivaRuntimeConfiguration,
org.apache.archiva.configuration.ArchivaRuntimeConfiguration.class );
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() != null )
{
res.setUrlFailureCacheConfiguration(
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration(),
org.apache.archiva.configuration.CacheConfiguration.class ) );
getModelMapper().map( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration(),
org.apache.archiva.configuration.CacheConfiguration.class ) );
}
if ( archivaRuntimeConfiguration.getFileLockConfiguration() != null )
{
res.setFileLockConfiguration(
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getFileLockConfiguration(),
org.apache.archiva.configuration.FileLockConfiguration.class ) );
getModelMapper().map( archivaRuntimeConfiguration.getFileLockConfiguration(),
org.apache.archiva.configuration.FileLockConfiguration.class ) );
}
return res;

View File

@ -18,13 +18,13 @@ package org.apache.archiva.admin.repository.runtime;
* under the License.
*/
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.CacheConfiguration;
import org.apache.archiva.admin.model.beans.LdapConfiguration;
import org.apache.archiva.admin.model.beans.LdapGroupMapping;
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
@ -43,7 +43,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -55,6 +54,7 @@ import java.util.Set;
*/
@Service( "redbackRuntimeConfigurationAdmin#default" )
public class DefaultRedbackRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements RedbackRuntimeConfigurationAdmin, UserConfiguration
{
@ -298,20 +298,18 @@ public class DefaultRedbackRuntimeConfigurationAdmin
org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
{
RedbackRuntimeConfiguration redbackRuntimeConfiguration =
new BeanReplicator().replicateBean( runtimeConfiguration, RedbackRuntimeConfiguration.class );
getModelMapper().map( runtimeConfiguration, RedbackRuntimeConfiguration.class );
if ( runtimeConfiguration.getLdapConfiguration() != null )
{
redbackRuntimeConfiguration.setLdapConfiguration(
new BeanReplicator().replicateBean( runtimeConfiguration.getLdapConfiguration(),
LdapConfiguration.class ) );
getModelMapper().map( runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class ) );
}
if ( runtimeConfiguration.getUsersCacheConfiguration() != null )
{
redbackRuntimeConfiguration.setUsersCacheConfiguration(
new BeanReplicator().replicateBean( runtimeConfiguration.getUsersCacheConfiguration(),
CacheConfiguration.class ) );
getModelMapper().map( runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class ) );
}
if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
@ -378,16 +376,16 @@ public class DefaultRedbackRuntimeConfigurationAdmin
RedbackRuntimeConfiguration redbackRuntimeConfiguration )
{
org.apache.archiva.configuration.RedbackRuntimeConfiguration res =
new BeanReplicator().replicateBean( redbackRuntimeConfiguration,
org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
getModelMapper().map( redbackRuntimeConfiguration,
org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
{
redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
}
res.setLdapConfiguration(
new BeanReplicator().replicateBean( redbackRuntimeConfiguration.getLdapConfiguration(),
org.apache.archiva.configuration.LdapConfiguration.class ) );
getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(),
org.apache.archiva.configuration.LdapConfiguration.class ) );
if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
{
@ -396,8 +394,8 @@ public class DefaultRedbackRuntimeConfigurationAdmin
res.setUsersCacheConfiguration(
new BeanReplicator().replicateBean( redbackRuntimeConfiguration.getUsersCacheConfiguration(),
org.apache.archiva.configuration.CacheConfiguration.class ) );
getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(),
org.apache.archiva.configuration.CacheConfiguration.class ) );
List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings();

View File

@ -574,6 +574,12 @@
<version>1.0-2</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>0.6.2</version>
</dependency>
<dependency>
<groupId>net.sf.beanlib</groupId>
<artifactId>beanlib</artifactId>