IndexDatabase.java revision 1127
207N/A * See LICENSE.txt included in this distribution for the specific
207N/A * file and include the License file at LICENSE.txt.
207N/Apublic class IndexDatabase {
207N/A private boolean interrupted;
207N/A initialize();
207N/A static void updateAll(ExecutorService executor, IndexChangedListener listener) throws IOException {
668N/A public static void update(ExecutorService executor, IndexChangedListener listener, List<String> paths) throws IOException {
668N/A } catch (IOException e) {
580N/A throw new FileNotFoundException("Failed to create root directory [" + indexDir.getAbsolutePath() + "]");
580N/A throw new FileNotFoundException("Failed to create root directory [" + spellDir.getAbsolutePath() + "]");
456N/A interrupted = false;
274N/A //TODO we might need to add writer.commit after certain phases of index generation, right now it will only happen in the end
274N/A writer = new IndexWriter(indexDirectory, AnalyzerGuru.getAnalyzer(),IndexWriter.MaxFieldLength.UNLIMITED);
207N/A //TODO below should be optional, since it traverses the tree once more to get total count! :(
359N/A while (uidIter.term() != null && uidIter.term().field().equals("u") && uidIter.term().text().startsWith(startuid)) {
207N/A removeFile();
672N/A } catch (IOException e) {
207N/A } catch (IOException e) {
564N/A log.log(Level.WARNING, "Failed to set last modified time on ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
270N/A log.log(Level.WARNING, "Failed to create file ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
207N/A } catch (IOException e) {
830N/A } catch (IOException e) {
207N/A public void createSpellingSuggestions() {
359N/A } catch (IOException e) {
460N/A } catch (IOException e) {
515N/A } catch (IOException e) {
207N/A log.log(Level.FINE, "Skipped symlink ''{0}'' -> ''{1}''", new Object[]{absolutePath, canonicalPath});
207N/A //below will only let go files and directories, anything else is considered special and is not added
207N/A private boolean acceptSymlink(String absolutePath, String canonicalPath) throws IOException {
594N/A absolutePath.substring(allowedSymlink.length()).equals(canonicalPath.substring(allowedTarget.length()))) {
207N/A private int indexDown(File dir, String parent, boolean count_only, int cur_count, int est_total) throws IOException {
207N/A if (isInterrupted()) {
207N/A return lcur_count;
207N/A return lcur_count;
460N/A return lcur_count;
207N/A lcur_count++;
460N/A if (count_only) {
207N/A if (RuntimeEnvironment.getInstance().isPrintProgress() && est_total > 0 && log.isLoggable(Level.INFO) )
207N/A log.log(Level.INFO, "Progress: {0} ({1}%)", new Object[]{lcur_count, (lcur_count * 100.0f / est_total) });
207N/A String uid = Util.uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); // construct uid for doc
207N/A removeFile();
459N/A return lcur_count;
207N/A interrupted = true;
207N/A private boolean isInterrupted() {
460N/A return interrupted;
208N/A } catch (IOException e) {
274N/A } catch (IOException e) {
} catch (IOException e) {
} catch (IOException e) {
if (p == null) {
return null;
return ret;
return null;
return null;
return null;
if (this.project != other.project && (this.project == null || !this.project.equals(other.project))) {
public int hashCode() {
return hash;