Package org.apache.maven.index.context

Examples of org.apache.maven.index.context.IndexingContext


        try
        {
            ManagedRepository repository = managedRepositoryAdmin.getManagedRepository( repositoryId );

            IndexingContext context = managedRepositoryAdmin.createIndexContext( repository );

            ArtifactIndexingTask task =
                new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH, context );

            task.setExecuteOnEntireRepo( true );
View Full Code Here


        {
            List<RemoteRepository> remoteRepositories = getRemoteRepositories();
            // close index on shutdown
            for ( RemoteRepository remoteRepository : remoteRepositories )
            {
                IndexingContext context = indexer.getIndexingContexts().get( remoteRepository.getId() );
                if ( context != null )
                {
                    indexer.removeIndexingContext( context, false );
                }
            }
View Full Code Here

        try
        {
            String appServerBase = getRegistry().getString( "appserver.base" );

            String contextKey = "remote-" + remoteRepository.getId();
            IndexingContext indexingContext = indexer.getIndexingContexts().get( contextKey );
            if ( indexingContext != null )
            {
                return indexingContext;
            }
            // create remote repository path
View Full Code Here

    protected void createIndex( String repository, List<File> filesToBeIndexed, boolean scan )
        throws Exception
    {

        IndexingContext context = nexusIndexer.getIndexingContexts().get( repository );

        if ( context != null )
        {
            nexusIndexer.removeIndexingContext( context, true );
        }

        File indexerDirectory = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer" );

        if ( indexerDirectory.exists() )
        {
            FileUtils.deleteDirectory( indexerDirectory );
        }

        assertFalse( indexerDirectory.exists() );

        File lockFile = new File( FileUtil.getBasedir(), "/target/repos/" + repository + "/.indexer/write.lock" );
        if ( lockFile.exists() )
        {
            lockFile.delete();
        }

        assertFalse( lockFile.exists() );

        File repo = new File( FileUtil.getBasedir(), "src/test/" + repository );
        assertTrue( repo.exists() );
        File indexDirectory =
            new File( FileUtil.getBasedir(), "target/index/test-" + Long.toString( System.currentTimeMillis() ) );
        indexDirectory.deleteOnExit();
        FileUtils.deleteDirectory( indexDirectory );

        context = nexusIndexer.addIndexingContext( repository, repository, repo, indexDirectory,
                                                   repo.toURI().toURL().toExternalForm(),
                                                   indexDirectory.toURI().toURL().toString(),
                                                   search.getAllIndexCreators() );

        // minimize datas in memory
        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 );
        }

        if ( scan )
        {
            nexusIndexer.scan( context, new ArtifactScanListener(), false );
        }
        // force flushing
        context.getIndexWriter().commit();
        context.setSearchable( true );

    }
View Full Code Here

    }

    @Override
    public void completeScan()
    {
        IndexingContext context = this.indexingContext;
        if ( context == null )
        {
            try
            {
                context = getIndexingContext();
View Full Code Here

                    remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );

                if ( remoteRepository != null )
                {
                    String logicalResource = getLogicalResource( archivaLocator, null, false );
                    IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
                    File resourceFile = StringUtils.equals( logicalResource, "/" )
                        ? new File( indexingContext.getIndexDirectoryFile().getParent() )
                        : new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
                    resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), //
                                                       locator.getResourcePath(), //
                                                       null, //
                                                       request.getRemoteAddr(), //
                                                       activePrincipal, //
View Full Code Here

            MergedRemoteIndexesTaskRequest taskRequest =
                new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );

            MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );

            IndexingContext indexingContext = job.execute().getIndexingContext();

            File mergedRepoDir = indexingContext.getIndexDirectoryFile();
            TemporaryGroupIndex temporaryGroupIndex =
                new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
                                         repositoryGroupConfiguration.getMergedIndexTtl() ) //
                    .setCreationTime( new Date().getTime() );
            temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
            session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
                                  temporaryGroupIndexMap );
View Full Code Here

        String tempRepoId = mergedIndexDirectory.getName();

        try
        {
            File indexLocation = new File( mergedIndexDirectory, indexMergerRequest.getMergedIndexPath() );
            IndexingContext indexingContext =
                indexer.addIndexingContext( tempRepoId, tempRepoId, mergedIndexDirectory, indexLocation, null, null,
                                            mavenIndexerUtils.getAllIndexCreators() );

            for ( String repoId : indexMergerRequest.getRepositoriesIds() )
            {
                IndexingContext idxToMerge = indexer.getIndexingContexts().get( repoId );
                if ( idxToMerge != null )
                {
                    indexingContext.merge( idxToMerge.getIndexDirectory() );
                }
            }

            indexingContext.optimize();
View Full Code Here

            return;
        }

        try
        {
            IndexingContext indexingContext = indexer.getIndexingContexts().get( temporaryGroupIndex.getIndexId() );
            if ( indexingContext != null )
            {
                indexer.removeIndexingContext( indexingContext, true );
            }
            File directory = temporaryGroupIndex.getDirectory();
View Full Code Here

        try
        {
            // close index on shutdown
            for ( ManagedRepository managedRepository : getManagedRepositories() )
            {
                IndexingContext context = indexer.getIndexingContexts().get( managedRepository.getId() );
                if ( context != null )
                {
                    indexer.removeIndexingContext( context, false );
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.maven.index.context.IndexingContext

Copyright © 2018 www.massapicom. 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.