private IndexingContext getIndexingContext() throws ConsumerException { if ( this.indexingContext == null ) { try { indexingContext = repository.getIndexingContext().getBaseContext(IndexingContext.class); } catch (UnsupportedBaseContextException e) { log.error("Bad repository type. Not nexus indexer compatible. "+repository.getType()); throw new ConsumerException("Bad repository type "+repository.getType()); } } return indexingContext; } }
@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { this.repository = repository; managedRepository = PathUtil.getPathFromUri( repository.getLocation() ); try { log.info( "Creating indexing context for repo : {}", repository.getId() ); if (repository.getType()== RepositoryType.MAVEN) { indexingContext = repository.getIndexingContext().getBaseContext(IndexingContext.class); } else { indexingContext= null; } } catch (UnsupportedBaseContextException e) { log.error("Bad repository type. Not nexus indexer compatible."); throw new ConsumerException("Bad repository type "+repository.getType()); } }
@Override public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException { if (!supports( repository.getType() )) { throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." ); } if (!supportsLayout( repository.getLayout() )) { throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); } ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(artifactMappingProviders, filetypes); content.setRepository( repository ); return content; }
/** * Creates a new repository instance with the same settings as this one. The cloned repository is not * registered or saved to the configuration. * * @param repo The origin repository * @return The cloned repository. */ public ManagedRepository clone(ManagedRepository repo, String newId) throws RepositoryException { if (managedRepositories.containsKey(newId) || remoteRepositories.containsKey(newId)) { throw new RepositoryException("The given id exists already "+newId); } RepositoryProvider provider = getProvider(repo.getType()); ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration(repo); cfg.setId(newId); ManagedRepository cloned = provider.createManagedInstance(cfg); cloned.addListener(this); return cloned; }
originRepo.close(); RepositoryProvider provider = getProvider( managedRepository.getType() ); ManagedRepositoryConfiguration newCfg = provider.getManagedConfiguration( managedRepository ); Configuration configuration = getArchivaConfiguration( ).getConfiguration( );
public ManagedRepositoryContent getManagedRepositoryContent( org.apache.archiva.repository.ManagedRepository mRepo ) throws RepositoryException { final String id = mRepo.getId(); ManagedRepositoryContent content = managedContentMap.get( id ); if ( content != null && content.getRepository()==mRepo) { return content; } RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); content = contentProvider.createManagedContent( mRepo ); if (content==null) { throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); } ManagedRepositoryContent previousContent = managedContentMap.put( id, content ); if (previousContent!=null) { previousContent.setRepository( null ); } return content; }
cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName());