Corrected access to Load_MediawikiWiki.html and Load_PHPBB3.html

A NullPointerException occured when trying to access theses pages in
Robinson (Search portal) mode
pull/39/head
luc 9 years ago
parent 85a9363012
commit 231be83eb6

@ -24,6 +24,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.util.Set;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants; import net.yacy.search.SwitchboardConstants;
@ -38,10 +40,16 @@ public class Load_MediawikiWiki {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
// define visible variables // define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()); String a;
if (a == null) a = "localhost:" + sb.getLocalPort(); Set<String> ips = sb.peers.mySeed().getIPs();
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet"); /* There may eventually have no registered ip in mySeed, for example in Robinson mode : this shouldn't prevent crawling a MediaWiki */
final String repository = "http://" + a + "/repository/"; if(ips != null && !ips.isEmpty()) {
a = sb.peers.mySeed().getPublicAddress(ips.iterator().next());
} else {
a = "localhost:" + sb.getLocalPort();
}
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
final String repository = "http://" + a + "/repository/";
prop.put("starturl", (intranet) ? repository : "http://"); prop.put("starturl", (intranet) ? repository : "http://");
prop.put("address", a); prop.put("address", a);

@ -24,6 +24,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import java.util.Set;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants; import net.yacy.search.SwitchboardConstants;
@ -38,8 +40,14 @@ public class Load_PHPBB3 {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
// define visible variables // define visible variables
String a = sb.peers.mySeed().getPublicAddress(sb.peers.mySeed().getIP()); String a;
if (a == null) a = "localhost:" + sb.getLocalPort(); Set<String> ips = sb.peers.mySeed().getIPs();
/* There may eventually have no registered ip in mySeed, for example in Robinson mode : this shouldn't prevent crawling a MediaWiki */
if(ips != null && !ips.isEmpty()) {
a = sb.peers.mySeed().getPublicAddress(ips.iterator().next());
} else {
a = "localhost:" + sb.getLocalPort();
}
final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet"); final boolean intranet = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "").equals("intranet");
final String repository = "http://" + a + "/repository/"; final String repository = "http://" + a + "/repository/";
prop.put("starturl", (intranet) ? repository : "http://"); prop.put("starturl", (intranet) ? repository : "http://");

Loading…
Cancel
Save