mirror of https://github.com/apache/archiva.git
initial work on removing hardcoded staging repositories. Still several tasks to do and some tests are failing in this state
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/staging-refactor@1185127 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23943dcdc2
commit
07f0744a63
|
@ -19,12 +19,12 @@ package org.apache.archiva.configuration;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.configuration.CombinedConfiguration;
|
||||
import org.apache.archiva.common.FileTypeUtils;
|
||||
import org.apache.archiva.configuration.functors.FiletypeSelectionPredicate;
|
||||
import org.apache.archiva.configuration.io.registry.ConfigurationRegistryReader;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.Predicate;
|
||||
import org.apache.commons.configuration.CombinedConfiguration;
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.codehaus.plexus.registry.RegistryException;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
|
@ -32,15 +32,15 @@ import org.codehaus.plexus.util.SelectorUtils;
|
|||
import org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* FileTypes
|
||||
|
|
|
@ -136,6 +136,7 @@
|
|||
The repository scanning configuration.
|
||||
</description>
|
||||
</field>
|
||||
<!-- TODO: remove? can't seem to use ranges to not generate above 1.3.0 -->
|
||||
<field>
|
||||
<name>webapp</name>
|
||||
<version>1.0.0+</version>
|
||||
|
@ -567,6 +568,15 @@
|
|||
The file system location for this repository.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>stagingLocation</name>
|
||||
<version>1.4.0+</version>
|
||||
<type>String</type>
|
||||
<required>false</required>
|
||||
<description>
|
||||
The file system location for any attached staging repositories.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>releases</name>
|
||||
<version>1.0.0+</version>
|
||||
|
@ -595,6 +605,14 @@
|
|||
<description>True if this repository should be scanned and processed.</description>
|
||||
<defaultValue>true</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>stagingRequired</name>
|
||||
<version>1.4.0+</version>
|
||||
<type>boolean</type>
|
||||
<description>
|
||||
Whether staging repositories can be created for this repository.
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>refreshCronExpression</name>
|
||||
<version>1.0.0+</version>
|
||||
|
|
|
@ -99,7 +99,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
|
|||
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), null );
|
||||
|
||||
String repoRoot = prepareTestRepos();
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
|
|||
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), null );
|
||||
|
||||
String repoRoot = prepareTestRepos();
|
||||
|
||||
|
@ -195,10 +195,10 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
|
|||
*/
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), null );
|
||||
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
|
||||
getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ), false, null );
|
||||
getRepoConfiguration( RELEASES_TEST_REPO_ID, RELEASES_TEST_REPO_NAME ), null );
|
||||
|
||||
String repoRoot = prepareTestRepos();
|
||||
|
||||
|
@ -248,7 +248,7 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest
|
|||
*/
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).deleteManagedRepository( TEST_REPO_ID, null, false );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository(
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), false, null );
|
||||
getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ), null );
|
||||
|
||||
String repoRoot = prepareTestRepos();
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ public class RepositoryPurgeConsumerTest
|
|||
{
|
||||
managedRepositoryAdmin.deleteManagedRepository( repoConfiguration.getId(), null, false );
|
||||
}
|
||||
managedRepositoryAdmin.addManagedRepository( repoConfiguration, false, null );
|
||||
managedRepositoryAdmin.addManagedRepository( repoConfiguration, null );
|
||||
}
|
||||
|
||||
private void removeRepoFromConfiguration( String configHint, ManagedRepository repoConfiguration )
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class AbstractProxyTestCase
|
|||
( (DefaultManagedRepositoryAdmin) applicationContext.getBean(
|
||||
ManagedRepositoryAdmin.class ) ).setArchivaConfiguration( config );
|
||||
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, null );
|
||||
//config.getConfiguration().addManagedRepository( repoConfig );
|
||||
|
||||
// Setup source repository (using legacy layout)
|
||||
|
@ -180,7 +180,7 @@ public abstract class AbstractProxyTestCase
|
|||
repoConfig = managedLegacyRepository.getRepository();
|
||||
|
||||
//config.getConfiguration().addManagedRepository( repoConfig );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, false, null );
|
||||
applicationContext.getBean( ManagedRepositoryAdmin.class ).addManagedRepository( repoConfig, null );
|
||||
|
||||
// Setup target (proxied to) repository.
|
||||
saveRemoteRepositoryConfig( ID_PROXIED1, "Proxied Repository 1",
|
||||
|
|
|
@ -128,7 +128,7 @@ public class HttpProxyTransferTest
|
|||
ManagedRepositoryAdmin managedRepositoryAdmin = applicationContext.getBean( ManagedRepositoryAdmin.class );
|
||||
if ( managedRepositoryAdmin.getManagedRepository( repo.getId() ) == null )
|
||||
{
|
||||
managedRepositoryAdmin.addManagedRepository( repo, false, null );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, null );
|
||||
}
|
||||
|
||||
//config.getConfiguration().addManagedRepository( repo );
|
||||
|
|
|
@ -45,15 +45,8 @@ public class ManagedRepository
|
|||
*/
|
||||
private String cronExpression = "0 0 * * * ?";
|
||||
|
||||
|
||||
/**
|
||||
* not need when creating the repo : only available when reading
|
||||
*/
|
||||
private ManagedRepository stagingRepository;
|
||||
|
||||
private boolean scanned = false;
|
||||
|
||||
|
||||
/**
|
||||
* default model value
|
||||
*/
|
||||
|
@ -66,7 +59,8 @@ public class ManagedRepository
|
|||
|
||||
private boolean deleteReleasedSnapshots;
|
||||
|
||||
private boolean stageRepoNeeded;
|
||||
// TODO: move to staging plugin and allow custom per-repository configuration from plugins
|
||||
private boolean stagingRequired;
|
||||
|
||||
private boolean resetStats;
|
||||
|
||||
|
@ -78,7 +72,7 @@ public class ManagedRepository
|
|||
public ManagedRepository( String id, String name, String location, String layout, boolean snapshots,
|
||||
boolean releases, boolean blockRedeployments, String cronExpression, String indexDir,
|
||||
boolean scanned, int daysOlder, int retentionCount, boolean deleteReleasedSnapshots,
|
||||
boolean stageRepoNeeded )
|
||||
boolean stagingRequired )
|
||||
{
|
||||
super( id, name, layout );
|
||||
|
||||
|
@ -92,7 +86,7 @@ public class ManagedRepository
|
|||
this.daysOlder = daysOlder;
|
||||
this.retentionCount = retentionCount;
|
||||
this.deleteReleasedSnapshots = deleteReleasedSnapshots;
|
||||
this.stageRepoNeeded = stageRepoNeeded;
|
||||
this.stagingRequired = stagingRequired;
|
||||
}
|
||||
|
||||
public String getCronExpression()
|
||||
|
@ -151,16 +145,6 @@ public class ManagedRepository
|
|||
}
|
||||
|
||||
|
||||
public ManagedRepository getStagingRepository()
|
||||
{
|
||||
return stagingRepository;
|
||||
}
|
||||
|
||||
|
||||
public void setStagingRepository( ManagedRepository stagingRepository )
|
||||
{
|
||||
this.stagingRepository = stagingRepository;
|
||||
}
|
||||
|
||||
public boolean isScanned()
|
||||
{
|
||||
|
@ -203,14 +187,14 @@ public class ManagedRepository
|
|||
this.deleteReleasedSnapshots = deleteReleasedSnapshots;
|
||||
}
|
||||
|
||||
public boolean isStageRepoNeeded()
|
||||
public boolean isStagingRequired()
|
||||
{
|
||||
return stageRepoNeeded;
|
||||
return stagingRequired;
|
||||
}
|
||||
|
||||
public void setStageRepoNeeded( boolean stageRepoNeeded )
|
||||
public void setStagingRequired( boolean stagingRequired )
|
||||
{
|
||||
this.stageRepoNeeded = stageRepoNeeded;
|
||||
this.stagingRequired = stagingRequired;
|
||||
}
|
||||
|
||||
public boolean isResetStats()
|
||||
|
@ -233,17 +217,15 @@ public class ManagedRepository
|
|||
sb.append( ", snapshots=" ).append( snapshots );
|
||||
sb.append( ", releases=" ).append( releases );
|
||||
sb.append( ", blockRedeployments=" ).append( blockRedeployments );
|
||||
sb.append( ", stagingRequired=" ).append( stagingRequired );
|
||||
sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
|
||||
sb.append( ", stagingRepository=" ).append( stagingRepository );
|
||||
sb.append( ", scanned=" ).append( scanned );
|
||||
sb.append( ", daysOlder=" ).append( daysOlder );
|
||||
sb.append( ", retentionCount=" ).append( retentionCount );
|
||||
sb.append( ", deleteReleasedSnapshots=" ).append( deleteReleasedSnapshots );
|
||||
sb.append( ", stageRepoNeeded=" ).append( stageRepoNeeded );
|
||||
sb.append( ", stagingRequired=" ).append( stagingRequired );
|
||||
sb.append( ", resetStats=" ).append( resetStats );
|
||||
sb.append( '}' );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,13 +44,12 @@ public interface ManagedRepositoryAdmin
|
|||
Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation, boolean deleteContent )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation )
|
||||
Boolean addManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
|
||||
Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation, boolean resetStats )
|
||||
Boolean updateManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation,
|
||||
boolean resetStats )
|
||||
throws RepositoryAdminException;
|
||||
|
||||
|
||||
|
|
|
@ -51,8 +51,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -60,6 +58,8 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* FIXME remove all generic Exception to have usefull ones
|
||||
|
@ -77,8 +77,6 @@ public class DefaultManagedRepositoryAdmin
|
|||
|
||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
public static final String STAGE_REPO_ID_END = "-stage";
|
||||
|
||||
|
||||
@Inject
|
||||
@Named( value = "archivaTaskScheduler#repository" )
|
||||
|
@ -107,13 +105,13 @@ public class DefaultManagedRepositoryAdmin
|
|||
|
||||
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
|
||||
{
|
||||
// TODO add staging repo information back too
|
||||
ManagedRepository repo =
|
||||
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
|
||||
repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
|
||||
repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
|
||||
repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
|
||||
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), false );
|
||||
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(),
|
||||
repoConfig.isStagingRequired() );
|
||||
|
||||
managedRepos.add( repo );
|
||||
}
|
||||
|
@ -148,8 +146,7 @@ public class DefaultManagedRepositoryAdmin
|
|||
return null;
|
||||
}
|
||||
|
||||
public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation )
|
||||
public Boolean addManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
|
||||
|
@ -158,18 +155,18 @@ public class DefaultManagedRepositoryAdmin
|
|||
return
|
||||
addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
|
||||
managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
|
||||
managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
|
||||
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
|
||||
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
|
||||
managedRepository.isDeleteReleasedSnapshots(), auditInformation,
|
||||
getArchivaConfiguration().getConfiguration() ) != null;
|
||||
managedRepository.isReleases(), managedRepository.isSnapshots(),
|
||||
managedRepository.isStagingRequired(), managedRepository.getCronExpression(),
|
||||
managedRepository.getIndexDirectory(), managedRepository.getDaysOlder(),
|
||||
managedRepository.getRetentionCount(), managedRepository.isDeleteReleasedSnapshots(),
|
||||
auditInformation, getArchivaConfiguration().getConfiguration() ) != null;
|
||||
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration addManagedRepository( String repoId, String layout, String name,
|
||||
String location, boolean blockRedeployments,
|
||||
boolean releasesIncluded, boolean snapshotsIncluded,
|
||||
boolean stageRepoNeeded, String cronExpression,
|
||||
boolean stagingRequired, String cronExpression,
|
||||
String indexDir, int daysOlder, int retentionCount,
|
||||
boolean deteleReleasedSnapshots,
|
||||
AuditInformation auditInformation,
|
||||
|
@ -205,6 +202,7 @@ public class DefaultManagedRepositoryAdmin
|
|||
|
||||
repository.setId( repoId );
|
||||
repository.setBlockRedeployments( blockRedeployments );
|
||||
repository.setStagingRequired( stagingRequired );
|
||||
repository.setReleases( releasesIncluded );
|
||||
repository.setSnapshots( snapshotsIncluded );
|
||||
repository.setName( name );
|
||||
|
@ -221,14 +219,6 @@ public class DefaultManagedRepositoryAdmin
|
|||
{
|
||||
addRepository( repository, config );
|
||||
addRepositoryRoles( repository );
|
||||
|
||||
if ( stageRepoNeeded )
|
||||
{
|
||||
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
|
||||
addRepository( stagingRepository, config );
|
||||
addRepositoryRoles( stagingRepository );
|
||||
triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
|
||||
}
|
||||
}
|
||||
catch ( RoleManagerException e )
|
||||
{
|
||||
|
@ -246,13 +236,6 @@ public class DefaultManagedRepositoryAdmin
|
|||
try
|
||||
{
|
||||
scanRepository( repoId, true );
|
||||
// olamy no need of scanning staged repo
|
||||
/*
|
||||
if ( stageRepoNeeded )
|
||||
{
|
||||
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
|
||||
scanRepository( stagingRepository.getId(), true );
|
||||
}*/
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
@ -282,14 +265,7 @@ public class DefaultManagedRepositoryAdmin
|
|||
|
||||
deleteManagedRepository( repository, deleteContent, config, false );
|
||||
|
||||
// stage repo exists ?
|
||||
ManagedRepositoryConfiguration stagingRepository =
|
||||
getArchivaConfiguration().getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
|
||||
if ( stagingRepository != null )
|
||||
{
|
||||
// do not trigger event when deleting the staged one
|
||||
deleteManagedRepository( stagingRepository, deleteContent, config, true );
|
||||
}
|
||||
// STAGE FIXME: delete staging location too
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -405,13 +381,14 @@ public class DefaultManagedRepositoryAdmin
|
|||
}
|
||||
|
||||
|
||||
public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation, boolean resetStats )
|
||||
public Boolean updateManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation,
|
||||
boolean resetStats )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
|
||||
log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ",
|
||||
Arrays.asList( managedRepository, needStageRepo, resetStats ).toArray() );
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( "updateManagedConfiguration repo {} resetStats {} ", Arrays.asList( managedRepository, resetStats ).toArray() );
|
||||
}
|
||||
|
||||
// Ensure that the fields are valid.
|
||||
|
||||
|
@ -426,23 +403,16 @@ public class DefaultManagedRepositoryAdmin
|
|||
configuration.removeManagedRepository( toremove );
|
||||
}
|
||||
|
||||
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( toremove );
|
||||
|
||||
// TODO remove content from old if path has changed !!!!!
|
||||
|
||||
if ( stagingRepository != null )
|
||||
{
|
||||
configuration.removeManagedRepository( stagingRepository );
|
||||
}
|
||||
|
||||
ManagedRepositoryConfiguration managedRepositoryConfiguration =
|
||||
addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
|
||||
managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
|
||||
managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
|
||||
managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
|
||||
managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
|
||||
managedRepository.isDeleteReleasedSnapshots(), auditInformation,
|
||||
getArchivaConfiguration().getConfiguration() );
|
||||
managedRepository.isReleases(), managedRepository.isSnapshots(),
|
||||
managedRepository.isStagingRequired(), managedRepository.getCronExpression(),
|
||||
managedRepository.getIndexDirectory(), managedRepository.getDaysOlder(),
|
||||
managedRepository.getRetentionCount(), managedRepository.isDeleteReleasedSnapshots(),
|
||||
auditInformation, getArchivaConfiguration().getConfiguration() );
|
||||
|
||||
// Save the repository configuration.
|
||||
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
|
||||
|
@ -498,27 +468,6 @@ public class DefaultManagedRepositoryAdmin
|
|||
configuration.addManagedRepository( repository );
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository )
|
||||
{
|
||||
ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
|
||||
stagingRepository.setId( repository.getId() + STAGE_REPO_ID_END );
|
||||
stagingRepository.setLayout( repository.getLayout() );
|
||||
stagingRepository.setName( repository.getName() + STAGE_REPO_ID_END );
|
||||
stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
|
||||
stagingRepository.setDaysOlder( repository.getDaysOlder() );
|
||||
stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
|
||||
stagingRepository.setIndexDir( repository.getIndexDir() );
|
||||
String path = repository.getLocation();
|
||||
int lastIndex = path.lastIndexOf( '/' );
|
||||
stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
|
||||
stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
|
||||
stagingRepository.setReleases( repository.isReleases() );
|
||||
stagingRepository.setRetentionCount( repository.getRetentionCount() );
|
||||
stagingRepository.setScanned( repository.isScanned() );
|
||||
stagingRepository.setSnapshots( repository.isSnapshots() );
|
||||
return stagingRepository;
|
||||
}
|
||||
|
||||
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
||||
{
|
||||
if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
|
||||
|
|
|
@ -93,8 +93,8 @@ public abstract class AbstractRepositoryAdminTest
|
|||
|
||||
protected ManagedRepository getTestManagedRepository( String repoId, String repoLocation )
|
||||
{
|
||||
return new ManagedRepository( repoId, "test repo", repoLocation, "default", false, true, true, "0 0 * * * ?",
|
||||
repoLocation + "/.index", false, 1, 2, true, false );
|
||||
return new ManagedRepository( repoId, "test repo", repoLocation, "default", false, true, true,
|
||||
"0 0 * * * ?", repoLocation + "/.index", false, 1, 2, true, false );
|
||||
}
|
||||
|
||||
protected File clearRepoLocation( String path )
|
||||
|
|
|
@ -50,9 +50,9 @@ public class RepositoryGroupAdminTest
|
|||
ManagedRepository managedRepositoryTwo =
|
||||
getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, getFakeAuditInformation() );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, getFakeAuditInformation() );
|
||||
|
||||
RepositoryGroup repositoryGroup =
|
||||
new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
|
||||
|
@ -96,9 +96,9 @@ public class RepositoryGroupAdminTest
|
|||
ManagedRepository managedRepositoryTwo =
|
||||
getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, getFakeAuditInformation() );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, getFakeAuditInformation() );
|
||||
|
||||
RepositoryGroup repositoryGroup = new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one" ) );
|
||||
|
||||
|
@ -156,9 +156,9 @@ public class RepositoryGroupAdminTest
|
|||
ManagedRepository managedRepositoryTwo =
|
||||
getTestManagedRepository( "test-new-two", APPSERVER_BASE_PATH + File.separator + "test-new-two" );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryOne, getFakeAuditInformation() );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( managedRepositoryTwo, getFakeAuditInformation() );
|
||||
|
||||
RepositoryGroup repositoryGroup =
|
||||
new RepositoryGroup( "repo-group-one", Arrays.asList( "test-new-one", "test-new-two" ) );
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.List;
|
|||
public class ManagedRepositoryAdminTest
|
||||
extends AbstractRepositoryAdminTest
|
||||
{
|
||||
public static final String STAGE_REPO_ID_END = DefaultManagedRepositoryAdmin.STAGE_REPO_ID_END;
|
||||
|
||||
@Test
|
||||
public void getAllManagedRepos()
|
||||
|
@ -85,7 +84,7 @@ public class ManagedRepositoryAdminTest
|
|||
repo.setName( "test repo" );
|
||||
repo.setLocation( repoLocation );
|
||||
repo.setCronExpression( "0 0 * * * ?" );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, getFakeAuditInformation() );
|
||||
repos = managedRepositoryAdmin.getManagedRepositories();
|
||||
assertNotNull( repos );
|
||||
assertEquals( initialSize + 1, repos.size() );
|
||||
|
@ -133,7 +132,7 @@ public class ManagedRepositoryAdminTest
|
|||
repo.setName( "test repo" );
|
||||
repo.setLocation( repoLocation );
|
||||
repo.setCronExpression( "0 0 * * * ?" );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, getFakeAuditInformation() );
|
||||
|
||||
assertTemplateRoleExists( repoId );
|
||||
|
||||
|
@ -148,7 +147,7 @@ public class ManagedRepositoryAdminTest
|
|||
repo.setLocation( repoLocation );
|
||||
repo.setCronExpression( "0 0 * * * ?" );
|
||||
|
||||
managedRepositoryAdmin.updateManagedRepository( repo, false, getFakeAuditInformation(), false );
|
||||
managedRepositoryAdmin.updateManagedRepository( repo, getFakeAuditInformation(), false );
|
||||
|
||||
repo = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
assertNotNull( repo );
|
||||
|
@ -193,7 +192,8 @@ public class ManagedRepositoryAdminTest
|
|||
repo.setName( "test repo" );
|
||||
repo.setLocation( repoLocation );
|
||||
repo.setCronExpression( "0 0 * * * ?" );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, true, getFakeAuditInformation() );
|
||||
repo.setStagingRequired( true );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, getFakeAuditInformation() );
|
||||
repos = managedRepositoryAdmin.getManagedRepositories();
|
||||
assertNotNull( repos );
|
||||
assertEquals( initialSize + 2, repos.size() );
|
||||
|
@ -204,27 +204,32 @@ public class ManagedRepositoryAdminTest
|
|||
|
||||
assertTrue( repoDir.exists() );
|
||||
|
||||
// STAGE FIXME: check the things that should exist here
|
||||
/*
|
||||
assertNotNull( managedRepositoryAdmin.getManagedRepository( repoId + STAGE_REPO_ID_END ) );
|
||||
|
||||
assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
|
||||
|
||||
assertTrue( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
|
||||
|
||||
*/
|
||||
managedRepositoryAdmin.deleteManagedRepository( repoId, getFakeAuditInformation(), true );
|
||||
|
||||
assertFalse( repoDir.exists() );
|
||||
|
||||
// STAGE FIXME: check the things that should have been removed
|
||||
/*
|
||||
assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
|
||||
|
||||
assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
|
||||
|
||||
*/
|
||||
repos = managedRepositoryAdmin.getManagedRepositories();
|
||||
assertNotNull( repos );
|
||||
assertEquals( initialSize, repos.size() );
|
||||
|
||||
assertTemplateRoleNotExists( repoId );
|
||||
|
||||
assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
|
||||
// STAGE FIXME: check the things that should have been removed
|
||||
// assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
|
||||
|
||||
mockAuditListener.clearEvents();
|
||||
|
||||
|
@ -250,13 +255,16 @@ public class ManagedRepositoryAdminTest
|
|||
|
||||
ManagedRepository repo = getTestManagedRepository( repoId, repoLocation );
|
||||
|
||||
managedRepositoryAdmin.addManagedRepository( repo, false, getFakeAuditInformation() );
|
||||
managedRepositoryAdmin.addManagedRepository( repo, getFakeAuditInformation() );
|
||||
|
||||
assertTemplateRoleExists( repoId );
|
||||
|
||||
// STAGE FIXME: check the things that should have been removed
|
||||
/*
|
||||
assertFalse( new File( repoLocation + STAGE_REPO_ID_END ).exists() );
|
||||
|
||||
assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
|
||||
*/
|
||||
|
||||
repos = managedRepositoryAdmin.getManagedRepositories();
|
||||
assertNotNull( repos );
|
||||
|
@ -272,7 +280,9 @@ public class ManagedRepositoryAdminTest
|
|||
|
||||
repo.setLocation( repoLocation );
|
||||
|
||||
managedRepositoryAdmin.updateManagedRepository( repo, true, getFakeAuditInformation(), false );
|
||||
repo.setStagingRequired( true );
|
||||
|
||||
managedRepositoryAdmin.updateManagedRepository( repo, getFakeAuditInformation(), false );
|
||||
|
||||
repo = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
assertNotNull( repo );
|
||||
|
@ -291,9 +301,12 @@ public class ManagedRepositoryAdminTest
|
|||
|
||||
assertTemplateRoleExists( repoId );
|
||||
|
||||
// STAGE FIXME: check the things that should have been removed
|
||||
/*
|
||||
assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
|
||||
|
||||
assertTemplateRoleExists( repoId + STAGE_REPO_ID_END );
|
||||
*/
|
||||
|
||||
managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false );
|
||||
|
||||
|
@ -302,9 +315,12 @@ public class ManagedRepositoryAdminTest
|
|||
|
||||
assertTemplateRoleNotExists( repoId );
|
||||
|
||||
// STAGE FIXME: check the things that should have been removed
|
||||
/*
|
||||
assertTrue( new File( stageRepoLocation + STAGE_REPO_ID_END ).exists() );
|
||||
|
||||
assertTemplateRoleNotExists( repoId + STAGE_REPO_ID_END );
|
||||
*/
|
||||
|
||||
assertAuditListenerCallAndUpdateAddAndDelete( true );
|
||||
|
||||
|
|
|
@ -48,13 +48,14 @@ public class MockManagedRepositoryAdmin
|
|||
|
||||
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
|
||||
{
|
||||
// TODO add staging repo information back too
|
||||
ManagedRepository repo =
|
||||
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
|
||||
repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
|
||||
repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
|
||||
repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
|
||||
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), true );
|
||||
new ManagedRepository( repoConfig.getId(), repoConfig.getName(),
|
||||
repoConfig.getLocation(), repoConfig.getLayout(), repoConfig.isSnapshots(),
|
||||
repoConfig.isReleases(), repoConfig.isBlockRedeployments(),
|
||||
repoConfig.getRefreshCronExpression(), repoConfig.getIndexDir(),
|
||||
repoConfig.isScanned(), repoConfig.getDaysOlder(),
|
||||
repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(),
|
||||
repoConfig.isStagingRequired() );
|
||||
|
||||
managedRepos.add( repo );
|
||||
}
|
||||
|
@ -89,15 +90,14 @@ public class MockManagedRepositoryAdmin
|
|||
return null;
|
||||
}
|
||||
|
||||
public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation )
|
||||
public Boolean addManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
|
||||
AuditInformation auditInformation, boolean resetStats )
|
||||
public Boolean updateManagedRepository( ManagedRepository managedRepository, AuditInformation auditInformation,
|
||||
boolean resetStats )
|
||||
throws RepositoryAdminException
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -99,9 +99,7 @@ public class DefaultManagedRepositoriesService
|
|||
|
||||
try
|
||||
{
|
||||
return managedRepositoryAdmin.addManagedRepository( managedRepository,
|
||||
managedRepository.isStageRepoNeeded(),
|
||||
getAuditInformation() );
|
||||
return managedRepositoryAdmin.addManagedRepository( managedRepository, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -116,9 +114,7 @@ public class DefaultManagedRepositoriesService
|
|||
|
||||
try
|
||||
{
|
||||
return managedRepositoryAdmin.updateManagedRepository( managedRepository,
|
||||
managedRepository.isStageRepoNeeded(),
|
||||
getAuditInformation(),
|
||||
return managedRepositoryAdmin.updateManagedRepository( managedRepository, getAuditInformation(),
|
||||
managedRepository.isResetStats() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
|
|
|
@ -41,9 +41,9 @@ public class MergingRepositoriesTest
|
|||
public void testAddArtifactToStagingRepository()
|
||||
{
|
||||
addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), getValidArtifactFilePath(),
|
||||
"merging-repo-stage", true );
|
||||
"merging-repo", true );
|
||||
assertTextPresent( "Artifact '" + getGroupId() + ":" + getArtifactId() + ":" + getVersion() +
|
||||
"' was successfully deployed to repository 'merging-repo-stage'" );
|
||||
"' was successfully staged for repository 'merging-repo'" );
|
||||
}
|
||||
|
||||
// here we test the merging (no conflicts artifacts are available)
|
||||
|
@ -92,6 +92,7 @@ public class MergingRepositoriesTest
|
|||
@Test(dependsOnMethods = {"testAddArtifactToStagingRepository"})
|
||||
public void testConfigurationChangesOfStagingRepository()
|
||||
{
|
||||
// STAGE FIXME: hardcoded ID
|
||||
editManagedRepository();
|
||||
addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), getValidArtifactFilePath(),
|
||||
"merging-repo-stage", true );
|
||||
|
|
|
@ -730,7 +730,7 @@ public abstract class AbstractArchivaTest
|
|||
setFieldValue( "repository.cronExpression", cron );
|
||||
setFieldValue( "repository.daysOlder", daysOlder );
|
||||
setFieldValue( "repository.retentionCount", retentionCount );
|
||||
checkField( "stageNeeded" );
|
||||
checkField( "repository.stagingRequired" );
|
||||
|
||||
clickButtonWithValue( "Add Repository" );
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.archiva.web.action;
|
|||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.audit.AuditEvent;
|
||||
|
@ -38,11 +37,13 @@ import org.codehaus.plexus.taskqueue.TaskQueueException;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,104 +70,72 @@ public class MergeAction
|
|||
|
||||
private String repoid;
|
||||
|
||||
private String sourceRepoId;
|
||||
private Collection<ArtifactMetadata> conflictSourceArtifactsToBeDisplayed;
|
||||
|
||||
private final String action = "merge";
|
||||
private static String SESSION_KEY = "default";
|
||||
|
||||
private final String hasConflicts = "CONFLICTS";
|
||||
|
||||
private List<ArtifactMetadata> conflictSourceArtifacts;
|
||||
|
||||
private List<ArtifactMetadata> conflictSourceArtifactsToBeDisplayed;
|
||||
|
||||
public String getConflicts()
|
||||
public String requestMerge()
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
if ( !repository.isStagingRequired() )
|
||||
{
|
||||
sourceRepoId = repoid + "-stage";
|
||||
ManagedRepository targetRepoConfig = managedRepositoryAdmin.getManagedRepository( sourceRepoId );
|
||||
|
||||
if ( targetRepoConfig != null )
|
||||
{
|
||||
return hasConflicts;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
addActionError( "RepositoryAdminException " + e.getMessage() );
|
||||
addActionError( "Repository [" + repository.getId() + "] is not configured for staging" );
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
// check for conflicts to display
|
||||
HashMap<String, ArtifactMetadata> map = new LinkedHashMap<String, ArtifactMetadata>();
|
||||
for ( ArtifactMetadata metadata : getConflictSourceArtifacts() )
|
||||
{
|
||||
String metadataId = metadata.getNamespace() + ":" + metadata.getProject() + ":" + metadata.getVersion();
|
||||
map.put( metadataId, metadata );
|
||||
}
|
||||
conflictSourceArtifactsToBeDisplayed = map.values();
|
||||
|
||||
return "confirm";
|
||||
}
|
||||
|
||||
public String doMerge()
|
||||
{
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
|
||||
|
||||
if ( repository.isReleases() && !repository.isSnapshots() )
|
||||
{
|
||||
mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
|
||||
}
|
||||
else
|
||||
{
|
||||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid );
|
||||
|
||||
for ( ArtifactMetadata metadata : sourceArtifacts )
|
||||
{
|
||||
triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
|
||||
}
|
||||
}
|
||||
|
||||
scanRepository();
|
||||
|
||||
addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log.error( e.getMessage(), e );
|
||||
addActionError( "Error occurred while merging the repositories: " + e.getMessage() );
|
||||
return ERROR;
|
||||
}
|
||||
finally
|
||||
{
|
||||
repositorySession.close();
|
||||
}
|
||||
return merge( true );
|
||||
}
|
||||
|
||||
public String mergeBySkippingConflicts()
|
||||
{
|
||||
return merge( false );
|
||||
}
|
||||
|
||||
private String merge( boolean overwriteConflicts )
|
||||
{
|
||||
// FIXME: stage repo should only need the repoid
|
||||
String sourceRepoId = null;
|
||||
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepoId );
|
||||
sourceArtifacts.removeAll( conflictSourceArtifacts );
|
||||
|
||||
if ( repository.isReleases() && !repository.isSnapshots() )
|
||||
if ( !overwriteConflicts )
|
||||
{
|
||||
mergeWithOutSnapshots( metadataRepository, sourceArtifacts, sourceRepoId, repoid );
|
||||
sourceArtifacts.removeAll( getConflictSourceArtifacts() );
|
||||
|
||||
Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>(
|
||||
sourceArtifacts );
|
||||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactsWithOutConflicts );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Filter<ArtifactMetadata> artifactsWithOutConflicts =
|
||||
new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
||||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactsWithOutConflicts );
|
||||
for ( ArtifactMetadata metadata : sourceArtifacts )
|
||||
{
|
||||
triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
|
||||
}
|
||||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid );
|
||||
}
|
||||
|
||||
// FIXME: this should happen in the merge itself
|
||||
for ( ArtifactMetadata metadata : sourceArtifacts )
|
||||
{
|
||||
triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
|
||||
}
|
||||
|
||||
// FIXME: this should happen in the merge itself, don't re-scan the whole thing. Make sure we test the
|
||||
// results
|
||||
scanRepository();
|
||||
|
||||
addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
|
||||
|
@ -185,31 +154,6 @@ public class MergeAction
|
|||
}
|
||||
}
|
||||
|
||||
public String mergeWithOutConlficts()
|
||||
{
|
||||
sourceRepoId = repoid + "-stage";
|
||||
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
conflictSourceArtifacts =
|
||||
repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
addActionError( "Error occurred while merging the repositories." );
|
||||
return ERROR;
|
||||
}
|
||||
finally
|
||||
{
|
||||
repositorySession.close();
|
||||
}
|
||||
|
||||
addActionMessage( "Repository '" + sourceRepoId + "' successfully merged to '" + repoid + "'." );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public ManagedRepository getRepository()
|
||||
{
|
||||
return repository;
|
||||
|
@ -223,30 +167,7 @@ public class MergeAction
|
|||
public void prepare()
|
||||
throws Exception
|
||||
{
|
||||
sourceRepoId = repoid + "-stage";
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
conflictSourceArtifacts =
|
||||
repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), sourceRepoId, repoid );
|
||||
}
|
||||
finally
|
||||
{
|
||||
repositorySession.close();
|
||||
}
|
||||
|
||||
this.repository = managedRepositoryAdmin.getManagedRepository( repoid );
|
||||
setConflictSourceArtifactsToBeDisplayed( conflictSourceArtifacts );
|
||||
}
|
||||
|
||||
public String getSourceRepoId()
|
||||
{
|
||||
return sourceRepoId;
|
||||
}
|
||||
|
||||
public void setSourceRepoId( String sourceRepoId )
|
||||
{
|
||||
this.sourceRepoId = sourceRepoId;
|
||||
}
|
||||
|
||||
public String getRepoid()
|
||||
|
@ -260,56 +181,39 @@ public class MergeAction
|
|||
}
|
||||
|
||||
public List<ArtifactMetadata> getConflictSourceArtifacts()
|
||||
throws Exception
|
||||
{
|
||||
return conflictSourceArtifacts;
|
||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
||||
try
|
||||
{
|
||||
return repositoryMerger.getConflictingArtifacts( repositorySession.getRepository(), repoid );
|
||||
}
|
||||
finally
|
||||
{
|
||||
repositorySession.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void setConflictSourceArtifacts( List<ArtifactMetadata> conflictSourceArtifacts )
|
||||
{
|
||||
this.conflictSourceArtifacts = conflictSourceArtifacts;
|
||||
}
|
||||
|
||||
public List<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
|
||||
public Collection<ArtifactMetadata> getConflictSourceArtifactsToBeDisplayed()
|
||||
{
|
||||
return conflictSourceArtifactsToBeDisplayed;
|
||||
}
|
||||
|
||||
public void setConflictSourceArtifactsToBeDisplayed( List<ArtifactMetadata> conflictSourceArtifacts )
|
||||
throws Exception
|
||||
private Filter<ArtifactMetadata> filterOutSnapshots( List<ArtifactMetadata> sourceArtifacts, String repoid )
|
||||
{
|
||||
this.conflictSourceArtifactsToBeDisplayed = new ArrayList<ArtifactMetadata>();
|
||||
HashMap<String, ArtifactMetadata> map = new HashMap<String, ArtifactMetadata>();
|
||||
for ( ArtifactMetadata metadata : conflictSourceArtifacts )
|
||||
for ( Iterator<ArtifactMetadata> i = sourceArtifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
String metadataId =
|
||||
metadata.getNamespace() + metadata.getProject() + metadata.getProjectVersion() + metadata.getVersion();
|
||||
map.put( metadataId, metadata );
|
||||
}
|
||||
conflictSourceArtifactsToBeDisplayed.addAll( map.values() );
|
||||
}
|
||||
|
||||
private void mergeWithOutSnapshots( MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts,
|
||||
String sourceRepoId, String repoid )
|
||||
throws Exception
|
||||
{
|
||||
List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<ArtifactMetadata>();
|
||||
for ( ArtifactMetadata metadata : sourceArtifacts )
|
||||
{
|
||||
|
||||
ArtifactMetadata metadata = i.next();
|
||||
if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) )
|
||||
{
|
||||
artifactsWithOutSnapshots.add( metadata );
|
||||
i.remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
triggerAuditEvent( repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES );
|
||||
}
|
||||
|
||||
}
|
||||
sourceArtifacts.removeAll( artifactsWithOutSnapshots );
|
||||
|
||||
Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
||||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots );
|
||||
return new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
||||
}
|
||||
|
||||
private void scanRepository()
|
||||
|
@ -346,4 +250,4 @@ public class MergeAction
|
|||
{
|
||||
this.managedRepositoryAdmin = managedRepositoryAdmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,6 +292,7 @@ public class UploadAction
|
|||
{
|
||||
try
|
||||
{
|
||||
// STAGE FIXME: handle staging, reduce external duplication - should be a wrapper like block redeployment
|
||||
ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId );
|
||||
|
||||
ArtifactReference artifactReference = new ArtifactReference();
|
||||
|
@ -424,6 +425,7 @@ public class UploadAction
|
|||
}
|
||||
}
|
||||
|
||||
// STAGE FIXME: if it was staged, say "staged for"
|
||||
String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version
|
||||
+ "\' was successfully deployed to repository \'" + repositoryId + "\'";
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ public class AddManagedRepositoryAction
|
|||
|
||||
private ManagedRepository repository;
|
||||
|
||||
private boolean stageNeeded;
|
||||
|
||||
private String action = "addRepository";
|
||||
|
||||
public void prepare()
|
||||
|
@ -54,6 +52,7 @@ public class AddManagedRepositoryAction
|
|||
this.repository.setReleases( false );
|
||||
this.repository.setScanned( false );
|
||||
this.repository.setBlockRedeployments( false );
|
||||
this.repository.setStagingRequired( false );
|
||||
}
|
||||
|
||||
public String input()
|
||||
|
@ -88,7 +87,7 @@ public class AddManagedRepositoryAction
|
|||
String result = SUCCESS;
|
||||
try
|
||||
{
|
||||
getManagedRepositoryAdmin().addManagedRepository( repository, stageNeeded, getAuditInformation() );
|
||||
getManagedRepositoryAdmin().addManagedRepository( repository, getAuditInformation() );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -147,12 +146,6 @@ public class AddManagedRepositoryAction
|
|||
this.repository = repository;
|
||||
}
|
||||
|
||||
|
||||
public void setStageNeeded( boolean stageNeeded )
|
||||
{
|
||||
this.stageNeeded = stageNeeded;
|
||||
}
|
||||
|
||||
public String getAction()
|
||||
{
|
||||
return action;
|
||||
|
|
|
@ -41,8 +41,6 @@ public class DeleteManagedRepositoryAction
|
|||
|
||||
private ManagedRepository repository;
|
||||
|
||||
private ManagedRepository stagingRepository;
|
||||
|
||||
private String repoid;
|
||||
|
||||
public void prepare()
|
||||
|
@ -51,7 +49,6 @@ public class DeleteManagedRepositoryAction
|
|||
if ( StringUtils.isNotBlank( repoid ) )
|
||||
{
|
||||
this.repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
|
||||
this.stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,15 +44,10 @@ public class EditManagedRepositoryAction
|
|||
|
||||
private ManagedRepository repository;
|
||||
|
||||
private ManagedRepository stagingRepository;
|
||||
|
||||
private String repoid;
|
||||
|
||||
private final String action = "editRepository";
|
||||
|
||||
private boolean stageNeeded;
|
||||
|
||||
|
||||
// FIXME better error message
|
||||
public void prepare()
|
||||
throws RepositoryAdminException
|
||||
|
@ -60,12 +55,12 @@ public class EditManagedRepositoryAction
|
|||
if ( StringUtils.isNotBlank( repoid ) )
|
||||
{
|
||||
repository = getManagedRepositoryAdmin().getManagedRepository( repoid );
|
||||
stagingRepository = getManagedRepositoryAdmin().getManagedRepository( repoid + "-stage" );
|
||||
}
|
||||
else if ( repository != null )
|
||||
{
|
||||
repository.setReleases( false );
|
||||
repository.setScanned( false );
|
||||
repository.setStagingRequired( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +110,7 @@ public class EditManagedRepositoryAction
|
|||
String result = SUCCESS;
|
||||
try
|
||||
{
|
||||
getManagedRepositoryAdmin().updateManagedRepository( repository, stageNeeded, getAuditInformation(),
|
||||
getManagedRepositoryAdmin().updateManagedRepository( repository, getAuditInformation(),
|
||||
resetStats );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
|
@ -175,17 +170,6 @@ public class EditManagedRepositoryAction
|
|||
}
|
||||
|
||||
|
||||
public boolean isStageNeeded()
|
||||
{
|
||||
return stageNeeded;
|
||||
}
|
||||
|
||||
public void setStageNeeded( boolean stageNeeded )
|
||||
{
|
||||
|
||||
this.stageNeeded = stageNeeded;
|
||||
}
|
||||
|
||||
public String getAction()
|
||||
{
|
||||
return action;
|
||||
|
@ -200,14 +184,4 @@ public class EditManagedRepositoryAction
|
|||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public ManagedRepository getStagingRepository()
|
||||
{
|
||||
return stagingRepository;
|
||||
}
|
||||
|
||||
public void setStagingRepository( ManagedRepository stagingRepository )
|
||||
{
|
||||
this.stagingRepository = stagingRepository;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Shows the Repositories Tab for the administrator.
|
||||
|
@ -152,10 +152,7 @@ public class RepositoriesAction
|
|||
List<ManagedRepository> managedRepositoriesList = new ArrayList<ManagedRepository>();
|
||||
for ( ManagedRepository repoConfig : managedRepositories )
|
||||
{
|
||||
if ( !repoConfig.getId().endsWith( "-stage" ) )
|
||||
{
|
||||
managedRepositoriesList.add( repoConfig );
|
||||
}
|
||||
managedRepositoriesList.add( repoConfig );
|
||||
}
|
||||
return managedRepositoriesList;
|
||||
}
|
||||
|
|
|
@ -415,8 +415,8 @@
|
|||
</action>
|
||||
|
||||
|
||||
<action name="merge" class="mergeAction" method="getConflicts">
|
||||
<result name="CONFLICTS">/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp</result>
|
||||
<action name="merge" class="mergeAction" method="requestMerge">
|
||||
<result name="confirm">/WEB-INF/jsp/admin/mergeExcludeConflicts.jsp</result>
|
||||
<result name="success">/WEB-INF/jsp/admin/mergeResults.jsp</result>
|
||||
<interceptor-ref name="configuredPrepareParamsStack"/>
|
||||
</action>
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
<s:form method="post" action="addRepository!commit" namespace="/admin" validate="true">
|
||||
<s:textfield name="repository.id" label="Identifier" size="10" required="true"/>
|
||||
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
|
||||
<s:checkbox name="stageNeeded" value="stageNeeded" label="Create stage repository"/>
|
||||
<s:submit value="Add Repository"/>
|
||||
</s:form>
|
||||
|
||||
|
|
|
@ -52,15 +52,6 @@
|
|||
<s:hidden name="repository.id"/>
|
||||
<s:label label="ID" name="repository.id" />
|
||||
<%@ include file="/WEB-INF/jsp/admin/include/repositoryForm.jspf" %>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${empty(stagingRepository)}">
|
||||
<s:checkbox id="stageNeeded" name="stageNeeded" value="false" label="Create stage repository"/>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<s:checkbox name="stageNeeded" value="true" label="Create stage repository"/>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<s:submit value="Update Repository"/>
|
||||
</s:form>
|
||||
|
||||
|
|
|
@ -34,3 +34,4 @@
|
|||
<s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/>
|
||||
<s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots"
|
||||
label="Delete Released Snapshots"/>
|
||||
<s:checkbox name="repository.stagingRequired" value="repository.stagingRequired" label="Require staging repository"/>
|
||||
|
|
|
@ -36,79 +36,38 @@
|
|||
</p>
|
||||
|
||||
<div class="infobox">
|
||||
<table class="infotable">
|
||||
<c:choose>
|
||||
<c:when test="${empty (conflictSourceArtifactsToBeDisplayed)}">
|
||||
<h1>No conflicting artifacts</h1>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${empty (conflictSourceArtifacts)}">
|
||||
<h1>No conflicting artifacts</h1>
|
||||
|
||||
<c:if test="${!repository.snapshots and repository.releases}">
|
||||
<div class="warningbox">
|
||||
<p>
|
||||
<strong>WARNING: Repository "${repoid}" does not allow to merge snapshots</strong>
|
||||
</p>
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<s:form method="post" action="merge" namespace="/admin" validate="false" theme="simple">
|
||||
<s:hidden name="repoid"/>
|
||||
<div class="buttons">
|
||||
<s:submit value="Merge All" method="doMerge"/>
|
||||
</div>
|
||||
</s:form>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div class="warningbox">
|
||||
<c:if test="${!repository.snapshots and repository.releases}">
|
||||
<p>
|
||||
<strong>WARNING: Repository "${repoid}" does not allow to merge snapshots</strong>
|
||||
</p>
|
||||
</c:if>
|
||||
<p>
|
||||
<strong>WARNING: The following are the artifacts in conflict.</strong>
|
||||
</p>
|
||||
</div>
|
||||
<c:forEach items="${conflictSourceArtifactsToBeDisplayed}" var="artifact">
|
||||
<tr>
|
||||
<td>Artifact Id :</td>
|
||||
<%--<td><code>${artifact.id}</code></td>--%>
|
||||
<td align="left"> <code>${artifact.namespace} ${" "} ${artifact.project} ${" "} ${artifact.version}</code></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
<s:form method="post" action="merge" namespace="/admin" validate="false" theme="simple">
|
||||
<s:hidden name="repoid"/>
|
||||
<div class="buttons">
|
||||
<s:submit value="Merge All" method="doMerge"/>
|
||||
</div>
|
||||
</s:form>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div class="warningbox">
|
||||
<p><strong>WARNING! The following are the artifacts in conflict:</strong></p>
|
||||
</div>
|
||||
<table class="infotable">
|
||||
<c:forEach items="${conflictSourceArtifactsToBeDisplayed}" var="artifact">
|
||||
<tr>
|
||||
<td>
|
||||
<s:form action="merge" method="post" namespace="/admin" validate="false">
|
||||
<s:hidden name="repoid"/>
|
||||
<div class="buttons">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<s:submit value="Merge All" method="doMerge"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<s:submit value="Merge With Skip" method="mergeBySkippingConflicts"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</s:form>
|
||||
</td>
|
||||
<td>Artifact Id :</td>
|
||||
<td align="left"> <code>${artifact.namespace} : ${artifact.project} : ${artifact.version}</code></td>
|
||||
</tr>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</table>
|
||||
</c:forEach>
|
||||
</table>
|
||||
<s:form action="merge" method="post" namespace="/admin" validate="false">
|
||||
<s:hidden name="repoid"/>
|
||||
<div class="buttons">
|
||||
<s:submit value="Merge and Overwrite Conflicts" method="doMerge"/>
|
||||
<s:submit value="Merge and Skip Conflicts" method="mergeBySkippingConflicts"/>
|
||||
</div>
|
||||
</s:form>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -271,21 +271,13 @@
|
|||
<archiva:copy-paste-snippet object="${repository}" wrapper="toggle" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<c:set var="str" value="${repository.id}" />
|
||||
<jsp:useBean id="str" type="java.lang.String" scope="page"/>
|
||||
<c:set var="location" value="${repository.location}"/>
|
||||
<jsp:useBean id="location" type="java.lang.String" scope="page"/>
|
||||
|
||||
<%-- TODO: fix this hard coding - make stage repository configuration more transparent than the actual ManagedRepositoryConfiguration --%>
|
||||
<c:if test='<%= new File (new File(location ).getParent() ,str + "-stage" ).exists()%>'>
|
||||
<tr>
|
||||
<th>
|
||||
stage repository location
|
||||
</th>
|
||||
<c:if test="${repository.stagingRequired}">
|
||||
<tr>
|
||||
<th>
|
||||
Stage repository location
|
||||
</th>
|
||||
<td>
|
||||
${repository.location}${'-stage'}
|
||||
${repository.stagingLocation}
|
||||
</td>
|
||||
</tr>
|
||||
<redback:ifAuthorized permission="archiva-merge-repository" resource="${repository.id}">
|
||||
|
@ -294,22 +286,12 @@
|
|||
<td>
|
||||
<s:form action="merge" theme="simple">
|
||||
<s:hidden name="repoid" value="%{#attr.repository.id}"/>
|
||||
<%--<s:hidden name="repository" value="%{repository}"/>--%>
|
||||
<table>
|
||||
<tr>
|
||||
<td><s:submit id="Merge" value="Merge"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<s:submit id="Merge" value="Merge"/>
|
||||
</s:form>
|
||||
</td>
|
||||
</tr>
|
||||
</redback:ifAuthorized>
|
||||
|
||||
|
||||
</c:if>
|
||||
|
||||
|
||||
|
||||
</c:if>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<%--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you under the Apache License, Version 2.0 (the
|
||||
~ "License"); you may not use this file except in compliance
|
||||
~ with the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
--%>
|
||||
|
||||
<%-- http://www.opensymphony.com/webwork/wikidocs/File%20Upload%20Interceptor.html --%>
|
||||
|
||||
<%@ page contentType="text/html; charset=UTF-8" %>
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
|
||||
<s:hidden name="repository.id"/>
|
||||
<s:label label="ID" name="repository.id" />
|
||||
|
||||
<s:textfield name="repository.name" label="Name" size="50" required="true"/>
|
||||
<s:textfield name="repository.location" label="Directory" size="50" required="true"/>
|
||||
<s:textfield name="repository.indexDir" label="Index Directory" size="50"/>
|
||||
<s:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
|
||||
name="repository.layout" label="Type"/>
|
||||
<s:textfield name="repository.cronExpression" label="Cron" size="40" required="true"/>
|
||||
<s:textfield name="repository.daysOlder" label="Repository Purge By Days Older Than" size="5"/>
|
||||
<s:textfield name="repository.retentionCount" label="Repository Purge By Retention Count" size="5"/>
|
||||
<s:checkbox name="repository.releases" value="repository.releases" label="Releases Included"/>
|
||||
<s:checkbox name="repository.blockRedeployments" value="repository.blockRedeployments" label="Block Re-deployment of Released Artifacts"/>
|
||||
<s:checkbox name="repository.snapshots" value="repository.snapshots" label="Snapshots Included"/>
|
||||
<s:checkbox name="repository.scanned" value="repository.scanned" label="Scannable"/>
|
||||
<s:checkbox name="repository.deleteReleasedSnapshots" value="repository.deleteReleasedSnapshots"
|
||||
label="Delete Released Snapshots"/>
|
|
@ -846,6 +846,8 @@ public class UploadActionTest
|
|||
verifyProjectMetadataChecksums( repoLocation );
|
||||
}
|
||||
|
||||
// FIXME STAGE: test staging pushes it to the right place
|
||||
|
||||
ManagedRepository getManagedRepository()
|
||||
{
|
||||
return new BeanReplicator().replicateBean( this.managedRepository, ManagedRepository.class );
|
||||
|
|
|
@ -181,15 +181,6 @@ public class DeleteManagedRepositoryActionTest
|
|||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
Configuration stageRepoConfiguration = new Configuration();
|
||||
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||
|
||||
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
action.setRepoid( REPO_ID );
|
||||
|
@ -344,13 +335,6 @@ public class DeleteManagedRepositoryActionTest
|
|||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration, expectCountGetConfig );
|
||||
|
||||
Configuration stageRepoConfiguration = new Configuration();
|
||||
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
// save for staging repo delete
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
archivaConfigurationControl.replay();
|
||||
|
@ -410,23 +394,6 @@ public class DeleteManagedRepositoryActionTest
|
|||
return r;
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration createStagingRepository()
|
||||
{
|
||||
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
|
||||
r.setId( REPO_ID + "-stage" );
|
||||
r.setName( "repo name" );
|
||||
r.setLocation( location.getAbsolutePath() );
|
||||
r.setLayout( "default" );
|
||||
r.setRefreshCronExpression( "* 0/5 * * * ?" );
|
||||
r.setDaysOlder( 0 );
|
||||
r.setRetentionCount( 0 );
|
||||
r.setReleases( true );
|
||||
r.setSnapshots( true );
|
||||
r.setScanned( false );
|
||||
r.setDeleteReleasedSnapshots( false );
|
||||
return r;
|
||||
}
|
||||
|
||||
private RemoteRepositoryConfiguration createRemoteRepository( String id, String url )
|
||||
{
|
||||
RemoteRepositoryConfiguration r = new RemoteRepositoryConfiguration();
|
||||
|
|
|
@ -154,9 +154,6 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
archivaConfiguration.getConfiguration();
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
Configuration stageRepoConfiguration = new Configuration();
|
||||
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||
|
||||
archivaConfigurationControl.replay();
|
||||
|
||||
|
@ -180,8 +177,6 @@ public class EditManagedRepositoryActionTest
|
|||
public void testEditRepository()
|
||||
throws Exception
|
||||
{
|
||||
String stageRepoId = REPO_ID + "-stage";
|
||||
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
|
||||
|
@ -192,16 +187,6 @@ public class EditManagedRepositoryActionTest
|
|||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
roleManagerControl.replay();
|
||||
|
||||
registry.getString( "appserver.base", "${appserver.base}" );
|
||||
|
@ -223,13 +208,6 @@ public class EditManagedRepositoryActionTest
|
|||
repositoryTaskScheduler.queueTask( task );
|
||||
repositoryTaskSchedulerControl.setVoidCallable();
|
||||
|
||||
RepositoryTask stageTask = new RepositoryTask();
|
||||
stageTask.setRepositoryId( stageRepoId );
|
||||
repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
|
||||
repositoryTaskSchedulerControl.setReturnValue( false );
|
||||
repositoryTaskScheduler.queueTask( stageTask );
|
||||
repositoryTaskSchedulerControl.setVoidCallable();
|
||||
|
||||
repositoryTaskSchedulerControl.replay();
|
||||
|
||||
Configuration configuration = createConfigurationForEditing( createRepository() );
|
||||
|
@ -241,9 +219,6 @@ public class EditManagedRepositoryActionTest
|
|||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
Configuration stageRepoConfiguration = new Configuration();
|
||||
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
|
@ -260,6 +235,7 @@ public class EditManagedRepositoryActionTest
|
|||
ManagedRepository repository = action.getRepository();
|
||||
populateRepository( repository );
|
||||
repository.setName( "new repo name" );
|
||||
repository.setStagingRequired( true );
|
||||
|
||||
MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
|
||||
RepositoryStatisticsManager repositoryStatisticsManager =
|
||||
|
@ -269,10 +245,10 @@ public class EditManagedRepositoryActionTest
|
|||
// no deletion
|
||||
repositoryStatisticsManagerControl.replay();
|
||||
|
||||
// STAGE FIXME: hardcoded ID
|
||||
new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
|
||||
|
||||
action.setRepository( repository );
|
||||
action.setStageNeeded( true );
|
||||
String status = action.commit();
|
||||
assertEquals( Action.SUCCESS, status );
|
||||
|
||||
|
@ -301,6 +277,7 @@ public class EditManagedRepositoryActionTest
|
|||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
// STAGE FIXME: hardcoded ID
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
|
||||
|
@ -345,15 +322,8 @@ public class EditManagedRepositoryActionTest
|
|||
|
||||
archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
|
||||
|
||||
Configuration stageRepoConfiguration = buildEasyConfiguration();
|
||||
stageRepoConfiguration.addManagedRepository( createStagingRepository() );
|
||||
archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
|
||||
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
archivaConfigurationControl.setReturnValue( configuration );
|
||||
|
||||
archivaConfiguration.save( configuration );
|
||||
configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
|
||||
archivaConfiguration.save( configuration );
|
||||
archivaConfiguration.save( configuration );
|
||||
|
||||
|
@ -367,9 +337,11 @@ public class EditManagedRepositoryActionTest
|
|||
repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
|
||||
repositoryStatisticsManagerControl.replay();
|
||||
|
||||
// STAGE FIXME: hardcoded ID
|
||||
new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
|
||||
|
||||
action.setStageNeeded( true );
|
||||
// FIXME: stage setting needed
|
||||
// action.setStageNeeded( true );
|
||||
action.setRepoid( REPO_ID );
|
||||
action.prepare();
|
||||
assertEquals( REPO_ID, action.getRepoid() );
|
||||
|
@ -599,29 +571,4 @@ public class EditManagedRepositoryActionTest
|
|||
populateRepository( r );
|
||||
return r;
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration createStagingRepository()
|
||||
throws IOException
|
||||
{
|
||||
ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
|
||||
r.setId( REPO_ID + "-stage" );
|
||||
populateStagingRepository( r );
|
||||
return r;
|
||||
}
|
||||
|
||||
private void populateStagingRepository( ManagedRepositoryConfiguration repository )
|
||||
throws IOException
|
||||
{
|
||||
repository.setId( REPO_ID + "-stage" );
|
||||
repository.setName( "repo name" );
|
||||
repository.setLocation( "${appserver.base}/location" );
|
||||
repository.setLayout( "default" );
|
||||
repository.setRefreshCronExpression( "* 0/5 * * * ?" );
|
||||
repository.setDaysOlder( 31 );
|
||||
repository.setRetentionCount( 20 );
|
||||
repository.setReleases( true );
|
||||
repository.setSnapshots( true );
|
||||
repository.setScanned( false );
|
||||
repository.setDeleteReleasedSnapshots( true );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,16 +83,16 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -253,10 +253,11 @@ public class ArchivaDavResourceFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
ManagedRepositoryContent managedRepository = null;
|
||||
ManagedRepositoryContent managedRepository;
|
||||
|
||||
try
|
||||
{
|
||||
// STAGE FIXME: replace with pseudo staging repository when needed - good time to switch to new repository API, and probably only use config here
|
||||
managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
|
||||
}
|
||||
catch ( RepositoryNotFoundException e )
|
||||
|
@ -315,7 +316,7 @@ public class ArchivaDavResourceFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( resourcesInAbsolutePath != null && resourcesInAbsolutePath.size() > 1 )
|
||||
if ( resourcesInAbsolutePath.size() > 1 )
|
||||
{
|
||||
// merge the metadata of all repos under group
|
||||
ArchivaRepositoryMetadata mergedMetadata = new ArchivaRepositoryMetadata();
|
||||
|
@ -534,16 +535,19 @@ public class ArchivaDavResourceFactory
|
|||
|
||||
// check if target repo is enabled for releases
|
||||
// we suppose that release-artifacts can be deployed only to repos enabled for releases
|
||||
if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath )
|
||||
&& !repositoryRequest.isSupportFile( resourcePath ) )
|
||||
// also ignore flag for staging repositories, no harm in redeploying there
|
||||
if ( managedRepository.getRepository().isReleases() && !repositoryRequest.isMetadata( resourcePath ) &&
|
||||
!repositoryRequest.isSupportFile( resourcePath ) &&
|
||||
!managedRepository.getRepository().isStagingRequired() )
|
||||
{
|
||||
ArtifactReference artifact = null;
|
||||
ArtifactReference artifact;
|
||||
try
|
||||
{
|
||||
artifact = managedRepository.toArtifactReference( resourcePath );
|
||||
|
||||
if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
|
||||
{
|
||||
// STAGE FIXME: make sure staging was already considered
|
||||
// check if artifact already exists and if artifact re-deployment to the repository is allowed
|
||||
if ( managedRepository.hasContent( artifact )
|
||||
&& managedRepository.getRepository().isBlockRedeployments() )
|
||||
|
|
|
@ -141,13 +141,13 @@ public class ArchivaDavResourceFactoryTest
|
|||
{
|
||||
defaultManagedRepositoryAdmin.addManagedRepository(
|
||||
createManagedRepository( RELEASES_REPO, new File( "target/test-classes/" + RELEASES_REPO ).getPath(),
|
||||
"default" ), false, null );
|
||||
"default" ), null );
|
||||
}
|
||||
if ( defaultManagedRepositoryAdmin.getManagedRepository( INTERNAL_REPO ) == null )
|
||||
{
|
||||
defaultManagedRepositoryAdmin.addManagedRepository(
|
||||
createManagedRepository( INTERNAL_REPO, new File( "target/test-classes/" + INTERNAL_REPO ).getPath(),
|
||||
"default" ), false, null );
|
||||
"default" ), null );
|
||||
}
|
||||
RepositoryGroup repoGroupConfig = new RepositoryGroup();
|
||||
repoGroupConfig.setId( LOCAL_REPO_GROUP );
|
||||
|
@ -335,7 +335,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
|
||||
defaultManagedRepositoryAdmin.addManagedRepository(
|
||||
createManagedRepository( LOCAL_MIRROR_REPO, new File( "target/test-classes/local-mirror" ).getPath(),
|
||||
"default" ), false, null );
|
||||
"default" ), null );
|
||||
|
||||
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<RepositoryGroupConfiguration>();
|
||||
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
|
||||
|
@ -506,7 +506,7 @@ public class ArchivaDavResourceFactoryTest
|
|||
{
|
||||
defaultManagedRepositoryAdmin.addManagedRepository(
|
||||
createManagedRepository( LEGACY_REPO, new File( "target/test-classes/" + LEGACY_REPO ).getPath(),
|
||||
"legacy" ), false, null );
|
||||
"legacy" ), null );
|
||||
DavResourceLocator locator =
|
||||
new ArchivaDavResourceLocator( "", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml",
|
||||
LEGACY_REPO, new ArchivaDavLocatorFactory() );
|
||||
|
|
|
@ -87,8 +87,6 @@ public class AdministrationServiceImpl
|
|||
|
||||
private RepositoryMerger repositoryMerger;
|
||||
|
||||
private static final String STAGE = "-stage";
|
||||
|
||||
private AuditListener auditListener;
|
||||
|
||||
private RepositorySessionFactory repositorySessionFactory;
|
||||
|
@ -360,7 +358,7 @@ public class AdministrationServiceImpl
|
|||
|
||||
public Boolean addManagedRepository( String repoId, String layout, String name, String location,
|
||||
boolean blockRedeployments, boolean releasesIncluded,
|
||||
boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression,
|
||||
boolean snapshotsIncluded, boolean stagingRequired, String cronExpression,
|
||||
int daysOlder, int retentionCount, boolean deleteReleasedSnapshots )
|
||||
throws Exception
|
||||
{
|
||||
|
@ -370,8 +368,8 @@ public class AdministrationServiceImpl
|
|||
snapshotsIncluded, releasesIncluded,
|
||||
blockRedeployments, cronExpression, null, false,
|
||||
daysOlder, retentionCount,
|
||||
deleteReleasedSnapshots, false );
|
||||
return managedRepositoryAdmin.addManagedRepository( repository, stageRepoNeeded, getAuditInformation() );
|
||||
deleteReleasedSnapshots, stagingRequired );
|
||||
return managedRepositoryAdmin.addManagedRepository( repository, getAuditInformation() );
|
||||
|
||||
}
|
||||
|
||||
|
@ -495,9 +493,7 @@ public class AdministrationServiceImpl
|
|||
public boolean merge( String repoId, boolean skipConflicts )
|
||||
throws Exception
|
||||
{
|
||||
String stagingId = repoId + STAGE;
|
||||
org.apache.archiva.admin.model.beans.ManagedRepository repoConfig;
|
||||
org.apache.archiva.admin.model.beans.ManagedRepository stagingConfig;
|
||||
|
||||
repoConfig = managedRepositoryAdmin.getManagedRepository( repoId );
|
||||
|
||||
|
@ -509,10 +505,11 @@ public class AdministrationServiceImpl
|
|||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||
if ( repoConfig != null )
|
||||
{
|
||||
stagingConfig = managedRepositoryAdmin.getManagedRepository( stagingId );
|
||||
|
||||
if ( stagingConfig != null )
|
||||
String stagingId = "foo";
|
||||
if ( repoConfig.isStagingRequired() )
|
||||
{
|
||||
// STAGE FIXME: duplication with webapp - move all MergeAction to the staging module and have this
|
||||
// use it - make sure this gets tested
|
||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( stagingId );
|
||||
|
||||
if ( repoConfig.isReleases() && !repoConfig.isSnapshots() )
|
||||
|
@ -521,7 +518,7 @@ public class AdministrationServiceImpl
|
|||
if ( skipConflicts )
|
||||
{
|
||||
List<ArtifactMetadata> conflicts =
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId );
|
||||
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
|
@ -550,7 +547,7 @@ public class AdministrationServiceImpl
|
|||
if ( skipConflicts )
|
||||
{
|
||||
List<ArtifactMetadata> conflicts =
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId );
|
||||
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
|
@ -651,7 +648,6 @@ public class AdministrationServiceImpl
|
|||
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots );
|
||||
}
|
||||
|
||||
|
||||
// FIXME find a way to get user id and adress
|
||||
private AuditInformation getAuditInformation()
|
||||
{
|
||||
|
|
|
@ -158,8 +158,6 @@ public class AdministrationServiceImplTest
|
|||
|
||||
private Registry registry;
|
||||
|
||||
private static final String STAGE = "-stage";
|
||||
|
||||
private DefaultManagedRepositoryAdmin managedRepositoryAdmin;
|
||||
|
||||
private DefaultRemoteRepositoryAdmin remoteRepositoryAdmin;
|
||||
|
@ -813,6 +811,7 @@ public class AdministrationServiceImplTest
|
|||
throws Exception
|
||||
{
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
|
||||
// STAGE FIXME: verify no staging
|
||||
|
||||
configControl.expectAndReturn( config.getManagedRepositories(),
|
||||
Arrays.asList( createManagedRepo( "repo", "default", "repo", true, false ) ), 1,
|
||||
|
@ -848,18 +847,18 @@ public class AdministrationServiceImplTest
|
|||
|
||||
ManagedRepositoryConfiguration merge = createManagedRepo( "merge", "default", "merge", true, true );
|
||||
merge.setLocation( "target/test-repository/merge" );
|
||||
ManagedRepositoryConfiguration staging = createStagingRepo( merge );
|
||||
|
||||
RepositoryTask task = new RepositoryTask();
|
||||
task.setScanAll( true );
|
||||
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
|
||||
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( merge, staging ), 1, 5 );
|
||||
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( merge ), 1, 5 );
|
||||
// STAGE FIXME: verify no staging
|
||||
|
||||
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
|
||||
// metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
|
||||
repositoryMergerControl.expectAndDefaultReturn(
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, staging.getId(), merge.getId() ), sources );
|
||||
repositoryMerger.merge( metadataRepository, staging.getId(), merge.getId() );
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, merge.getId() ), sources );
|
||||
// repositoryMerger.merge( metadataRepository, staging.getId(), merge.getId() );
|
||||
repositoryMergerControl.setVoidCallable();
|
||||
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "merge" ),
|
||||
false );
|
||||
|
@ -919,15 +918,14 @@ public class AdministrationServiceImplTest
|
|||
|
||||
ManagedRepositoryConfiguration repo = createManagedRepo( "repo", "default", "repo", true, true );
|
||||
repo.setLocation( "target/test-repository/one" );
|
||||
ManagedRepositoryConfiguration staging = createStagingRepo( repo );
|
||||
|
||||
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( repo, staging ), 1, 5 );
|
||||
configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( repo ), 1, 5 );
|
||||
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
|
||||
|
||||
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
|
||||
// FIXME STAGE: get sources
|
||||
repositoryMergerControl.expectAndDefaultReturn(
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, staging.getId(), repo.getId() ), conflicts );
|
||||
repositoryMerger.merge( metadataRepository, staging.getId(), repo.getId(), artifactsWithOutConflicts );
|
||||
repositoryMerger.getConflictingArtifacts( metadataRepository, repo.getId() ), conflicts );
|
||||
repositoryMerger.merge( metadataRepository, null, repo.getId(), artifactsWithOutConflicts );
|
||||
repositoryMergerControl.setMatcher( MockControl.ALWAYS_MATCHER );
|
||||
repositoryMergerControl.setVoidCallable();
|
||||
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "repo" ),
|
||||
|
@ -967,6 +965,7 @@ public class AdministrationServiceImplTest
|
|||
String layout = "default";
|
||||
String name = projId + " Releases";
|
||||
String releaseLocation = "target/test-repository/" + projId + ".releases";
|
||||
// STAGE FIXME: hardcoded ID
|
||||
String stageLocation = releaseLocation + "-stage";
|
||||
String appserverBase = "target";
|
||||
|
||||
|
@ -999,6 +998,7 @@ public class AdministrationServiceImplTest
|
|||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
||||
roleManagerControl.setVoidCallable();
|
||||
|
||||
// STAGE FIXME: hardcoded ID
|
||||
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId + "-stage" );
|
||||
roleManagerControl.setReturnValue( false );
|
||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId + "-stage" );
|
||||
|
@ -1033,7 +1033,8 @@ public class AdministrationServiceImplTest
|
|||
repositoryTaskScheduler.queueTask( task );
|
||||
repositoryTaskSchedulerControl.setVoidCallable();
|
||||
|
||||
//staged repo
|
||||
//STAGE FIXME: hardcoded id
|
||||
String STAGE="-stage";
|
||||
repositoryTaskSchedulerControl.expectAndReturn(
|
||||
repositoryTaskScheduler.isProcessingRepositoryTask( repoId + STAGE ), false );
|
||||
task = new RepositoryTask();
|
||||
|
@ -1259,19 +1260,6 @@ public class AdministrationServiceImplTest
|
|||
return repoConfig;
|
||||
}
|
||||
|
||||
private ManagedRepositoryConfiguration createStagingRepo( ManagedRepositoryConfiguration repoConfig )
|
||||
{
|
||||
ManagedRepositoryConfiguration stagingRepo = new ManagedRepositoryConfiguration();
|
||||
stagingRepo.setId( repoConfig.getId() + STAGE );
|
||||
stagingRepo.setLayout( repoConfig.getLayout() );
|
||||
stagingRepo.setName( repoConfig + STAGE );
|
||||
stagingRepo.setReleases( repoConfig.isReleases() );
|
||||
stagingRepo.setSnapshots( repoConfig.isSnapshots() );
|
||||
stagingRepo.setLocation( repoConfig.getLocation() );
|
||||
|
||||
return stagingRepo;
|
||||
}
|
||||
|
||||
private AuditEvent createAuditEvent( ManagedRepositoryConfiguration repoConfig )
|
||||
{
|
||||
AuditEvent auditEvent = new AuditEvent();
|
||||
|
|
|
@ -157,6 +157,7 @@ public class Maven2RepositoryMerger
|
|||
// pom file copying
|
||||
String fileName = artifactMetadata.getProject() + "-" + artifactMetadata.getVersion() + ".pom";
|
||||
|
||||
// STAGE FIXME: don't re-parse and construct the path - use the filename we already have
|
||||
// pom file copying
|
||||
// TODO need to use path translator to get the pom file path
|
||||
// String fileName = artifactMetadata.getProject() + "-" + artifactMetadata.getVersion() + ".pom";
|
||||
|
@ -172,10 +173,10 @@ public class Maven2RepositoryMerger
|
|||
|
||||
String index = artifactPath.substring( lastIndex + 1 );
|
||||
int last = index.lastIndexOf( '.' );
|
||||
File sourcePomFile = new File( sourceRepoPath, artifactPath.substring( 0, lastIndex ) + "/"
|
||||
+ artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
|
||||
File targetPomFile = new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) + "/"
|
||||
+ artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
|
||||
File sourcePomFile = new File( sourceRepoPath, artifactPath.substring( 0, lastIndex ) + "/" +
|
||||
artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
|
||||
File targetPomFile = new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) + "/" +
|
||||
artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
|
||||
|
||||
if ( !targetPomFile.exists() && sourcePomFile.exists() )
|
||||
{
|
||||
|
@ -187,15 +188,16 @@ public class Maven2RepositoryMerger
|
|||
{
|
||||
|
||||
// updating version metadata files
|
||||
File versionMetaDataFileInSourceRepo =
|
||||
pathTranslator.toFile( new File( sourceRepoPath ), artifactMetadata.getNamespace(),
|
||||
artifactMetadata.getProject(), artifactMetadata.getVersion(),
|
||||
METADATA_FILENAME );
|
||||
File versionMetaDataFileInSourceRepo = pathTranslator.toFile( new File( sourceRepoPath ),
|
||||
artifactMetadata.getNamespace(),
|
||||
artifactMetadata.getProject(),
|
||||
artifactMetadata.getVersion(),
|
||||
METADATA_FILENAME );
|
||||
|
||||
if ( versionMetaDataFileInSourceRepo.exists() )
|
||||
{
|
||||
String relativePathToVersionMetadataFile =
|
||||
versionMetaDataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
|
||||
String relativePathToVersionMetadataFile = versionMetaDataFileInSourceRepo.getAbsolutePath().split(
|
||||
sourceRepoPath )[1];
|
||||
File versionMetaDataFileInTargetRepo = new File( targetRepoPath, relativePathToVersionMetadataFile );
|
||||
|
||||
if ( !versionMetaDataFileInTargetRepo.exists() )
|
||||
|
@ -215,8 +217,8 @@ public class Maven2RepositoryMerger
|
|||
|
||||
if ( projectMetadataFileInSourceRepo.exists() )
|
||||
{
|
||||
String relativePathToProjectMetadataFile =
|
||||
projectMetadataFileInSourceRepo.getAbsolutePath().split( sourceRepoPath )[1];
|
||||
String relativePathToProjectMetadataFile = projectMetadataFileInSourceRepo.getAbsolutePath().split(
|
||||
sourceRepoPath )[1];
|
||||
File projectMetadataFileInTargetRepo = new File( targetRepoPath, relativePathToProjectMetadataFile );
|
||||
|
||||
if ( !projectMetadataFileInTargetRepo.exists() )
|
||||
|
@ -234,6 +236,7 @@ public class Maven2RepositoryMerger
|
|||
|
||||
}
|
||||
|
||||
// TODO: replace with another copy method
|
||||
private void copyFile( File sourceFile, File targetFile )
|
||||
throws IOException
|
||||
{
|
||||
|
@ -332,12 +335,11 @@ public class Maven2RepositoryMerger
|
|||
return metadata;
|
||||
}
|
||||
|
||||
public List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
||||
String targetRepo )
|
||||
public List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String targetRepo )
|
||||
throws Exception
|
||||
{
|
||||
List<ArtifactMetadata> targetArtifacts = metadataRepository.getArtifacts( targetRepo );
|
||||
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepo );
|
||||
List<ArtifactMetadata> sourceArtifacts = Collections.emptyList(); // STAGE FIXME: metadataRepository.getArtifacts( sourceRepo );
|
||||
List<ArtifactMetadata> conflictsArtifacts = new ArrayList<ArtifactMetadata>();
|
||||
|
||||
for ( ArtifactMetadata targetArtifact : targetArtifacts )
|
||||
|
@ -354,9 +356,6 @@ public class Maven2RepositoryMerger
|
|||
}
|
||||
}
|
||||
|
||||
sourceArtifacts.removeAll( conflictsArtifacts );
|
||||
Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
||||
// merge( sourceRepo, targetRepo, artifactsWithOutConflicts );
|
||||
return conflictsArtifacts;
|
||||
}
|
||||
|
||||
|
@ -364,10 +363,10 @@ public class Maven2RepositoryMerger
|
|||
{
|
||||
boolean isSame = false;
|
||||
|
||||
if ( ( sourceArtifact.getNamespace().equals( targetArtifact.getNamespace() ) )
|
||||
&& ( sourceArtifact.getProject().equals( targetArtifact.getProject() ) )
|
||||
&& ( sourceArtifact.getId().equals( targetArtifact.getId() ) )
|
||||
&& ( sourceArtifact.getProjectVersion().equals( targetArtifact.getProjectVersion() ) ) )
|
||||
if ( ( sourceArtifact.getNamespace().equals( targetArtifact.getNamespace() ) ) &&
|
||||
( sourceArtifact.getProject().equals( targetArtifact.getProject() ) ) && ( sourceArtifact.getId().equals(
|
||||
targetArtifact.getId() ) ) && ( sourceArtifact.getProjectVersion().equals(
|
||||
targetArtifact.getProjectVersion() ) ) )
|
||||
|
||||
{
|
||||
isSame = true;
|
||||
|
|
|
@ -34,7 +34,6 @@ public interface RepositoryMerger
|
|||
Filter<ArtifactMetadata> filter )
|
||||
throws Exception;
|
||||
|
||||
List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String sourceRepo,
|
||||
String targetRepo )
|
||||
List<ArtifactMetadata> getConflictingArtifacts( MetadataRepository metadataRepository, String targetRepo )
|
||||
throws Exception;
|
||||
}
|
|
@ -149,8 +149,8 @@ public class Maven2RepositoryMergerTest
|
|||
when( metadataRepository.getArtifacts( sourceRepoId ) ).thenReturn( sourceRepoArtifactsList );
|
||||
when( metadataRepository.getArtifacts( TEST_REPO_ID ) ).thenReturn( targetRepoArtifactsList );
|
||||
|
||||
assertEquals( 1, repositoryMerger.getConflictingArtifacts( metadataRepository, sourceRepoId,
|
||||
TEST_REPO_ID ).size() );
|
||||
// STAGE FIXME: not testing the right thing
|
||||
assertEquals( 1, repositoryMerger.getConflictingArtifacts( metadataRepository, TEST_REPO_ID ).size() );
|
||||
verify( metadataRepository ).getArtifacts( TEST_REPO_ID );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue