mirror of https://github.com/apache/archiva.git
[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:
parent
0396658ae6
commit
5ff9dab635
|
@ -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.admin.ArchivaAdministration;
|
||||
import org.apache.archiva.admin.model.beans.FileType;
|
||||
|
@ -50,13 +49,7 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<LegacyArtifactPath> legacyArtifactPaths = new ArrayList<LegacyArtifactPath>();
|
||||
for ( org.apache.archiva.admin.model.beans.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() )
|
||||
{
|
||||
legacyArtifactPaths.add(
|
||||
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
|
||||
}
|
||||
return legacyArtifactPaths;
|
||||
return archivaAdministration.getLegacyArtifactPaths();
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -69,9 +62,7 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath,
|
||||
org.apache.archiva.admin.model.beans.LegacyArtifactPath.class ),
|
||||
getAuditInformation() );
|
||||
archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -127,12 +118,7 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
org.apache.archiva.admin.model.beans.FileType fileType = archivaAdministration.getFileType( fileTypeId );
|
||||
if ( fileType == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new BeanReplicator().replicateBean( fileType, FileType.class );
|
||||
return archivaAdministration.getFileType( fileTypeId );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -145,9 +131,7 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
archivaAdministration.addFileType(
|
||||
new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.model.beans.FileType.class ),
|
||||
getAuditInformation() );
|
||||
archivaAdministration.addFileType( fileType, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -256,17 +240,12 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<org.apache.archiva.admin.model.beans.FileType> modelfileTypes = archivaAdministration.getFileTypes();
|
||||
List<FileType> modelfileTypes = archivaAdministration.getFileTypes();
|
||||
if ( modelfileTypes == null || modelfileTypes.isEmpty() )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<FileType> fileTypes = new ArrayList<FileType>( modelfileTypes.size() );
|
||||
for ( org.apache.archiva.admin.model.beans.FileType fileType : modelfileTypes )
|
||||
{
|
||||
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
|
||||
}
|
||||
return fileTypes;
|
||||
return modelfileTypes;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -305,12 +284,7 @@ public class DefaultArchivaAdministrationService
|
|||
{
|
||||
try
|
||||
{
|
||||
org.apache.archiva.admin.model.beans.OrganisationInformation organisationInformation =
|
||||
archivaAdministration.getOrganisationInformation();
|
||||
|
||||
return organisationInformation == null
|
||||
? null
|
||||
: new BeanReplicator().replicateBean( organisationInformation, OrganisationInformation.class );
|
||||
return archivaAdministration.getOrganisationInformation();
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -329,9 +303,7 @@ public class DefaultArchivaAdministrationService
|
|||
}
|
||||
else
|
||||
{
|
||||
archivaAdministration.setOrganisationInformation(
|
||||
new BeanReplicator().replicateBean( organisationInformation,
|
||||
org.apache.archiva.admin.model.beans.OrganisationInformation.class ) );
|
||||
archivaAdministration.setOrganisationInformation( organisationInformation );
|
||||
}
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -55,24 +55,7 @@ public class DefaultManagedRepositoriesService
|
|||
{
|
||||
List<org.apache.archiva.admin.model.beans.ManagedRepository> repos =
|
||||
managedRepositoryAdmin.getManagedRepositories();
|
||||
|
||||
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;
|
||||
return repos == null ? Collections.<ManagedRepository>emptyList() : repos;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -113,23 +96,11 @@ public class DefaultManagedRepositoriesService
|
|||
public Boolean addManagedRepository( ManagedRepository managedRepository )
|
||||
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
|
||||
{
|
||||
return managedRepositoryAdmin.addManagedRepository( repo, managedRepository.isStageRepoNeeded(),
|
||||
return managedRepositoryAdmin.addManagedRepository( managedRepository,
|
||||
managedRepository.isStageRepoNeeded(),
|
||||
getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
|
@ -142,19 +113,11 @@ public class DefaultManagedRepositoriesService
|
|||
public Boolean updateManagedRepository( ManagedRepository managedRepository )
|
||||
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
|
||||
{
|
||||
return managedRepositoryAdmin.updateManagedRepository( repo, managedRepository.isStageRepoNeeded(),
|
||||
return managedRepositoryAdmin.updateManagedRepository( managedRepository,
|
||||
managedRepository.isStageRepoNeeded(),
|
||||
getAuditInformation(),
|
||||
managedRepository.isResetStats() );
|
||||
}
|
||||
|
|
|
@ -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.beans.NetworkProxy;
|
||||
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 javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -46,12 +45,8 @@ public class DefaultNetworkProxyService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>();
|
||||
for ( org.apache.archiva.admin.model.beans.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() )
|
||||
{
|
||||
networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) );
|
||||
}
|
||||
return networkProxies;
|
||||
List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
|
||||
return networkProxies == null ? Collections.<NetworkProxy>emptyList() : networkProxies;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -64,9 +59,7 @@ public class DefaultNetworkProxyService
|
|||
{
|
||||
try
|
||||
{
|
||||
org.apache.archiva.admin.model.beans.NetworkProxy networkProxy =
|
||||
networkProxyAdmin.getNetworkProxy( networkProxyId );
|
||||
return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class );
|
||||
return networkProxyAdmin.getNetworkProxy( networkProxyId );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -83,9 +76,7 @@ public class DefaultNetworkProxyService
|
|||
{
|
||||
return;
|
||||
}
|
||||
getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
|
||||
org.apache.archiva.admin.model.beans.NetworkProxy.class ),
|
||||
getAuditInformation() );
|
||||
getNetworkProxyAdmin().addNetworkProxy( networkProxy, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -102,9 +93,7 @@ public class DefaultNetworkProxyService
|
|||
}
|
||||
try
|
||||
{
|
||||
getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
|
||||
org.apache.archiva.admin.model.beans.NetworkProxy.class ),
|
||||
getAuditInformation() );
|
||||
getNetworkProxyAdmin().updateNetworkProxy( networkProxy, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
|
|
@ -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.beans.ProxyConnector;
|
||||
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 javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -46,12 +45,8 @@ public class DefaultProxyConnectorService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>();
|
||||
for ( org.apache.archiva.admin.model.beans.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() )
|
||||
{
|
||||
proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
|
||||
}
|
||||
return proxyConnectors;
|
||||
List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectors();
|
||||
return proxyConnectors == null ? Collections.<ProxyConnector>emptyList() : proxyConnectors;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -64,11 +59,7 @@ public class DefaultProxyConnectorService
|
|||
{
|
||||
try
|
||||
{
|
||||
org.apache.archiva.admin.model.beans.ProxyConnector proxyConnector =
|
||||
proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
|
||||
return proxyConnector == null
|
||||
? null
|
||||
: new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class );
|
||||
return proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -85,9 +76,7 @@ public class DefaultProxyConnectorService
|
|||
}
|
||||
try
|
||||
{
|
||||
return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
|
||||
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
|
||||
getAuditInformation() );
|
||||
return proxyConnectorAdmin.addProxyConnector( proxyConnector, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -104,9 +93,7 @@ public class DefaultProxyConnectorService
|
|||
}
|
||||
try
|
||||
{
|
||||
return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
|
||||
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
|
||||
getAuditInformation() );
|
||||
return proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -123,9 +110,7 @@ public class DefaultProxyConnectorService
|
|||
}
|
||||
try
|
||||
{
|
||||
return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
|
||||
org.apache.archiva.admin.model.beans.ProxyConnector.class ),
|
||||
getAuditInformation() );
|
||||
return proxyConnectorAdmin.updateProxyConnector( proxyConnector, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -48,17 +48,8 @@ public class DefaultRemoteRepositoriesService
|
|||
{
|
||||
try
|
||||
{
|
||||
List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
|
||||
for ( org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
|
||||
{
|
||||
RemoteRepository repo = new RemoteRepository( remoteRepository.getId(), remoteRepository.getName(),
|
||||
remoteRepository.getUrl(), remoteRepository.getLayout(),
|
||||
remoteRepository.getUserName(),
|
||||
remoteRepository.getPassword(),
|
||||
remoteRepository.getTimeout() );
|
||||
remoteRepositories.add( repo );
|
||||
}
|
||||
return remoteRepositories;
|
||||
List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories();
|
||||
return remoteRepositories == null ? Collections.<RemoteRepository>emptyList() : remoteRepositories;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -89,26 +80,14 @@ public class DefaultRemoteRepositoriesService
|
|||
public Boolean addRemoteRepository( RemoteRepository remoteRepository )
|
||||
throws Exception
|
||||
{
|
||||
return remoteRepositoryAdmin.addRemoteRepository( getModelRemoteRepository( remoteRepository ),
|
||||
getAuditInformation() );
|
||||
return remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getAuditInformation() );
|
||||
}
|
||||
|
||||
public Boolean updateRemoteRepository( RemoteRepository remoteRepository )
|
||||
throws Exception
|
||||
{
|
||||
return remoteRepositoryAdmin.updateRemoteRepository( getModelRemoteRepository( remoteRepository ),
|
||||
getAuditInformation() );
|
||||
return remoteRepositoryAdmin.updateRemoteRepository( remoteRepository, 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() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue