]> source.dussan.org Git - archiva.git/commitdiff
use model mapper
authorOlivier Lamy <olamy@apache.org>
Thu, 26 Dec 2013 12:55:56 +0000 (12:55 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 26 Dec 2013 12:55:56 +0000 (12:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1553475 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-common/pom.xml
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/networkproxy/DefaultNetworkProxyAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java
pom.xml

index 94d979e8e5aa5baa6dec31415b70f042c9f31af4..d2599e860b15f39c6275949de75ca358a04c54d3 100644 (file)
       <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>
index 25b3d5bd7171925872bac98d82f688979cc5d547..32e7cfed1aba6c2885d4714d79f4b680c8fc4604 100644 (file)
       <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>
             <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},
index 3286e22bbe1a95aacda489c3fdb70230223dc3ff..194028f295adb765ab74db535f6745a785c74c53 100644 (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;
index e9586253960a2a7ea547132e902595d084656cb5..93933ad20551222b5a6a7b249f1dfd2177eeb3ba 100644 (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 );
index abc3caae56caf6a607ead2b53c6c6c30ff23085b..f53ae3fe70d6bf141a1fd23ed7bf274b8c235e49 100644 (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;
index 897bd5c7a9b011253441c0905136953f58dda91a..bf0bde93b3faba2c362de0779917fd6d05fbfe82 100644 (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 );
     }
 }
index b3104fe3e25ab4c791b811b293f893f8240a11a6..bd9fdab40993d6e387ac925b4a9d597326ad8316 100644 (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 )
index 3ac847b9fef23d734fec1dbaee3162876a34e3e8..be7004e68a04b29492d0ccfa51eaa9b5ae6aa840 100644 (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;
index 37ffe0aa816103447f852d3ec815760e083dfed7..6373a3427bd97020d8e1fb4c4f59d705f6992523 100644 (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();
 
diff --git a/pom.xml b/pom.xml
index 529a61aba16848d640f207c9400fd2fe7894151a..44c4270977eb128179addc4a0575aa231fb8802e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <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>