Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

NEXUS-5216: Fix. #536

Merged
merged 2 commits into from

4 participants

@cstamas
Owner

The fix is actually done in dependency, change:
sonatype/nexus-archetype-common@0f71332

@cstamas cstamas NEXUS-5216: Fix.
The fix is actually done in dependency, change:
sonatype/nexus-archetype-common@0f71332
c940573
@adreghiciu
Owner

+1

@nabcos

+1

@cstamas cstamas NEXUS-5216: More improvements to MAC plugin
* added log entry for NEXUS-5216 case, Nexus will nag you
if you fetch a catalog for a repository that is not indexable
(has no IndexingContext)
* Added repo URL as since initial implementation Nexus now has
means to build "repo URL"
* smaller improvements
728fbb5
@jdillon
Owner

BTW, its really helpful to give pull requests meaningful titles, so that when reviewing its easy to tell what this is about. ASIS "Fix." tells me nothing about what this is, and the "NEXUS-5216" means extra work to go hit JIRA to get more information.

Adding detailed title/descriptions to pull requests will significantly help folks in the review/oversight process.

@cstamas cstamas merged commit 6900dd3 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 6, 2012
  1. @cstamas

    NEXUS-5216: Fix.

    cstamas authored
    The fix is actually done in dependency, change:
    sonatype/nexus-archetype-common@0f71332
Commits on Sep 7, 2012
  1. @cstamas

    NEXUS-5216: More improvements to MAC plugin

    cstamas authored
    * added log entry for NEXUS-5216 case, Nexus will nag you
    if you fetch a catalog for a repository that is not indexable
    (has no IndexingContext)
    * Added repo URL as since initial implementation Nexus now has
    means to build "repo URL"
    * smaller improvements
This page is out of date. Refresh to see the latest.
View
8 nexus/nexus-core-plugins/nexus-archetype-plugin/pom.xml
@@ -31,9 +31,15 @@
<dependencies>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.sonatype.spice</groupId>
<artifactId>nexus-archetype-common</artifactId>
- <version>1.1</version>
+ <version>1.2-SNAPSHOT</version>
</dependency>
<dependency>
View
7 ...ugins/nexus-archetype-plugin/src/main/java/org/sonatype/nexus/plugins/mac/ArchetypeContentGenerator.java
@@ -28,6 +28,7 @@
import org.sonatype.nexus.proxy.item.ContentLocator;
import org.sonatype.nexus.proxy.item.StorageFileItem;
import org.sonatype.nexus.proxy.repository.Repository;
+import org.sonatype.nexus.rest.RepositoryURLBuilder;
/**
* Archetype catalog content generator.
@@ -49,6 +50,9 @@
@Inject
private IndexArtifactFilter indexArtifactFilter;
+ @Inject
+ private RepositoryURLBuilder repositoryURLBuilder;
+
@Override
public String getGeneratorId()
{
@@ -62,7 +66,8 @@ public ContentLocator generateContent( Repository repository, String path, Stora
// make length unknown (since it will be known only in the moment of actual content pull)
item.setLength( -1 );
- return new ArchetypeContentLocator( repository.getId(),
+ return new ArchetypeContentLocator( repository,
+ repositoryURLBuilder.getExposedRepositoryContentUrl( repository ),
( (DefaultIndexerManager) indexerManager ).getRepositoryIndexContext( repository ), macPlugin,
new ArtifactInfoFilter()
{
View
46 ...plugins/nexus-archetype-plugin/src/main/java/org/sonatype/nexus/plugins/mac/ArchetypeContentLocator.java
@@ -21,20 +21,27 @@
import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer;
import org.apache.maven.index.ArtifactInfoFilter;
import org.apache.maven.index.context.IndexingContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonatype.nexus.proxy.item.ContentLocator;
+import org.sonatype.nexus.proxy.repository.Repository;
+import org.sonatype.nexus.proxy.utils.RepositoryStringUtils;
/**
* A content locator to generate archetype catalog. This way, the actual work (search, archetype catalog model fillup
* from results, converting it to string and flushing it as byte array backed stream) is postponed to very last moment,
* when the content itself is asked for.
- *
+ *
* @author cstamas
*/
public class ArchetypeContentLocator
implements ContentLocator
{
+ private final Logger logger;
+
+ private final Repository repository;
- private final String repositoryId;
+ private final String repositoryContentUrl;
private final IndexingContext indexingContext;
@@ -44,10 +51,13 @@
private volatile String payload;
- public ArchetypeContentLocator( String repositoryId, IndexingContext indexingContext, MacPlugin macPlugin,
- ArtifactInfoFilter artifactInfoFilter )
+ public ArchetypeContentLocator( final Repository repository, final String repositoryContentUrl,
+ final IndexingContext indexingContext, final MacPlugin macPlugin,
+ final ArtifactInfoFilter artifactInfoFilter )
{
- this.repositoryId = repositoryId;
+ this.logger = LoggerFactory.getLogger( getClass() );
+ this.repository = repository;
+ this.repositoryContentUrl = repositoryContentUrl;
this.indexingContext = indexingContext;
this.macPlugin = macPlugin;
this.artifactInfoFilter = artifactInfoFilter;
@@ -58,25 +68,23 @@ protected synchronized String generateCatalogPayload()
{
if ( payload == null )
{
- // TODO: what if URL is needed?
- // this content generator will be sucked from the repo root,
- // so it is fine for it to have no repositoryUrl
- // perm filter added, now this generator will generate catalog with archetypes that user
- // fetching it may see
+ final MacRequest req = new MacRequest( repository.getId(), repositoryContentUrl, artifactInfoFilter );
- // TODO: we have now the URL too, but I want to wait for ArchetypeCatalog improvements and possible changes
- MacRequest req = new MacRequest( repositoryId, null, artifactInfoFilter );
+ // NEXUS-5216: Warn if indexing context is null (indexable=false) for given repository but continue
+ // to return the correct empty catalog
+ if ( indexingContext == null )
+ {
+ logger.info(
+ "Archetype Catalog for repository {} is not buildable as it lacks IndexingContext (indexable=false?).",
+ RepositoryStringUtils.getHumanizedNameString( repository ) );
+ }
// get the catalog
- ArchetypeCatalog catalog = macPlugin.listArcherypesAsCatalog( req, indexingContext );
-
+ final ArchetypeCatalog catalog = macPlugin.listArcherypesAsCatalog( req, indexingContext );
// serialize it to XML
- StringWriter sw = new StringWriter();
-
- ArchetypeCatalogXpp3Writer writer = new ArchetypeCatalogXpp3Writer();
-
+ final StringWriter sw = new StringWriter();
+ final ArchetypeCatalogXpp3Writer writer = new ArchetypeCatalogXpp3Writer();
writer.write( sw, catalog );
-
payload = sw.toString();
}
View
14 ...plugins/nexus-archetype-plugin/src/main/java/org/sonatype/nexus/plugins/mac/MacPluginEventInspector.java
@@ -15,7 +15,7 @@
import javax.inject.Inject;
import javax.inject.Named;
-import org.slf4j.Logger;
+import org.sonatype.nexus.logging.AbstractLoggingComponent;
import org.sonatype.nexus.proxy.RepositoryNotAvailableException;
import org.sonatype.nexus.proxy.ResourceStoreRequest;
import org.sonatype.nexus.proxy.events.EventInspector;
@@ -39,14 +39,12 @@
* @author cstamas
*/
public class MacPluginEventInspector
+ extends AbstractLoggingComponent
implements EventInspector
{
private static final String ARCHETYPE_PATH = "/archetype-catalog.xml";
@Inject
- private Logger logger;
-
- @Inject
@Named( "maven2" )
private ContentClass maven2ContentClass;
@@ -117,18 +115,18 @@ else if ( evt instanceof RepositoryEventLocalStatusChanged )
}
catch ( RepositoryNotAvailableException e )
{
- logger.info( "Unable to install the generated archetype catalog, repository \""
+ getLogger().info( "Unable to install the generated archetype catalog, repository \""
+ e.getRepository().getId() + "\" is out of service." );
}
catch ( Exception e )
{
- if ( logger.isDebugEnabled() )
+ if ( getLogger().isDebugEnabled() )
{
- logger.info( "Unable to install the generated archetype catalog!", e );
+ getLogger().info( "Unable to install the generated archetype catalog!", e );
}
else
{
- logger.info( "Unable to install the generated archetype catalog:" + e.getMessage() );
+ getLogger().info( "Unable to install the generated archetype catalog:" + e.getMessage() );
}
}
}
Something went wrong with that request. Please try again.