private Path getRepositoryBasedir( String repoId ) throws RepositoryStorageRuntimeException { ManagedRepository repositoryConfiguration = repositoryRegistry.getManagedRepository( repoId ); return Paths.get( repositoryConfiguration.getLocation() ); }
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(); }
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(); }
public void removeRepository(ManagedRepository managedRepository, Configuration configuration) throws RepositoryException { final String id = managedRepository.getId(); ManagedRepository repo = getManagedRepository( id ); if (repo!=null) { rwLock.writeLock().lock(); try { repo = managedRepositories.remove( id ); if (repo!=null) { repo.close(); ManagedRepositoryConfiguration cfg = configuration.findManagedRepositoryById( id ); if (cfg!=null) { configuration.removeManagedRepository( cfg ); } } } finally { rwLock.writeLock().unlock(); } } }
@Override public RepositoryScanStatistics scanRepositoryDirectoriesNow( String repositoryId ) throws ArchivaRestServiceException { long sinceWhen = RepositoryScanner.FRESH_SCAN; try { return repoScanner.scan( repositoryRegistry.getManagedRepository( repositoryId ), sinceWhen ); } catch ( RepositoryScannerException e ) { log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( "RepositoryScannerException exception: " + e.getMessage(), 500, e ); } }
private ManagedRepository findArtifactInRepositories( List<String> repositoryIds, Artifact projectArtifact ) { for ( String repoId : repositoryIds ) ManagedRepository managedRepo = repositoryRegistry.getManagedRepository(repoId); Path repoDir = managedRepo.getLocalPath();
ManagedRepository repo = getManagedRepository( id ); if (repo!=null) { rwLock.writeLock().lock();
throw new IllegalStateException( "Repository Id is null" ); ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId ); if (repo==null) { throw new RepositoryException( "Repository not found "+repoId );
@Override public Boolean scanRepositoryNow( String repositoryId, boolean fullScan ) throws ArchivaRestServiceException { try { org.apache.archiva.repository.ManagedRepository repository = repositoryRegistry.getManagedRepository( repositoryId ); ArtifactIndexingTask task = new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH, repository.getIndexingContext() ); task.setExecuteOnEntireRepo( true ); task.setOnlyUpdate( !fullScan ); archivaIndexingTaskExecutor.executeTask( task ); scheduler.queueTask( new RepositoryTask( repositoryId, fullScan ) ); return Boolean.TRUE; } catch ( Exception e ) { log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), e ); } }
org.apache.archiva.repository.ManagedRepository managedRepo = repositoryRegistry.getManagedRepository(repoId);
@Override public DavResource createResource( final DavResourceLocator locator, final DavSession davSession ) throws DavException { ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator ); ManagedRepositoryContent managedRepositoryContent; ManagedRepository repo = repositoryRegistry.getManagedRepository( archivaLocator.getRepositoryId( ) ); if (repo==null) { throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Invalid repository: " + archivaLocator.getRepositoryId() ); } managedRepositoryContent = repo.getContent(); if (managedRepositoryContent==null) { log.error("Inconsistency detected. Repository content not found for '{}'", archivaLocator.getRepositoryId()); throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Invalid repository: " + archivaLocator.getRepositoryId() ); } DavResource resource = null; String logicalResource = getLogicalResource( archivaLocator, repo, false ); if ( logicalResource.startsWith( "/" ) ) { logicalResource = logicalResource.substring( 1 ); } Path resourceFile = Paths.get( managedRepositoryContent.getRepoRoot(), logicalResource ); resource = new ArchivaDavResource( resourceFile.toAbsolutePath().toString(), logicalResource, repo, davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler, fileLockManager ); resource.addLockManager( lockManager ); return resource; }
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( repositoryId ); if (managedRepository==null) { throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not find repository with id "+repositoryId );
@Override public void beginScan( ManagedRepository repoConfig, Date whenGathered ) throws ConsumerException { try { ManagedRepository repo = repositoryRegistry.getManagedRepository( repoConfig.getId( ) ); if (repo==null) { throw new RepositoryNotFoundException( "Repository not found: "+repoConfig.getId() ); } this.repository = repo.getContent(); if (this.repository==null) { throw new RepositoryNotFoundException( "Repository content not found: "+repoConfig.getId() ); } this.repositoryDir = Paths.get( repository.getRepoRoot( ) ); this.scanStartTimestamp = System.currentTimeMillis( ); } catch ( RepositoryException e ) { throw new ConsumerException( e.getMessage( ), e ); } }
private ManagedRepository getStagingRepository(RepositoryProvider provider, ManagedRepositoryConfiguration baseRepoCfg, Configuration configuration) throws RepositoryException { ManagedRepository stageRepo = getManagedRepository( baseRepoCfg.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX ); if ( stageRepo == null ) { stageRepo = provider.createStagingInstance( baseRepoCfg ); if (stageRepo.supportsFeature(StagingRepositoryFeature.class)) { stageRepo.getFeature(StagingRepositoryFeature.class).get().setStageRepoNeeded(false); } ManagedRepositoryConfiguration stageCfg = provider.getManagedConfiguration( stageRepo ); updateRepositoryReferences( provider, stageRepo, stageCfg, configuration); } return stageRepo; }
@Test public void testNonArtifactFile() throws Exception { RepositoryRegistry repositoryRegistry = applicationContext.getBean(RepositoryRegistry.class); ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( managedRepository ); repositoryRegistry.putRepository( getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME )); String repoRoot = prepareTestRepos(); // test listeners for the correct artifacts listenerControl.replay(); Path file = Paths.get(repoRoot, INDEX_PATH ); if ( !Files.exists(file) ) { // help windauze to create directory with . Files.createDirectories( file.getParent() ); Files.createFile( file ); } assertTrue( Files.exists(file) ); repoPurge.process( INDEX_PATH ); listenerControl.verify(); assertTrue( Files.exists(file) ); }
org.apache.archiva.repository.ManagedRepository managedRepo = repositoryRegistry.getManagedRepository(targetRepositoryId); MetadataRepository metadataRepository = repositorySession.getRepository(); List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( sourceRepositoryId );
sourceArtifacts.removeAll( conflictSourceArtifacts ); org.apache.archiva.repository.ManagedRepository managedRepo = repositoryRegistry.getManagedRepository(targetRepositoryId);
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( TEST_REPO_ID ); repositoryRegistry.putRepository(
ManagedRepository repo = repositoryRegistry.getManagedRepository( proxyConfig.getSourceRepoId( ) ); if (repo==null) { log.error("Cannot find source repository after config change "+proxyConfig.getSourceRepoId());
ManagedRepository managedRepository = repositoryRegistry.getManagedRepository( TEST_REPO_ID ); repositoryRegistry.removeRepository( TEST_REPO_ID ); repositoryRegistry.putRepository(