*) blacklists can be exported as XML or plain text now

*) blacklist import via file upload works now

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5412 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 16 years ago
parent 1594a15be9
commit cf69557ea2

@ -38,15 +38,52 @@
</form>
<!-- blacklist import from file -->
<form action="sharedBlacklist_p.html" method="get">
<form action="sharedBlacklist_p.html" method="post" enctype="multipart/form-data">
<fieldset>
<legend>file:</legend>
<legend>plain text file:</legend>
Upload a regular text file which contains one blacklist entry per line.<br /><br />
<input type="hidden" name="currentBlacklist" value="#[currentBlacklist]#" />
<input type="text" name="file" />
<input type="file" name="file" />
<input type="submit" value="Load new blacklist items" />
</fieldset>
</form>
</fieldset>::#(/disabled)#
<fieldset class="exportListItems">
<legend>Export blacklist items to...</legend>
<form action="xml/blacklists_p.xml" method="get">
<fieldset>
<legend>XML file:</legend>
Here you can export a blacklist as an XML file. This file will contain additional
information about which cases a blacklist is activated for.<br /><br />
<select name="listname">
<option value="">all</option>
#{blackListNames}#
<option value="#[blackListName]#">#[blackListName]#</option>
#{/blackListNames}#
</select>
<input type="submit" value="Export list as XML" />
</fieldset>
</form>
<form action="yacy/list.html" method="get">
<fieldset>
<legend>plain text file:</legend>
Here you can export a blacklist as a regular text file with one blacklist entry per line.
This file will not contain any additional information.<br /><br />
<select name="listname">
<option value="">all</option>
#{blackListNames}#
<option value="#[blackListName]#">#[blackListName]#</option>
#{/blackListNames}#
</select>
<input type="hidden" name="col" value="black" />
<input type="submit" value="Export list as text" />
</fieldset>
</form>
</fieldset>
#%env/templates/footer.template%#
</body>
</html>

@ -42,7 +42,7 @@ import de.anomic.yacy.yacySeed;
import java.util.List;
public class BlacklistImpExp_p {
private final static String DISABLED = "disabled_";
private final static String DISABLED = "disabled_";
public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
@ -63,7 +63,6 @@ public class BlacklistImpExp_p {
blacklistToUse = dirlist.get(0);
}
// List known hosts for BlackList retrieval
if (sb.webIndex.seedDB != null && sb.webIndex.seedDB.sizeConnected() > 0) { // no nullpointer error
int peerCount = 0;
@ -87,9 +86,18 @@ public class BlacklistImpExp_p {
prop.put(DISABLED + "otherHosts", peerCount);
}
prop.putXML(DISABLED + "currentBlacklist", (blacklistToUse==null) ? "" : blacklistToUse);
prop.put("disabled", (blacklistToUse == null) ? "1" : "0");
int count = 0;
for (String element : dirlist) {
if (element.endsWith(".black")) {
prop.putHTML("blackListNames_" + count + "_blackListName", element);
count++;
}
}
prop.put("blackListNames", count);
return prop;
}
}

@ -31,6 +31,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
@ -47,6 +48,9 @@ import de.anomic.server.serverSwitch;
import de.anomic.tools.nxTools;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacyURL;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class sharedBlacklist_p {
@ -167,12 +171,14 @@ public class sharedBlacklist_p {
final String sourceFileName = post.get("file");
prop.putHTML("page_source", sourceFileName);
final File sourceFile = new File(listManager.listsPath, sourceFileName);
if (!sourceFile.exists() || !sourceFile.canRead() || !sourceFile.isFile()) {
prop.put("status", STATUS_FILE_ERROR);
prop.put("page", "1");
} else {
otherBlacklist = listManager.getListArray(sourceFile);
final String fileString = post.get("file$file");
if (fileString != null) {
try {
otherBlacklist = nxTools.strings(fileString.getBytes("UTF-8"), "UTF-8");
} catch (IOException ex) {
Logger.getLogger(sharedBlacklist_p.class.getName()).log(Level.SEVERE, null, ex);
}
}
} else if (post.containsKey("add")) {

Loading…
Cancel
Save