@SuppressWarnings( "unchecked" ) private void updateRepositoryReferences( RepositoryProvider provider, RemoteRepository repo, RemoteRepositoryConfiguration cfg, Configuration configuration) throws RepositoryException { if ( repo instanceof EditableRemoteRepository && repo.getContent() == null) { EditableRemoteRepository editableRepo = (EditableRemoteRepository) repo; editableRepo.setContent( repositoryContentFactory.getRemoteRepositoryContent( repo ) ); if (repo.supportsFeature(IndexCreationFeature.class) && repo.getIndexingContext()==null ) { createIndexingContext(editableRepo); } } }
private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException { org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id ); if (repo==null) { throw new RepositoryException( "Repository not found "+id ); } return repo.getContent(); }
protected <T> void raiseEvent(RepositoryEvent<T> event) { for(RepositoryEventListener listr : listener) { listr.raise(event); } }
@Override public void beginScan( ManagedRepository repo, Date whenGathered ) throws ConsumerException { repoId = repo.getId(); this.whenGathered = whenGathered; }
private Path getRepositoryBasedir( String repoId ) throws RepositoryStorageRuntimeException { ManagedRepository repositoryConfiguration = repositoryRegistry.getManagedRepository( repoId ); return Paths.get( repositoryConfiguration.getLocation() ); }
private void createIndexingContext(EditableRepository editableRepo) throws RepositoryException { if (editableRepo.supportsFeature(IndexCreationFeature.class)) { ArchivaIndexManager idxManager = getIndexManager(editableRepo.getType()); try { editableRepo.setIndexingContext(idxManager.createContext(editableRepo)); idxManager.updateLocalIndexPath(editableRepo); } catch (IndexCreationFailedException e) { throw new RepositoryException("Could not create index for repository "+editableRepo.getId()+": "+e.getMessage(),e); } } }
@SuppressWarnings( "unchecked" ) public void removeRepository(Repository repo) throws RepositoryException { if (repo instanceof RemoteRepository ) { removeRepository( (RemoteRepository)repo ); } else if (repo instanceof ManagedRepository) { removeRepository( (ManagedRepository)repo); } else { throw new RepositoryException( "Repository type not known: "+repo.getClass() ); } }
@Override public String getId( ) { return repository.getId( ); }
public void removeRepository(String repoId) throws RepositoryException { Repository repo = getRepository(repoId); if (repo!=null) { removeRepository(repo); } }
private RemoteRepository createNewRemoteRepository( RepositoryProvider provider, RemoteRepositoryConfiguration cfg ) throws RepositoryException { log.debug("Creating remote repo {}", cfg.getId()); RemoteRepository repo = provider.createRemoteInstance( cfg ); repo.addListener(this); updateRepositoryReferences( provider, repo, cfg , null); return repo; }
@Override public boolean supports( RepositoryType type ) { return type.equals( RepositoryType.MAVEN ); }
public BasicManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path basePath ) { super( primaryLocale, type, id, name, basePath ); initFeatures(); }
@Override public String getName( ) { return getName( primaryLocale ); }
public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path basePath ) { super( primaryLocale, type, id, name, basePath ); initFeatures(); }
@Override public String getDescription( ) { return getDescription( primaryLocale ); }
/** * Reloads the registry from the configuration. */ public void reload() { initialize(); }
private void initFeatures() { addFeature( remoteIndexFeature ); addFeature( indexCreationFeature ); }
private ManagedRepositoryContent getManagedRepositoryContent(String id) throws RepositoryException { org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( id ); if (repo==null) { throw new RepositoryException( "Could not find repository "+id ); } return repo.getContent(); }
@Override public String toString() { return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repository.getId() + ", resourceFile=" + resourceFile + "]"; }
public BasicManagedRepository( String id, String name, Path basePath ) { super( RepositoryType.MAVEN, id, name, basePath ); initFeatures(); }