This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 257567
Collapse All | Expand All

(-)maven.indexer/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/indexer/Bundle.properties
2
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/indexer/Bundle.properties
3
AutoUpdate-Show-In-Client: false
3
AutoUpdate-Show-In-Client: false
4
OpenIDE-Module-Specification-Version: 2.37
4
OpenIDE-Module-Specification-Version: 2.38
5
OpenIDE-Module: org.netbeans.modules.maven.indexer/2
5
OpenIDE-Module: org.netbeans.modules.maven.indexer/2
6
6
(-)maven.indexer/nbproject/project.xml (-2 / +2 lines)
Lines 168-173 Link Here
168
                <friend>org.netbeans.modules.maven.refactoring</friend>
168
                <friend>org.netbeans.modules.maven.refactoring</friend>
169
                <friend>org.netbeans.modules.maven.repository</friend>
169
                <friend>org.netbeans.modules.maven.repository</friend>
170
                <friend>org.netbeans.modules.maven.search</friend>
170
                <friend>org.netbeans.modules.maven.search</friend>
171
                <friend>ro.emilianbold.modules.maven.search.remote</friend>
171
                <package>org.apache.lucene</package>
172
                <package>org.apache.lucene</package>
172
                <package>org.apache.lucene.analysis</package>
173
                <package>org.apache.lucene.analysis</package>
173
                <package>org.apache.lucene.analysis.standard</package>
174
                <package>org.apache.lucene.analysis.standard</package>
Lines 185-192 Link Here
185
                <package>org.apache.lucene.util</package>
186
                <package>org.apache.lucene.util</package>
186
                <package>org.apache.lucene.util.cache</package>
187
                <package>org.apache.lucene.util.cache</package>
187
                <package>org.netbeans.modules.maven.indexer.api</package>
188
                <package>org.netbeans.modules.maven.indexer.api</package>
188
                <package>org.netbeans.modules.maven.indexer.api.ui</package>
189
                <package>org.netbeans.modules.maven.indexer.spi</package>
189
                <package>org.netbeans.modules.maven.indexer.spi.ui</package>
190
                <package>org.netbeans.modules.maven.indexer.spi.impl</package>
190
                <package>org.netbeans.modules.maven.indexer.spi.impl</package>
191
            </friend-packages>
191
            </friend-packages>
192
            <class-path-extension>
192
            <class-path-extension>
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java (-195 / +162 lines)
Lines 102-108 Link Here
102
import org.codehaus.plexus.util.FileUtils;
102
import org.codehaus.plexus.util.FileUtils;
103
import org.netbeans.api.annotations.common.CheckForNull;
103
import org.netbeans.api.annotations.common.CheckForNull;
104
import org.netbeans.api.annotations.common.NullAllowed;
104
import org.netbeans.api.annotations.common.NullAllowed;
105
import org.netbeans.api.annotations.common.SuppressWarnings;
106
import org.netbeans.modules.maven.embedder.EmbedderFactory;
105
import org.netbeans.modules.maven.embedder.EmbedderFactory;
107
import org.netbeans.modules.maven.embedder.MavenEmbedder;
106
import org.netbeans.modules.maven.embedder.MavenEmbedder;
108
import org.netbeans.modules.maven.indexer.api.NBArtifactInfo;
107
import org.netbeans.modules.maven.indexer.api.NBArtifactInfo;
Lines 111-117 Link Here
111
import org.netbeans.modules.maven.indexer.api.QueryField;
110
import org.netbeans.modules.maven.indexer.api.QueryField;
112
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
111
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
113
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
112
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
114
import org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result;
115
import org.netbeans.modules.maven.indexer.spi.ArchetypeQueries;
113
import org.netbeans.modules.maven.indexer.spi.ArchetypeQueries;
116
import org.netbeans.modules.maven.indexer.spi.BaseQueries;
114
import org.netbeans.modules.maven.indexer.spi.BaseQueries;
117
import org.netbeans.modules.maven.indexer.spi.ChecksumQueries;
115
import org.netbeans.modules.maven.indexer.spi.ChecksumQueries;
Lines 120-127 Link Here
120
import org.netbeans.modules.maven.indexer.spi.ContextLoadedQuery;
118
import org.netbeans.modules.maven.indexer.spi.ContextLoadedQuery;
121
import org.netbeans.modules.maven.indexer.spi.DependencyInfoQueries;
119
import org.netbeans.modules.maven.indexer.spi.DependencyInfoQueries;
122
import org.netbeans.modules.maven.indexer.spi.GenericFindQuery;
120
import org.netbeans.modules.maven.indexer.spi.GenericFindQuery;
123
import org.netbeans.modules.maven.indexer.spi.Redo;
121
import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation;
124
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation;
122
import org.netbeans.modules.maven.indexer.spi.ResultImplementation;
123
import org.netbeans.modules.maven.indexer.spi.impl.Redo;
125
import org.netbeans.modules.maven.indexer.spi.impl.IndexingNotificationProvider;
124
import org.netbeans.modules.maven.indexer.spi.impl.IndexingNotificationProvider;
126
import org.openide.modules.Places;
125
import org.openide.modules.Places;
127
import org.openide.util.BaseUtilities;
126
import org.openide.util.BaseUtilities;
Lines 133-191 Link Here
133
import org.openide.util.lookup.ServiceProvider;
132
import org.openide.util.lookup.ServiceProvider;
134
import org.openide.util.lookup.ServiceProviders;
133
import org.openide.util.lookup.ServiceProviders;
135
import org.openide.util.NbBundle.Messages;
134
import org.openide.util.NbBundle.Messages;
135
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexQueryProvider;
136
136
137
@ServiceProviders({
137
@ServiceProviders({
138
    @ServiceProvider(service=RepositoryIndexerImplementation.class),
138
    @ServiceProvider(service=RepositoryIndexerImplementation.class),
139
    @ServiceProvider(service=BaseQueries.class),
139
    @ServiceProvider(service=RepositoryIndexQueryProvider.class, position = Integer.MAX_VALUE)
140
    @ServiceProvider(service=ChecksumQueries.class),
141
    @ServiceProvider(service=ArchetypeQueries.class),
142
    @ServiceProvider(service=DependencyInfoQueries.class),
143
    @ServiceProvider(service=ClassesQuery.class),
144
    @ServiceProvider(service=ClassUsageQuery.class),
145
    @ServiceProvider(service=GenericFindQuery.class),
146
    @ServiceProvider(service=ContextLoadedQuery.class)
147
})
140
})
148
public class NexusRepositoryIndexerImpl implements RepositoryIndexerImplementation,
141
public class NexusRepositoryIndexerImpl implements RepositoryIndexerImplementation, RepositoryIndexQueryProvider,
149
        BaseQueries, ChecksumQueries, ArchetypeQueries, DependencyInfoQueries,
142
        BaseQueries, ChecksumQueries, ArchetypeQueries, DependencyInfoQueries,
150
        ClassesQuery, ClassUsageQuery, GenericFindQuery, ContextLoadedQuery {
143
        ClassesQuery, ClassUsageQuery, GenericFindQuery, ContextLoadedQuery {
151
144
152
    
153
    public static abstract class Accessor {
154
  
155
        @SuppressWarnings("MS_SHOULD_BE_FINAL")
156
        public static Accessor ACCESSOR;
157
        
158
        protected Accessor() {
159
            ACCESSOR = this;
160
        }
161
        
162
        public abstract void addSkipped(Result<?> result, Collection<RepositoryInfo> infos);
163
        
164
        public abstract List<RepositoryInfo> getSkipped(Result<?> result);
165
        
166
        public abstract void setStringResults(Result<String> result, Collection<String> newResults);
167
        
168
        public abstract void setVersionResults(Result<NBVersionInfo> result, Collection<NBVersionInfo> newResults);
169
        
170
        public abstract void addSkipped(Result<?> result, RepositoryInfo info);
171
        
172
        public abstract Result<String> createStringResult(Redo<String> redo);
173
        
174
        public abstract Result<NBVersionInfo> createVersionResult(Redo<NBVersionInfo> redo);
175
        
176
        public abstract Result<NBGroupInfo> createGroupResult(Redo<NBGroupInfo> redo);
177
        
178
        public abstract void setGroupResults(Result<NBGroupInfo> result, Collection<NBGroupInfo> newResults);
179
        
180
        public abstract Result<RepositoryQueries.ClassUsage> createClassResult(Redo<RepositoryQueries.ClassUsage> redo);
181
        
182
        public abstract void setClassResults(Result<RepositoryQueries.ClassUsage> result, Collection<RepositoryQueries.ClassUsage> newResults);
183
        
184
        public abstract void addTotalResults(Result<?> result, int moreResults);
185
        
186
        public abstract void addReturnedResults(Result<?> result, int moreResults);
187
    }
188
    
189
    private static final Logger LOGGER = Logger.getLogger(NexusRepositoryIndexerImpl.class.getName());
145
    private static final Logger LOGGER = Logger.getLogger(NexusRepositoryIndexerImpl.class.getName());
190
       
146
       
191
    static {
147
    static {
Lines 216-221 Link Here
216
    private static final Set<Mutex> indexingMutexes = new HashSet<Mutex>();
172
    private static final Set<Mutex> indexingMutexes = new HashSet<Mutex>();
217
    private static final RequestProcessor RP = new RequestProcessor("indexing", 1);
173
    private static final RequestProcessor RP = new RequestProcessor("indexing", 1);
218
174
175
    @Override
176
    public boolean handlesRepository(RepositoryInfo repo) {
177
        // should always come as last when looked up
178
        // handles all remote repos
179
        return true; 
180
    }
181
    
182
    @Override
183
    public BaseQueries getBaseQueries() {
184
        return this;
185
    }
186
187
    @Override
188
    public ChecksumQueries getChecksumQueries() {
189
        return this;
190
    }
191
192
    @Override
193
    public ArchetypeQueries getArchetypeQueries() {
194
        return this;
195
    }
196
197
    @Override
198
    public DependencyInfoQueries getDependencyInfoQueries() {
199
        return this;
200
    }
201
202
    @Override
203
    public ClassesQuery getClassesQuery() {
204
        return this;
205
    }
206
207
    @Override
208
    public ClassUsageQuery getClassUsageQuery() {
209
        return this;
210
    }
211
212
    @Override
213
    public GenericFindQuery getGenericFindQuery() {
214
        return this;
215
    }
216
217
    @Override
218
    public ContextLoadedQuery getContextLoadedQuery() {
219
        return this;
220
    }
221
    
219
    private Mutex getRepoMutex(RepositoryInfo repo) {
222
    private Mutex getRepoMutex(RepositoryInfo repo) {
220
        return getRepoMutex(repo.getId());
223
        return getRepoMutex(repo.getId());
221
    }
224
    }
Lines 914-920 Link Here
914
    }
917
    }
915
918
916
    @Override
919
    @Override
917
    public RepositoryQueries.Result<String> getGroups(List<RepositoryInfo> repos) {
920
    public ResultImplementation<String> getGroups(List<RepositoryInfo> repos) {
918
        return filterGroupIds("", repos);
921
        return filterGroupIds("", repos);
919
    }
922
    }
920
923
Lines 971-988 Link Here
971
    }
974
    }
972
    }
975
    }
973
976
977
    private ResultImplementation<String> filterGroupIds(final String prefix, final List<RepositoryInfo> repos) {
978
        Redo<String> redo = new Redo<String>() {
974
    @Override
979
    @Override
975
    public RepositoryQueries.Result<String> filterGroupIds(final String prefix, final List<RepositoryInfo> repos) {
980
            public void run(ResultImpl<String> result) {
976
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
981
                filterGroupIds(prefix, result, result.getSkipped(), false);
977
            @Override
978
            public void run(Result<String> result) {
979
                filterGroupIds(prefix, result, Accessor.ACCESSOR.getSkipped(result), false);
980
            }
982
            }
981
        });
983
        };
984
        ResultImpl<String> result = new ResultImpl<String>(redo);
982
        return filterGroupIds(prefix, result, repos, true);
985
        return filterGroupIds(prefix, result, repos, true);
983
    }
986
    }
984
    
987
    
985
    private RepositoryQueries.Result<String> filterGroupIds(final String prefix, final RepositoryQueries.Result<String> result, 
988
    private ResultImplementation<String> filterGroupIds(final String prefix, final ResultImpl<String> result, 
986
                                                            final List<RepositoryInfo> repos, final boolean skipUnIndexed) {
989
                                                            final List<RepositoryInfo> repos, final boolean skipUnIndexed) {
987
        final Set<String> groups = new TreeSet<String>(result.getResults());
990
        final Set<String> groups = new TreeSet<String>(result.getResults());
988
        final List<RepositoryInfo> slowCheck = new ArrayList<RepositoryInfo>();
991
        final List<RepositoryInfo> slowCheck = new ArrayList<RepositoryInfo>();
Lines 1025-1046 Link Here
1025
//            }
1028
//            }
1026
//        }, skipAction, skipUnIndexed);
1029
//        }, skipAction, skipUnIndexed);
1027
        
1030
        
1028
        Accessor.ACCESSOR.setStringResults(result, groups);
1031
        result.setResults(groups);
1029
        return result;
1032
        return result;
1030
    }
1033
    }
1031
1034
1032
    @Override
1035
    @Override
1033
    public Result<String> getGAVsForPackaging(final String packaging, List<RepositoryInfo> repos) {
1036
    public ResultImplementation<String> getGAVsForPackaging(final String packaging, List<RepositoryInfo> repos) {
1034
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
1037
        ResultImpl<String> result = new ResultImpl<>(new Redo<String>() {
1035
            @Override
1038
            @Override
1036
            public void run(Result<String> result) {
1039
            public void run(ResultImpl<String> result) {
1037
                getGAVsForPackaging(packaging, result, Accessor.ACCESSOR.getSkipped(result), false);
1040
                getGAVsForPackaging(packaging, result, result.getSkipped(), false);
1038
            }
1041
            }
1039
        });
1042
        });
1040
        return getGAVsForPackaging(packaging,result, repos, true);
1043
        return getGAVsForPackaging(packaging,result, repos, true);
1041
    }
1044
    }
1042
    
1045
    
1043
    private Result<String> getGAVsForPackaging(final String packaging, final Result<String> result, 
1046
    private ResultImplementation<String> getGAVsForPackaging(final String packaging, final ResultImpl<String> result, 
1044
                                             List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1047
                                             List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1045
        final List<String> infos = new ArrayList<String>(result.getResults());
1048
        final List<String> infos = new ArrayList<String>(result.getResults());
1046
        final SkippedAction skipAction = new SkippedAction(result);
1049
        final SkippedAction skipAction = new SkippedAction(result);
Lines 1058-1087 Link Here
1058
                            }
1061
                            }
1059
                        }
1062
                        }
1060
                    } finally {
1063
                    } finally {
1061
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1064
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1062
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1065
                        result.addTotalResultCount(response.getTotalHitsCount());
1063
                        response.close();
1066
                        response.close();
1064
                    }
1067
                    }
1065
                }
1068
                }
1066
            }
1069
            }
1067
        }, skipAction, skipUnIndexed);
1070
        }, skipAction, skipUnIndexed);
1068
        Accessor.ACCESSOR.setStringResults(result, infos);
1071
        result.setResults(infos);
1069
        return result;        
1072
        return result;        
1070
    }
1073
    }
1071
    
1074
    
1072
1073
    @Override
1075
    @Override
1074
    public Result<NBVersionInfo> getRecords(final String groupId, final String artifactId, final String version, List<RepositoryInfo> repos) {
1076
    public ResultImplementation<NBVersionInfo> getRecords(final String groupId, final String artifactId, final String version, List<RepositoryInfo> repos) {
1075
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1077
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1076
            @Override
1078
            @Override
1077
            public void run(Result<NBVersionInfo> result) {
1079
            public void run(ResultImpl<NBVersionInfo> result) {
1078
                getRecords(groupId, artifactId, version, result, Accessor.ACCESSOR.getSkipped(result), false);
1080
                getRecords(groupId, artifactId, version, result, result.getSkipped(), false);
1079
            }
1081
            }
1080
        });
1082
        });
1081
        return getRecords(groupId, artifactId, version, result, repos, true);
1083
        return getRecords(groupId, artifactId, version, result, repos, true);
1082
    }
1084
    }
1083
    
1085
    
1084
    private Result<NBVersionInfo> getRecords(final String groupId, final String artifactId, final String version, final Result<NBVersionInfo> result, 
1086
    private ResultImplementation<NBVersionInfo> getRecords(final String groupId, final String artifactId, final String version, final ResultImpl<NBVersionInfo> result, 
1085
                                             List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1087
                                             List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1086
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1088
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1087
        final SkippedAction skipAction = new SkippedAction(result);
1089
        final SkippedAction skipAction = new SkippedAction(result);
Lines 1097-1126 Link Here
1097
                            infos.add(convertToNBVersionInfo(ai));
1099
                            infos.add(convertToNBVersionInfo(ai));
1098
                        }
1100
                        }
1099
                    } finally {
1101
                    } finally {
1100
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1102
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1101
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1103
                        result.addTotalResultCount(response.getTotalHitsCount());
1102
                        response.close();
1104
                        response.close();
1103
                    }
1105
                    }
1104
                }
1106
                }
1105
            }
1107
            }
1106
        }, skipAction, skipUnIndexed);
1108
        }, skipAction, skipUnIndexed);
1107
        doSortIssue226100(infos);
1109
        doSortIssue226100(infos);
1108
        Accessor.ACCESSOR.setVersionResults(result, infos);
1110
        result.setResults(infos);
1109
        return result;
1111
        return result;
1110
    }
1112
    }
1111
1113
1112
    @Override
1114
    @Override
1113
    public RepositoryQueries.Result<String> getArtifacts(final String groupId, final List<RepositoryInfo> repos) {
1115
    public ResultImplementation<String> getArtifacts(final String groupId, final List<RepositoryInfo> repos) {
1114
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
1116
        ResultImpl<String> result = new ResultImpl<>(new Redo<String>() {
1115
            @Override
1117
            @Override
1116
            public void run(Result<String> result) {
1118
            public void run(ResultImpl<String> result) {
1117
                getArtifacts(groupId, result, Accessor.ACCESSOR.getSkipped(result), false);
1119
                getArtifacts(groupId, result, result.getSkipped(), false);
1118
            }
1120
            }
1119
        });
1121
        });
1120
        return getArtifacts(groupId, result, repos, true);
1122
        return getArtifacts(groupId, result, repos, true);
1121
    }
1123
    }
1122
    
1124
    
1123
    private  RepositoryQueries.Result<String> getArtifacts(final String groupId, final Result<String> result, final List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1125
    private  ResultImplementation<String> getArtifacts(final String groupId, final ResultImpl<String> result, final List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1124
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1126
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1125
        final SkippedAction skipAction = new SkippedAction(result);
1127
        final SkippedAction skipAction = new SkippedAction(result);
1126
        iterate(repos, new RepoAction() {
1128
        iterate(repos, new RepoAction() {
Lines 1141-1161 Link Here
1141
                }
1143
                }
1142
            }
1144
            }
1143
        }, skipAction, skipUnIndexed);
1145
        }, skipAction, skipUnIndexed);
1144
        Accessor.ACCESSOR.setStringResults(result, artifacts);
1146
        result.setResults(artifacts);
1145
        return result;
1147
        return result;
1146
    }
1148
    }
1147
1149
1148
    @Override
1150
    @Override
1149
    public RepositoryQueries.Result<NBVersionInfo> getVersions(final String groupId, final String artifactId, List<RepositoryInfo> repos) {
1151
    public ResultImplementation<NBVersionInfo> getVersions(final String groupId, final String artifactId, List<RepositoryInfo> repos) {
1150
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1152
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1151
            @Override
1153
            @Override
1152
            public void run(Result<NBVersionInfo> result) {
1154
            public void run(ResultImpl<NBVersionInfo> result) {
1153
                getVersions(groupId, artifactId, result, Accessor.ACCESSOR.getSkipped(result), false);
1155
                getVersions(groupId, artifactId, result, result.getSkipped(), false);
1154
            }
1156
            }
1155
        });
1157
        });
1156
        return getVersions(groupId, artifactId, result, repos, true);
1158
        return getVersions(groupId, artifactId, result, repos, true);
1157
    }
1159
    }
1158
    private RepositoryQueries.Result<NBVersionInfo> getVersions(final String groupId, final String artifactId, final Result<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1160
    private ResultImplementation<NBVersionInfo> getVersions(final String groupId, final String artifactId, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1159
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1161
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1160
        final SkippedAction skipAction = new SkippedAction(result);
1162
        final SkippedAction skipAction = new SkippedAction(result);
1161
        iterate(repos, new RepoAction() {
1163
        iterate(repos, new RepoAction() {
Lines 1170-1199 Link Here
1170
                            infos.add(convertToNBVersionInfo(ai));
1172
                            infos.add(convertToNBVersionInfo(ai));
1171
                        }
1173
                        }
1172
                    } finally {
1174
                    } finally {
1173
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1175
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1174
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1176
                        result.addTotalResultCount(response.getTotalHitsCount());
1175
                        response.close();
1177
                        response.close();
1176
                    }
1178
                    }
1177
                }
1179
                }
1178
            }
1180
            }
1179
        }, skipAction, skipUnIndexed);
1181
        }, skipAction, skipUnIndexed);
1180
        doSortIssue226100(infos);
1182
        doSortIssue226100(infos);
1181
        Accessor.ACCESSOR.setVersionResults(result, infos);
1183
        result.setResults(infos);
1182
        return result;
1184
        return result;
1183
    }
1185
    }
1184
1186
1185
    @Override
1187
    @Override
1186
    public RepositoryQueries.Result<NBVersionInfo> findVersionsByClass(final String className, List<RepositoryInfo> repos) {
1188
    public ResultImplementation<NBVersionInfo> findVersionsByClass(final String className, List<RepositoryInfo> repos) {
1187
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1189
        ResultImpl<NBVersionInfo> result = new ResultImpl(new Redo<NBVersionInfo>() {
1188
            @Override
1190
            @Override
1189
            public void run(Result<NBVersionInfo> result) {
1191
            public void run(ResultImpl<NBVersionInfo> result) {
1190
                findVersionsByClass(className, result, Accessor.ACCESSOR.getSkipped(result), false);
1192
                findVersionsByClass(className, result, result.getSkipped(), false);
1191
            }
1193
            }
1192
        });
1194
        });
1193
        return findVersionsByClass(className, result, repos, true);
1195
        return findVersionsByClass(className, result, repos, true);
1194
    }
1196
    }
1195
    
1197
    
1196
    private RepositoryQueries.Result<NBVersionInfo> findVersionsByClass(final String className, final Result<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1198
    private ResultImplementation<NBVersionInfo> findVersionsByClass(final String className, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1197
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1199
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1198
        final SkippedAction skipAction = new SkippedAction(result);
1200
        final SkippedAction skipAction = new SkippedAction(result);
1199
        iterate(repos, new RepoAction() {
1201
        iterate(repos, new RepoAction() {
Lines 1215-1245 Link Here
1215
                        infos.addAll(postProcessClasses(response.getResults(), clsname));
1217
                        infos.addAll(postProcessClasses(response.getResults(), clsname));
1216
                    } finally {
1218
                    } finally {
1217
                        //?? really count in this case?
1219
                        //?? really count in this case?
1218
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1220
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1219
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1221
                        result.addTotalResultCount(response.getTotalHitsCount());
1220
                        response.close();
1222
                        response.close();
1221
                    }
1223
                    }
1222
                }
1224
                }
1223
            }
1225
            }
1224
        }, skipAction, skipUnIndexed);
1226
        }, skipAction, skipUnIndexed);
1225
        doSortIssue226100(infos);
1227
        doSortIssue226100(infos);
1226
        Accessor.ACCESSOR.setVersionResults(result, infos);
1228
        result.setResults(infos);
1227
        return result;
1229
        return result;
1228
    }
1230
    }
1229
1231
1230
    @Override 
1232
    @Override 
1231
    public RepositoryQueries.Result<RepositoryQueries.ClassUsage> findClassUsages(final String className, @NullAllowed List<RepositoryInfo> repos) {
1233
    public ResultImplementation<RepositoryQueries.ClassUsage> findClassUsages(final String className, @NullAllowed List<RepositoryInfo> repos) {
1232
        RepositoryQueries.Result<RepositoryQueries.ClassUsage> result = Accessor.ACCESSOR.createClassResult(new Redo<RepositoryQueries.ClassUsage>() {
1234
        ResultImpl<RepositoryQueries.ClassUsage> result = new ResultImpl<>(new Redo<RepositoryQueries.ClassUsage>() {
1233
            @Override
1235
            @Override
1234
            public void run(Result<RepositoryQueries.ClassUsage> result) {
1236
            public void run(ResultImpl<RepositoryQueries.ClassUsage> result) {
1235
                findClassUsages(className, result, Accessor.ACCESSOR.getSkipped(result), false);
1237
                findClassUsages(className, result, result.getSkipped(), false);
1236
            }
1238
            }
1237
        });
1239
        });
1238
        return findClassUsages(className, result, repos, true);
1240
        return findClassUsages(className, result, repos, true);
1239
        
1241
        
1240
    }
1242
    }
1241
    
1243
    
1242
    private RepositoryQueries.Result<RepositoryQueries.ClassUsage> findClassUsages(final String className, Result<RepositoryQueries.ClassUsage> result, @NullAllowed List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1244
    private ResultImplementation<RepositoryQueries.ClassUsage> findClassUsages(final String className, ResultImpl<RepositoryQueries.ClassUsage> result, @NullAllowed List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1243
        List<RepositoryInfo> localRepos = new ArrayList<RepositoryInfo>();
1245
        List<RepositoryInfo> localRepos = new ArrayList<RepositoryInfo>();
1244
        if (repos == null) {
1246
        if (repos == null) {
1245
            repos = RepositoryPreferences.getInstance().getRepositoryInfos();
1247
            repos = RepositoryPreferences.getInstance().getRepositoryInfos();
Lines 1261-1281 Link Here
1261
                return r1.getArtifact().compareTo(r2.getArtifact());
1263
                return r1.getArtifact().compareTo(r2.getArtifact());
1262
            }
1264
            }
1263
        });
1265
        });
1264
        Accessor.ACCESSOR.setClassResults(result, results);
1266
        result.setResults(results);
1265
        return result;
1267
        return result;
1266
    }
1268
    }
1267
    
1269
    
1268
    @Override
1270
    @Override
1269
    public RepositoryQueries.Result<NBVersionInfo> findDependencyUsage(final String groupId, final String artifactId, final String version, @NullAllowed List<RepositoryInfo> repos) {
1271
    public ResultImplementation<NBVersionInfo> findDependencyUsage(final String groupId, final String artifactId, final String version, @NullAllowed List<RepositoryInfo> repos) {
1270
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1272
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1271
            @Override
1273
            @Override
1272
            public void run(Result<NBVersionInfo> result) {
1274
            public void run(ResultImpl<NBVersionInfo> result) {
1273
                findDependencyUsage(groupId, artifactId, version, result, Accessor.ACCESSOR.getSkipped(result), false);
1275
                findDependencyUsage(groupId, artifactId, version, result, result.getSkipped(), false);
1274
            }
1276
            }
1275
        });
1277
        });
1276
        return findDependencyUsage(groupId, artifactId, version, result, repos, true);
1278
        return findDependencyUsage(groupId, artifactId, version, result, repos, true);
1277
    }
1279
    }
1278
    private RepositoryQueries.Result<NBVersionInfo> findDependencyUsage(String groupId, String artifactId, String version, final Result<NBVersionInfo> result, @NullAllowed List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1280
    private ResultImplementation<NBVersionInfo> findDependencyUsage(String groupId, String artifactId, String version, final ResultImpl<NBVersionInfo> result, @NullAllowed List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1279
        final Query q = ArtifactDependencyIndexCreator.query(groupId, artifactId, version);
1281
        final Query q = ArtifactDependencyIndexCreator.query(groupId, artifactId, version);
1280
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1282
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1281
        final SkippedAction skipAction = new SkippedAction(result);
1283
        final SkippedAction skipAction = new SkippedAction(result);
Lines 1288-1324 Link Here
1288
                            infos.add(convertToNBVersionInfo(ai));
1290
                            infos.add(convertToNBVersionInfo(ai));
1289
                        }
1291
                        }
1290
                    } finally {
1292
                    } finally {
1291
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1293
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1292
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1294
                        result.addTotalResultCount(response.getTotalHitsCount());
1293
                        response.close();
1295
                        response.close();
1294
                    }
1296
                    }
1295
                }
1297
                }
1296
            }
1298
            }
1297
        }, skipAction, skipUnIndexed);
1299
        }, skipAction, skipUnIndexed);
1298
        Accessor.ACCESSOR.setVersionResults(result, infos);
1300
        result.setResults(infos);
1299
        return result;
1301
        return result;
1300
    }
1302
    }
1301
    
1303
    
1302
    @Override
1304
    @Override
1303
    public Result<NBGroupInfo> findDependencyUsageGroups(final String groupId, final String artifactId, final String version, List<RepositoryInfo> repos) {
1305
    public ResultImplementation<NBGroupInfo> findDependencyUsageGroups(final String groupId, final String artifactId, final String version, List<RepositoryInfo> repos) {
1304
        RepositoryQueries.Result<NBGroupInfo> result = Accessor.ACCESSOR.createGroupResult(new Redo<NBGroupInfo>() {
1306
        ResultImpl<NBGroupInfo> result = new ResultImpl<>(new Redo<NBGroupInfo>() {
1305
            @Override
1307
            @Override
1306
            public void run(Result<NBGroupInfo> result) {
1308
            public void run(ResultImpl<NBGroupInfo> result) {
1307
                findDependencyUsageGroups(groupId, artifactId, version, result, Accessor.ACCESSOR.getSkipped(result), false);
1309
                findDependencyUsageGroups(groupId, artifactId, version, result, result.getSkipped(), false);
1308
            }
1310
            }
1309
        });
1311
        });
1310
        return findDependencyUsageGroups(groupId, artifactId, version, result, repos, true);
1312
        return findDependencyUsageGroups(groupId, artifactId, version, result, repos, true);
1311
    }
1313
    }
1312
1314
1313
    private Result<NBGroupInfo> findDependencyUsageGroups(String groupId, String artifactId, String version, Result<NBGroupInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1315
    private ResultImplementation<NBGroupInfo> findDependencyUsageGroups(String groupId, String artifactId, String version, ResultImpl<NBGroupInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1314
        //tempmaps
1316
        //tempmaps
1315
        Map<String, NBGroupInfo> groupMap = new HashMap<String, NBGroupInfo>();
1317
        Map<String, NBGroupInfo> groupMap = new HashMap<String, NBGroupInfo>();
1316
        Map<String, NBArtifactInfo> artifactMap = new HashMap<String, NBArtifactInfo>();
1318
        Map<String, NBArtifactInfo> artifactMap = new HashMap<String, NBArtifactInfo>();
1317
        List<NBGroupInfo> groupInfos = new ArrayList<NBGroupInfo>(result.getResults());
1319
        List<NBGroupInfo> groupInfos = new ArrayList<NBGroupInfo>(result.getResults());
1318
        Result<NBVersionInfo> res = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1320
        ResultImpl<NBVersionInfo> res = new ResultImpl(new Redo<NBVersionInfo>() {
1319
1321
1320
            @Override
1322
            @Override
1321
            public void run(Result<NBVersionInfo> result) {
1323
            public void run(ResultImpl<NBVersionInfo> result) {
1322
                //noop will not be called
1324
                //noop will not be called
1323
            }
1325
            }
1324
        });
1326
        });
Lines 1326-1334 Link Here
1326
        convertToNBGroupInfo(res.getResults(),
1328
        convertToNBGroupInfo(res.getResults(),
1327
                groupMap, artifactMap, groupInfos);
1329
                groupMap, artifactMap, groupInfos);
1328
        if (res.isPartial()) {
1330
        if (res.isPartial()) {
1329
            Accessor.ACCESSOR.addSkipped(result, Accessor.ACCESSOR.getSkipped(res));
1331
            result.addSkipped(res.getSkipped());
1330
        }
1332
        }
1331
        Accessor.ACCESSOR.setGroupResults(result, groupInfos);
1333
        result.setResults(groupInfos);
1332
        return result;
1334
        return result;
1333
        
1335
        
1334
    }
1336
    }
Lines 1360-1376 Link Here
1360
    
1362
    
1361
1363
1362
    @Override
1364
    @Override
1363
    public RepositoryQueries.Result<NBVersionInfo> findBySHA1(final String sha1, List<RepositoryInfo> repos) {
1365
    public ResultImplementation<NBVersionInfo> findBySHA1(final String sha1, List<RepositoryInfo> repos) {
1364
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1366
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1365
            @Override
1367
            @Override
1366
            public void run(Result<NBVersionInfo> result) {
1368
            public void run(ResultImpl<NBVersionInfo> result) {
1367
                findBySHA1(sha1, result, Accessor.ACCESSOR.getSkipped(result), false);
1369
                findBySHA1(sha1, result, result.getSkipped(), false);
1368
            }
1370
            }
1369
        });
1371
        });
1370
        return findBySHA1(sha1, result, repos, true);
1372
        return findBySHA1(sha1, result, repos, true);
1371
    }
1373
    }
1372
    
1374
    
1373
    private RepositoryQueries.Result<NBVersionInfo> findBySHA1(final String sha1, final Result<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1375
    private ResultImplementation<NBVersionInfo> findBySHA1(final String sha1, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1374
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1376
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1375
        final SkippedAction skipAction = new SkippedAction(result);
1377
        final SkippedAction skipAction = new SkippedAction(result);
1376
        iterate(repos, new RepoAction() {
1378
        iterate(repos, new RepoAction() {
Lines 1384-1413 Link Here
1384
                            infos.add(convertToNBVersionInfo(ai));
1386
                            infos.add(convertToNBVersionInfo(ai));
1385
                        }
1387
                        }
1386
                    } finally {
1388
                    } finally {
1387
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1389
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1388
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1390
                        result.addTotalResultCount(response.getTotalHitsCount());
1389
                        response.close();
1391
                        response.close();
1390
                    }
1392
                    }
1391
                }
1393
                }
1392
            }
1394
            }
1393
        }, skipAction, skipUnIndexed);
1395
        }, skipAction, skipUnIndexed);
1394
        doSortIssue226100(infos);
1396
        doSortIssue226100(infos);
1395
        Accessor.ACCESSOR.setVersionResults(result, infos);
1397
        result.setResults(infos);
1396
        return result;
1398
        return result;
1397
    }
1399
    }
1398
1400
1399
    @Override
1401
    @Override
1400
    public RepositoryQueries.Result<NBVersionInfo> findArchetypes(List<RepositoryInfo> repos) {
1402
    public ResultImplementation<NBVersionInfo> findArchetypes(List<RepositoryInfo> repos) {
1401
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1403
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1402
            @Override
1404
            @Override
1403
            public void run(Result<NBVersionInfo> result) {
1405
            public void run(ResultImpl<NBVersionInfo> result) {
1404
                findArchetypes( result, Accessor.ACCESSOR.getSkipped(result), false);
1406
                findArchetypes( result, result.getSkipped(), false);
1405
            }
1407
            }
1406
        });
1408
        });
1407
        return findArchetypes( result, repos, true);
1409
        return findArchetypes( result, repos, true);
1408
    }
1410
    }
1409
    
1411
    
1410
    private RepositoryQueries.Result<NBVersionInfo> findArchetypes(final Result<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1412
    private ResultImplementation<NBVersionInfo> findArchetypes(final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1411
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1413
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1412
        final SkippedAction skipAction = new SkippedAction(result);
1414
        final SkippedAction skipAction = new SkippedAction(result);
1413
        iterate(repos, new RepoAction() {
1415
        iterate(repos, new RepoAction() {
Lines 1426-1455 Link Here
1426
                            infos.add(convertToNBVersionInfo(ai));
1428
                            infos.add(convertToNBVersionInfo(ai));
1427
                        }
1429
                        }
1428
                    } finally {
1430
                    } finally {
1429
                        Accessor.ACCESSOR.addReturnedResults(result, response.getTotalProcessedArtifactInfoCount());
1431
                        result.addReturnedResultCount(response.getTotalProcessedArtifactInfoCount());
1430
                        Accessor.ACCESSOR.addTotalResults(result, response.getTotalHitsCount());
1432
                        result.addTotalResultCount(response.getTotalHitsCount());
1431
                        response.close();
1433
                        response.close();
1432
                    }
1434
                    }
1433
                }
1435
                }
1434
            }
1436
            }
1435
        }, skipAction, skipUnIndexed);
1437
        }, skipAction, skipUnIndexed);
1436
        doSortIssue226100(infos);
1438
        doSortIssue226100(infos);
1437
        Accessor.ACCESSOR.setVersionResults(result, infos);
1439
        result.setResults(infos);
1438
        return result;
1440
        return result;
1439
    }
1441
    }
1440
1442
1441
    @Override
1443
    @Override
1442
    public RepositoryQueries.Result<String> filterPluginArtifactIds(final String groupId, final String prefix, List<RepositoryInfo> repos) {
1444
    public ResultImplementation<String> filterPluginArtifactIds(final String groupId, final String prefix, List<RepositoryInfo> repos) {
1443
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
1445
        ResultImpl<String> result = new ResultImpl<>(new Redo<String>() {
1444
            @Override
1446
            @Override
1445
            public void run(Result<String> result) {
1447
            public void run(ResultImpl<String> result) {
1446
                filterPluginArtifactIds(groupId, prefix, result, Accessor.ACCESSOR.getSkipped(result), false);
1448
                filterPluginArtifactIds(groupId, prefix, result, result.getSkipped(), false);
1447
            }
1449
            }
1448
        });
1450
        });
1449
        return filterPluginArtifactIds(groupId, prefix, result, repos, true);
1451
        return filterPluginArtifactIds(groupId, prefix, result, repos, true);
1450
    }
1452
    }
1451
    
1453
    
1452
    private RepositoryQueries.Result<String> filterPluginArtifactIds(final String groupId, final String prefix, Result<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1454
    private ResultImplementation<String> filterPluginArtifactIds(final String groupId, final String prefix, ResultImpl<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1453
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1455
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1454
        final SkippedAction skipAction = new SkippedAction(result);
1456
        final SkippedAction skipAction = new SkippedAction(result);
1455
        iterate(repos, new RepoAction() {
1457
        iterate(repos, new RepoAction() {
Lines 1471-1492 Link Here
1471
                }
1473
                }
1472
            }
1474
            }
1473
        }, skipAction, skipUnIndexed);
1475
        }, skipAction, skipUnIndexed);
1474
        Accessor.ACCESSOR.setStringResults(result, artifacts);
1476
        result.setResults(artifacts);
1475
        return result;
1477
        return result;
1476
    }
1478
    }
1477
1479
1478
    @Override
1480
    @Override
1479
    public RepositoryQueries.Result<String> filterPluginGroupIds(final String prefix, List<RepositoryInfo> repos) {
1481
    public ResultImplementation<String> filterPluginGroupIds(final String prefix, List<RepositoryInfo> repos) {
1480
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
1482
        ResultImpl<String> result = new ResultImpl<>(new Redo<String>() {
1481
            @Override
1483
            @Override
1482
            public void run(Result<String> result) {
1484
            public void run(ResultImpl<String> result) {
1483
                filterPluginGroupIds( prefix, result, Accessor.ACCESSOR.getSkipped(result), false);
1485
                filterPluginGroupIds( prefix, result, result.getSkipped(), false);
1484
            }
1486
            }
1485
        });
1487
        });
1486
        return filterPluginGroupIds( prefix, result, repos, true);
1488
        return filterPluginGroupIds( prefix, result, repos, true);
1487
    }
1489
    }
1488
    
1490
    
1489
    private RepositoryQueries.Result<String> filterPluginGroupIds(final String prefix, Result<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1491
    private ResultImplementation<String> filterPluginGroupIds(final String prefix, ResultImpl<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1490
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1492
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1491
        final SkippedAction skipAction = new SkippedAction(result);
1493
        final SkippedAction skipAction = new SkippedAction(result);
1492
        iterate(repos, new RepoAction() {
1494
        iterate(repos, new RepoAction() {
Lines 1509-1564 Link Here
1509
                }
1511
                }
1510
            }
1512
            }
1511
        }, skipAction, skipUnIndexed);
1513
        }, skipAction, skipUnIndexed);
1512
        Accessor.ACCESSOR.setStringResults(result, artifacts);
1514
        result.setResults(artifacts);
1513
        return result;
1515
        return result;
1514
    }
1516
    }
1515
1517
1516
    @Override
1518
    @Override
1517
    public RepositoryQueries.Result<String> filterArtifactIdForGroupId(final String groupId, final String prefix, List<RepositoryInfo> repos) {
1519
    public ResultImplementation<NBVersionInfo> find(final List<QueryField> fields, List<RepositoryInfo> repos) {
1518
        RepositoryQueries.Result<String> result = Accessor.ACCESSOR.createStringResult(new Redo<String>() {
1520
        ResultImpl<NBVersionInfo> result = new ResultImpl<>(new Redo<NBVersionInfo>() {
1519
            @Override
1521
            @Override
1520
            public void run(Result<String> result) {
1522
            public void run(ResultImpl<NBVersionInfo> result) {
1521
                filterArtifactIdForGroupId( groupId, prefix, result, Accessor.ACCESSOR.getSkipped(result), false);
1523
                find( fields, result, result.getSkipped(), false);
1522
            }
1524
            }
1523
        });
1525
        });
1524
        return filterArtifactIdForGroupId( groupId, prefix, result, repos, true);
1525
    }
1526
    private RepositoryQueries.Result<String> filterArtifactIdForGroupId(final String groupId, final String prefix, Result<String> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1527
        final Set<String> artifacts = new TreeSet<String>(result.getResults());
1528
        final SkippedAction skipAction = new SkippedAction(result);
1529
        iterate(repos, new RepoAction() {
1530
            @Override public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
1531
                BooleanQuery bq = new BooleanQuery();
1532
                String id = groupId + ArtifactInfo.FS + prefix;
1533
                bq.add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.UINFO, id))), BooleanClause.Occur.MUST));
1534
                //mkleint: this is not capped, because only a string is collected (and collapsed), the rest gets CGed fast
1535
                IteratorSearchResponse response = repeatedPagedSearch(bq, Collections.singletonList(context), NO_CAP_RESULT_COUNT);
1536
                if (response != null) {
1537
                    try {
1538
                        for (ArtifactInfo artifactInfo : response.getResults()) {
1539
                            artifacts.add(artifactInfo.artifactId);
1540
                        }
1541
                    } finally {
1542
                        response.close();
1543
                    }
1544
                }
1545
            }
1546
        }, skipAction, skipUnIndexed);       
1547
        Accessor.ACCESSOR.setStringResults(result, artifacts);
1548
        return result;
1549
    }
1550
1551
    @Override
1552
    public RepositoryQueries.Result<NBVersionInfo> find(final List<QueryField> fields, List<RepositoryInfo> repos) {
1553
        RepositoryQueries.Result<NBVersionInfo> result = Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
1554
            @Override
1555
            public void run(Result<NBVersionInfo> result) {
1556
                find( fields, result, Accessor.ACCESSOR.getSkipped(result), false);
1557
            }
1558
        });
1559
        return find(fields,  result, repos, true);
1526
        return find(fields,  result, repos, true);
1560
    }
1527
    }
1561
    private RepositoryQueries.Result<NBVersionInfo> find(final List<QueryField> fields, final Result<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1528
    private ResultImplementation<NBVersionInfo> find(final List<QueryField> fields, final ResultImpl<NBVersionInfo> result, List<RepositoryInfo> repos, final boolean skipUnIndexed) {
1562
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1529
        final List<NBVersionInfo> infos = new ArrayList<NBVersionInfo>(result.getResults());
1563
        final SkippedAction skipAction = new SkippedAction(result);
1530
        final SkippedAction skipAction = new SkippedAction(result);
1564
        iterate(repos, new RepoAction() {
1531
        iterate(repos, new RepoAction() {
Lines 1636-1650 Link Here
1636
                            infos.add(convertToNBVersionInfo(ai));
1603
                            infos.add(convertToNBVersionInfo(ai));
1637
                        }
1604
                        }
1638
                    } finally {
1605
                    } finally {
1639
                        Accessor.ACCESSOR.addReturnedResults(result, resp.getTotalProcessedArtifactInfoCount());
1606
                        result.addReturnedResultCount(resp.getTotalProcessedArtifactInfoCount());
1640
                        Accessor.ACCESSOR.addTotalResults(result, resp.getTotalHitsCount());
1607
                        result.addTotalResultCount(resp.getTotalHitsCount());
1641
                        resp.close();
1608
                        resp.close();
1642
                    }
1609
                    }
1643
                }
1610
                }
1644
            }
1611
            }
1645
        }, skipAction, skipUnIndexed);
1612
        }, skipAction, skipUnIndexed);
1646
        doSortIssue226100(infos);
1613
        doSortIssue226100(infos);
1647
        Accessor.ACCESSOR.setVersionResults(result, infos);
1614
        result.setResults(infos);
1648
        return result;
1615
        return result;
1649
    }
1616
    }
1650
    
1617
    
Lines 1781-1796 Link Here
1781
1748
1782
    private static class SkippedAction implements RepoAction {
1749
    private static class SkippedAction implements RepoAction {
1783
1750
1784
        private final Result<?> result;
1751
        private final ResultImpl<?> result;
1785
1752
1786
        private SkippedAction(Result<?> result) {
1753
        private SkippedAction(ResultImpl<?> result) {
1787
            this.result = result;
1754
            this.result = result;
1788
        }
1755
        }
1789
        
1756
        
1790
        @Override
1757
        @Override
1791
        public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
1758
        public void run(RepositoryInfo repo, IndexingContext context) throws IOException {
1792
            //indexing context is always null here..
1759
            //indexing context is always null here..
1793
            Accessor.ACCESSOR.addSkipped(result, repo);
1760
            result.addSkipped(repo);
1794
        }
1761
        }
1795
        
1762
        
1796
    }
1763
    }
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/OnStop.java (-1 / +1 lines)
Lines 44-50 Link Here
44
44
45
import java.util.logging.Level;
45
import java.util.logging.Level;
46
import java.util.logging.Logger;
46
import java.util.logging.Logger;
47
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation;
47
import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation;
48
import org.openide.util.Lookup;
48
import org.openide.util.Lookup;
49
49
50
@org.openide.modules.OnStop
50
@org.openide.modules.OnStop
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/ResultImpl.java (+152 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer;
43
44
import java.util.ArrayList;
45
import java.util.Collection;
46
import java.util.Collections;
47
import java.util.List;
48
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
49
import org.netbeans.modules.maven.indexer.spi.ResultImplementation;
50
import org.netbeans.modules.maven.indexer.spi.impl.Redo;
51
import org.netbeans.modules.project.spi.intern.ProjectIDEServices;
52
53
/**
54
 *
55
 * @author Tomas Stupka
56
 */
57
public class ResultImpl<T> implements ResultImplementation {
58
    private final List<RepositoryInfo> skipped = new ArrayList<>();
59
    private final List<T> results = new ArrayList<>();
60
    private final Redo<T> redoAction;
61
62
    private int totalResults = 0;
63
    private int returnedResults = 0;
64
65
    /**
66
     * used internally by the repository indexing/searching engine(s)
67
     */
68
    public ResultImpl(Redo<T> redo) {
69
        redoAction = redo;
70
    }
71
72
    /**
73
     * returns true is one or more indexes were skipped, eg because the indexing was taking place.
74
     * @return 
75
     */
76
    @Override
77
    public synchronized boolean isPartial() {
78
        return !skipped.isEmpty();
79
    }
80
81
    /**
82
     * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
83
     */
84
    synchronized void addSkipped(RepositoryInfo info) {
85
        skipped.add(info);
86
    }
87
88
    /**
89
     * waits for currently unaccessible indexes to finish, not to be called in AWT thread.
90
     */
91
    @Override
92
    public void waitForSkipped() {
93
        assert !ProjectIDEServices.isEventDispatchThread();
94
        redoAction.run(this);
95
        synchronized (this) {
96
            skipped.clear();
97
        }
98
    }
99
100
    synchronized void setResults(Collection<T> newResults) {
101
        results.clear();
102
        results.addAll(newResults);
103
    }
104
105
    @Override
106
    public synchronized List<T> getResults() {
107
        return Collections.unmodifiableList(results);
108
    }
109
110
111
    /**
112
     * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
113
     */
114
    synchronized void addSkipped(Collection<RepositoryInfo> infos) {
115
        skipped.addAll(infos);
116
    }
117
118
    /**
119
     * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
120
     */
121
    synchronized List<RepositoryInfo> getSkipped() {
122
        return Collections.unmodifiableList(skipped);
123
    }
124
    
125
    /**
126
     * total number of hits
127
     * @return
128
     * @since 2.20
129
     */
130
    @Override
131
    public int getTotalResultCount() {
132
        return totalResults;
133
    }
134
135
    void addTotalResultCount(int moreTotalResults) {
136
        totalResults += moreTotalResults;
137
    }
138
    /**
139
     * in some cases not entirely accurate number of processed and returned hits, typically should be less or equals to totalResultCount
140
     * @return 
141
     * @since 2.20
142
     */
143
    @Override
144
    public int getReturnedResultCount() {
145
        return returnedResults;
146
    }
147
148
    void addReturnedResultCount(int moreReturnedResults) {
149
        returnedResults = moreReturnedResults + returnedResults;
150
    }
151
    
152
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryIndexer.java (-7 / +28 lines)
Lines 43-51 Link Here
43
43
44
import java.util.Collection;
44
import java.util.Collection;
45
import org.apache.maven.artifact.Artifact;
45
import org.apache.maven.artifact.Artifact;
46
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl;
47
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation;
47
import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation;
48
import org.openide.util.Lookup;
48
import org.openide.util.Lookup;
49
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexQueryProvider;
49
50
50
/**
51
/**
51
 *
52
 *
Lines 55-81 Link Here
55
56
56
    public static void indexRepo(RepositoryInfo repo) {
57
    public static void indexRepo(RepositoryInfo repo) {
57
        assert repo != null;
58
        assert repo != null;
58
        findImplementation().indexRepo(repo);
59
        RepositoryIndexerImplementation impl = findImplementation(repo);
60
        if(impl != null) {
61
            // fires 
62
            impl.indexRepo(repo);
63
        } else {
64
            repo.fireIndexChange();
59
    }
65
    }
66
    }
60
    
67
    
61
    public static void updateIndexWithArtifacts(RepositoryInfo repo, Collection<Artifact> artifacts) {
68
    public static void updateIndexWithArtifacts(RepositoryInfo repo, Collection<Artifact> artifacts) {
62
        assert repo != null;
69
        assert repo != null;
63
        if (artifacts == null || artifacts.isEmpty()) {
70
        if (artifacts == null || artifacts.isEmpty()) {
64
            return;
71
            return;
65
        }
72
        }
66
        findImplementation().updateIndexWithArtifacts(repo, artifacts);
73
        RepositoryIndexerImplementation impl = findImplementation(repo);
74
        if(impl != null) {
75
            impl.updateIndexWithArtifacts(repo, artifacts);
67
    }
76
    }
77
    }
68
78
69
    public static void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact) {
79
    public static void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact) {
70
        assert repo != null;
80
        assert repo != null;
71
        if (artifact == null) {
81
        if (artifact == null) {
72
            return;
82
            return;
73
        }
83
        }
74
        findImplementation().deleteArtifactFromIndex(repo, artifact);
84
        RepositoryIndexerImplementation impl = findImplementation(repo);
85
        if(impl != null) {
86
            impl.deleteArtifactFromIndex(repo, artifact);
75
    }
87
    }
88
    }
76
    
89
    
77
    static @NonNull RepositoryIndexerImplementation findImplementation() {
90
    static RepositoryIndexerImplementation findImplementation(RepositoryInfo repo) {
78
        return Lookup.getDefault().lookup(RepositoryIndexerImplementation.class);
91
        Lookup l = Lookup.getDefault();
92
        Collection<? extends RepositoryIndexQueryProvider> queryProviders = l.lookupAll(RepositoryIndexQueryProvider.class);
93
        for (RepositoryIndexQueryProvider queryProvider : queryProviders) {
94
            if(!(queryProvider instanceof NexusRepositoryIndexerImpl) && queryProvider.handlesRepository(repo)) {
95
                // skip if 
96
                return null;
79
    }
97
    }
98
        }
99
        return l.lookup(RepositoryIndexerImplementation.class);
100
    }
80
    
101
    
81
}
102
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryQueries.java (-184 / +188 lines)
Lines 46-63 Link Here
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.Collection;
48
import java.util.Collection;
49
import java.util.Collections;
49
import java.util.HashMap;
50
import java.util.Iterator;
50
import java.util.Iterator;
51
import java.util.LinkedList;
51
import java.util.List;
52
import java.util.List;
53
import java.util.Map;
54
import java.util.Map.Entry;
52
import java.util.Set;
55
import java.util.Set;
53
import java.util.logging.Level;
56
import java.util.logging.Level;
54
import java.util.logging.Logger;
57
import java.util.logging.Logger;
58
import org.apache.lucene.search.BooleanQuery;
55
import org.netbeans.api.annotations.common.NonNull;
59
import org.netbeans.api.annotations.common.NonNull;
56
import org.netbeans.api.annotations.common.NullAllowed;
60
import org.netbeans.api.annotations.common.NullAllowed;
57
import org.netbeans.modules.maven.indexer.NexusRepositoryIndexerImpl;
61
import org.netbeans.modules.maven.indexer.ResultImpl;
58
import org.netbeans.modules.maven.indexer.spi.*;
62
import org.netbeans.modules.maven.indexer.spi.ArchetypeQueries;
63
import org.netbeans.modules.maven.indexer.spi.BaseQueries;
64
import org.netbeans.modules.maven.indexer.spi.ChecksumQueries;
65
import org.netbeans.modules.maven.indexer.spi.ClassUsageQuery;
66
import org.netbeans.modules.maven.indexer.spi.ClassesQuery;
67
import org.netbeans.modules.maven.indexer.spi.ContextLoadedQuery;
68
import org.netbeans.modules.maven.indexer.spi.DependencyInfoQueries;
69
import org.netbeans.modules.maven.indexer.spi.GenericFindQuery;
70
import org.netbeans.modules.maven.indexer.spi.NullResultImpl;
71
import org.netbeans.modules.maven.indexer.spi.ResultImplementation;
59
import org.netbeans.modules.project.spi.intern.ProjectIDEServices;
72
import org.netbeans.modules.project.spi.intern.ProjectIDEServices;
60
import org.openide.util.Lookup;
73
import org.openide.util.Lookup;
74
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexQueryProvider;
61
75
62
/**
76
/**
63
 * Searches Maven repositories in various ways.
77
 * Searches Maven repositories in various ways.
Lines 71-246 Link Here
71
85
72
    /**
86
    /**
73
     * query result set
87
     * query result set
88
     * @param <T>
74
     * @since 2.9
89
     * @since 2.9
75
     */
90
     */
76
    public final static class Result<T> {
91
    public final static class Result<T> {
77
        private final List<RepositoryInfo> skipped = new ArrayList<RepositoryInfo>();
92
        private final ResultImplementation<T> impl;
78
        private List<T> results = new ArrayList<T>();
79
        private final Redo<T> redoAction;
80
        int totalResults = 0;
81
        int returnedResults = 0;
82
        
93
        
83
        /**
94
        /**
84
         * used internally by the repository indexing/searching engine(s)
95
         * Creates a Result instance.
96
         * @param impl 
85
         */
97
         */
86
        Result(Redo<T> redo) {
98
        public Result(ResultImplementation<T> impl) {
87
            redoAction = redo;
99
            this.impl = impl;
88
        }
100
        }
89
        
101
        
90
        /**
102
        /**
91
         * returns true is one or more indexes were skipped, eg because the indexing was taking place.
103
         * Returns true is one or more indexes were skipped, e.g. because the indexing was taking place.
92
         * @return 
104
         * @return 
93
         */
105
         */
94
        public synchronized boolean isPartial() {
106
        public synchronized boolean isPartial() {
95
            return !skipped.isEmpty();
107
            return impl.isPartial();
96
        }
108
        }
97
        
109
        
98
        /**
110
        /**
99
         * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
111
         * Waits for currently unaccessible indexes to finish, not to be called in AWT thread.
100
         */
112
         */
101
        synchronized void addSkipped(RepositoryInfo info) {
102
            skipped.add(info);
103
        }
104
        
105
        /**
106
         * waits for currently unaccessible indexes to finish, not to be called in AWT thread.
107
         */
108
        public void waitForSkipped() {
113
        public void waitForSkipped() {
109
            assert !ProjectIDEServices.isEventDispatchThread();
114
            assert !ProjectIDEServices.isEventDispatchThread();
110
            redoAction.run(this);
115
            impl.waitForSkipped();
111
            synchronized (this) {
112
                skipped.clear();
113
            }
116
            }
114
        }
115
        
117
        
116
        synchronized void setResults(Collection<T> newResults) {
117
            results.clear();
118
            results.addAll(newResults);
119
        }
120
        
121
        public synchronized List<T> getResults() {
122
            return Collections.unmodifiableList(results);
123
        }
124
        
125
        
126
        /**
118
        /**
127
         * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
119
         * Returns a list of results
120
         * @return 
128
         */
121
         */
129
        synchronized void addSkipped(Collection<RepositoryInfo> infos) {
122
        public synchronized List<T> getResults() {
130
            skipped.addAll(infos);
123
            return impl.getResults();
131
        }
124
        }
132
        
125
        
133
        /**
126
        /**
134
         * used internally by the repository indexing/searching engine(s) to mark the result as partially skipped
127
         * Total number of hits
135
         */
136
        synchronized List<RepositoryInfo> getSkipped() {
137
            return Collections.unmodifiableList(skipped);
138
        }
139
        /**
140
         * total number of hits
141
         * @return
128
         * @return
142
         * @since 2.20
129
         * @since 2.20
143
         */
130
         */
144
        public int getTotalResultCount() {
131
        public int getTotalResultCount() {
145
            return totalResults;
132
            return impl.getTotalResultCount();
146
        }
133
        }
147
134
148
        void addTotalResultCount(int moreTotalResults) {
149
            totalResults = totalResults + moreTotalResults;
150
        }
151
        /**
135
        /**
152
         * in some cases not entirely accurate number of processed and returned hits, typically should be less or equals to totalResultCount
136
         * in some cases not entirely accurate number of processed and returned hits, typically should be less or equals to totalResultCount
153
         * @return 
137
         * @return 
154
         * @since 2.20
138
         * @since 2.20
155
         */
139
         */
156
        public int getReturnedResultCount() {
140
        public int getReturnedResultCount() {
157
            return returnedResults;
141
            return impl.getReturnedResultCount();
158
        }
142
        }
159
160
        void addReturnedResultCount(int moreReturnedResults) {
161
            returnedResults = returnedResults + moreReturnedResults;
162
        }
143
        }
163
        
144
        
145
    private final static class CompositeResult<T> implements ResultImplementation {
164
        
146
        
147
        private final List<ResultImplementation<T>> results;
165
        
148
        
149
        public CompositeResult(List<ResultImplementation<T>> results) {
150
            this.results = results;
166
    } 
151
    } 
167
    
152
    
168
    
169
    static {
170
        new AccessorImpl();       
171
    }
172
    
173
    
174
    
175
    static class AccessorImpl extends NexusRepositoryIndexerImpl.Accessor {
176
177
        @Override
153
        @Override
178
        public void addSkipped(Result<?> result, Collection<RepositoryInfo> infos) {
154
        public boolean isPartial() {
179
            result.addSkipped(infos);
155
            for (ResultImplementation<T> result : results) {
156
                if(result.isPartial()) {
157
                    return true;
180
        }
158
        }
181
182
        @Override
183
        public List<RepositoryInfo> getSkipped(Result<?> result) {
184
            return result.getSkipped();
185
        }
159
        }
186
160
            return false;
187
        @Override
188
        public void addSkipped(Result<?> result, RepositoryInfo info) {
189
            result.addSkipped(info);
190
        }
161
        }
191
162
192
        @Override
163
        @Override
193
        public Result<String> createStringResult(Redo<String> redo) {
164
        public void waitForSkipped() {
194
            return new Result<String>(redo);
165
            for (ResultImplementation<T> result : results) {
166
                result.waitForSkipped();
195
        }
167
        }
196
197
        @Override
198
        public Result<NBVersionInfo> createVersionResult(Redo<NBVersionInfo> redo) {
199
            return new Result<NBVersionInfo>(redo);
200
        }
168
        }
201
169
202
        @Override
170
        @Override
203
        public void setStringResults(Result<String> result, Collection<String> newResults) {
171
        public List<T> getResults() {
204
            result.setResults(newResults);
172
            List<T> ret = new LinkedList<>();
173
            for (ResultImplementation<T> result : results) {
174
                ret.addAll(result.getResults());
205
        }
175
        }
206
176
            return ret;
207
        @Override
208
        public void setVersionResults(Result<NBVersionInfo> result, Collection<NBVersionInfo> newResults) {
209
            result.setResults(newResults);
210
        }
177
        }
211
178
212
        @Override
179
        @Override
213
        public Result<NBGroupInfo> createGroupResult(Redo<NBGroupInfo> redo) {
180
        public int getTotalResultCount() {
214
            return new Result<NBGroupInfo>(redo);
181
            int ret = 0;
182
            for (ResultImplementation<T> result : results) {
183
                ret += result.getTotalResultCount();
215
        }
184
        }
216
185
            return ret;
217
        @Override
218
        public void setGroupResults(Result<NBGroupInfo> result, Collection<NBGroupInfo> newResults) {
219
            result.setResults(newResults);
220
        }
186
        }
221
187
222
        @Override
188
        @Override
223
        public Result<ClassUsage> createClassResult(Redo<ClassUsage> redo) {
189
        public int getReturnedResultCount() {
224
            return new Result<ClassUsage>(redo);
190
            int ret = 0;
191
            for (ResultImplementation<T> result : results) {
192
                ret += result.getReturnedResultCount();
225
        }
193
        }
226
194
            return ret;
227
        @Override
228
        public void setClassResults(Result<ClassUsage> result, Collection<ClassUsage> newResults) {
229
            result.setResults(newResults);
230
        }
195
        }
231
232
        @Override
233
        public void addTotalResults(Result<?> result, int moreResults) {
234
            result.addTotalResultCount(moreResults);
235
        }
196
        }
236
197
237
        @Override
238
        public void addReturnedResults(Result<?> result, int moreResults) {
239
            result.addReturnedResultCount(moreResults);
240
        }
241
    }
242
    
243
    
244
   /**
198
   /**
245
     * One usage result.
199
     * One usage result.
246
     */
200
     */
Lines 268-300 Link Here
268
        }
222
        }
269
    }
223
    }
270
    
224
    
225
    private static interface QueryCall<T> {
226
        ResultImplementation<T> call(RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos);
227
    }
271
    
228
    
272
    private static @NonNull BaseQueries findBaseQueries() {
229
    private static <T> Result<T> getQueryResult(List<RepositoryInfo> repos, QueryCall<T> c) {
273
        return Lookup.getDefault().lookup(BaseQueries.class);
230
        List<ResultImplementation<T>> results = new LinkedList<>();
231
        if (repos == null) {
232
            repos = RepositoryPreferences.getInstance().getRepositoryInfos();
274
    }
233
    }
234
        Map<RepositoryIndexQueryProvider, List<RepositoryInfo>> qp2Repo = getQueryProvider2Repo(repos);
235
        for(Map.Entry<RepositoryIndexQueryProvider, List<RepositoryInfo>> e : qp2Repo.entrySet()) {
236
            results.add(c.call(e.getKey(), e.getValue()));
237
        }
238
        return new Result<>(new CompositeResult<>(results));
239
    }
275
240
276
    /**
241
    private static Map<RepositoryIndexQueryProvider, List<RepositoryInfo>> getQueryProvider2Repo(List<RepositoryInfo> repos) {
277
     * 
242
        Collection<? extends RepositoryIndexQueryProvider> idxs = Lookup.getDefault().lookupAll(RepositoryIndexQueryProvider.class);
278
     * @param repos
243
        Map<RepositoryIndexQueryProvider, List<RepositoryInfo>> qp2Repo = new HashMap<>();
279
     * @return 
244
        for (RepositoryInfo repo : repos) {
280
     * @since 2.9
245
            for (RepositoryIndexQueryProvider idx : idxs) {
281
     */
246
                if(idx.handlesRepository(repo)) {
282
    public static Result<String> getGroupsResult(@NullAllowed List<RepositoryInfo> repos) {
247
                    List<RepositoryInfo> mappedRepos = qp2Repo.get(idx);
283
        return findBaseQueries().getGroups(repos);
248
                    if(mappedRepos == null) {
249
                        mappedRepos = new LinkedList<>();
250
                        qp2Repo.put(idx, mappedRepos);
284
    }
251
    }
252
                    mappedRepos.add(repo);
253
                    break;
254
                }
255
            }
256
        }
257
        return qp2Repo;
258
    }
285
    
259
    
286
    /**
260
    /**
287
     * 
261
     * 
288
     * @param prefix
289
     * @param repos
262
     * @param repos
290
     * @return 
263
     * @return 
291
     * @since 2.9
264
     * @since 2.9
292
     */
265
     */
293
    public static Result<String> filterGroupIdsResult(String prefix, @NullAllowed List<RepositoryInfo> repos) {
266
    public static Result<String> getGroupsResult(@NullAllowed List<RepositoryInfo> repos) {
294
        return findBaseQueries().filterGroupIds(prefix, repos);
267
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
268
            BaseQueries baseQueries = queryProvider.getBaseQueries();
269
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
270
            return baseQueries.getGroups(providerRepos);
271
        });
295
    }
272
    }
296
273
297
    
298
    /**
274
    /**
299
     * 
275
     * 
300
     * @param groupId
276
     * @param groupId
Lines 305-311 Link Here
305
     * @since 2.9
281
     * @since 2.9
306
     */
282
     */
307
    public static Result<NBVersionInfo> getRecordsResult(String groupId, String artifactId, String version, @NullAllowed List<RepositoryInfo> repos) {
283
    public static Result<NBVersionInfo> getRecordsResult(String groupId, String artifactId, String version, @NullAllowed List<RepositoryInfo> repos) {
308
        return findBaseQueries().getRecords(groupId, artifactId, version, repos);
284
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
285
            BaseQueries baseQueries = queryProvider.getBaseQueries();
286
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
287
            return baseQueries.getRecords(groupId, artifactId, version, providerRepos);
288
        });
309
    }
289
    }
310
    
290
    
311
    /**
291
    /**
Lines 316-325 Link Here
316
     * @since 2.28
296
     * @since 2.28
317
     */
297
     */
318
    public static Result<String> getGAVsForPackaging(String packaging, @NullAllowed List<RepositoryInfo> repos) {
298
    public static Result<String> getGAVsForPackaging(String packaging, @NullAllowed List<RepositoryInfo> repos) {
319
        return findBaseQueries().getGAVsForPackaging(packaging, repos);
299
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
300
            BaseQueries baseQueries = queryProvider.getBaseQueries();
301
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
302
            return baseQueries.getGAVsForPackaging(packaging, providerRepos);
303
        });
320
    }    
304
    }    
321
305
322
    
323
    /**
306
    /**
324
     * 
307
     * 
325
     * @param groupId
308
     * @param groupId
Lines 328-337 Link Here
328
     * @since 2.9
311
     * @since 2.9
329
     */
312
     */
330
    public static Result<String> getArtifactsResult(String groupId, @NullAllowed List<RepositoryInfo> repos) {
313
    public static Result<String> getArtifactsResult(String groupId, @NullAllowed List<RepositoryInfo> repos) {
331
        return findBaseQueries().getArtifacts(groupId, repos);
314
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
315
            BaseQueries baseQueries = queryProvider.getBaseQueries();
316
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
317
            return baseQueries.getArtifacts(groupId, providerRepos);
318
        });
332
    }
319
    }
333
320
334
    
335
    /**
321
    /**
336
     * 
322
     * 
337
     * @param groupId
323
     * @param groupId
Lines 341-354 Link Here
341
     * @since 2.9
327
     * @since 2.9
342
     */
328
     */
343
    public static Result<NBVersionInfo> getVersionsResult(String groupId, String artifactId, @NullAllowed List<RepositoryInfo> repos) {
329
    public static Result<NBVersionInfo> getVersionsResult(String groupId, String artifactId, @NullAllowed List<RepositoryInfo> repos) {
344
        return findBaseQueries().getVersions(groupId, artifactId, repos);
330
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
331
            BaseQueries baseQueries = queryProvider.getBaseQueries();
332
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
333
            return baseQueries.getVersions(groupId, artifactId, providerRepos);
334
        });
345
    }
335
    }
346
336
347
    
348
    private static @NonNull DependencyInfoQueries findDIQ() {
349
        return Lookup.getDefault().lookup(DependencyInfoQueries.class);
350
    }
351
    
352
    /**
337
    /**
353
     * 
338
     * 
354
     * @param groupId
339
     * @param groupId
Lines 359-368 Link Here
359
     * @since 2.9
344
     * @since 2.9
360
     */
345
     */
361
    public static Result<NBGroupInfo> findDependencyUsageResult(String groupId, String artifactId, String version, @NullAllowed List<RepositoryInfo> repos) {
346
    public static Result<NBGroupInfo> findDependencyUsageResult(String groupId, String artifactId, String version, @NullAllowed List<RepositoryInfo> repos) {
362
        return findDIQ().findDependencyUsageGroups(groupId, artifactId, version, repos);
347
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
348
            DependencyInfoQueries dependencyInfoQueries = queryProvider.getDependencyInfoQueries();
349
            return dependencyInfoQueries != null ? 
350
                    dependencyInfoQueries.findDependencyUsageGroups(groupId, artifactId, version, providerRepos) :
351
                    new NullResultImpl<>();
352
        });        
363
    }
353
    }
364
    
354
    
365
    
366
    /**
355
    /**
367
     * 
356
     * 
368
     * @param file
357
     * @param file
Lines 377-402 Link Here
377
        } catch (IOException ex) {
366
        } catch (IOException ex) {
378
            Logger.getLogger(RepositoryQueries.class.getName()).log(Level.INFO, "Could not determine SHA-1 of " + file, ex);
367
            Logger.getLogger(RepositoryQueries.class.getName()).log(Level.INFO, "Could not determine SHA-1 of " + file, ex);
379
        }
368
        }
380
        return NexusRepositoryIndexerImpl.Accessor.ACCESSOR.createVersionResult(new Redo<NBVersionInfo>() {
369
        return new Result<>(new NullResultImpl<>());
381
            @Override
382
            public void run(Result<NBVersionInfo> result) {
383
                //noop
384
            }
370
            }
385
        });
386
        
371
        
387
    }
388
    
389
    private static ChecksumQueries findChecksumQueries() {
390
        return Lookup.getDefault().lookup(ChecksumQueries.class);
391
    }    
392
393
    private static Result<NBVersionInfo> findBySHA1(String sha1, @NullAllowed List<RepositoryInfo> repos) {
372
    private static Result<NBVersionInfo> findBySHA1(String sha1, @NullAllowed List<RepositoryInfo> repos) {
394
        return findChecksumQueries().findBySHA1(sha1, repos);
373
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
374
            ChecksumQueries checksumQueries = queryProvider.getChecksumQueries();
375
            return checksumQueries != null ? 
376
                    checksumQueries.findBySHA1(sha1, providerRepos) : 
377
                    new NullResultImpl<>();
378
        });
395
    }
379
    }
396
    
380
    
397
    private static @NonNull ClassesQuery findClassesQueries() {
398
        return Lookup.getDefault().lookup(ClassesQuery.class);
399
    }    
400
    /**
381
    /**
401
     * 
382
     * 
402
     * @param className
383
     * @param className
Lines 411-417 Link Here
411
     * @since 2.9
392
     * @since 2.9
412
     */
393
     */
413
    public static Result<NBVersionInfo> findVersionsByClassResult(final String className, @NullAllowed List<RepositoryInfo> repos) {
394
    public static Result<NBVersionInfo> findVersionsByClassResult(final String className, @NullAllowed List<RepositoryInfo> repos) {
414
        return findClassesQueries().findVersionsByClass(className, repos);
395
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
396
            ClassesQuery classesQuery = queryProvider.getClassesQuery();
397
            return classesQuery != null ? 
398
                    classesQuery.findVersionsByClass(className, providerRepos) : 
399
                    new NullResultImpl<>();
400
        });
415
    }
401
    }
416
402
417
    /**
403
    /**
Lines 438-446 Link Here
438
        //TODO first process the loaded ones, index and wait for finish of indexing of the unloaded ones..
424
        //TODO first process the loaded ones, index and wait for finish of indexing of the unloaded ones..
439
        for (Iterator<RepositoryInfo> it1 = query.getRepositories().iterator(); it1.hasNext();) {
425
        for (Iterator<RepositoryInfo> it1 = query.getRepositories().iterator(); it1.hasNext();) {
440
            RepositoryInfo repositoryInfo = it1.next();
426
            RepositoryInfo repositoryInfo = it1.next();
441
            List<RepositoryInfo> repositoryInfoL = new ArrayList<RepositoryInfo>(1);
427
            List<RepositoryInfo> repositoryInfoL = new ArrayList<>(1);
442
            repositoryInfoL.add(repositoryInfo);
428
            repositoryInfoL.add(repositoryInfo);
443
            query.addResults(findClassesQueries().findVersionsByClass(query.getClassName(), repositoryInfoL).getResults(), !it1.hasNext());
429
            Result<NBVersionInfo> queryResult = getQueryResult(repositoryInfoL, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
430
                ClassesQuery classesQuery = queryProvider.getClassesQuery();
431
                return classesQuery != null ? 
432
                        classesQuery.findVersionsByClass(query.getClassName(), providerRepos) : 
433
                        new NullResultImpl<>();
434
            });
435
            query.addResults(queryResult.getResults(), !it1.hasNext());
444
            // still someone waiting for results?
436
            // still someone waiting for results?
445
            if (query.countObservers() == 0)
437
            if (query.countObservers() == 0)
446
                return;
438
                return;
Lines 449-458 Link Here
449
            query.addResults(null, true);
441
            query.addResults(null, true);
450
    }
442
    }
451
    
443
    
452
    private static @NonNull ClassUsageQuery findClassUsageQuery() {
453
        return Lookup.getDefault().lookup(ClassUsageQuery.class);
454
    }
455
456
    /**
444
    /**
457
     * Finds all usages of a given class.
445
     * Finds all usages of a given class.
458
     * The implementation may not provide results within the same artifact, or on classes in the JRE.
446
     * The implementation may not provide results within the same artifact, or on classes in the JRE.
Lines 462-475 Link Here
462
     * @since 2.9
450
     * @since 2.9
463
     */
451
     */
464
    public static Result<ClassUsage> findClassUsagesResult(String className, @NullAllowed List<RepositoryInfo> repos) {
452
    public static Result<ClassUsage> findClassUsagesResult(String className, @NullAllowed List<RepositoryInfo> repos) {
465
        return findClassUsageQuery().findClassUsages(className, repos);
453
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
454
            ClassUsageQuery classUsageQuery = queryProvider.getClassUsageQuery();
455
            return classUsageQuery != null ? 
456
                    classUsageQuery.findClassUsages(className, repos) :
457
                    new NullResultImpl<>();
458
        });
466
    }
459
    }
467
460
468
    
469
    private static @NonNull ArchetypeQueries findArchetypeQueries() {
470
        return Lookup.getDefault().lookup(ArchetypeQueries.class);
471
    }
472
    
473
    /**
461
    /**
474
     * 
462
     * 
475
     * @param repos
463
     * @param repos
Lines 477-487 Link Here
477
     * @since 2.9
465
     * @since 2.9
478
     */
466
     */
479
    public static Result<NBVersionInfo> findArchetypesResult(@NullAllowed List<RepositoryInfo> repos) {
467
    public static Result<NBVersionInfo> findArchetypesResult(@NullAllowed List<RepositoryInfo> repos) {
480
        return findArchetypeQueries().findArchetypes(repos);
468
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
469
            ArchetypeQueries archetypeQueries = queryProvider.getArchetypeQueries();
470
            return archetypeQueries != null ? 
471
                    archetypeQueries.findArchetypes(repos) : 
472
                    new NullResultImpl<>();
473
        });
481
    }
474
    }
482
    
475
    
483
484
    
485
    /**
476
    /**
486
     * 
477
     * 
487
     * @param groupId
478
     * @param groupId
Lines 491-500 Link Here
491
     * @since 2.9
482
     * @since 2.9
492
     */
483
     */
493
    public static Result<String> filterPluginArtifactIdsResult(String groupId, String prefix, @NullAllowed List<RepositoryInfo> repos) {
484
    public static Result<String> filterPluginArtifactIdsResult(String groupId, String prefix, @NullAllowed List<RepositoryInfo> repos) {
494
        return findBaseQueries().filterPluginArtifactIds(groupId, prefix, repos);
485
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
486
            BaseQueries baseQueries = queryProvider.getBaseQueries();
487
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
488
            return baseQueries.filterPluginArtifactIds(groupId, prefix, providerRepos);
489
        });
495
    }
490
    }
496
491
497
    
498
    /**
492
    /**
499
     * 
493
     * 
500
     * @param prefix
494
     * @param prefix
Lines 503-516 Link Here
503
     * @since 2.9
497
     * @since 2.9
504
     */
498
     */
505
    public static Result<String> filterPluginGroupIdsResult(String prefix, @NullAllowed List<RepositoryInfo> repos) {
499
    public static Result<String> filterPluginGroupIdsResult(String prefix, @NullAllowed List<RepositoryInfo> repos) {
506
        return findBaseQueries().filterPluginGroupIds(prefix, repos);
500
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
501
            BaseQueries baseQueries = queryProvider.getBaseQueries();
502
            assert baseQueries != null: "RepositoryIndexQueryProvider.getBaseQueries not allowed to return null";
503
            return baseQueries.filterPluginGroupIds(prefix, providerRepos);
504
        });
507
    }
505
    }
508
506
509
510
    private static @NonNull GenericFindQuery findFindQuery() {
511
        return Lookup.getDefault().lookup(GenericFindQuery.class);
512
    }
513
    
514
    /**
507
    /**
515
     * @throws BooleanQuery.TooManyClauses This runtime exception can be thrown if given query is too
508
     * @throws BooleanQuery.TooManyClauses This runtime exception can be thrown if given query is too
516
     * general and such search can't be executed as it would probably end with
509
     * general and such search can't be executed as it would probably end with
Lines 525-531 Link Here
525
     * @since 2.9
518
     * @since 2.9
526
     */
519
     */
527
    public static Result<NBVersionInfo> findResult(List<QueryField> fields, @NullAllowed List<RepositoryInfo> repos) {
520
    public static Result<NBVersionInfo> findResult(List<QueryField> fields, @NullAllowed List<RepositoryInfo> repos) {
528
        return findFindQuery().find(fields, repos);
521
        return getQueryResult(repos, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
522
            GenericFindQuery genericFindQuery = queryProvider.getGenericFindQuery();
523
            return genericFindQuery != null ? 
524
                    genericFindQuery.find(fields, providerRepos) : 
525
                    new NullResultImpl<>();
526
        });
529
    }
527
    }
530
528
531
    /**
529
    /**
Lines 551-559 Link Here
551
    public static void find(QueryRequest query) {
549
    public static void find(QueryRequest query) {
552
        for (Iterator<RepositoryInfo> it1 = query.getRepositories().iterator(); it1.hasNext();) {
550
        for (Iterator<RepositoryInfo> it1 = query.getRepositories().iterator(); it1.hasNext();) {
553
            RepositoryInfo repositoryInfo = it1.next();
551
            RepositoryInfo repositoryInfo = it1.next();
554
            List<RepositoryInfo> repositoryInfoL = new ArrayList<RepositoryInfo>(1);
552
            List<RepositoryInfo> repositoryInfoL = new ArrayList<>(1);
555
            repositoryInfoL.add(repositoryInfo);
553
            repositoryInfoL.add(repositoryInfo);
556
            query.addResults(findFindQuery().find(query.getQueryFields(), repositoryInfoL).getResults(), !it1.hasNext());
554
            Result<NBVersionInfo> qeuryResult = 
555
                getQueryResult(repositoryInfoL, (RepositoryIndexQueryProvider queryProvider, List<RepositoryInfo> providerRepos) -> {
556
                    GenericFindQuery genericFindQuery = queryProvider.getGenericFindQuery();
557
                    return genericFindQuery != null ? 
558
                            genericFindQuery.find(query.getQueryFields(), providerRepos) : 
559
                            new NullResultImpl<>();
560
            });
561
            query.addResults(qeuryResult.getResults(), !it1.hasNext());
557
            // still someone waiting for results?
562
            // still someone waiting for results?
558
            if (query.countObservers() == 0)
563
            if (query.countObservers() == 0)
559
                return;
564
                return;
Lines 563-578 Link Here
563
    }
568
    }
564
    
569
    
565
    public static @NonNull List<RepositoryInfo> getLoadedContexts() {
570
    public static @NonNull List<RepositoryInfo> getLoadedContexts() {
566
        List<RepositoryInfo> toRet = new ArrayList<RepositoryInfo>();
571
        List<RepositoryInfo> toRet = new ArrayList<>();
567
        ContextLoadedQuery clq = Lookup.getDefault().lookup(ContextLoadedQuery.class);
572
        List<RepositoryInfo> repos = RepositoryPreferences.getInstance().getRepositoryInfos();
573
        Map<RepositoryIndexQueryProvider, List<RepositoryInfo>> i2r = getQueryProvider2Repo(repos);
574
        for(Entry<RepositoryIndexQueryProvider, List<RepositoryInfo>> e : i2r.entrySet()) {
575
            ContextLoadedQuery clq = e.getKey().getContextLoadedQuery();
568
        assert clq != null;
576
        assert clq != null;
569
        toRet.addAll(clq.getLoaded(RepositoryPreferences.getInstance().getRepositoryInfos()));
577
            toRet.addAll(clq.getLoaded(repos));
578
        }
570
        return toRet;
579
        return toRet;
571
    }
580
    }
572
581
573
    
574
    public static Result<String> filterArtifactIdForGroupIdResult(String groupId, String prefix, @NullAllowed List<RepositoryInfo> repos) {
575
        return findBaseQueries().filterArtifactIdForGroupId(groupId, prefix, repos);
576
    }
582
    }
577
578
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/ArchetypeQueries.java (-1 / +1 lines)
Lines 53-58 Link Here
53
 */
53
 */
54
public interface ArchetypeQueries {
54
public interface ArchetypeQueries {
55
55
56
    RepositoryQueries.Result<NBVersionInfo> findArchetypes(List<RepositoryInfo> repos);
56
    ResultImplementation<NBVersionInfo> findArchetypes(List<RepositoryInfo> repos);
57
57
58
}
58
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/BaseQueries.java (-12 / +64 lines)
Lines 44-73 Link Here
44
import java.util.List;
44
import java.util.List;
45
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
45
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
46
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
46
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
47
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
48
47
49
/**
48
/**
50
 * The basic set of queries. To be implemented by all index managers.
49
 * The basic set of queries. To be implemented by all index managers.
50
 * 
51
 * <p><b>Note</b> that all calls might be made from the IDE-s user interface and
52
 * even if the return time isn't crucial for the UI responsivity, it still should be 
53
 * "reasonably" fast.</p>
54
 * 
51
 * @author Milos Kleint
55
 * @author Milos Kleint
52
 */
56
 */
53
public interface BaseQueries {
57
public interface BaseQueries {
54
58
55
    RepositoryQueries.Result<String> getGroups(List<RepositoryInfo> repos);
59
    /**
60
     * Returns all group id-s available.
61
     * 
62
     * @param repos repositories to search in
63
     * @return groupId-s
64
     */
65
    ResultImplementation<String> getGroups(List<RepositoryInfo> repos);
56
66
57
    RepositoryQueries.Result<String> filterGroupIds(String prefix, List<RepositoryInfo> repos);
67
    /**
68
     * Returns versions given by GAV.
69
     * 
70
     * @param groupId
71
     * @param artifactId
72
     * @param version
73
     * @param repos repositories to search in
74
     * @return NBVersionInfo-s
75
     */
76
    ResultImplementation<NBVersionInfo> getRecords(String groupId, String artifactId, String version, List<RepositoryInfo> repos);
58
77
59
    RepositoryQueries.Result<NBVersionInfo> getRecords(String groupId, String artifactId, String version, List<RepositoryInfo> repos);
78
    /**
79
     * Returns versions given by a groupId, artifactId.
80
     * 
81
     * @param groupId
82
     * @param artifactId
83
     * @param repos repositories to search in
84
     * @return NBVersionInfo-s
85
     */
86
    ResultImplementation<NBVersionInfo> getVersions(String groupId, String artifactId, List<RepositoryInfo> repos);
60
87
61
    RepositoryQueries.Result<String> getArtifacts(String groupId, List<RepositoryInfo> repos);
88
    /**
89
     * Returns all artifactId-s given by a groupId.
90
     * 
91
     * @param groupId
92
     * @param repos repositories to search in
93
     * @return artifactId-s
94
     */
95
    ResultImplementation<String> getArtifacts(String groupId, List<RepositoryInfo> repos);
62
96
63
    RepositoryQueries.Result<NBVersionInfo> getVersions(String groupId, String artifactId, List<RepositoryInfo> repos);
97
    /**
98
     * Returns all artifactId-s given by a groupId and artifactId prefix. 
99
     * 
100
     * @param groupId 
101
     * @param artifactIdPrefix
102
     * @param repos repositories to search in
103
     * @return artifactId-s
104
     */
105
    ResultImplementation<String> filterPluginArtifactIds(String groupId, String artifactIdPrefix, List<RepositoryInfo> repos);
64
106
65
    RepositoryQueries.Result<String> filterPluginArtifactIds(String groupId, String prefix, List<RepositoryInfo> repos);
107
    /**
108
     * Returns all groupId-s given by a groupId prefix. 
109
     * 
110
     * @param prefix
111
     * @param repos repositories to search in
112
     * @return groupId-s
113
     */
114
    ResultImplementation<String> filterPluginGroupIds(String prefix, List<RepositoryInfo> repos);
66
115
67
    RepositoryQueries.Result<String> filterPluginGroupIds(String prefix, List<RepositoryInfo> repos);
116
    /**
117
     * Return all GAV-s given by a packaging.
118
     * 
119
     * @param packaging
120
     * @param repos repositories to search in
121
     * @return GAV-s
122
     */
123
    ResultImplementation<String> getGAVsForPackaging(String packaging, List<RepositoryInfo> repos);
68
124
69
    RepositoryQueries.Result<String> filterArtifactIdForGroupId(String groupId, String prefix, List<RepositoryInfo> repos);
70
71
    RepositoryQueries.Result<String> getGAVsForPackaging(String packaging, List<RepositoryInfo> repos);
72
73
}
125
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/ChecksumQueries.java (-1 / +1 lines)
Lines 51-55 Link Here
51
 * @author Milos Kleint
51
 * @author Milos Kleint
52
 */
52
 */
53
public interface ChecksumQueries {
53
public interface ChecksumQueries {
54
    RepositoryQueries.Result<NBVersionInfo> findBySHA1(String sha1, List<RepositoryInfo> repos);
54
    ResultImplementation<NBVersionInfo> findBySHA1(String sha1, List<RepositoryInfo> repos);
55
}
55
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/ClassUsageQuery.java (-1 / +1 lines)
Lines 59-64 Link Here
59
     * @param repos repositories of this type to search in
59
     * @param repos repositories of this type to search in
60
     * @return result object with a list of usages
60
     * @return result object with a list of usages
61
     */
61
     */
62
    RepositoryQueries.Result<RepositoryQueries.ClassUsage> findClassUsages(String className, List<RepositoryInfo> repos);
62
    ResultImplementation<RepositoryQueries.ClassUsage> findClassUsages(String className, List<RepositoryInfo> repos);
63
63
64
}
64
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/ClassesQuery.java (-2 / +2 lines)
Lines 43-51 Link Here
43
package org.netbeans.modules.maven.indexer.spi;
43
package org.netbeans.modules.maven.indexer.spi;
44
44
45
import java.util.List;
45
import java.util.List;
46
import org.apache.lucene.search.BooleanQuery;
46
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
47
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
47
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
48
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
48
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
49
49
50
/**
50
/**
51
 * Query to find artifacts information from class names.
51
 * Query to find artifacts information from class names.
Lines 61-65 Link Here
61
     * accordingly, for example by telling user that entered text for
61
     * accordingly, for example by telling user that entered text for
62
     * search is too general.
62
     * search is too general.
63
     */
63
     */
64
    public RepositoryQueries.Result<NBVersionInfo> findVersionsByClass(final String className, List<RepositoryInfo> repos);
64
    public ResultImplementation<NBVersionInfo> findVersionsByClass(final String className, List<RepositoryInfo> repos);
65
}
65
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/DependencyInfoQueries.java (-3 / +2 lines)
Lines 45-51 Link Here
45
import org.netbeans.modules.maven.indexer.api.NBGroupInfo;
45
import org.netbeans.modules.maven.indexer.api.NBGroupInfo;
46
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
46
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
47
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
47
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
48
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
49
48
50
/**
49
/**
51
 * Query to find dependency information of artifacts.Non mandatory for repository managers.
50
 * Query to find dependency information of artifacts.Non mandatory for repository managers.
Lines 53-60 Link Here
53
 */
52
 */
54
public interface DependencyInfoQueries {
53
public interface DependencyInfoQueries {
55
54
56
    RepositoryQueries.Result<NBVersionInfo> findDependencyUsage(String groupId, String artifactId, String version, List<RepositoryInfo> repoIds);
55
    ResultImplementation<NBVersionInfo> findDependencyUsage(String groupId, String artifactId, String version, List<RepositoryInfo> repoIds);
57
    
56
    
58
    RepositoryQueries.Result<NBGroupInfo> findDependencyUsageGroups(String groupId, String artifactId, String version, List<RepositoryInfo> repoIds);
57
    ResultImplementation<NBGroupInfo> findDependencyUsageGroups(String groupId, String artifactId, String version, List<RepositoryInfo> repoIds);
59
58
60
}
59
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/GenericFindQuery.java (-2 / +2 lines)
Lines 43-52 Link Here
43
package org.netbeans.modules.maven.indexer.spi;
43
package org.netbeans.modules.maven.indexer.spi;
44
44
45
import java.util.List;
45
import java.util.List;
46
import org.apache.lucene.search.BooleanQuery;
46
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
47
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
47
import org.netbeans.modules.maven.indexer.api.QueryField;
48
import org.netbeans.modules.maven.indexer.api.QueryField;
48
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
49
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
49
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
50
50
51
/**
51
/**
52
 * non mandatory query to for generic searching within the repository.
52
 * non mandatory query to for generic searching within the repository.
Lines 63-68 Link Here
63
     * accordingly, for example by telling user that entered text for
63
     * accordingly, for example by telling user that entered text for
64
     * search is too general.
64
     * search is too general.
65
     */
65
     */
66
    public RepositoryQueries.Result<NBVersionInfo> find(List<QueryField> fields, List<RepositoryInfo> repos);
66
    public ResultImplementation<NBVersionInfo> find(List<QueryField> fields, List<RepositoryInfo> repos);
67
    
67
    
68
}
68
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/NullResultImpl.java (+79 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi;
43
44
import java.util.Collections;
45
import java.util.List;
46
47
/**
48
 * Convenience class.
49
 * 
50
 * @author Tomas Stupka
51
 * @param <T>
52
 */
53
public final class NullResultImpl<T> implements ResultImplementation<T> {        
54
55
    @Override
56
    public boolean isPartial() {
57
        return false;
58
    }
59
60
    @Override
61
    public void waitForSkipped() {
62
63
    }
64
    
65
    @Override
66
    public List<T> getResults() {            
67
        return Collections.EMPTY_LIST;
68
    }
69
70
    @Override
71
    public int getTotalResultCount() {
72
        return 0;
73
    }
74
    
75
    @Override
76
    public int getReturnedResultCount() {
77
        return 0;
78
    }        
79
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/Redo.java (-53 lines)
Lines 1-53 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi;
43
44
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
45
46
/**
47
 * used internally by the repository indexing/searching engine(s)
48
 * @author mkleint
49
 */
50
public interface Redo<T> {
51
    void run(RepositoryQueries.Result<T> result);
52
}    
53
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/RepositoryIndexQueryProvider.java (+130 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi;
43
44
import org.netbeans.api.annotations.common.CheckForNull;
45
import org.netbeans.api.annotations.common.NonNull;
46
import org.netbeans.api.annotations.common.NullAllowed;
47
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
48
49
/**
50
 * Provides repository queries.<br> 
51
 * Register via <code>@ServiceProvider(service=RepositoryIndexQueryProvider.class)</code>
52
 * 
53
 * @author Tomas Stupka
54
 * @since 2.38
55
 */
56
public interface RepositoryIndexQueryProvider {
57
    
58
    /** 
59
     * Determines if queries for the given repository are handled by this provider or not.
60
     * 
61
     * @param repo the repository
62
     * @return <code>true</code> if the given repository is handled by this provider, otherwise <code>false</code>
63
     * @since 2.38
64
     */
65
    boolean handlesRepository(RepositoryInfo repo);
66
    
67
    /**
68
     * Returns a {@link ArchetypeQueries} implementation.
69
     * 
70
     * @return ArchetypeQueries or <code>null</code> if not provided
71
     * @since 2.38
72
     */
73
    @CheckForNull ArchetypeQueries getArchetypeQueries();
74
    
75
    /**
76
     * Returns a {@link BaseQueries} implementation.
77
     * 
78
     * @return BaseQueries
79
     * @since 2.38
80
     */
81
    @NonNull BaseQueries getBaseQueries();
82
    
83
    /**
84
     * Returns a {@link ChecksumQueries} implementation.
85
     * 
86
     * @return ChecksumQueries or <code>null</code> if not provided
87
     * @since 2.38
88
     */
89
    @CheckForNull ChecksumQueries getChecksumQueries();
90
    
91
    /**
92
     * Returns a {@link ClassUsageQuery} implementation.
93
     * 
94
     * @return ClassUsageQuery or <code>null</code> if not provided
95
     * @since 2.38
96
     */
97
    @CheckForNull ClassUsageQuery getClassUsageQuery();
98
    
99
    /**
100
     * Returns a {@link ClassesQuery} implementation.
101
     * 
102
     * @return ClassesQuery or <code>null</code> if not provided
103
     * @since 2.38
104
     */
105
    @CheckForNull ClassesQuery getClassesQuery();
106
    
107
    /**
108
     * Returns a {@link ContextLoadedQuery} implementation.
109
     * 
110
     * @return ContextLoadedQuery or <code>null</code> if not provided
111
     * @since 2.38
112
     */
113
    @CheckForNull ContextLoadedQuery getContextLoadedQuery();
114
    
115
    /**
116
     * Returns a {@link DependencyInfoQueries} implementation.
117
     * 
118
     * @return DependencyInfoQueries or <code>null</code> if not provided
119
     * @since 2.38
120
     */
121
    @CheckForNull DependencyInfoQueries getDependencyInfoQueries();
122
    
123
    /**
124
     * Returns a {@link GenericFindQuery} implementation.
125
     * 
126
     * @return GenericFindQuery or <code>null</code> if not provided
127
     * @since 2.38
128
     */
129
    @CheckForNull GenericFindQuery getGenericFindQuery();
130
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/RepositoryIndexerImplementation.java (-67 lines)
Lines 1-67 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi;
43
44
import java.util.Collection;
45
import org.apache.maven.artifact.Artifact;
46
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
47
48
/**
49
 * Implementation of repository indexer (repository manager). Apart from basic
50
 * indexing features also serves as provider of various index queries.
51
 * There is one implementation based on apache indexer
52
 * 
53
 * @author Milos Kleint
54
 */
55
public interface RepositoryIndexerImplementation {
56
    
57
    /**
58
     * Index local repository or retrieve remote prepopulated index for local use.
59
     * @param repo
60
     */
61
    void indexRepo(RepositoryInfo repo);
62
    
63
    void updateIndexWithArtifacts(RepositoryInfo repo, Collection<Artifact> artifacts);
64
65
    void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact);
66
67
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/ResultImplementation.java (+94 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi;
43
44
import java.util.List;
45
46
/**
47
 * Implement to provide a maven index query result.
48
 * 
49
 * @author Tomas Stupka
50
 * @param <T>
51
 * @since 2.38
52
 * @see org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result
53
 */
54
public interface ResultImplementation<T> {
55
    /**
56
     * Returns true is one or more indexes were skipped, e.g. because the indexing was taking place.
57
     * 
58
     * @return <code>true</code> if the result is partial, otherwise <code>false</code>
59
     * @since 2.38
60
     */
61
    public boolean isPartial();
62
    
63
    /**
64
     * Waits for currently unaccessible indexes to finish, not to be called in AWT thread.
65
     * 
66
     * @since 2.38
67
     */
68
    public void waitForSkipped();
69
    
70
    /**
71
     * Returns the results.
72
     * 
73
     * @return a list of results
74
     * @since 2.38
75
     */
76
    public List<T> getResults();
77
    
78
    /**
79
     * Total number of hits.
80
     * 
81
     * @return the total number of hits
82
     * @since 2.38
83
     */
84
    public int getTotalResultCount();
85
    
86
    /**
87
     * In some cases not entirely accurate number of processed and returned hits, 
88
     * typically should be less or equal to {@link #getReturnedResultCount()}.
89
     * 
90
     * @return the returned result count
91
     * @since 2.38
92
     */
93
    public int getReturnedResultCount();
94
}
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/Redo.java (+53 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.spi.impl;
43
44
import org.netbeans.modules.maven.indexer.ResultImpl;
45
46
/**
47
 * used internally by the repository indexing/searching engine(s)
48
 * @author mkleint
49
 */
50
public interface Redo<T> {
51
    void run(ResultImpl<T> result);
52
}    
53
(-)maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/RepositoryIndexerImplementation.java (+72 lines)
Line 0 Link Here
1
package org.netbeans.modules.maven.indexer.spi.impl;
2
3
/*
4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
 *
6
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
7
 *
8
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
9
 * Other names may be trademarks of their respective owners.
10
 *
11
 * The contents of this file are subject to the terms of either the GNU
12
 * General Public License Version 2 only ("GPL") or the Common
13
 * Development and Distribution License("CDDL") (collectively, the
14
 * "License"). You may not use this file except in compliance with the
15
 * License. You can obtain a copy of the License at
16
 * http://www.netbeans.org/cddl-gplv2.html
17
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
 * specific language governing permissions and limitations under the
19
 * License.  When distributing the software, include this License Header
20
 * Notice in each file and include the License file at
21
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
 * particular file as subject to the "Classpath" exception as provided
23
 * by Oracle in the GPL Version 2 section of the License file that
24
 * accompanied this code. If applicable, add the following below the
25
 * License Header, with the fields enclosed by brackets [] replaced by
26
 * your own identifying information:
27
 * "Portions Copyrighted [year] [name of copyright owner]"
28
 *
29
 * If you wish your version of this file to be governed by only the CDDL
30
 * or only the GPL Version 2, indicate your decision by adding
31
 * "[Contributor] elects to include this software in this distribution
32
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
33
 * single choice of license, a recipient has the option to distribute
34
 * your version of this file under either the CDDL, the GPL Version 2 or
35
 * to extend the choice of license to its licensees as provided above.
36
 * However, if you add GPL Version 2 code and therefore, elected the GPL
37
 * Version 2 license, then the option applies only if the new code is
38
 * made subject to such option by the copyright holder.
39
 *
40
 * Contributor(s):
41
 *
42
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
43
 */
44
45
46
import java.util.Collection;
47
import org.apache.maven.artifact.Artifact;
48
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
49
50
/**
51
 * 
52
 * Used internally.
53
 * 
54
 * Implementation of repository indexer (repository manager). Apart from basic
55
 * indexing features also serves as provider of various index queries.
56
 * There is one implementation based on apache indexer
57
 * 
58
 * @author Milos Kleint
59
 */
60
public interface RepositoryIndexerImplementation {
61
    
62
    /**
63
     * Index local repository or retrieve remote prepopulated index for local use.
64
     * @param repo
65
     */
66
    void indexRepo(RepositoryInfo repo);
67
    
68
    void updateIndexWithArtifacts(RepositoryInfo repo, Collection<Artifact> artifacts);
69
70
    void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact);
71
72
}
(-)maven.indexer/test/unit/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImplTest.java (-2 / +10 lines)
Lines 46-53 Link Here
46
import java.util.Collections;
46
import java.util.Collections;
47
import java.util.List;
47
import java.util.List;
48
import org.apache.maven.index.ArtifactInfo;
48
import org.apache.maven.index.ArtifactInfo;
49
import org.netbeans.junit.MockServices;
50
import org.netbeans.modules.maven.indexer.api.AbstractTestQueryProvider.TestIndexer1;
49
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
51
import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
50
import org.netbeans.modules.maven.indexer.api.QueryField;
52
import org.netbeans.modules.maven.indexer.api.QueryField;
53
import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
51
import org.openide.util.test.TestFileUtils;
54
import org.openide.util.test.TestFileUtils;
52
55
53
public class NexusRepositoryIndexerImplTest extends NexusTestBase {
56
public class NexusRepositoryIndexerImplTest extends NexusTestBase {
Lines 56-65 Link Here
56
        super(n);
59
        super(n);
57
    }
60
    }
58
    
61
    
59
    public void testFilterGroupIds() throws Exception {
62
    public void testFilterPluginGroupIdsRepositoryQueries() throws Exception {
63
        // add an alternative QueryProvider _not_ handlig our request
64
        MockServices.setServices(TestIndexer1.class); 
65
        
60
        install(File.createTempFile("whatever", ".txt", getWorkDir()), "test", "spin", "1.1", "txt");
66
        install(File.createTempFile("whatever", ".txt", getWorkDir()), "test", "spin", "1.1", "txt");
61
        nrii.indexRepo(info);
67
        nrii.indexRepo(info);
62
        assertEquals("[test]", nrii.filterGroupIds("", Collections.singletonList(info)).getResults().toString());
68
        // RepositoryQueries should handle the query via our NexusRepositoryIndexerImpl
69
        RepositoryQueries.Result<String> res = RepositoryQueries.getArtifactsResult("test", Collections.singletonList(info));        
70
        assertEquals("[spin]", res.getResults().toString());
63
    }
71
    }
64
72
65
    public void testFind() throws Exception {
73
    public void testFind() throws Exception {
(-)maven.indexer/test/unit/src/org/netbeans/modules/maven/indexer/NexusTestBase.java (-1 / +2 lines)
Lines 49-54 Link Here
49
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
49
import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
50
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
50
import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
51
import org.openide.modules.api.PlacesTestUtils;
51
import org.openide.modules.api.PlacesTestUtils;
52
import org.openide.util.Lookup;
52
import org.openide.util.Utilities;
53
import org.openide.util.Utilities;
53
import org.openide.util.test.TestFileUtils;
54
import org.openide.util.test.TestFileUtils;
54
55
Lines 75-81 Link Here
75
        artifactInstaller = embedder.lookupComponent(ArtifactInstaller.class);
76
        artifactInstaller = embedder.lookupComponent(ArtifactInstaller.class);
76
        info = new RepositoryInfo("test", "Test", repo.getAbsolutePath(), null);
77
        info = new RepositoryInfo("test", "Test", repo.getAbsolutePath(), null);
77
        RepositoryPreferences.getInstance().addOrModifyRepositoryInfo(info);
78
        RepositoryPreferences.getInstance().addOrModifyRepositoryInfo(info);
78
        nrii = new NexusRepositoryIndexerImpl();
79
        nrii = Lookup.getDefault().lookup(NexusRepositoryIndexerImpl.class);
79
    }
80
    }
80
81
81
    @Override protected Level logLevel() {
82
    @Override protected Level logLevel() {
(-)maven.indexer/test/unit/src/org/netbeans/modules/maven/indexer/api/AbstractTestQueryProvider.java (+181 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2016 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2016 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.indexer.api;
43
44
import java.net.URISyntaxException;
45
import java.util.Arrays;
46
import java.util.Collection;
47
import java.util.List;
48
import org.apache.maven.artifact.Artifact;
49
import org.netbeans.modules.maven.indexer.spi.ArchetypeQueries;
50
import org.netbeans.modules.maven.indexer.spi.BaseQueries;
51
import org.netbeans.modules.maven.indexer.spi.ChecksumQueries;
52
import org.netbeans.modules.maven.indexer.spi.ClassUsageQuery;
53
import org.netbeans.modules.maven.indexer.spi.ClassesQuery;
54
import org.netbeans.modules.maven.indexer.spi.ContextLoadedQuery;
55
import org.netbeans.modules.maven.indexer.spi.DependencyInfoQueries;
56
import org.netbeans.modules.maven.indexer.spi.GenericFindQuery;
57
import org.netbeans.modules.maven.indexer.spi.ResultImplementation;
58
import org.openide.util.Exceptions;
59
import org.netbeans.modules.maven.indexer.spi.RepositoryIndexQueryProvider;
60
61
/**
62
 *
63
 * @author tomas
64
 */
65
public abstract class AbstractTestQueryProvider implements RepositoryIndexQueryProvider {
66
67
    private static final String TESTREPO = "testrepo";
68
    
69
    public static class TestIndexer1 extends AbstractTestQueryProvider {
70
        public static final String ID = TESTREPO + ".1";
71
        public static RepositoryInfo REPO;
72
        static {
73
            try {REPO = new RepositoryInfo(ID, ID, null, "http://test1"); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); }
74
        }
75
        public TestIndexer1() {
76
            this.repos = new RepositoryInfo[] {REPO};
77
        }
78
        protected String getID() {
79
            return ID;
80
        }
81
    }
82
    public static class TestIndexer2 extends AbstractTestQueryProvider {
83
        public static final String ID = TESTREPO + ".2";
84
        public static RepositoryInfo REPO;
85
        static {
86
            try {REPO = new RepositoryInfo(ID, ID, null, "http://test1"); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); }
87
        }
88
        public TestIndexer2() {
89
            this.repos = new RepositoryInfo[] {REPO};
90
        }
91
        
92
        protected String getID() {
93
            return ID;
94
        }
95
    }
96
    
97
    protected RepositoryInfo[] repos;
98
    public AbstractTestQueryProvider() {
99
    }
100
101
    @Override
102
    public boolean handlesRepository(RepositoryInfo repo) {
103
        for (RepositoryInfo r : repos) {
104
            if(repo.getId().equals(r.getId())) {
105
                return true;
106
            }
107
        }    
108
        return false;
109
    }
110
111
    abstract protected String getID();
112
113
    @Override
114
    public ArchetypeQueries getArchetypeQueries() {
115
        return new ArchetypeQueries() {
116
            @Override
117
            public ResultImplementation<NBVersionInfo> findArchetypes(List<RepositoryInfo> repos) {
118
                return new ResultImplementation<NBVersionInfo>() {
119
                    @Override
120
                    public boolean isPartial() {
121
                        return false;
122
                    }
123
124
                    @Override
125
                    public void waitForSkipped() { }
126
127
                    @Override
128
                    public List<NBVersionInfo> getResults() {
129
                        return Arrays.asList(new NBVersionInfo(getID(), getID(), getID(), "1.0", "jar", "jar", "test", "test", null));
130
                    }
131
132
                    @Override
133
                    public int getTotalResultCount() {
134
                        return 1;
135
                    }
136
137
                    @Override
138
                    public int getReturnedResultCount() {
139
                        return 1;
140
                    }
141
                };
142
            }
143
        };
144
    }
145
    
146
    @Override
147
    public BaseQueries getBaseQueries() {
148
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
149
    }
150
151
    @Override
152
    public ChecksumQueries getChecksumQueries() {
153
        return null;
154
    }
155
156
    @Override
157
    public ClassUsageQuery getClassUsageQuery() {
158
        return null;
159
    }
160
161
    @Override
162
    public ClassesQuery getClassesQuery() {
163
        return null;
164
    }
165
166
    @Override
167
    public ContextLoadedQuery getContextLoadedQuery() {
168
        return null;
169
    }
170
171
    @Override
172
    public DependencyInfoQueries getDependencyInfoQueries() {
173
        return null;
174
    }
175
176
    @Override
177
    public GenericFindQuery getGenericFindQuery() {
178
        return null;
179
    }
180
181
}
(-)maven.indexer/test/unit/src/org/netbeans/modules/maven/indexer/api/RepositoryQueriesTest.java (+144 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.indexer.api;
44
45
import java.io.File;
46
import java.net.URISyntaxException;
47
import java.util.ArrayList;
48
import java.util.Arrays;
49
import java.util.Collections;
50
import java.util.List;
51
import org.netbeans.junit.MockServices;
52
import org.netbeans.junit.NbTestCase;
53
import org.netbeans.modules.maven.indexer.api.AbstractTestQueryProvider.TestIndexer1;
54
import org.netbeans.modules.maven.indexer.api.AbstractTestQueryProvider.TestIndexer2;
55
import org.netbeans.modules.maven.indexer.spi.ArchetypeQueries;
56
import org.openide.util.Exceptions;
57
58
public class RepositoryQueriesTest extends NbTestCase {
59
60
    public RepositoryQueriesTest(String name) {
61
        super(name);
62
    }
63
    
64
    @Override 
65
    protected void setUp() throws Exception {
66
        super.setUp();
67
    }
68
    
69
    public void testAlternativeQueryProvider() throws URISyntaxException {
70
        
71
    }
72
    
73
    public void testAlternativeResult() throws URISyntaxException {
74
        MockServices.setServices(TestIndexer1.class);
75
        
76
        RepositoryQueries.Result<NBVersionInfo> result = RepositoryQueries.findArchetypesResult(Arrays.asList(TestIndexer1.REPO));
77
        assertEquals(TestIndexer1.ID, result.getResults().get(0).getArtifactId());
78
        assertEquals(1, result.getTotalResultCount());
79
        assertEquals(1, result.getReturnedResultCount());
80
    }
81
    
82
    public void testTwoReposTwoQueryProviders() throws URISyntaxException {
83
        MockServices.setServices(TestIndexer1.class, TestIndexer2.class);
84
85
        RepositoryQueries.Result<NBVersionInfo> result = RepositoryQueries.findArchetypesResult(Arrays.asList(TestIndexer1.REPO, TestIndexer2.REPO));
86
        assertEquals(2, result.getTotalResultCount());
87
        assertEquals(2, result.getReturnedResultCount());
88
        assertArtefactIds(result.getResults(), new String[] {TestIndexer1.ID, TestIndexer2.ID});
89
    }
90
    
91
    public void testTwoReposOneAccepted() throws URISyntaxException {
92
        MockServices.setServices(TestIndexer1.class);
93
        
94
        RepositoryQueries.Result<NBVersionInfo> result = RepositoryQueries.findArchetypesResult(Arrays.asList(TestIndexer1.REPO, TestIndexer2.REPO));
95
        assertEquals(1, result.getTotalResultCount());
96
        assertEquals(1, result.getReturnedResultCount());
97
        assertArtefactIds(result.getResults(), new String[] {TestIndexer1.ID});
98
    }
99
    
100
    public void testNullResult() throws URISyntaxException {
101
        MockServices.setServices(NullQueryProvider.class);
102
        List<RepositoryInfo> repos = Arrays.asList(NullQueryProvider.REPO);
103
        assertEquals(0, RepositoryQueries.findArchetypesResult(repos).getTotalResultCount());
104
        assertEquals(0, RepositoryQueries.findBySHA1Result(new File(""), Arrays.asList(NullQueryProvider.REPO)).getTotalResultCount());
105
        assertEquals(0, RepositoryQueries.findClassUsagesResult("", repos).getTotalResultCount());
106
        assertEquals(0, RepositoryQueries.findDependencyUsageResult("","","", repos).getTotalResultCount());
107
        assertEquals(0, RepositoryQueries.findResult(Collections.EMPTY_LIST, repos).getTotalResultCount());
108
        assertEquals(0, RepositoryQueries.findVersionsByClassResult("", repos).getTotalResultCount());
109
        assertEquals(0, RepositoryQueries.getLoadedContexts().size());
110
    }
111
112
    private void assertArtefactIds(List<NBVersionInfo> infos, String[] ids) {
113
        assertEquals(ids.length, infos.size());
114
        List<String> returnedIds = new ArrayList<>(infos.size());
115
        infos.stream().forEach((info) -> returnedIds.add(info.getArtifactId()));
116
        for (String id : ids) {
117
            assertTrue(returnedIds.contains(id));
118
        }
119
    }
120
121
    public static class NullQueryProvider extends AbstractTestQueryProvider {
122
        static final String ID = "nullrepo";
123
        static RepositoryInfo REPO;
124
        static {
125
            try {
126
                REPO = new RepositoryInfo(ID, ID, null, "http://test1");
127
            } catch (URISyntaxException ex) {
128
                Exceptions.printStackTrace(ex);
129
            }
130
        }
131
132
        public NullQueryProvider() {
133
            this.repos = new RepositoryInfo[] {REPO};
134
        }
135
        protected String getID() {
136
            return ID;
137
        }
138
        @Override
139
        public ArchetypeQueries getArchetypeQueries() {
140
            return null;
141
        }        
142
    }
143
144
}

Return to bug 257567