Examples of ArtifactContext


Examples of org.apache.maven.index.ArtifactContext

        context.getIndexWriter().setMaxBufferedDocs( -1 );
        context.getIndexWriter().setRAMBufferSizeMB( 1 );
        for ( File artifactFile : filesToBeIndexed )
        {
            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

            if ( artifactFile.getPath().endsWith( ".pom" ) )
            {
                ac.getArtifactInfo().fextension = "pom";
                ac.getArtifactInfo().packaging = "pom";
                ac.getArtifactInfo().classifier = "pom";
            }
            nexusIndexer.addArtifactToIndex( ac, context );
            context.updateTimestamp( true );
        }
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

                {
                    log.debug( "no artifact pass in indexing task so skip it" );
                }
                else
                {
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        // MRM-1779 pom must be indexed too
                        // TODO make that configurable?
                        if ( artifactFile.getPath().endsWith( ".pom" ) )
                        {
                            ac.getArtifactInfo().fextension = "pom";
                            ac.getArtifactInfo().packaging = "pom";
                            ac.getArtifactInfo().classifier = "pom";
                        }
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            //IndexSearcher s = context.getIndexSearcher();
                            //String uinfo = ac.getArtifactInfo().getUinfo();
                            //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                            BooleanQuery q = new BooleanQuery();
                            q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                                ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                            if ( ac.getArtifactInfo().classifier != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                    ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                            }
                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }
                            else
                            {
                                log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                                // TODO check if update exists !!
                                nexusIndexer.deleteArtifactFromIndex( ac, context );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }

                            context.updateTimestamp();
                            context.commit();


                        }
                        else
                        {
                            log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                        }
                    }
                }
                // close the context if not a repo scan request
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

                }

                try
                {
                    File artifactFile = indexingTask.getResourceFile();
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            //IndexSearcher s = context.getIndexSearcher();
                            //String uinfo = ac.getArtifactInfo().getUinfo();
                            //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                            BooleanQuery q = new BooleanQuery();
                            q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                                ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                            if ( ac.getArtifactInfo().classifier != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                    ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                            }
                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }
                            else
                            {
                                log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                                // TODO check if update exists !!
                                nexusIndexer.deleteArtifactFromIndex( ac, context );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }

                            context.updateTimestamp();

                            // close the context if not a repo scan request
                            if ( !indexingTask.isExecuteOnEntireRepo() )
                            {
                                log.debug( "Finishing indexing task on resource file : {}",
                                           indexingTask.getResourceFile().getPath() );
                                finishIndexingTask( indexingTask, repository, context );
                            }
                        }
                        else
                        {
                            log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                        }
                    }
                }
                catch ( IOException e )
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

                {
                    log.debug( "no artifact pass in indexing task so skip it" );
                }
                else
                {
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            //IndexSearcher s = context.getIndexSearcher();
                            //String uinfo = ac.getArtifactInfo().getUinfo();
                            //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                            BooleanQuery q = new BooleanQuery();
                            q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                                ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                            if ( ac.getArtifactInfo().classifier != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                    ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                            }
                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }
                            else
                            {
                                log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                                // TODO check if update exists !!
                                nexusIndexer.deleteArtifactFromIndex( ac, context );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }

                            context.updateTimestamp();
                            context.commit();


                        }
                        else
                        {
                            log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                        }
                    }
                }
                // close the context if not a repo scan request
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

          if (ra.length > 4) {
            ai.packaging = ArtifactInfo.renvl(ra[4]);
          }

          // minimal ArtifactContext for removal
          final ArtifactContext ac = new ArtifactContext(null, null, null, ai, ai.calculateGav());
          if (contextPath == null
              || context.getGavCalculator().gavToPath(ac.getGav()).startsWith(contextPath)) {
            if (IndexOp.DELETED == remove(ac)) {
              deleted++;
            }
          }
        }
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

    uidLock.lock(Action.read);

    try {

      ArtifactContext ac = null;

      // if we have a valid indexing context and have access to a File
      if (DefaultFSLocalRepositoryStorage.class.isAssignableFrom(repository.getLocalStorage().getClass())) {
        File file =
            ((DefaultFSLocalRepositoryStorage) repository.getLocalStorage()).getFileFromBase(repository,
                new ResourceStoreRequest(item));

        if (file.exists()) {
          try {
            ac = artifactContextProducer.getArtifactContext(context, file);
          }
          catch (IllegalArgumentException e) {
            // cannot create artifact context, forget it
            return;
          }

          if (ac != null) {
            if (log.isDebugEnabled()) {
              log.debug("The ArtifactContext created from file is fine, continuing.");
            }

            ArtifactInfo ai = ac.getArtifactInfo();

            if (ai.sha1 == null) {
              // if repo has no sha1 checksum, odd nexus one
              ai.sha1 =
                  item.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_SHA1_KEY);
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

    // store extension if classifier is not empty
    if (!Strings.isNullOrEmpty(ai.classifier)) {
      ai.packaging = gav.getExtension();
    }

    ArtifactContext ac = null;

    // we need to convert Nexus Gav to Indexer Gav
    org.apache.maven.index.artifact.Gav igav = GavUtils.convert(gav);

    try {
      ac = new ArtifactContext(null, null, null, ai, igav);
    }
    catch (IllegalArgumentException e) {
      // ac cannot be created, just forget it being indexed
      return;
    }

    // remove file from index
    if (log.isDebugEnabled()) {
      log.debug("Deleting artifact " + ai.groupId + ":" + ai.artifactId + ":" + ai.version
          + " from index (DELETE).");
    }

    // NEXUS-814: we should not delete always
    if (!item.getItemContext().containsKey(SnapshotRemover.MORE_TS_SNAPSHOTS_EXISTS_FOR_GAV)) {
      final RepositoryItemUidLock uidLock = item.getRepositoryItemUid().getLock();

      uidLock.lock(Action.read);

      try {
        getNexusIndexer().deleteArtifactFromIndex(ac, context);
      }
      finally {
        uidLock.unlock();
      }
    }
    else {
      // do NOT remove file from index
      if (log.isDebugEnabled()) {
        log.debug("NOT deleting artifact " + ac.getArtifactInfo().groupId + ":"
            + ac.getArtifactInfo().artifactId + ":" + ac.getArtifactInfo().version
            + " from index (DELETE), since it is a timestamped snapshot and more builds exists.");
      }
    }
  }
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

      // add one archetype
      ArtifactInfo artifactInfo =
          new ArtifactInfo(context.getRepositoryId(), "org.sonatype.nexus.plugins", "nexus-archetype-plugin", "1.0",
              null);
      artifactInfo.packaging = "maven-archetype";
      ArtifactContext ac = new ArtifactContext(null, null, null, artifactInfo, artifactInfo.calculateGav());
      nexusIndexer.addArtifactToIndex(ac, context);
      // get catalog again
      catalog = macPlugin.listArcherypesAsCatalog(request, context);
      // repo has 4 artifacts indexed (plus 3 "internal" fields)
      assertThat("We have at least 4 Lucene documents in there for 3 artifacts!", context.getSize() >= 7);
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

        context.getIndexWriter().setMaxBufferedDocs( -1 );
        context.getIndexWriter().setRAMBufferSizeMB( 1 );
        for ( File artifactFile : filesToBeIndexed )
        {
            assertTrue( "file not exists " + artifactFile.getPath(), artifactFile.exists() );
            ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );
            nexusIndexer.addArtifactToIndex( ac, context );
            context.updateTimestamp( true );
        }

        if ( scan )
View Full Code Here

Examples of org.apache.maven.index.ArtifactContext

                {
                    log.debug( "no artifact pass in indexing task so skip it" );
                }
                else
                {
                    ArtifactContext ac = artifactContextProducer.getArtifactContext( context, artifactFile );

                    if ( ac != null )
                    {
                        if ( indexingTask.getAction().equals( ArtifactIndexingTask.Action.ADD ) )
                        {
                            //IndexSearcher s = context.getIndexSearcher();
                            //String uinfo = ac.getArtifactInfo().getUinfo();
                            //TopDocs d = s.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), 1 );

                            BooleanQuery q = new BooleanQuery();
                            q.add( nexusIndexer.constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().groupId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression(
                                ac.getArtifactInfo().artifactId ) ), BooleanClause.Occur.MUST );
                            q.add( nexusIndexer.constructQuery( MAVEN.VERSION, new SourcedSearchExpression(
                                ac.getArtifactInfo().version ) ), BooleanClause.Occur.MUST );
                            if ( ac.getArtifactInfo().classifier != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.CLASSIFIER, new SourcedSearchExpression(
                                    ac.getArtifactInfo().classifier ) ), BooleanClause.Occur.MUST );
                            }
                            if ( ac.getArtifactInfo().packaging != null )
                            {
                                q.add( nexusIndexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression(
                                    ac.getArtifactInfo().packaging ) ), BooleanClause.Occur.MUST );
                            }
                            FlatSearchRequest flatSearchRequest = new FlatSearchRequest( q, context );
                            FlatSearchResponse flatSearchResponse = nexusIndexer.searchFlat( flatSearchRequest );
                            if ( flatSearchResponse.getResults().isEmpty() )
                            {
                                log.debug( "Adding artifact '{}' to index..", ac.getArtifactInfo() );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }
                            else
                            {
                                log.debug( "Updating artifact '{}' in index..", ac.getArtifactInfo() );
                                // TODO check if update exists !!
                                nexusIndexer.deleteArtifactFromIndex( ac, context );
                                nexusIndexer.addArtifactToIndex( ac, context );
                            }

                            context.updateTimestamp();
                            context.commit();


                        }
                        else
                        {
                            log.debug( "Removing artifact '{}' from index..", ac.getArtifactInfo() );
                            nexusIndexer.deleteArtifactFromIndex( ac, context );
                        }
                    }
                }
                // close the context if not a repo scan request
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.