Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
enabled rebuildIndex for /Table_YMark_p.html (rebuilds the tags and folders index)
apfelmaennchen11ae5b108e63
diff --git a/htroot/Table_YMark_p.html b/htroot/Table_YMark_p.htmlindex fddc19a4d..a59508979 100644--- a/htroot/Table_YMark_p.html+++ b/htroot/Table_YMark_p.html@@ -55,7 +55,7 @@<input type="submit" name="addrow" value="Add a new Row" disabled/><input type="submit" name="deleterows" value="Delete Selected Rows" /><input type="submit" name="deletetable" value="Delete Table" />- <input type="submit" name="rebuildindex" value="Rebuild Index" disabled/>+ <input type="submit" name="rebuildindex" value="Rebuild Index" /></p><div id="table" style="float:left; overflow:auto;"><table class="sortable" border="0" cellpadding="2" cellspacing="1">diff --git a/htroot/Table_YMark_p.java b/htroot/Table_YMark_p.javaindex 139644637..170e4ef7e 100644--- a/htroot/Table_YMark_p.java+++ b/htroot/Table_YMark_p.java@@ -127,6 +127,14 @@ public class Table_YMark_p {Log.logException(e);}+ // apply rebuildIndex request+ if (post.get("rebuildindex", "").length() > 0) try {+ sb.tables.bookmarks.folders.rebuildIndex(bmk_user);+ sb.tables.bookmarks.tags.rebuildIndex(bmk_user);+ } catch (IOException e) {+ Log.logException(e);+ }+if (post.get("deleterows", "").length() > 0) {for (Map.Entry<String, String> entry: post.entrySet()) {if (entry.getValue().startsWith("mark_")) try {diff --git a/source/de/anomic/data/YMarkIndex.java b/source/de/anomic/data/YMarkIndex.javaindex 9144a8d35..4d7cbb526 100644--- a/source/de/anomic/data/YMarkIndex.java+++ b/source/de/anomic/data/YMarkIndex.java@@ -100,8 +100,8 @@ public class YMarkIndex {protected void removeIndexEntry(final String user, String keysString, final byte[] urlHash) {final String[] keyArray = keysString.split(YMarkTables.TAGS_SEPARATOR);- for (final String tag : keyArray) {- this.updateIndexTable(user, tag, urlHash, INDEX_ACTION.REMOVE);+ for (final String key : keyArray) {+ this.updateIndexTable(user, key, urlHash, INDEX_ACTION.REMOVE);}}@@ -166,6 +166,21 @@ public class YMarkIndex {}return urlSet;}++ public void rebuildIndex(final String bmk_user) throws IOException {+ final Iterator<Tables.Row> plainIterator = this.worktables.iterator(YMarkTables.TABLES.BOOKMARKS.tablename(bmk_user));+ this.clearCache();+ this.worktables.clear(bmk_user + this.table_basename);+ while (plainIterator.hasNext()) {+ Tables.Row row = plainIterator.next();+ if (row != null && row.containsKey(this.table_basename.substring(1))) {+ final String url = new String(row.get(YMarkTables.BOOKMARK.URL.key()));+ final String key = this.table_basename.substring(1);+ final String keysString = row.get(key, YMarkTables.BOOKMARK.get(key).deflt());+ this.insertIndexEntry(bmk_user, keysString, YMarkTables.getBookmarkId(url));+ }+ }+ }/*** YMark function that updates the tag/folder index