record.setRepositoryId( this.repository.getId() ); record.setFilename( path ); record.setContents( FileUtils.readFileToString( file, null ) ); ArtifactReference ref = repository.toArtifactReference( path ); ArchivaArtifact artifact = new ArchivaArtifact( ref ); record.setArtifact( artifact );
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 );
private boolean isValidModel( ArchivaProjectModel model, ManagedRepositoryContent repo, ArchivaArtifact artifact ) throws ConsumerException File artifactFile = repo.toFile( artifact );
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 ); } }
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() ); } }
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 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 ); } }
artifact.getModel().setRepositoryId( this.repository.getId() );
public void beginScan( ManagedRepositoryConfiguration repository ) throws ConsumerException { this.managedRepository = new ManagedDefaultRepositoryContent(); this.managedRepository.setRepository( repository ); }
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) );
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 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 ); } }
artifact.getModel().setRepositoryId( this.repository.getId() );
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 );
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() ); File file = new File( repositoryContent.getRepoRoot(), repositoryContent.toPath( artifact ) );
/** * 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; } }
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() ); } }
private boolean isValidModel( ArchivaProjectModel model, ManagedRepositoryContent repo, ArchivaArtifact artifact ) throws ConsumerException File artifactFile = repo.toFile( artifact );