public void beginScan( ManagedRepositoryConfiguration repository ) throws ConsumerException { this.managedRepository = new ManagedDefaultRepositoryContent(); this.managedRepository.setRepository( repository ); }
public void beginScan( ManagedRepositoryConfiguration repo ) throws ConsumerException { try { this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() ); this.repositoryDir = new File( repository.getRepoRoot() ); } catch(RepositoryException e) { throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e ); } }
public void beginScan( ManagedRepositoryConfiguration repo ) throws ConsumerException { try { this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() ); this.repositoryDir = new File( repository.getRepoRoot() ); this.index = indexFactory.createFileContentIndex( repository.getRepository() ); } catch ( RepositoryException e ) { throw new ConsumerException( "Unable to start IndexContentConsumer: " + e.getMessage(), e ); } }
private ManagedRepositoryContent getRepository( ArchivaArtifact artifact ) throws ConsumerException { String repoId = artifact.getModel().getRepositoryId(); try { return repositoryFactory.getManagedRepositoryContent( repoId ); } catch ( RepositoryException e ) { throw new ConsumerException( "Unable to process project model: " + e.getMessage(), e ); } }
/** * Get a Live Artifact from a Path. * <p/> * Will resolve the artifact details from the path, and then return a database live version * of that artifact. Suitable for modification and saving (without the need to check for * existance in database prior to save.) * * @param path the path to work from. * @return the artifact that is suitable for database saving. */ public ArchivaArtifact getLiveArtifact( String path ) { try { ArtifactReference artifact = repository.toArtifactReference( path ); ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), artifact.getType(), repository.getId()); return liveArtifact; } catch ( LayoutException e ) { triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: " + e.getMessage() ); return null; } }
private String toPath( ArchivaArtifact artifact ) { try { String repoId = artifact.getModel().getRepositoryId(); ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId ); return repo.toPath( artifact ); } catch ( RepositoryException e ) { log.warn( "Unable to calculate path for artifact: " + artifact ); return ""; } }
/** * Get a Live Artifact from a Path. * <p/> * Will resolve the artifact details from the path, and then return a database live version * of that artifact. Suitable for modification and saving (without the need to check for * existance in database prior to save.) * * @param path the path to work from. * @return the artifact that is suitable for database saving. */ public ArchivaArtifact getLiveArtifact( String path ) { try { ArtifactReference artifact = repository.toArtifactReference( path ); ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), artifact.getType() ); return liveArtifact; } catch ( LayoutException e ) { triggerConsumerError( TYPE_NOT_ARTIFACT, "Path " + path + " cannot be converted to artifact: " + e.getMessage() ); return null; } }
public void processArchivaArtifact( ArchivaArtifact artifact ) throws ConsumerException { HashcodesRecord record = new HashcodesRecord(); record.setRepositoryId( artifact.getModel().getRepositoryId() ); record.setArtifact( artifact ); IndexedRepositoryDetails pnl = getIndexedRepositoryDetails( artifact ); String artifactPath = pnl.repository.toPath( artifact ); record.setFilename( artifactPath ); try { pnl.index.modifyRecord( record ); } catch ( RepositoryIndexException e ) { triggerConsumerError( INDEX_ERROR, "Unable to index hashcodes: " + e.getMessage() ); } }
throw new ContentNotFoundException( "Unable to get related artifacts using a non-existant directory: " + repoDir.getAbsolutePath() ); throw new ContentNotFoundException( "Unable to get related artifacts using a non-directory: " + repoDir.getAbsolutePath() );
public void processArchivaArtifact( ArchivaArtifact artifact ) throws ConsumerException { try { ManagedRepositoryContent repositoryContent = repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); if( !file.exists() ) { artifactDAO.deleteArtifact( artifact ); } } catch ( RepositoryException re ) { throw new ConsumerException( "Can't run database cleanup remove artifact consumer: " + re.getMessage() ); } catch ( ArchivaDatabaseException e ) { throw new ConsumerException( e.getMessage() ); } }
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered ) throws ConsumerException { try { this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() ); this.repositoryDir = new File( repository.getRepoRoot() ); this.whenGathered = whenGathered; } catch(RepositoryException e) { throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e ); } }
private ManagedRepositoryContent getRepository( ArchivaArtifact artifact ) throws ConsumerException { String repoId = artifact.getModel().getRepositoryId(); try { return repositoryFactory.getManagedRepositoryContent( repoId ); } catch ( RepositoryException e ) { throw new ConsumerException( "Unable to process project model: " + e.getMessage(), e ); } }
private String toPath( ArchivaArtifact artifact ) { try { String repoId = artifact.getModel().getRepositoryId(); ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId ); return repo.toPath( artifact ); } catch ( RepositoryException e ) { log.warn( "Unable to calculate path for artifact: " + artifact ); return ""; } }
public void processFile( String path ) throws ConsumerException { try { ArtifactReference reference = managedRepository.toArtifactReference( path ); Artifact artifact = artifactFactory.createArtifact( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), reference.getClassifier(), reference.getType() ); artifactConverter.convert( artifact, destinationRepository ); } catch ( LayoutException e ) { getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e ); } catch ( ArtifactConversionException e ) { getLogger().warn( "Unable to convert artifact: " + path + " : " + e.getMessage(), e ); } }
public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException { File groupDir = new File( repository.getLocation(), reference.getGroupId() ); if ( !groupDir.exists() ) { throw new ContentNotFoundException( "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() ); } if ( !groupDir.isDirectory() ) { throw new ContentNotFoundException( "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() ); } // First gather up the versions found as artifacts in the managed repository. File typeDirs[] = groupDir.listFiles(); for ( File typeDir : typeDirs ) { if ( !typeDir.isDirectory() ) { // Skip it, we only care about directories. continue; } if ( !typeDir.getName().endsWith( "s" ) ) { // Skip it, we only care about directories that end in "s". } deleteVersions( typeDir, reference ); } }
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); re.getMessage() );
private void initRepositoryMap() { synchronized ( this.repositoryMap ) { this.repositoryMap.clear(); Iterator<ManagedRepositoryConfiguration> it = configuration.getConfiguration().getManagedRepositories().iterator(); while ( it.hasNext() ) { ManagedRepositoryConfiguration repository = it.next(); try { IndexedRepositoryDetails pnl = new IndexedRepositoryDetails(); pnl.repository = repositoryFactory.getManagedRepositoryContent( repository.getId() ); pnl.index = indexFactory.createHashcodeIndex( repository ); this.repositoryMap.put( repository.getId(), pnl ); } catch ( RepositoryException e ) { getLogger().error( "Unable to load repository content object: " + e.getMessage(), e ); } } } }
repoFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repoContent.getRepoRoot(), repoContent.toPath( artifact ) ); RepositoryContentIndex bytecodeIndex = repoIndexFactory.createBytecodeIndex( repoContent.getRepository() ); RepositoryContentIndex hashcodesIndex = repoIndexFactory.createHashcodeIndex( repoContent.getRepository() ); RepositoryContentIndex fileContentIndex = repoIndexFactory.createFileContentIndex( repoContent.getRepository() ); fileContentRecord.setFilename( repoContent.toPath( artifact ) ); fileContentIndex.deleteRecord( fileContentRecord ); throw new ConsumerException( "Can't run index cleanup consumer: " + e.getMessage() );
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); triggerAuditEvent( repositoryContent.getRepository().getId(), artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(), AuditEvent.REMOVE_SCANNED ); re.getMessage() );
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) ); throw new ConsumerException( "Can't run database cleanup remove artifact consumer: " + re.getMessage() );