Permalink
Browse files

Merge pull request #780 from sonatype/nexus-5608-group-wl-double-update

WL update misbehaving
  • Loading branch information...
2 parents 683c647 + 9987b2e commit 99591afa53ec1abeb59792be44a371b9aea75405 @cstamas cstamas committed Mar 22, 2013
@@ -18,11 +18,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonatype.nexus.configuration.Configurable;
-import org.sonatype.nexus.configuration.ConfigurationChangeEvent;
import org.sonatype.nexus.proxy.RequestContext;
import org.sonatype.nexus.proxy.events.RepositoryConfigurationUpdatedEvent;
-import org.sonatype.nexus.proxy.events.RepositoryGroupMembersChangedEvent;
import org.sonatype.nexus.proxy.events.RepositoryItemEvent;
import org.sonatype.nexus.proxy.events.RepositoryItemEventCache;
import org.sonatype.nexus.proxy.events.RepositoryItemEventDelete;
@@ -31,7 +28,6 @@
import org.sonatype.nexus.proxy.events.RepositoryRegistryEventAdd;
import org.sonatype.nexus.proxy.item.StorageFileItem;
import org.sonatype.nexus.proxy.item.uid.IsHiddenAttribute;
-import org.sonatype.nexus.proxy.maven.MavenGroupRepository;
import org.sonatype.nexus.proxy.maven.MavenHostedRepository;
import org.sonatype.nexus.proxy.maven.MavenRepository;
import org.sonatype.nexus.proxy.maven.maven2.Maven2ContentClass;
@@ -99,7 +95,7 @@ protected void handleRepositoryModified( final MavenRepository mavenRepository )
{
// we will end up here regularly if reconfiguration was about putting repository out of service
getLogger().debug( "Repository {} is in bad state for white-list update: {}",
- RepositoryStringUtils.getHumanizedNameString( mavenRepository ), e.getMessage() );
+ mavenRepository, e.getMessage() );
}
}
@@ -312,48 +308,4 @@ public void onRepositoryConfigurationUpdatedEvent( final RepositoryConfiguration
handleRepositoryModified( mavenRepository );
}
}
-
- // == Handlers for Group changes (WL of group and groups of groups needs to be updated)
-
- /**
- * This subscription is disabled, as this event is fired BEFORE configuration is committed, so group members are NOT
- * discovered properly and leading to bad WL content!
- *
- * @param evt
- */
- // @Subscribe
- // @AllowConcurrentEvents
- public void onRepositoryGroupMembersChangedEvent( final RepositoryGroupMembersChangedEvent evt )
- {
- if ( isRepositoryHandled( evt.getRepository() ) )
- {
- final MavenRepository mavenRepository = evt.getRepository().adaptToFacet( MavenRepository.class );
- handleRepositoryModified( mavenRepository );
- }
- }
-
- /**
- * Workaround for method above! This tricky subscriber actually listens for group member changes, but it does it by
- * hooking to {@link ConfigurationChangeEvent} instead of {@link RepositoryGroupMembersChangedEvent}, since former
- * is fired AFTER configuration is committed, while latter is fired BEFORE.
- *
- * @param evt
- */
- @Subscribe
- @AllowConcurrentEvents
- public void onConfigurationChangeEvent( final ConfigurationChangeEvent evt )
- {
- for ( Configurable configurable : evt.getChanges() )
- {
- if ( configurable instanceof Repository )
- {
- final Repository repository = (Repository) configurable;
- final MavenGroupRepository mavenGroupRepository = repository.adaptToFacet( MavenGroupRepository.class );
- if ( mavenGroupRepository != null && isRepositoryHandled( mavenGroupRepository ) )
- {
- handleRepositoryModified( mavenGroupRepository );
- }
- }
- }
- }
}
@@ -30,7 +30,6 @@
import org.sonatype.nexus.proxy.maven.wl.discovery.RemoteStrategy;
import org.sonatype.nexus.proxy.maven.wl.discovery.StrategyFailedException;
import org.sonatype.nexus.proxy.maven.wl.discovery.StrategyResult;
-import org.sonatype.nexus.proxy.utils.RepositoryStringUtils;
/**
* Default {@link RemoteContentDiscoverer} implementation.
@@ -73,8 +72,7 @@ public RemoteContentDiscovererImpl( final List<RemoteStrategy> remoteStrategies
new DiscoveryResult<MavenProxyRepository>( mavenProxyRepository );
for ( RemoteStrategy strategy : remoteStrategies )
{
- getLogger().debug( "Discovery of {} with strategy {} attempted",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), strategy.getId() );
+ getLogger().debug( "Discovery of {} with strategy {} attempted", mavenProxyRepository, strategy.getId() );
try
{
final StrategyResult strategyResult = strategy.discover( mavenProxyRepository );
@@ -103,14 +101,14 @@ public RemoteContentDiscovererImpl( final List<RemoteStrategy> remoteStrategies
if ( discoveryResult.isSuccessful() )
{
- getLogger().debug( "Discovery of {} with strategy {} successful",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), strategy.getId() );
+ getLogger().debug( "Discovery of {} with strategy {} successful", mavenProxyRepository,
+ strategy.getId() );
break;
}
else
{
- getLogger().debug( "Discovery of {} with strategy {} unsuccessful",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), strategy.getId() );
+ getLogger().debug( "Discovery of {} with strategy {} unsuccessful", mavenProxyRepository,
+ strategy.getId() );
}
}
return discoveryResult;
@@ -35,7 +35,6 @@
import org.sonatype.nexus.proxy.maven.wl.discovery.RemoteStrategy;
import org.sonatype.nexus.proxy.maven.wl.discovery.StrategyFailedException;
import org.sonatype.nexus.proxy.maven.wl.discovery.StrategyResult;
-import org.sonatype.nexus.proxy.utils.RepositoryStringUtils;
/**
* Remote prefix file strategy.
@@ -72,11 +71,10 @@ public StrategyResult discover( final MavenProxyRepository mavenProxyRepository
final List<String> remoteFilePath = config.getRemotePrefixFilePaths();
for ( String path : remoteFilePath )
{
- getLogger().debug( "Looking for remote prefix on {} at path {}",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), path );
+ getLogger().debug( "Looking for remote prefix on {} at path {}", mavenProxyRepository, path );
// we keep exclusive lock on UID during discovery to prevent other WL threads grabbing this file
// prematurely. We release the lock only when file is present locally, and is validated.
- // in that moment it's not published yet, but the content is correct and it will be
+ // in that moment it's not published yet, but the content is correct and it will be
// the same that will get published.
final RepositoryItemUid uid = mavenProxyRepository.createUid( path );
uid.getLock().lock( Action.update );
@@ -85,8 +83,7 @@ public StrategyResult discover( final MavenProxyRepository mavenProxyRepository
item = retrieveFromRemoteIfExists( mavenProxyRepository, path );
if ( item != null )
{
- getLogger().debug( "Remote prefix on {} at path {} found!",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), path );
+ getLogger().debug( "Remote prefix on {} at path {} found!", mavenProxyRepository, path );
long prefixFileAgeInDays = ( System.currentTimeMillis() - item.getModified() ) / 86400000L;
final PrefixSource prefixSource = createPrefixSource( mavenProxyRepository, path );
if ( prefixSource != null )
@@ -38,7 +38,6 @@
import org.sonatype.nexus.proxy.maven.wl.internal.scrape.ScrapeContext;
import org.sonatype.nexus.proxy.maven.wl.internal.scrape.Scraper;
import org.sonatype.nexus.proxy.storage.remote.httpclient.HttpClientManager;
-import org.sonatype.nexus.proxy.utils.RepositoryStringUtils;
/**
* Remote scrape strategy.
@@ -81,8 +80,7 @@ public RemoteScrapeStrategy( final WLConfig config, final HttpClientManager http
public StrategyResult discover( final MavenProxyRepository mavenProxyRepository )
throws StrategyFailedException, IOException
{
- getLogger().debug( "Remote scrape on {} tried",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ) );
+ getLogger().debug( "Remote scrape on {} tried", mavenProxyRepository );
// check does a proxy have a valid URL at all
final String remoteRepositoryRootUrl = mavenProxyRepository.getRemoteUrl();
boolean isValidHttpUrl;
@@ -110,39 +108,35 @@ public StrategyResult discover( final MavenProxyRepository mavenProxyRepository
new ScrapeContext( mavenProxyRepository, httpClient, config.getRemoteScrapeDepth() );
if ( isMarkedForNoScrape( context ) )
{
- getLogger().debug( "Remote {} marked as no-scrape, giving up.",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ) );
+ getLogger().debug( "Remote {} marked as no-scrape, giving up.", mavenProxyRepository );
throw new StrategyFailedException( "Remote forbids scraping, is flagged as \"no-scrape\"." );
}
final Page rootPage = Page.getPageFor( context, remoteRepositoryRootUrl );
final ArrayList<Scraper> appliedScrapers = new ArrayList<Scraper>( scrapers );
Collections.sort( appliedScrapers, new PriorityOrderingComparator<Scraper>() );
for ( Scraper scraper : appliedScrapers )
{
- getLogger().debug( "Remote scraping {} with Scraper {}",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), scraper.getId() );
+ getLogger().debug( "Remote scraping {} with Scraper {}", mavenProxyRepository, scraper.getId() );
scraper.scrape( context, rootPage );
if ( context.isStopped() )
{
if ( context.isSuccessful() )
{
- getLogger().debug( "Remote scraping {} with Scraper {} succeeded.",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), scraper.getId() );
+ getLogger().debug( "Remote scraping {} with Scraper {} succeeded.", mavenProxyRepository,
+ scraper.getId() );
return new StrategyResult( context.getMessage(), context.getPrefixSource() );
}
else
{
- getLogger().debug( "Remote scraping {} with Scraper {} stopped execution.",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), scraper.getId() );
+ getLogger().debug( "Remote scraping {} with Scraper {} stopped execution.", mavenProxyRepository,
+ scraper.getId() );
throw new StrategyFailedException( context.getMessage() );
}
}
- getLogger().debug( "Remote scraping {} with Scraper {} skipped.",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ), scraper.getId() );
+ getLogger().debug( "Remote scraping {} with Scraper {} skipped.", mavenProxyRepository, scraper.getId() );
}
- getLogger().debug( "Not possible remote scrape of {}, no scraper succeeded.",
- RepositoryStringUtils.getHumanizedNameString( mavenProxyRepository ) );
+ getLogger().debug( "Not possible remote scrape of {}, no scraper succeeded.", mavenProxyRepository );
throw new StrategyFailedException( "No scraper was able to scrape remote (or remote prevents scraping)." );
}
Oops, something went wrong.

0 comments on commit 99591af

Please sign in to comment.