[MRM-1520] remove duplicate beans : no more need of BeanReplicator in some places

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171404 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-16 07:10:59 +00:00
parent 0396658ae6
commit 5ff9dab635
5 changed files with 35 additions and 147 deletions

View File

@ -18,7 +18,6 @@ package org.apache.archiva.rest.services;
* under the License. * under the License.
*/ */
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType; import org.apache.archiva.admin.model.beans.FileType;
@ -50,13 +49,7 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>(); return archivaAdministration.getLegacyArtifactPaths();
for ( org.apache.archiva.admin.model.beans.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
{
legacyArtifactPaths.add(
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
}
return legacyArtifactPaths;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -69,9 +62,7 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath, archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
org.apache.archiva.admin.model.beans.LegacyArtifactPath.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -127,12 +118,7 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
org.apache.archiva.admin.model.beans.FileType fileType = archivaAdministration.getFileType( fileTypeId ); return archivaAdministration.getFileType( fileTypeId );
if ( fileType == null )
{
return null;
}
return new BeanReplicator().replicateBean( fileType, FileType.class );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -145,9 +131,7 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
archivaAdministration.addFileType( archivaAdministration.addFileType( fileType, getAuditInformation() );
new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.model.beans.FileType.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -256,17 +240,12 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
List<org.apache.archiva.admin.model.beans.FileType> modelfileTypes = archivaAdministration.getFileTypes(); List<FileType> modelfileTypes = archivaAdministration.getFileTypes();
if ( modelfileTypes == null || modelfileTypes.isEmpty() ) if ( modelfileTypes == null || modelfileTypes.isEmpty() )
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
List<FileType> fileTypes = new ArrayList<FileType>( modelfileTypes.size() ); return modelfileTypes;
for ( org.apache.archiva.admin.model.beans.FileType fileType : modelfileTypes )
{
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
}
return fileTypes;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -305,12 +284,7 @@ public class DefaultArchivaAdministrationService
{ {
try try
{ {
org.apache.archiva.admin.model.beans.OrganisationInformation organisationInformation = return archivaAdministration.getOrganisationInformation();
archivaAdministration.getOrganisationInformation();
return organisationInformation == null
? null
: new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -329,9 +303,7 @@ public class DefaultArchivaAdministrationService
} }
else else
{ {
archivaAdministration.setOrganisationInformation( archivaAdministration.setOrganisationInformation( organisationInformation );
new BeanReplicator().replicateBean( organisationInformation,
org.apache.archiva.admin.model.beans.OrganisationInformation.class ) );
} }
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )

View File

@ -28,7 +28,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -55,24 +55,7 @@ public class DefaultManagedRepositoriesService
{ {
List<org.apache.archiva.admin.model.beans.ManagedRepository> repos = List<org.apache.archiva.admin.model.beans.ManagedRepository> repos =
managedRepositoryAdmin.getManagedRepositories(); managedRepositoryAdmin.getManagedRepositories();
return repos == null ? Collections.<ManagedRepository>emptyList() : repos;
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( repos.size() );
for ( org.apache.archiva.admin.model.beans.ManagedRepository repoConfig : repos )
{
// TODO staging repo too
ManagedRepository repo =
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
repoConfig.isBlockRedeployments(), repoConfig.getCronExpression(),
repoConfig.getIndexDirectory(), repoConfig.isScanned(),
repoConfig.getDaysOlder(), repoConfig.getRetentionCount(),
repoConfig.isDeleteReleasedSnapshots(), repoConfig.isStageRepoNeeded() );
managedRepos.add( repo );
}
return managedRepos;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -113,23 +96,11 @@ public class DefaultManagedRepositoriesService
public Boolean addManagedRepository( ManagedRepository managedRepository ) public Boolean addManagedRepository( ManagedRepository managedRepository )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
org.apache.archiva.admin.model.beans.ManagedRepository repo =
new org.apache.archiva.admin.model.beans.ManagedRepository();
repo.setLocation( managedRepository.getLocation() );
repo.setBlockRedeployments( managedRepository.isBlockRedeployments() );
repo.setCronExpression( managedRepository.getCronExpression() );
repo.setId( managedRepository.getId() );
repo.setLayout( managedRepository.getLayout() );
repo.setName( managedRepository.getName() );
repo.setReleases( managedRepository.isReleases() );
repo.setSnapshots( managedRepository.isSnapshots() );
repo.setIndexDirectory( managedRepository.getIndexDirectory() );
repo.setDaysOlder( managedRepository.getDaysOlder() );
repo.setDeleteReleasedSnapshots( managedRepository.isDeleteReleasedSnapshots() );
repo.setRetentionCount( managedRepository.getRetentionCount() );
try try
{ {
return managedRepositoryAdmin.addManagedRepository( repo, managedRepository.isStageRepoNeeded(), return managedRepositoryAdmin.addManagedRepository( managedRepository,
managedRepository.isStageRepoNeeded(),
getAuditInformation() ); getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
@ -142,19 +113,11 @@ public class DefaultManagedRepositoriesService
public Boolean updateManagedRepository( ManagedRepository managedRepository ) public Boolean updateManagedRepository( ManagedRepository managedRepository )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
org.apache.archiva.admin.model.beans.ManagedRepository repo =
new org.apache.archiva.admin.model.beans.ManagedRepository();
repo.setLocation( managedRepository.getLocation() );
repo.setBlockRedeployments( managedRepository.isBlockRedeployments() );
repo.setCronExpression( managedRepository.getCronExpression() );
repo.setId( managedRepository.getId() );
repo.setLayout( managedRepository.getLayout() );
repo.setName( managedRepository.getName() );
repo.setReleases( managedRepository.isReleases() );
repo.setSnapshots( managedRepository.isSnapshots() );
try try
{ {
return managedRepositoryAdmin.updateManagedRepository( repo, managedRepository.isStageRepoNeeded(), return managedRepositoryAdmin.updateManagedRepository( managedRepository,
managedRepository.isStageRepoNeeded(),
getAuditInformation(), getAuditInformation(),
managedRepository.isResetStats() ); managedRepository.isResetStats() );
} }

View File

@ -18,7 +18,6 @@ package org.apache.archiva.rest.services;
* under the License. * under the License.
*/ */
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.beans.NetworkProxy;
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
@ -27,7 +26,7 @@ import org.apache.archiva.rest.api.services.NetworkProxyService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -46,12 +45,8 @@ public class DefaultNetworkProxyService
{ {
try try
{ {
List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>(); List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
for ( org.apache.archiva.admin.model.beans.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() ) return networkProxies == null ? Collections.<NetworkProxy>emptyList() : networkProxies;
{
networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) );
}
return networkProxies;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -64,9 +59,7 @@ public class DefaultNetworkProxyService
{ {
try try
{ {
org.apache.archiva.admin.model.beans.NetworkProxy networkProxy = return networkProxyAdmin.getNetworkProxy( networkProxyId );
networkProxyAdmin.getNetworkProxy( networkProxyId );
return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -83,9 +76,7 @@ public class DefaultNetworkProxyService
{ {
return; return;
} }
getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy, getNetworkProxyAdmin().addNetworkProxy( networkProxy, getAuditInformation() );
org.apache.archiva.admin.model.beans.NetworkProxy.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -102,9 +93,7 @@ public class DefaultNetworkProxyService
} }
try try
{ {
getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy, getNetworkProxyAdmin().updateNetworkProxy( networkProxy, getAuditInformation() );
org.apache.archiva.admin.model.beans.NetworkProxy.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {

View File

@ -18,7 +18,6 @@ package org.apache.archiva.rest.services;
* under the License. * under the License.
*/ */
import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.beans.ProxyConnector;
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
@ -27,7 +26,7 @@ import org.apache.archiva.rest.api.services.ProxyConnectorService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -46,12 +45,8 @@ public class DefaultProxyConnectorService
{ {
try try
{ {
List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>(); List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectors();
for ( org.apache.archiva.admin.model.beans.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() ) return proxyConnectors == null ? Collections.<ProxyConnector>emptyList() : proxyConnectors;
{
proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
}
return proxyConnectors;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -64,11 +59,7 @@ public class DefaultProxyConnectorService
{ {
try try
{ {
org.apache.archiva.admin.model.beans.ProxyConnector proxyConnector = return proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
return proxyConnector == null
? null
: new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -85,9 +76,7 @@ public class DefaultProxyConnectorService
} }
try try
{ {
return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector, return proxyConnectorAdmin.addProxyConnector( proxyConnector, getAuditInformation() );
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -104,9 +93,7 @@ public class DefaultProxyConnectorService
} }
try try
{ {
return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector, return proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation() );
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -123,9 +110,7 @@ public class DefaultProxyConnectorService
} }
try try
{ {
return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector, return proxyConnectorAdmin.updateProxyConnector( proxyConnector, getAuditInformation() );
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
getAuditInformation() );
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {

View File

@ -27,7 +27,7 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -48,17 +48,8 @@ public class DefaultRemoteRepositoriesService
{ {
try try
{ {
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>(); List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories();
for ( org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() ) return remoteRepositories == null ? Collections.<RemoteRepository>emptyList() : remoteRepositories;
{
RemoteRepository repo = new RemoteRepository( remoteRepository.getId(), remoteRepository.getName(),
remoteRepository.getUrl(), remoteRepository.getLayout(),
remoteRepository.getUserName(),
remoteRepository.getPassword(),
remoteRepository.getTimeout() );
remoteRepositories.add( repo );
}
return remoteRepositories;
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
@ -89,26 +80,14 @@ public class DefaultRemoteRepositoriesService
public Boolean addRemoteRepository( RemoteRepository remoteRepository ) public Boolean addRemoteRepository( RemoteRepository remoteRepository )
throws Exception throws Exception
{ {
return remoteRepositoryAdmin.addRemoteRepository( getModelRemoteRepository( remoteRepository ), return remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getAuditInformation() );
getAuditInformation() );
} }
public Boolean updateRemoteRepository( RemoteRepository remoteRepository ) public Boolean updateRemoteRepository( RemoteRepository remoteRepository )
throws Exception throws Exception
{ {
return remoteRepositoryAdmin.updateRemoteRepository( getModelRemoteRepository( remoteRepository ), return remoteRepositoryAdmin.updateRemoteRepository( remoteRepository, getAuditInformation() );
getAuditInformation() );
} }
private org.apache.archiva.admin.model.beans.RemoteRepository getModelRemoteRepository(
RemoteRepository remoteRepository )
{
return new org.apache.archiva.admin.model.beans.RemoteRepository( remoteRepository.getId(),
remoteRepository.getName(),
remoteRepository.getUrl(),
remoteRepository.getLayout(),
remoteRepository.getUserName(),
remoteRepository.getPassword(),
remoteRepository.getTimeout() );
}
} }