- changed default browser from netscape to firefox

- fixed "Inefficient use of keySet iterator instead of entrySet iterator" [WMI_WRONG_MAP_ITERATOR, FindBugs]
- fixed some possible null pointer accesses


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5063 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
danielr 17 years ago
parent 7989335ed6
commit 753a1ae430

@ -452,7 +452,7 @@ staticIP=
# the browser type is optional and works only under certain conditions
browserPopUpTrigger=true
browserPopUpPage=ConfigBasic.html
browserPopUpApplication=netscape
browserPopUpApplication=firefox
# defines if the YaCy icon appears in the system tray on supported platforms
trayIcon=true

@ -39,6 +39,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@ -114,12 +115,11 @@ public class BlacklistCleaner_p {
prop.put(RESULTS + "disabled", (ies.size() == 0) ? "1" : "0");
if (ies.size() > 0) {
prop.put(RESULTS + DISABLED + "entries", ies.size());
final Iterator<String> it = ies.keySet().iterator();
int i = 0;
String s;
while (it.hasNext()) {
s = it.next();
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", ies.get(s).longValue());
for (Entry<String, Integer> entry: ies.entrySet()) {
s = entry.getKey();
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", entry.getValue().longValue());
prop.putHTML(RESULTS + DISABLED + ENTRIES + i + "_entry", s);
i++;
}

@ -39,9 +39,18 @@ public class IndexShare_p {
public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {
// return variable that accumulates replacements
final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();
final serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) {
if(switchboard == null) {
prop.put("linkfreq", "30");
prop.put("wordfreq", "10");
prop.put("dtable", "");
prop.put("rtable", "");
prop.putNum("wcount", 0);
prop.putNum("ucount", 0);
return prop; // be save
}
if (post == null) {
prop.put("linkfreq", switchboard.getConfig("defaultLinkReceiveFrequency","30"));
prop.put("wordfreq", switchboard.getConfig("defaultWordReceiveFrequency","10"));
prop.put("dtable", "");

@ -27,6 +27,7 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import de.anomic.http.HttpClient;
import de.anomic.http.httpHeader;
@ -125,12 +126,9 @@ public class News {
prop.putHTML("table_list_" + i + "_att", attributeMap.toString());
int j = 0;
if (attributeMap.size() > 0) {
final Iterator<String> attributeKeys = attributeMap.keySet().iterator();
while (attributeKeys.hasNext()) {
final String key = attributeKeys.next();
final String value = attributeMap.get(key);
prop.put("table_list_" + i + "_attributes_" + j + "_name",key);
prop.putHTML("table_list_" + i + "_attributes_" + j + "_value",value);
for (Entry<String, String> attribute: attributeMap.entrySet()) {
prop.put("table_list_" + i + "_attributes_" + j + "_name", attribute.getKey());
prop.putHTML("table_list_" + i + "_attributes_" + j + "_value", attribute.getValue());
j++;
}
}

@ -26,8 +26,8 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSearchEvent;
@ -104,11 +104,10 @@ public class Ranking_p {
private static void putRanking(final serverObjects prop, final Map<String, String> map, final String prefix, final String attrExtension) {
prop.put("attr" + attrExtension, map.size());
final Iterator<String> it = map.keySet().iterator();
String key;
int i, j = 0;
while (it.hasNext()) {
key = it.next();
for (final Entry<String, String> entry: map.entrySet()) {
key = entry.getKey();
prop.put("attr" + attrExtension + "_" + j + "_name", rankingParameters.get(key.substring(prefix.length())));
prop.put("attr" + attrExtension + "_" + j + "_nameorg", key);
prop.put("attr" + attrExtension + "_" + j + "_select", maxRankingRange);
@ -117,7 +116,7 @@ public class Ranking_p {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_value", i);
try {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked",
(i == Integer.valueOf(map.get(key)).intValue()) ? "1" : "0");
(i == Integer.valueOf(entry.getValue()).intValue()) ? "1" : "0");
} catch (final NumberFormatException e) {
prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked", "0");
}
@ -135,10 +134,12 @@ public class Ranking_p {
plasmaSearchEvent.cleanupEvents(true);
// case if no values are requested
if ((post == null) || (env == null)) {
if ((post == null) || (sb == null)) {
// we create empty entries for template strings
final serverObjects prop = defaultValues();
final plasmaSearchRankingProfile ranking = sb.getRanking();
final plasmaSearchRankingProfile ranking;
if(sb == null) ranking = new plasmaSearchRankingProfile(plasmaSearchQuery.CONTENTDOM_TEXT);
else ranking = sb.getRanking();
putRanking(prop, ranking, "local");
return prop;
}

@ -33,6 +33,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
import de.anomic.data.htmlTools;
import de.anomic.http.httpHeader;
@ -95,8 +96,10 @@ public class Threaddump_p {
final File classPath = new File(rootPath, "source");
for (final Thread thread: stackTraces.keySet()) {
final StackTraceElement[] stackTraceElements = stackTraces.get(thread);
Thread thread;
for (final Entry<Thread, StackTraceElement[]> entry: stackTraces.entrySet()) {
thread = entry.getKey();
final StackTraceElement[] stackTraceElements = entry.getValue();
StackTraceElement ste;
String line;
String tracename = "";

@ -178,7 +178,7 @@ public final class hello {
serverCore.checkInterruption();
final StringBuffer seeds = new StringBuffer(768);
// attach some more seeds, as requested
if ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.sizeConnected() > 0)) {
if (sb.webIndex.seedDB.sizeConnected() > 0) {
if (count > sb.webIndex.seedDB.sizeConnected()) { count = sb.webIndex.seedDB.sizeConnected(); }
if (count > 100) { count = 100; }

@ -48,6 +48,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
@ -772,10 +773,9 @@ public class bookmarksDB {
writer.close();
links = scraper.getAnchors();
} catch (final IOException e) { serverLog.logWarning("BOOKMARKS", "error during load of links: "+ e.getClass() +" "+ e.getMessage());}
final Iterator<yacyURL> it = links.keySet().iterator();
while (it.hasNext()) {
url= it.next();
title=links.get(url);
for (Entry<yacyURL, String> link: links.entrySet()) {
url= link.getKey();
title=link.getValue();
serverLog.logInfo("BOOKMARKS", "links.get(url)");
if(title.equals("")){//cannot be displayed
title=url.toString();

@ -432,13 +432,12 @@ public final class userDB {
if (timeStamp < 0) throw new IllegalArgumentException();
final Long lastAccess = this.getLastAccess();
long oldTimeUsed = getTimeUsed();
long newTimeUsed = oldTimeUsed;
long newTimeUsed = getTimeUsed();
if (incrementTimeUsed) {
if ((lastAccess == null)||((lastAccess != null)&&(timeStamp-lastAccess.longValue()>=1000*60))) { //1 minute
//this.mem.put(TIME_USED,Long.toString(newTimeUsed = ++oldTimeUsed));
newTimeUsed = ++oldTimeUsed;
newTimeUsed++;
if(lastAccess != null){
this.oldDate.setTime(new Date(lastAccess.longValue()));
this.newDate.setTime(new Date(System.currentTimeMillis()));

@ -343,12 +343,8 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
FileOutputStream fos = null;
try {
fos = new FileOutputStream(f);
final Iterator<String> i = keySet().iterator();
String key, value;
while (i.hasNext()) {
key = i.next();
value = get(key);
fos.write((key + "=" + value + "\r\n").getBytes());
for (java.util.Map.Entry<String, String> entry: entrySet()) {
fos.write((entry.getKey() + "=" + entry.getValue() + "\r\n").getBytes());
}
fos.flush();
} finally {

@ -29,6 +29,7 @@ package de.anomic.index;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@ -99,11 +100,12 @@ public class indexDefaultReferenceBlacklist extends indexAbstractReferenceBlackl
// loop over all Regexentrys
if(!matched) {
final HashMap<String, ArrayList<String>> blacklistMapNotMatched = super.getBlacklistMap(blacklistType,false);
for(final String key: blacklistMapNotMatched.keySet()) {
String key;
for(final Entry<String, ArrayList<String>> entry: blacklistMapNotMatched.entrySet()) {
key = entry.getKey();
try {
if(Pattern.matches(key, hostlow)) {
app = blacklistMapNotMatched.get(key);
app = entry.getValue();
for (int i=0; i<app.size(); i++) {
if(Pattern.matches(app.get(i), path))
return true;

@ -34,6 +34,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Map.Entry;
public class kelondroMSetTools {
@ -300,12 +301,11 @@ public class kelondroMSetTools {
}
private static <A, B> TreeMap<A, B> excludeConstructiveByTestMapInSet(final TreeMap<A, B> map, final TreeSet<A> set) {
final Iterator<A> mi = map.keySet().iterator();
final TreeMap<A, B> result = new TreeMap<A, B>(map.comparator());
A o;
while (mi.hasNext()) {
o = mi.next();
if (!(set.contains(o))) result.put(o, map.get(o));
for (Entry<A, B> entry: map.entrySet()) {
o = entry.getKey();
if (!(set.contains(o))) result.put(o, entry.getValue());
}
return result;
}

@ -48,6 +48,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -946,10 +947,9 @@ public final class plasmaParser {
// found links
int anchorNr = 0;
final Map<yacyURL, String> anchors = document.getAnchors();
final Iterator<yacyURL> anchorIter = anchors.keySet().iterator();
while (anchorIter.hasNext()) {
final yacyURL key = anchorIter.next();
System.out.println("URL " + anchorNr + ":\t" + key.toString() + " | " + anchors.get(key));
for (Entry<yacyURL, String> anchor: anchors.entrySet()) {
final yacyURL key = anchor.getKey();
System.out.println("URL " + anchorNr + ":\t" + key.toString() + " | " + anchor.getValue());
anchorNr++;
}
document.close();

@ -723,8 +723,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// clean search events which have cached relations to the old index
plasmaSearchEvent.cleanupEvents(true);
// switch the networks
synchronized (this.webIndex) {
this.webIndex.close();
synchronized (this) {
synchronized (this.webIndex) {
this.webIndex.close();
}
setConfig("network.unit.definition", networkDefinition);
overwriteNetworkDefinition(this);
final File indexPrimaryPath = getConfigPath(plasmaSwitchboardConstants.INDEX_PRIMARY_PATH, plasmaSwitchboardConstants.INDEX_PATH_DEFAULT);
@ -1685,7 +1687,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
if (System.currentTimeMillis() - lastPPMUpdate > 30000) {
// we don't want to do this too often
updateMySeed();
serverProfiling.update("ppm", new Long(currentPPM()));
serverProfiling.update("ppm", Long.valueOf(currentPPM()));
lastPPMUpdate = System.currentTimeMillis();
}
serverProfiling.update("indexed", queueEntry.url().toNormalform(true, false));
@ -1870,7 +1872,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
final long timeInterval = 1000 * 60 * 60;
final TreeSet<Long> accessSet = tracker.get(host);
if (accessSet == null) return 0;
return accessSet.tailSet(new Long(System.currentTimeMillis() - timeInterval)).size();
return accessSet.tailSet(Long.valueOf(System.currentTimeMillis() - timeInterval)).size();
}
public void startTransferWholeIndex(final yacySeed seed, final boolean delete) {
@ -2197,7 +2199,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
while (enu.hasNext()) {
ys = yacySeed.genRemoteSeed(enu.next(), null, false);
if ((ys != null) &&
((!webIndex.seedDB.mySeedIsDefined()) || (webIndex.seedDB.mySeed().hash != ys.hash))) {
((!webIndex.seedDB.mySeedIsDefined()) || !webIndex.seedDB.mySeed().hash.equals(ys.hash))) {
if (webIndex.peerActions.connectPeer(ys, false)) lc++;
//seedDB.writeMap(ys.hash, ys.getMap(), "init");
//System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());

@ -96,7 +96,7 @@ public final class plasmaWordIndex implements indexRI {
private final indexCollectionRI collections; // new database structure to replace AssortmentCluster and FileCluster
private final serverLog log;
indexRepositoryReference referenceURL;
public yacySeedDB seedDB;
public final yacySeedDB seedDB;
public yacyNewsPool newsPool;
private final File primaryRoot, secondaryRoot;
public IndexingStack queuePreStack;

@ -131,7 +131,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
HashMap<String, String> denyHost;
int commandMaxLength;
private int maxBusySessions;
ConcurrentHashMap<Session, Object> busySessions;
final ConcurrentHashMap<Session, Object> busySessions;
/*
private static ServerSocketFactory getServerSocketFactory(boolean dflt, File keyfile, String passphrase) {
@ -400,7 +400,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
Thread.interrupted();
// shut down all busySessions
if (this.busySessions != null) for (final Session session: this.busySessions.keySet()) {
for (final Session session: this.busySessions.keySet()) {
try {
session.interrupt();
} catch (final SecurityException e ) {
@ -420,7 +420,7 @@ public final class serverCore extends serverAbstractBusyThread implements server
// close all sessions
this.log.logInfo("Closing server sessions ...");
if (this.busySessions != null) for (final Session s: this.busySessions.keySet()) {
for (final Session s: this.busySessions.keySet()) {
s.interrupt();
s.close();
}

@ -50,7 +50,6 @@ import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import de.anomic.data.htmlTools;
@ -271,11 +270,10 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
// the keyMapper may contain regular expressions as defined in String.matches
// this method is particulary useful when parsing the result of checkbox forms
final ArrayList<String> v = new ArrayList<String>();
final Iterator<String> e = keySet().iterator();
String key;
while (e.hasNext()) {
key = e.next();
if (key.matches(keyMapper)) v.add(get(key));
for (Map.Entry<String, String> entry: entrySet()) {
key = entry.getKey();
if (key.matches(keyMapper)) v.add(entry.getValue());
}
// make a String[]
final String[] result = new String[v.size()];
@ -285,11 +283,8 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
// put all elements of another hashtable into the own table
public void putAll(final serverObjects add) {
final Iterator<String> e = add.keySet().iterator();
String k;
while (e.hasNext()) {
k = e.next();
put(k, add.get(k));
for (Map.Entry<String, String> entry: add.entrySet()) {
put(entry.getKey(), entry.getValue());
}
}
@ -298,11 +293,10 @@ public class serverObjects extends HashMap<String, String> implements Cloneable
BufferedOutputStream fos = null;
try {
fos = new BufferedOutputStream(new FileOutputStream(f));
final Iterator<String> e = keySet().iterator();
String key, value;
while (e.hasNext()) {
key = e.next();
value = get(key).replaceAll("\n", "\\\\n");
for (Map.Entry<String, String> entry: entrySet()) {
key = entry.getKey();
value = entry.getValue().replaceAll("\n", "\\\\n");
fos.write((key + "=" + value + "\r\n").getBytes());
}
} finally {

@ -318,7 +318,8 @@ public final class serverSystem {
}
} catch (final Exception e) {
System.err.println("ERROR "+ e.getClass() +" in openBrowser(): "+ e.getMessage());
System.out.println("please start your browser and open the following location: " + url);
// browser could not be started automatically, tell user to do it
System.out.println("please start your browser and open the following location: " + url);
}
}

@ -54,7 +54,6 @@ public class yacyPeerActions {
if (userAgents != null) userAgents.clear();
userAgents = null;
if (dhtAction != null) dhtAction.close();
dhtAction.close();
}
public synchronized boolean connectPeer(final yacySeed seed, final boolean direct) {

@ -346,7 +346,7 @@ public final class yacy {
final String browserPopUpPage = sb.getConfig("browserPopUpPage", "ConfigBasic.html");
//boolean properPW = (sb.getConfig("adminAccount", "").length() == 0) && (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);
//if (!properPW) browserPopUpPage = "ConfigBasic.html";
final String browserPopUpApplication = sb.getConfig("browserPopUpApplication", "netscape");
final String browserPopUpApplication = sb.getConfig("browserPopUpApplication", "firefox");
serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);
}

Loading…
Cancel
Save