public String getPrimaryKey() { StringBuffer id = new StringBuffer(); id.append( artifact.getGroupId() ).append( ":" ); id.append( artifact.getArtifactId() ).append( ":" ); id.append( artifact.getVersion() ); if ( artifact.getClassifier() != null ) { id.append( ":" ).append( artifact.getClassifier() ); } id.append( ":" ).append( artifact.getType() ); return id.toString(); }
public String getPrimaryKey() { StringBuffer id = new StringBuffer(); id.append( artifact.getGroupId() ).append( ":" ); id.append( artifact.getArtifactId() ).append( ":" ); id.append( artifact.getVersion() ); if ( artifact.getClassifier() != null ) { id.append( ":" ).append( artifact.getClassifier() ); } id.append( ":" ).append( artifact.getType() ); return id.toString(); }
public void addArtifact( ArchivaArtifact artifact ) { this.artifacts.add( artifact ); String ver = artifact.getVersion(); if ( !this.versions.contains( ver ) ) { this.versions.add( ver ); } if ( StringUtils.isBlank( this.groupId ) ) { this.groupId = artifact.getGroupId(); } if ( StringUtils.isBlank( this.artifactId ) ) { this.artifactId = artifact.getArtifactId(); } if ( StringUtils.isBlank( this.version ) ) { this.version = ver; } }
if ( !artifact.getVersion().equalsIgnoreCase( model.getVersion() ) && !VersionUtil.getBaseVersion( artifact.getVersion() ).equalsIgnoreCase( model.getVersion() ) ) appendModel( emsg, model ); emsg.append( "]; The model version [" ).append( model.getVersion() ); emsg.append( "] does not match the version portion of the filename: " ).append( artifact.getVersion() );
if ( !artifact.getVersion().equalsIgnoreCase( model.getVersion() ) && !VersionUtil.getBaseVersion( artifact.getVersion() ).equalsIgnoreCase( model.getVersion() ) ) appendModel( emsg, model ); emsg.append( "]; The model version [" ).append( model.getVersion() ); emsg.append( "] does not match the version portion of the filename: " ).append( artifact.getVersion() );
private void validateAppropriateModel( String location, ArchivaArtifact artifact, ArchivaProjectModel model ) throws ConsumerException { if ( model != null ) { if ( !StringUtils.equals( model.getGroupId(), artifact.getGroupId() ) ) { addProblem( artifact, "The groupId of the " + location + " project model doesn't match with the artifact, expected <" + artifact.getGroupId() + ">, but was actually <" + model.getGroupId() + ">" ); } if ( !StringUtils.equals( model.getArtifactId(), artifact.getArtifactId() ) ) { addProblem( artifact, "The artifactId of the " + location + " project model doesn't match with the artifact, expected <" + artifact.getArtifactId() + ">, but was actually <" + model.getArtifactId() + ">" ); } if ( !StringUtils.equals( model.getVersion(), artifact.getVersion() ) ) { addProblem( artifact, "The version of the " + location + " project model doesn't match with the artifact, expected <" + artifact.getVersion() + ">, but was actually <" + model.getVersion() + ">" ); } } }
getProjectModelFromDatabase( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) ) != null ) if ( VersionUtil.isUniqueSnapshot( artifact.getVersion() ) ) model.setVersion( artifact.getVersion() );
artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
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 Document convert( LuceneRepositoryContentRecord record ) { if ( !( record instanceof FileContentRecord ) ) { throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to " + FileContentRecord.class.getName() + "." ); } FileContentRecord filecontent = (FileContentRecord) record; LuceneDocumentMaker doc = new LuceneDocumentMaker( filecontent ); if( filecontent.getArtifact() != null ) { // Artifact Reference doc.addFieldTokenized( ArtifactKeys.GROUPID, filecontent.getArtifact().getGroupId() ); doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, filecontent.getArtifact().getGroupId() ); doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, filecontent.getArtifact().getArtifactId() ); doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, filecontent.getArtifact().getArtifactId() ); doc.addFieldTokenized( ArtifactKeys.VERSION, filecontent.getArtifact().getVersion() ); doc.addFieldExact( ArtifactKeys.VERSION_EXACT, filecontent.getArtifact().getVersion() ); doc.addFieldTokenized( ArtifactKeys.TYPE, filecontent.getArtifact().getType() ); doc.addFieldUntokenized( ArtifactKeys.CLASSIFIER, filecontent.getArtifact().getClassifier() ); } doc.addFieldTokenized( FileContentKeys.FILENAME, filecontent.getFilename() ); doc.addFieldTokenized( FileContentKeys.CONTENT, filecontent.getContents() ); return doc.getDocument(); }
public Document convert( LuceneRepositoryContentRecord record ) { if ( !( record instanceof BytecodeRecord ) ) { throw new ClassCastException( "Unable to convert type " + record.getClass().getName() + " to " + BytecodeRecord.class.getName() + "." ); } BytecodeRecord bytecode = (BytecodeRecord) record; LuceneDocumentMaker doc = new LuceneDocumentMaker( bytecode ); // Artifact Reference doc.addFieldTokenized( ArtifactKeys.GROUPID, bytecode.getArtifact().getGroupId() ); doc.addFieldExact( ArtifactKeys.GROUPID_EXACT, bytecode.getArtifact().getGroupId() ); doc.addFieldTokenized( ArtifactKeys.ARTIFACTID, bytecode.getArtifact().getArtifactId() ); doc.addFieldExact( ArtifactKeys.ARTIFACTID_EXACT, bytecode.getArtifact().getArtifactId() ); doc.addFieldTokenized( ArtifactKeys.VERSION, bytecode.getArtifact().getVersion() ); doc.addFieldExact( ArtifactKeys.VERSION_EXACT, bytecode.getArtifact().getVersion() ); doc.addFieldTokenized( ArtifactKeys.TYPE, bytecode.getArtifact().getType() ); doc.addFieldUntokenized( ArtifactKeys.CLASSIFIER, bytecode.getArtifact().getClassifier() ); // Bytecode Specifics doc.addFieldExact( BytecodeKeys.JDK, JavaArtifactHelper.getJavaDetails( bytecode.getArtifact() ).getJdk() ); doc.addFieldTokenized( BytecodeKeys.CLASSES, bytecode.getClasses() ); doc.addFieldTokenized( BytecodeKeys.METHODS, bytecode.getMethods() ); doc.addFieldTokenized( BytecodeKeys.FILES, bytecode.getFiles() ); return doc.getDocument(); }
problem.setGroupId( artifact.getGroupId() ); problem.setArtifactId( artifact.getArtifactId() ); problem.setVersion( artifact.getVersion() ); problem.setType( DuplicateArtifactReport.PROBLEM_TYPE_DUPLICATE_ARTIFACTS ); problem.setOrigin( getId() );
if ( hasProjectModelInDatabase( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) ) if ( VersionUtil.isUniqueSnapshot( artifact.getVersion() ) ) model.setVersion( artifact.getVersion() );
triggerAuditEvent( repositoryContent.getRepository().getId(), artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion(), AuditEvent.REMOVE_SCANNED );
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 ); } }
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 ); } }