private ManagedRepositoryConfiguration findRepository( ArchivaArtifact artifact ) { return (ManagedRepositoryConfiguration) this.repositoryMap.get( artifact.getModel().getRepositoryId() ); }
private IndexedRepositoryDetails getIndexedRepositoryDetails( ArchivaArtifact artifact ) { String repoId = artifact.getModel().getRepositoryId(); if ( StringUtils.isBlank( repoId ) ) { throw new IllegalStateException( "Unable to process artifact [" + artifact + "] as it has no repository id associated with it." ); } return getIndexedRepositoryDetails( repoId ); }
public boolean evaluate( Object object ) { boolean satisfies = false; if ( object instanceof ArchivaArtifact ) { ArchivaArtifact artifact = (ArchivaArtifact) object; satisfies = !artifact.getModel().isProcessed(); } else if ( object instanceof ArchivaArtifactModel ) { ArchivaArtifactModel model = (ArchivaArtifactModel) object; satisfies = !model.isProcessed(); } return satisfies; } }
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 ""; } }
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 LuceneRepositoryContentRecord convert( Document document ) throws ParseException { HashcodesRecord record = new HashcodesRecord(); record.setRepositoryId( document.get( LuceneDocumentMaker.REPOSITORY_ID ) ); // Artifact Reference String groupId = document.get( ArtifactKeys.GROUPID ); String artifactId = document.get( ArtifactKeys.ARTIFACTID ); String version = document.get( ArtifactKeys.VERSION ); String classifier = document.get( ArtifactKeys.CLASSIFIER ); String type = document.get( ArtifactKeys.TYPE ); ArchivaArtifact artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type ); record.setArtifact( artifact ); // Hashcode Specifics record.getArtifact().getModel().setChecksumMD5( document.get( HashcodesKeys.MD5 ) ); record.getArtifact().getModel().setChecksumSHA1( document.get( HashcodesKeys.SHA1 ) ); return record; } }
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 ); } }
if( artifact.getModel().getRepositoryId() == null ) artifact.getModel().setRepositoryId( this.repository.getId() ); try artifact.getModel().setChecksumMD5( digestMd5.calc( artifactFile ) ); artifact.getModel().setChecksumSHA1( digestSha1.calc( artifactFile ) ); artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) ); artifact.getModel().setSize( artifactFile.length() ); artifact.getModel().setOrigin( "FileSystem" ); artifact.getModel().setWhenProcessed( null ); if ( artifact.getModel().getWhenGathered() == null ) artifact.getModel().setWhenGathered( whenGathered );
artifact.getModel().setRepositoryId( this.repository.getId() ); try artifact.getModel().setChecksumMD5( digestMd5.calc( artifactFile ) ); artifact.getModel().setChecksumSHA1( digestSha1.calc( artifactFile ) ); artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) ); artifact.getModel().setSize( artifactFile.length() ); artifact.getModel().setOrigin( "FileSystem" ); artifact.getModel().setWhenProcessed( null );
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 ); } }
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() ); } }
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
public Document convert( LuceneRepositoryContentRecord record ) { if ( !( record instanceof HashcodesRecord ) ) { throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to " + HashcodesRecord.class.getName() + "." ); } HashcodesRecord hashcodes = (HashcodesRecord) record; LuceneDocumentMaker doc = new LuceneDocumentMaker( hashcodes ); // Artifact Reference doc.addFieldTokenized( ArtifactKeys.GROUPID, hashcodes.getArtifact().getGroupId() ); doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, hashcodes.getArtifact().getGroupId() ); doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, hashcodes.getArtifact().getArtifactId() ); doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, hashcodes.getArtifact().getArtifactId() ); doc.addFieldTokenized( ArtifactKeys.VERSION, hashcodes.getArtifact().getVersion() ); doc.addFieldExact( ArtifactKeys.VERSION_EXACT, hashcodes.getArtifact().getVersion() ); doc.addFieldTokenized( ArtifactKeys.TYPE, hashcodes.getArtifact().getType() ); doc.addFieldUntokenized( ArtifactKeys.CLASSIFIER, hashcodes.getArtifact().getClassifier() ); // Hashcode Specifics doc.addFieldUntokenized( HashcodesKeys.MD5, hashcodes.getArtifact().getModel().getChecksumMD5() ); doc.addFieldUntokenized( HashcodesKeys.SHA1, hashcodes.getArtifact().getModel().getChecksumSHA1() ); return doc.getDocument(); }
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() ); } }
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
repositoryFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
private void addProblem( ArchivaArtifact artifact, String msg ) throws ConsumerException { RepositoryProblem problem = new RepositoryProblem(); problem.setRepositoryId( artifact.getModel().getRepositoryId() ); problem.setPath( toPath( artifact ) ); problem.setGroupId( artifact.getGroupId() ); problem.setArtifactId( artifact.getArtifactId() ); problem.setVersion( artifact.getVersion() ); problem.setType( LocationArtifactsReport.PROBLEM_TYPE_BAD_ARTIFACT_LOCATION ); problem.setOrigin( getId() ); problem.setMessage( msg ); try { dao.getRepositoryProblemDAO().saveRepositoryProblem( problem ); } catch ( ArchivaDatabaseException e ) { String emsg = "Unable to save problem with artifact location to DB: " + e.getMessage(); log.warn( emsg, e ); throw new ConsumerException( emsg, e ); } }
private void addProblem( ArchivaArtifact artifact, String msg ) throws ConsumerException { ManagedRepositoryContent repo = getRepository( artifact ); RepositoryProblem problem = new RepositoryProblem(); problem.setRepositoryId( artifact.getModel().getRepositoryId() ); problem.setPath( repo.toPath( artifact ) ); problem.setGroupId( artifact.getGroupId() ); problem.setArtifactId( artifact.getArtifactId() ); problem.setVersion( artifact.getVersion() ); problem.setType( CorruptArtifactReport.PROBLEM_TYPE_CORRUPT_ARTIFACT ); problem.setOrigin( getId() ); problem.setMessage( msg ); try { dao.getRepositoryProblemDAO().saveRepositoryProblem( problem ); } catch ( ArchivaDatabaseException e ) { String emsg = "Unable to save problem with artifact location to DB: " + e.getMessage(); log.warn( emsg, e ); throw new ConsumerException( emsg, e ); } }
repoFactory.getManagedRepositoryContent( artifact.getModel().getRepositoryId() );
private void addProblem( ArchivaArtifact artifact, String msg ) throws ConsumerException { ManagedRepositoryContent repo = getRepository( artifact ); RepositoryProblem problem = new RepositoryProblem(); problem.setRepositoryId( artifact.getModel().getRepositoryId() ); problem.setPath( repo.toPath( artifact ) ); problem.setGroupId( artifact.getGroupId() ); problem.setArtifactId( artifact.getArtifactId() ); problem.setVersion( artifact.getVersion() ); problem.setType( CorruptArtifactReport.PROBLEM_TYPE_CORRUPT_ARTIFACT ); problem.setOrigin( getId() ); problem.setMessage( msg ); try { dao.getRepositoryProblemDAO().saveRepositoryProblem( problem ); } catch ( ArchivaDatabaseException e ) { String emsg = "Unable to save problem with artifact location to DB: " + e.getMessage(); getLogger().warn( emsg, e ); throw new ConsumerException( emsg, e ); } }