@SuppressWarnings( "unchecked" ) @Override public <T extends RepositoryContent, V extends Repository> T createContent( Class<T> clazz, V repository ) throws RepositoryException { if (!supports( repository.getType() )) { throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." ); } if (repository instanceof ManagedRepository && ManagedRepositoryContent.class.isAssignableFrom( clazz ) ) { return (T) this.createManagedContent( (ManagedRepository) repository ); } else if (repository instanceof RemoteRepository && RemoteRepository.class.isAssignableFrom( clazz )) { return (T) this.createRemoteContent( (RemoteRepository) repository ); } else { throw new RepositoryException( "Repository flavour is not supported: "+repository.getClass().getName() ); } }
@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 ); } MavenIndexContext context = new MavenIndexContext( repository, mvnCtx ); return context; }
if (rRepo.getType().equals(RepositoryType.MAVEN)) { assert rRepo.getIndexingContext() != null; IndexingContext context = rRepo.getIndexingContext().getBaseContext(IndexingContext.class);
/** * Resets the indexing context of a given repository. * * @param repo * @throws IndexUpdateFailedException */ @SuppressWarnings( "unchecked" ) public void resetIndexingContext(Repository repo) throws IndexUpdateFailedException { if (repo.hasIndex() && repo instanceof EditableRepository) { EditableRepository eRepo = (EditableRepository) repo; ArchivaIndexingContext newCtx = getIndexManager(repo.getType()).reset(repo.getIndexingContext()); eRepo.setIndexingContext(newCtx); } }
repositoryRegistry.getRepository( id ) ).filter( repo -> repo.getType().equals( RepositoryType.MAVEN ) ) .map( repo -> { try