Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

refactoring of method calling for objects from kelondroMapDataMining

orbiter0f5fe8cc530a
diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.java
index 1944277f1..cf82cfc6f 100644
--- a/source/de/anomic/crawler/CrawlProfile.java
+++ b/source/de/anomic/crawler/CrawlProfile.java
@@ -203,7 +203,12 @@ public class CrawlProfile {
}
public entry getEntry(String handle) {
- HashMap<String, String> m = profileTable.getMap(handle);
+ HashMap<String, String> m;
+ try {
+ m = profileTable.get(handle);
+ } catch (IOException e) {
+ return null;
+ }
if (m == null) return null;
return new entry(m);
}
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index 471ef95e9..7afae118b 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -117,12 +117,15 @@ public class RobotsTxt {
private Entry getEntry(String hostName) {
try {
- HashMap<String, String> record = this.robotsTable.getMap(hostName);
+ HashMap<String, String> record = this.robotsTable.get(hostName);
if (record == null) return null;
return new Entry(hostName, record);
} catch (kelondroException e) {
resetDatabase();
return null;
+ } catch (IOException e) {
+ resetDatabase();
+ return null;
}
}
diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.java
index 98e7c1d2e..90e3a54c3 100644
--- a/source/de/anomic/data/blogBoard.java
+++ b/source/de/anomic/data/blogBoard.java
@@ -139,9 +139,13 @@ public class blogBoard {
}
private BlogEntry readBlogEntry(String key, kelondroMapDataMining base) {
key = normalize(key);
- if (key.length() > keyLength)
- key = key.substring(0, keyLength);
- HashMap<String, String> record = base.getMap(key);
+ if (key.length() > keyLength) key = key.substring(0, keyLength);
+ HashMap<String, String> record;
+ try {
+ record = base.get(key);
+ } catch (IOException e) {
+ record = null;
+ }
if (record == null)
return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null);
return new BlogEntry(key, record);
diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.java
index dd0f2d51e..cc9f0968c 100644
--- a/source/de/anomic/data/blogBoardComments.java
+++ b/source/de/anomic/data/blogBoardComments.java
@@ -133,7 +133,12 @@ public class blogBoardComments {
private CommentEntry read(String key, kelondroMapDataMining base) {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
- HashMap<String, String> record = base.getMap(key);
+ HashMap<String, String> record;
+ try {
+ record = base.get(key);
+ } catch (IOException e) {
+ record = null;
+ }
if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
return new CommentEntry(key, record);
}
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index 225e46626..6997476a9 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -337,7 +337,11 @@ public class bookmarksDB {
private Tag loadTag(String hash){
HashMap<String, String> map;
Tag ret=null;
- map = tagsTable.getMap(hash);
+ try {
+ map = tagsTable.get(hash);
+ } catch (IOException e) {
+ return null;
+ }
if(map!=null){
ret=new Tag(hash, map);
tagCache.put(hash, ret);
@@ -520,7 +524,11 @@ public class bookmarksDB {
public bookmarksDate getDate(String date){
HashMap<String, String> map;
- map=datesTable.getMap(date);
+ try {
+ map=datesTable.get(date);
+ } catch (IOException e) {
+ map = null;
+ }
if(map==null) return new bookmarksDate(date);
return new bookmarksDate(date, map);
}
diff --git a/source/de/anomic/data/messageBoard.java b/source/de/anomic/data/messageBoard.java
index 082a58543..3b3e47957 100644
--- a/source/de/anomic/data/messageBoard.java
+++ b/source/de/anomic/data/messageBoard.java
@@ -216,7 +216,12 @@ public class messageBoard {
}
public entry read(String key) {
- HashMap<String, String> record = database.getMap(key);
+ HashMap<String, String> record;
+ try {
+ record = database.get(key);
+ } catch (IOException e) {
+ return null;
+ }
return new entry(key, record);
}
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index d79dcdd2a..4b7c2ee63 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -105,7 +105,12 @@ public final class userDB {
if(userName.length()>128){
userName=userName.substring(0, 127);
}
- HashMap<String, String> record = userTable.getMap(userName);
+ HashMap<String, String> record;
+ try {
+ record = userTable.get(userName);
+ } catch (IOException e) {
+ return null;
+ }
if (record == null) return null;
return new Entry(userName, record);
}
diff --git a/source/de/anomic/data/wikiBoard.java b/source/de/anomic/data/wikiBoard.java
index 74c704a39..11365f743 100644
--- a/source/de/anomic/data/wikiBoard.java
+++ b/source/de/anomic/data/wikiBoard.java
@@ -294,7 +294,7 @@ public class wikiBoard {
try {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
- HashMap<String, String> record = base.getMap(key);
+ HashMap<String, String> record = base.get(key);
if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
return new entry(key, record);
} catch (IOException e) {
diff --git a/source/de/anomic/kelondro/kelondroMapDataMining.java b/source/de/anomic/kelondro/kelondroMapDataMining.java
index 76a6c59fe..35b6fbf6b 100644
--- a/source/de/anomic/kelondro/kelondroMapDataMining.java
+++ b/source/de/anomic/kelondro/kelondroMapDataMining.java
@@ -94,7 +94,7 @@ public class kelondroMapDataMining extends kelondroMap {
this.elementCount = 0;
while (it.hasNext()) {
mapname = new String(it.next());
- map = getMap(new String(mapname));
+ map = super.get(new String(mapname));
if (map == null) break;
if (sortfields != null) for (int i = 0; i < sortfields.length; i++) {
@@ -179,7 +179,7 @@ public class kelondroMapDataMining extends kelondroMap {
// update elementCount
if ((longaccfields != null) || (doubleaccfields != null)) {
- final Map<String, String> oldMap = getMap(key, false);
+ final Map<String, String> oldMap = super.get(key, false);
if (oldMap == null) {
// new element
elementCount++;
@@ -252,7 +252,7 @@ public class kelondroMapDataMining extends kelondroMap {
// update elementCount
if ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) {
- final Map<String, String> map = getMap(key);
+ final Map<String, String> map = super.get(key);
if (map != null) {
// update count
elementCount--;
@@ -267,28 +267,6 @@ public class kelondroMapDataMining extends kelondroMap {
super.remove(key);
}
- public HashMap<String, String> getMap(String key) {
- try {
- HashMap<String, String> mapEntry = super.get(key);
- if (mapEntry == null) return null;
- return mapEntry;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- protected Map<String, String> getMap(String key, boolean cache) {
- try {
- HashMap<String, String> mapEntry = super.get(key, cache);
- if (mapEntry == null) return null;
- return mapEntry;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
private void deleteSortCluster(final String key) {
if (key == null) return;
kelondroMScoreCluster<String> cluster;
@@ -406,7 +384,11 @@ public class kelondroMapDataMining extends kelondroMap {
finish = true;
return null;
}
- map = getMap(nextKey);
+ try {
+ map = get(nextKey);
+ } catch (IOException e) {
+ break;
+ }
if (map == null) continue; // circumvention of a modified exception
map.put("key", nextKey);
return map;
diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java
index 2117c32ea..9b8355931 100644
--- a/source/de/anomic/plasma/plasmaHTCache.java
+++ b/source/de/anomic/plasma/plasmaHTCache.java
@@ -562,7 +562,12 @@ public final class plasmaHTCache {
public static IResourceInfo loadResourceInfo(yacyURL url) throws UnsupportedProtocolException, IllegalAccessException {
// loading data from database
- Map<String, String> hdb = responseHeaderDB.getMap(url.hash());
+ Map<String, String> hdb;
+ try {
+ hdb = responseHeaderDB.get(url.hash());
+ } catch (IOException e) {
+ return null;
+ }
if (hdb == null) return null;
// generate the cached object
@@ -746,7 +751,12 @@ public final class plasmaHTCache {
}
if (url != null) return url;
// try responseHeaderDB
- Map<String, String> hdb = responseHeaderDB.getMap(urlHash);
+ Map<String, String> hdb;
+ try {
+ hdb = responseHeaderDB.get(urlHash);
+ } catch (IOException e1) {
+ hdb = null;
+ }
if (hdb != null) {
Object origRequestLine = hdb.get(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE);
if ((origRequestLine != null)&&(origRequestLine instanceof String)) {
diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java
index 87a049a44..b77eee33b 100644
--- a/source/de/anomic/yacy/yacySeedDB.java
+++ b/source/de/anomic/yacy/yacySeedDB.java
@@ -542,7 +542,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasConnected(String hash) {
try {
- return (seedActiveDB.get(hash) != null);
+ return seedActiveDB.has(hash);
} catch (IOException e) {
return false;
}
@@ -550,7 +550,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasDisconnected(String hash) {
try {
- return (seedPassiveDB.get(hash) != null);
+ return seedPassiveDB.has(hash);
} catch (IOException e) {
return false;
}
@@ -558,7 +558,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasPotential(String hash) {
try {
- return (seedPotentialDB.get(hash) != null);
+ return seedPotentialDB.has(hash);
} catch (IOException e) {
return false;
}
@@ -567,7 +567,12 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
private yacySeed get(String hash, kelondroMapDataMining database) {
if (hash == null) return null;
if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
- HashMap<String, String> entry = database.getMap(hash);
+ HashMap<String, String> entry;
+ try {
+ entry = database.get(hash);
+ } catch (IOException e) {
+ entry = null;
+ }
if (entry == null) return null;
return new yacySeed(hash, entry);
}