@Override protected String getGroupKey( ArtifactInfo artifactInfo ) { return artifactInfo.getRepository() + ":" + artifactInfo.getGroupId() + ":" + artifactInfo.getArtifactId() + ":" + artifactInfo.getVersion() + ":" + artifactInfo.getClassifier(); }
public void artifactDiscovered( ArtifactContext ac ) { count++; long t = System.currentTimeMillis(); ArtifactInfo ai = ac.getArtifactInfo(); if ( !quiet && debug && "maven-plugin".equals( ai.getPackaging() ) ) { System.err.printf( "Plugin: %s:%s:%s - %s %s\n", // ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPrefix(), "" + ai.getGoals() ); } if ( !quiet && ( debug || ( t - ts ) > 2000L ) ) { System.err.printf( " %6d %s\n", count, formatFile( ac.getPom() ) ); ts = t; } }
public void addArtifactToIndex( String repository, File artifactFile, String groupId, String artifactId, String version, String extension, String classifier ) throws IOException { ArtifactInfo artifactInfo = new ArtifactInfo( repository, groupId, artifactId, version, classifier, extension ); if ( extension != null ) { artifactInfo.setFieldValue( MAVEN.EXTENSION, extension ); } LOGGER.debug( "Adding artifact: {}; repo: {}; type: {}", new String[]{ artifactInfo.getUinfo(), repository, extension } ); getIndexer().addArtifactsToIndex( asList( new ArtifactContext( null, artifactFile, null, artifactInfo, artifactInfo.calculateGav() ) ), indexingContext ); }
@Override protected String getGroupKey( ArtifactInfo artifactInfo ) { return artifactInfo.getRepository() + ":" + artifactInfo.getGroupId(); }
@Override protected String getGroupKey( ArtifactInfo artifactInfo ) { return artifactInfo.getGroupId() + " : " + artifactInfo.getArtifactId(); }
if ( StringUtils.equalsIgnoreCase( "pom", artifactInfo.getFileExtension() ) && !includePoms ) String id = SearchUtil.getHitId( artifactInfo.getGroupId(), // artifactInfo.getArtifactId(), // artifactInfo.getClassifier(), // artifactInfo.getPackaging() ); Map<String, SearchResultHit> hitsMap = results.getHitsMap(); if ( !hit.getVersions().contains( artifactInfo.getVersion() ) ) hit.addVersion( artifactInfo.getVersion() ); hit.setArtifactId( artifactInfo.getArtifactId() ); hit.setGroupId( artifactInfo.getGroupId() ); hit.setRepositoryId( artifactInfo.getRepository() ); hit.addVersion( artifactInfo.getVersion() ); hit.setBundleExportPackage( artifactInfo.getBundleExportPackage() ); hit.setBundleExportService( artifactInfo.getBundleExportService() ); hit.setBundleSymbolicName( artifactInfo.getBundleSymbolicName() ); hit.setBundleVersion( artifactInfo.getBundleVersion() ); hit.setBundleDescription( artifactInfo.getBundleDescription() ); hit.setBundleDocUrl( artifactInfo.getBundleDocUrl() ); hit.setBundleRequireBundle( artifactInfo.getBundleRequireBundle() ); hit.setBundleImportPackage( artifactInfo.getBundleImportPackage() ); hit.setBundleLicense( artifactInfo.getBundleLicense() ); hit.setBundleName( artifactInfo.getBundleName() ); hit.setContext( artifactInfo.getContext() ); hit.setGoals( artifactInfo.getGoals() ); hit.setPrefix( artifactInfo.getPrefix() );
new StringBuilder().append( ArtifactInfo.nvl( ai.getPackaging() )).append( ArtifactInfo.FS ).append( Long.toString( ai.getLastModified() ) ).append( ArtifactInfo.FS ).append( Long.toString( ai.getSize() ) ).append( ArtifactInfo.FS ).append( ai.getSourcesExists().toString() ).append( ArtifactInfo.FS ).append( ai.getJavadocExists().toString() ).append( ArtifactInfo.FS ).append( ai.getSignatureExists().toString() ).append( ArtifactInfo.FS ).append( ai.getFileExtension() ).toString(); doc.add( FLD_GROUP_ID_KW.toField( ai.getGroupId() ) ); doc.add( FLD_ARTIFACT_ID_KW.toField( ai.getArtifactId() ) ); doc.add( FLD_VERSION_KW.toField( ai.getVersion() ) ); doc.add( FLD_GROUP_ID.toField( ai.getGroupId() ) ); doc.add( FLD_ARTIFACT_ID.toField( ai.getArtifactId() ) ); doc.add( FLD_VERSION.toField( ai.getVersion() ) ); doc.add( FLD_EXTENSION.toField( ai.getFileExtension() ) ); if ( ai.getName() != null ) doc.add( FLD_NAME.toField( ai.getName() ) ); if ( ai.getDescription() != null ) doc.add( FLD_DESCRIPTION.toField( ai.getDescription() ) ); if ( ai.getPackaging() != null ) doc.add( FLD_PACKAGING.toField( ai.getPackaging() ) ); if ( ai.getClassifier() != null )
ai.setGroupId( r[0] ); ai.setArtifactId( r[1] ); ai.setVersion( r[2] ); ai.setClassifier( ArtifactInfo.renvl( r[3] ) ); ai.setFileExtension( r[4] ); ai.setPackaging( ArtifactInfo.renvl( r[0] ) ); ai.setLastModified( Long.parseLong( r[1] ) ); ai.setSize( Long.parseLong( r[2] ) ); ai.setSourcesExists( ArtifactAvailability.fromString( r[ 3 ] ) ); ai.setJavadocExists( ArtifactAvailability.fromString( r[ 4 ] ) ); ai.setSignatureExists( ArtifactAvailability.fromString( r[ 5 ] ) ); ai.setFileExtension( r[6] ); if ( ai.getClassifier() != null // || "pom".equals( ai.getPackaging() ) // || "war".equals( ai.getPackaging() ) // || "ear".equals( ai.getPackaging() ) )
ArtifactInfo ai = new ArtifactInfo(); ai.setRepository( context.getRepositoryId() ); ai.setGroupId( ra[0] ); ai.setArtifactId( ra[1] ); ai.setVersion( ra[2] ); ai.setClassifier( ArtifactInfo.renvl( ra[3] ) ); ai.setPackaging( ArtifactInfo.renvl( ra[4] ) ); ArtifactContext ac = new ArtifactContext( null, null, null, ai, ai.calculateGav() );
public boolean accepts( IndexingContext ctx, ArtifactInfo ai ) { String key = ai.getGroupId() + ai.getArtifactId() + ai.getPackaging() + ai.getClassifier(); if ( !repositoriesIgnored ) { key = ai.getRepository() + key; } if ( gas.contains( key ) ) { return false; } else { gas.add( key ); postprocess( ctx, ai ); return true; } }
public ArchetypeCatalog getArchetypeCatalog( final Properties properties ) { final ArchetypeCatalog catalog = new ArchetypeCatalog(); try { final Map<String, String> repositories = getRepositoryMap(); final Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) ); final FlatSearchRequest searchRequest = new FlatSearchRequest( pq ); searchRequest.setContexts( getIndexingContexts() ); final FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest ); for ( ArtifactInfo info : searchResponse.getResults() ) { Archetype archetype = new Archetype(); archetype.setGroupId( info.getGroupId() ); archetype.setArtifactId( info.getArtifactId() ); archetype.setVersion( info.getVersion() ); archetype.setDescription( info.getDescription() ); archetype.setRepository( repositories.get( info.getRepository() ) ); catalog.addArchetype( archetype ); } } catch ( Exception ex ) { getLogger().error( "Unable to retrieve archetypes", ex ); } return catalog; }
if ( StringUtils.startsWith( artifactInfo.getContext(), "remote-" ) ) getManagedRepoId( StringUtils.substringAfter( artifactInfo.getContext(), "remote-" ), selectedRepos ); if ( managedRepoId != null ) artifactInfo.setContext( managedRepoId ); sb.append( '/' ).append( artifactInfo.getContext() ); sb.append( '/' ).append( StringUtils.replaceChars( artifactInfo.getGroupId(), '.', '/' ) ); sb.append( '/' ).append( artifactInfo.getArtifactId() ); sb.append( '/' ).append( artifactInfo.getVersion() ); sb.append( '/' ).append( artifactInfo.getArtifactId() ); sb.append( '-' ).append( artifactInfo.getVersion() ); if ( StringUtils.isNotBlank( artifactInfo.getClassifier() ) ) sb.append( '-' ).append( artifactInfo.getClassifier() ); if ( StringUtils.equals( "maven-plugin", artifactInfo.getPackaging() ) ) sb.append( '.' ).append( artifactInfo.getPackaging() );
private boolean applyArtifactInfoFilters( ArtifactInfo artifactInfo, List<? extends ArtifactInfoFilter> artifactInfoFilters, Map<String, SearchResultHit> currentResult ) { if ( artifactInfoFilters == null || artifactInfoFilters.isEmpty() ) { return true; } ArchivaArtifactModel artifact = new ArchivaArtifactModel(); artifact.setArtifactId( artifactInfo.getArtifactId() ); artifact.setClassifier( artifactInfo.getClassifier() ); artifact.setGroupId( artifactInfo.getGroupId() ); artifact.setRepositoryId( artifactInfo.getRepository() ); artifact.setVersion( artifactInfo.getVersion() ); artifact.setChecksumMD5( artifactInfo.getMd5() ); artifact.setChecksumSHA1( artifactInfo.getSha1() ); for ( ArtifactInfoFilter filter : artifactInfoFilters ) { if ( !filter.addArtifactInResult( artifact, currentResult ) ) { return false; } } return true; }
public TreeNode createVNode( IndexTreeView tview, TreeViewRequest req, ArtifactInfo ai, String path ) { TreeNode result = createNode( tview, req, path, false, ai.getVersion(), Type.V ); result.setGroupId( ai.getGroupId() ); result.setArtifactId( ai.getArtifactId() ); result.setVersion( ai.getVersion() ); return decorateVNode( tview, req, ai, path, result ); }
new ArtifactInfo( context.getRepositoryId(), groupId, artifactId, version, classifier, gav.getExtension() ); if ( !StringUtils.isEmpty( ai.getClassifier() ) ) ai.setPackaging( gav.getExtension() ); ai.setFileName( file.getName() ); ai.setFileExtension( gav.getExtension() );
public void updateLegacyDocument( ArtifactInfo ai, Document doc ) { updateDocument( ai, doc ); // legacy! if ( ai.getPrefix() != null ) { doc.add( new Field( ArtifactInfo.PLUGIN_PREFIX, ai.getPrefix(), Field.Store.YES, Field.Index.NOT_ANALYZED ) ); } if ( ai.getGoals() != null ) { doc.add( new Field( ArtifactInfo.PLUGIN_GOALS, ArtifactInfo.lst2str( ai.getGoals() ), Field.Store.YES, Field.Index.NO ) ); } doc.removeField( ArtifactInfo.GROUP_ID ); doc.add( new Field( ArtifactInfo.GROUP_ID, ai.getGroupId(), Field.Store.NO, Field.Index.NOT_ANALYZED ) ); }
public boolean updateArtifactInfo( Document doc, ArtifactInfo ai ) { boolean res = false; if ( "maven-plugin".equals( ai.getPackaging() ) ) { ai.setPrefix( doc.get( ArtifactInfo.PLUGIN_PREFIX ) ); String goals = doc.get( ArtifactInfo.PLUGIN_GOALS ); if ( goals != null ) { ai.setGoals( ArtifactInfo.str2lst( goals ) ); } res = true; } return res; }
private Document getOldDocument(ArtifactContext ac) throws IOException { final TopDocs result = contextIndexSearcher.search( new TermQuery(new Term(ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo())), 2); if (result.totalHits == 1) { return contextIndexSearcher.doc(result.scoreDocs[0].doc); } return null; } }
@Override public String toString() { final StringBuilder result = new StringBuilder( getUinfo() ); if ( !Strings.isNullOrEmpty( getPackaging() ) ) { result.append( "[" ).append( getPackaging() ).append( "]" ); } return result.toString(); }