IndexDatabase.java revision 1318
372N/A * See LICENSE.txt included in this distribution for the specific
372N/A * file and include the License file at LICENSE.txt.
372N/Apublic class IndexDatabase {
372N/A private boolean interrupted;
this(null);
initialize();
public void run() {
} catch (Throwable e) {
public static void update(ExecutorService executor, IndexChangedListener listener, List<String> paths) throws IOException {
} catch (IOException e) {
public void run() {
} catch (Throwable e) {
throw new FileNotFoundException("Failed to create root directory [" + indexDir.getAbsolutePath() + "]");
throw new FileNotFoundException("Failed to create root directory [" + spellDir.getAbsolutePath() + "]");
synchronized (lock) {
if (running) {
running = true;
interrupted = false;
//TODO we might need to add writer.commit after certain phases of index generation, right now it will only happen in the end
while (uidIter.term() != null && uidIter.term().field().equals("u") && uidIter.term().text().startsWith(startuid)) {
removeFile();
} catch (IOException e) {
} catch (IOException e) {
synchronized (lock) {
running = false;
optimize();
log.log(Level.WARNING, "Failed to set last modified time on ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
log.log(Level.WARNING, "Failed to create file ''{0}'', used for timestamping the index database.", timestamp.getAbsolutePath());
public void run() {
} catch (Throwable e) {
public void optimize() {
synchronized (lock) {
if (running) {
running = true;
synchronized (lock) {
dirty = false;
} catch (IOException e) {
} catch (IOException e) {
synchronized (lock) {
running = false;
public void createSpellingSuggestions() {
} catch (IOException e) {
} catch (IOException e) {
private boolean isDirty() {
synchronized (lock) {
return dirty;
private void setDirty() {
synchronized (lock) {
dirty = true;
} catch (IOException e) {
setDirty();
Document d;
} catch (Exception e) {
path);
setDirty();
log.log(Level.FINE, "Skipped symlink ''{0}'' -> ''{1}''", new Object[]{absolutePath, canonicalPath});
//below will only let go files and directories, anything else is considered special and is not added
absolutePath.substring(allowedSymlink.length()).equals(canonicalPath.substring(allowedTarget.length()))) {
boolean local = false;
local = true;
local = true;
return local;
private int indexDown(File dir, String parent, boolean count_only, int cur_count, int est_total) throws IOException {
if (isInterrupted()) {
return lcur_count;
return lcur_count;
return lcur_count;
lcur_count++;
if (count_only) {
if (RuntimeEnvironment.getInstance().isPrintProgress() && est_total > 0 && log.isLoggable(Level.INFO) )
log.log(Level.INFO, "Progress: {0} ({1}%)", new Object[]{lcur_count, (lcur_count * 100.0f / est_total) });
String uid = Util.path2uid(path, DateTools.timeToString(file.lastModified(), DateTools.Resolution.MILLISECOND)); // construct uid for doc
removeFile();
} catch (Exception e) {
return lcur_count;
public void interrupt() {
synchronized (lock) {
interrupted = true;
private boolean isInterrupted() {
synchronized (lock) {
return interrupted;
} catch (IOException e) {
} 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;