@Test public void createContext() throws Exception { ArchivaIndexingContext ctx = createTestContext(); assertNotNull(ctx); assertEquals(repository, ctx.getRepository()); assertEquals("test-repo", ctx.getId()); assertEquals(indexPath.toAbsolutePath(), ctx.getPath().getFilePath().toAbsolutePath()); assertTrue(Files.exists(indexPath)); List<Path> li = Files.list(indexPath).collect(Collectors.toList()); assertTrue(li.size()>0); }
@Override public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException { log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType()); if ( repository.getType( ) != RepositoryType.MAVEN ) { throw new UnsupportedRepositoryTypeException( repository.getType( ) ); } IndexingContext mvnCtx = null; try { if ( repository instanceof RemoteRepository ) { mvnCtx = createRemoteContext( (RemoteRepository) repository ); } else if ( repository instanceof ManagedRepository ) { mvnCtx = createManagedContext( (ManagedRepository) repository ); } } catch ( IOException e ) { log.error( "IOException during context creation " + e.getMessage( ), e ); throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e ); } return new MavenIndexContext( repository, mvnCtx ); }
MavenIndexManager implements ArchivaIndexManager { @Override public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException { log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType()); if ( repository.getType( ) != RepositoryType.MAVEN ) { throw new UnsupportedRepositoryTypeException( repository.getType( ) ); } IndexingContext mvnCtx = null; try { if ( repository instanceof RemoteRepository ) { mvnCtx = createRemoteContext( (RemoteRepository) repository ); } else if ( repository instanceof ManagedRepository ) { mvnCtx = createManagedContext( (ManagedRepository) repository ); } } catch ( IOException e ) { log.error( "IOException during context creation " + e.getMessage( ), e ); throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e ); } return new MavenIndexContext( repository, mvnCtx ); } }
MavenIndexManager implements ArchivaIndexManager { @Override public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException { log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType()); if ( repository.getType( ) != RepositoryType.MAVEN ) { throw new UnsupportedRepositoryTypeException( repository.getType( ) ); } IndexingContext mvnCtx = null; try { if ( repository instanceof RemoteRepository ) { mvnCtx = createRemoteContext( (RemoteRepository) repository ); } else if ( repository instanceof ManagedRepository ) { mvnCtx = createManagedContext( (ManagedRepository) repository ); } } catch ( IOException e ) { log.error( "IOException during context creation " + e.getMessage( ), e ); throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e ); } return new MavenIndexContext( repository, mvnCtx ); }  }
MavenIndexManager implements ArchivaIndexManager { @Override public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException { log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType()); if ( repository.getType( ) != RepositoryType.MAVEN ) { throw new UnsupportedRepositoryTypeException( repository.getType( ) ); } IndexingContext mvnCtx = null; try { if ( repository instanceof RemoteRepository ) { mvnCtx = createRemoteContext( (RemoteRepository) repository ); } else if ( repository instanceof ManagedRepository ) { mvnCtx = createManagedContext( (ManagedRepository) repository ); } } catch ( IOException e ) { log.error( "IOException during context creation " + e.getMessage( ), e ); throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e ); } return new MavenIndexContext( repository, mvnCtx ); }  static IndexingContext getMvnContext( ArchivaIndexingContext context ); @Override void pack( final ArchivaIndexingContext context ); @Override void scan(final ArchivaIndexingContext context); @Override void update(final ArchivaIndexingContext context, final boolean fullUpdate); @Override void addArtifactsToIndex( final ArchivaIndexingContext context, final Collection<URI> artifactReference ); @Override void removeArtifactsFromIndex( ArchivaIndexingContext context, Collection<URI> artifactReference ); @Override boolean supportsRepository( RepositoryType type ); @Override ArchivaIndexingContext createContext( Repository repository ); @Override ArchivaIndexingContext reset(ArchivaIndexingContext context); @Override ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo); @Override void updateLocalIndexPath(Repository repo); @Override ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<ArchivaIndexingContext> contexts,
                                                boolean packIndex); }
MavenIndexManager implements ArchivaIndexManager { @Override public ArchivaIndexingContext createContext( Repository repository ) throws IndexCreationFailedException { log.debug("Creating context for repo {}, type: {}", repository.getId(), repository.getType()); if ( repository.getType( ) != RepositoryType.MAVEN ) { throw new UnsupportedRepositoryTypeException( repository.getType( ) ); } IndexingContext mvnCtx = null; try { if ( repository instanceof RemoteRepository ) { mvnCtx = createRemoteContext( (RemoteRepository) repository ); } else if ( repository instanceof ManagedRepository ) { mvnCtx = createManagedContext( (ManagedRepository) repository ); } } catch ( IOException e ) { log.error( "IOException during context creation " + e.getMessage( ), e ); throw new IndexCreationFailedException( "Could not create index context for repository " + repository.getId( ) + ( StringUtils.isNotEmpty( e.getMessage( ) ) ? ": " + e.getMessage( ) : "" ), e ); } return new MavenIndexContext( repository, mvnCtx ); }  static IndexingContext getMvnContext( ArchivaIndexingContext context ); @Override void pack( final ArchivaIndexingContext context ); @Override void scan(final ArchivaIndexingContext context); @Override void update(final ArchivaIndexingContext context, final boolean fullUpdate); @Override void addArtifactsToIndex( final ArchivaIndexingContext context, final Collection<URI> artifactReference ); @Override void removeArtifactsFromIndex( ArchivaIndexingContext context, Collection<URI> artifactReference ); @Override boolean supportsRepository( RepositoryType type ); @Override ArchivaIndexingContext createContext( Repository repository ); @Override ArchivaIndexingContext reset(ArchivaIndexingContext context); @Override ArchivaIndexingContext move(ArchivaIndexingContext context, Repository repo); @Override void updateLocalIndexPath(Repository repo); @Override ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<ArchivaIndexingContext> contexts,
                                                boolean packIndex);  }