diff --git a/build.xml b/build.xml
index a417001f0..e1e215d1a 100644
--- a/build.xml
+++ b/build.xml
@@ -97,6 +97,7 @@
+
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.java
index 9e6f8cb2a..256df6fd8 100644
--- a/htroot/Blacklist_p.java
+++ b/htroot/Blacklist_p.java
@@ -224,7 +224,7 @@ public class Blacklist_p {
}
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + ".BlackLists",blacklistToUse)) {
- plasmaSwitchboard.urlBlacklist.add(supportedBlacklistTypes[blTypes],oldEntry.substring(0, pos), oldEntry.substring(pos + 1));
+ plasmaSwitchboard.urlBlacklist.remove(supportedBlacklistTypes[blTypes],oldEntry.substring(0, pos));
}
}
diff --git a/source/de/anomic/soap/AbstractService.java b/source/de/anomic/soap/AbstractService.java
index c143c4f3c..8d9dc1fde 100644
--- a/source/de/anomic/soap/AbstractService.java
+++ b/source/de/anomic/soap/AbstractService.java
@@ -79,6 +79,10 @@ public abstract class AbstractService {
protected httpHeader requestHeader;
protected MessageContext messageContext;
+ protected static final boolean NO_AUTHENTICATION = false;
+ protected static final boolean AUTHENTICATION_NEEDED = true;
+
+
/**
* This function is called by the available service functions to
* extract all needed informations from the SOAP message context.
@@ -167,6 +171,8 @@ public abstract class AbstractService {
} catch (Exception e) {
if (e instanceof AxisFault) throw (AxisFault) e;
+ e.printStackTrace();
+
// create a new AxisFault Object
throw new AxisFault(e.getMessage());
}
diff --git a/source/de/anomic/soap/build.xml b/source/de/anomic/soap/build.xml
index 2d2000359..3f7cce37f 100644
--- a/source/de/anomic/soap/build.xml
+++ b/source/de/anomic/soap/build.xml
@@ -30,9 +30,10 @@
+
-
+
diff --git a/source/de/anomic/soap/httpdSoapHandler.java b/source/de/anomic/soap/httpdSoapHandler.java
index ad8a46086..68ba07400 100644
--- a/source/de/anomic/soap/httpdSoapHandler.java
+++ b/source/de/anomic/soap/httpdSoapHandler.java
@@ -149,7 +149,8 @@ public final class httpdSoapHandler extends httpdAbstractHandler implements http
"search=de.anomic.soap.services.SearchService",
"crawl=de.anomic.soap.services.CrawlService",
"status=de.anomic.soap.services.StatusService",
- "admin=de.anomic.soap.services.AdminService"
+ "admin=de.anomic.soap.services.AdminService",
+ "blacklist=de.anomic.soap.services.BlacklistService"
};
/* ===============================================================
diff --git a/source/de/anomic/soap/services/BlacklistService.java b/source/de/anomic/soap/services/BlacklistService.java
new file mode 100644
index 000000000..1d1a0aaea
--- /dev/null
+++ b/source/de/anomic/soap/services/BlacklistService.java
@@ -0,0 +1,443 @@
+package de.anomic.soap.services;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.apache.axis.AxisFault;
+import org.w3c.dom.Document;
+
+import de.anomic.data.listManager;
+import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.soap.AbstractService;
+
+public class BlacklistService extends AbstractService {
+
+
+ private static final String LIST_MANAGER_LISTS_PATH = "listManager.listsPath";
+ private static final String BLACKLISTS = ".BlackLists";
+ private static final String BLACKLISTS_TYPES = "BlackLists.types";
+ private final static String BLACKLIST_SHARED = "BlackLists.Shared";
+
+ /* =====================================================================
+ * Used XML Templates
+ * ===================================================================== */
+ private static final String TEMPLATE_BLACKLIST_XML = "xml/blacklists_p.xml";
+
+
+
+
+ public Document getBlacklistList() throws Exception {
+ try {
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // generating the template containing the network status information
+ byte[] result = writeTemplate(TEMPLATE_BLACKLIST_XML, new serverObjects());
+
+ // sending back the result to the client
+ return this.convertContentToXML(result);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public void createBlacklist(String blacklistName, boolean shareBlacklist, String[] activateForBlacklistTypes) throws IOException {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // check if we know all types passed to this function
+ checkForKnownBlacklistTypes(activateForBlacklistTypes);
+
+ if (blacklistName.indexOf("/") != -1)
+ throw new IllegalArgumentException("Blacklist name must not contain '/'.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist already exists
+ if (blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' already exist.");
+
+ // creating the new file
+ createBlacklistFile(blacklistName);
+
+ // share the newly created blacklist
+ if (shareBlacklist) doShareBlacklist(blacklistName);
+
+ // activate blacklist
+ this.activateBlacklistForTypes(blacklistName,activateForBlacklistTypes);
+ }
+
+ public void deleteBlacklist(String blacklistName) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // deactivate list
+ deativateBlacklistForAllTypes(blacklistName);
+
+ // unshare list
+ doUnshareBlacklist(blacklistName);
+
+ // delete the file
+ deleteBlacklistFile(blacklistName);
+ }
+
+ public void shareBlacklist(String blacklistName) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // share blacklist
+ this.doShareBlacklist(blacklistName);
+ }
+
+ public void unshareBlacklist(String blacklistName) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // share blacklist
+ this.doUnshareBlacklist(blacklistName);
+ }
+
+ public void activateBlacklist(String blacklistName, String[] activateForBlacklistTypes) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // check if we know all types passed to this function
+ checkForKnownBlacklistTypes(activateForBlacklistTypes);
+
+ // activate blacklist
+ activateBlacklistForTypes(blacklistName, activateForBlacklistTypes);
+ }
+
+ public void deactivateBlacklist(String blacklistName, String[] deactivateForBlacklistTypes) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+
+ // check if we know all types passed to this function
+ checkForKnownBlacklistTypes(deactivateForBlacklistTypes);
+
+ // activate blacklist
+ deactivateBlacklistForTypes(blacklistName, deactivateForBlacklistTypes);
+ }
+
+ public void addBlacklistItem(String blacklistName, String blacklistItem) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+ if ((blacklistItem == null)||(blacklistItem.length() == 0))
+ throw new IllegalArgumentException("Blacklist item must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // prepare item
+ blacklistItem = prepareBlacklistItem(blacklistItem);
+
+ // TODO: check if the entry is already in there
+
+ // append the line to the file
+ addBlacklistItemToFile(blacklistItem, blacklistName);
+
+ // pass the entry to the blacklist engine
+ addBlacklistItemToBlacklist(blacklistItem, blacklistName);
+ }
+
+ public void removeBlacklistItem(String blacklistName, String blacklistItem) throws AxisFault {
+ // Check for errors
+ if ((blacklistName == null)||(blacklistName.length() == 0))
+ throw new IllegalArgumentException("Blacklist name must not be null or empty.");
+ if ((blacklistItem == null)||(blacklistItem.length() == 0))
+ throw new IllegalArgumentException("Blacklist item must not be null or empty.");
+
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // initialize the list manager
+ initBlacklistManager();
+
+ // check if the blacklist file exists
+ if (!blacklistExists(blacklistName))
+ throw new AxisFault("Blacklist with name '" + blacklistName + "' does not exist.");
+
+ // prepare item
+ blacklistItem = prepareBlacklistItem(blacklistItem);
+
+ // remove blacklist from file
+ removeBlacklistItemFromBlacklistFile(blacklistItem,blacklistName);
+
+ // remove it from the blacklist engine
+ removeBlacklistItemFromBlacklist(blacklistItem,blacklistName);
+ }
+
+ public String[] getBlacklistTypes() throws AxisFault {
+ // extracting the message context
+ extractMessageContext(AUTHENTICATION_NEEDED);
+
+ // return supported types
+ return getSupportedBlacklistTypeArray();
+ }
+
+ private void addBlacklistItemToBlacklist(String blacklistItem, String blacklistName) {
+ // split the item into host part and path
+ String[] itemParts = getBlacklistItemParts(blacklistItem);
+
+ // getting the supported blacklist types
+ String[] supportedBlacklistTypes = getSupportedBlacklistTypeArray();
+
+ // loop through the various types
+ for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
+
+ // if the current blacklist is activated for the type, add the item to the list
+ if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + BLACKLISTS,blacklistName)) {
+ plasmaSwitchboard.urlBlacklist.add(supportedBlacklistTypes[blTypes],itemParts[0], itemParts[1]);
+ }
+ }
+ }
+
+ private void addBlacklistItemToFile(String blacklistItem, String blacklistName) throws AxisFault {
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(new FileWriter(getBlacklistFile(blacklistName), true));
+ pw.println(blacklistItem);
+ pw.close();
+ } catch (IOException e) {
+ throw new AxisFault("Unable to append blacklist entry.",e);
+ } finally {
+ if (pw != null) try { pw.close(); } catch (Exception e){ /* */}
+ }
+ }
+
+ private void removeBlacklistItemFromBlacklistFile(String blacklistItem, String blacklistName) {
+ // load blacklist data from file
+ ArrayList list = listManager.getListArray(getBlacklistFile(blacklistName));
+
+ // delete the old entry from file
+ if (list != null) {
+ for (int i=0; i < list.size(); i++) {
+ if (((String)list.get(i)).equals(blacklistItem)) {
+ list.remove(i);
+ break;
+ }
+ }
+ listManager.writeList(getBlacklistFile(blacklistName), (String[])list.toArray(new String[list.size()]));
+ }
+ }
+
+ private void removeBlacklistItemFromBlacklist(String blacklistItem, String blacklistName) {
+ String[] itemParts = getBlacklistItemParts(blacklistItem);
+
+ // getting the supported blacklist types
+ String[] supportedBlacklistTypes = getSupportedBlacklistTypeArray();
+
+ // loop through the various types
+ for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
+
+ // if the current blacklist is activated for the type, remove the item from the list
+ if (listManager.ListInListslist(supportedBlacklistTypes[blTypes] + BLACKLISTS,blacklistName)) {
+ plasmaSwitchboard.urlBlacklist.remove(supportedBlacklistTypes[blTypes],itemParts[0]);
+ }
+ }
+ }
+
+ private String prepareBlacklistItem(String blacklistItem) {
+ if (blacklistItem == null) throw new NullPointerException("Item is null");
+
+ // cut of heading http://
+ if (blacklistItem.startsWith("http://") ){
+ blacklistItem = blacklistItem.substring("http://".length());
+ }
+
+ // adding missing parts
+ int pos = blacklistItem.indexOf("/");
+ if (pos < 0) {
+ // add default empty path pattern
+ blacklistItem = blacklistItem + "/.*";
+ }
+ return blacklistItem;
+ }
+
+ private String[] getBlacklistItemParts(String blacklistItem) {
+ if (blacklistItem == null) throw new NullPointerException("Item is null");
+
+ int pos = blacklistItem.indexOf("/");
+ if (pos == -1) throw new IllegalArgumentException("Item format is not correct.");
+
+ return new String[] {
+ blacklistItem.substring(0, pos),
+ blacklistItem.substring(pos + 1)
+ };
+ }
+
+ private String[] getSharedBlacklistArray() {
+ String sharedBlacklists = this.switchboard.getConfig(BLACKLIST_SHARED, "");
+ String[] supportedBlacklistTypeArray = sharedBlacklists.split(",");
+ return supportedBlacklistTypeArray;
+ }
+
+ private File getBlacklistFile(String blacklistName) {
+ File blacklistFile = new File(listManager.listsPath, blacklistName);
+ return blacklistFile;
+ }
+
+ private boolean blacklistExists(String blacklistName) {
+ File blacklistFile = getBlacklistFile(blacklistName);
+ return blacklistFile.exists();
+ }
+
+ private HashSet getSharedBlacklistSet() {
+ HashSet supportedTypesSet = new HashSet(Arrays.asList(getSharedBlacklistArray()));
+ return supportedTypesSet;
+ }
+
+ private String[] getSupportedBlacklistTypeArray() {
+ String supportedBlacklistTypesStr = this.switchboard.getConfig(BLACKLISTS_TYPES, "");
+ String[] supportedBlacklistTypeArray = supportedBlacklistTypesStr.split(",");
+ return supportedBlacklistTypeArray;
+ }
+
+ private void createBlacklistFile(String blacklistName) throws IOException {
+ File newFile = getBlacklistFile(blacklistName);
+ newFile.createNewFile();
+ }
+
+ private void deleteBlacklistFile(String blacklistName) {
+ File BlackListFile = new File(listManager.listsPath, blacklistName);
+ BlackListFile.delete();
+ }
+
+ private void doShareBlacklist(String blacklistName) {
+ listManager.addListToListslist(BLACKLIST_SHARED, blacklistName);
+ }
+
+ private void doUnshareBlacklist(String blacklistName) {
+ listManager.removeListFromListslist(BLACKLIST_SHARED, blacklistName);
+ }
+
+ private void initBlacklistManager() {
+ // init Manager properties
+ if (listManager.switchboard == null)
+ listManager.switchboard = (plasmaSwitchboard) this.switchboard;
+
+ if (listManager.listsPath == null)
+ listManager.listsPath = new File(listManager.switchboard.getRootPath(),listManager.switchboard.getConfig(LIST_MANAGER_LISTS_PATH, "DATA/LISTS"));
+ }
+
+ private void ativateBlacklistForAllTypes(String blacklistName) {
+ String[] supportedBlacklistTypes = getSupportedBlacklistTypeArray();
+ this.activateBlacklistForTypes(blacklistName,supportedBlacklistTypes);
+ }
+
+ private void activateBlacklistForTypes(String blacklistName, String[] activateForBlacklistTypes) {
+ if (activateForBlacklistTypes == null) return;
+
+ for (int blTypes=0; blTypes < activateForBlacklistTypes.length; blTypes++) {
+ listManager.addListToListslist(activateForBlacklistTypes[blTypes] + BLACKLISTS, blacklistName);
+ }
+ }
+
+ private void deativateBlacklistForAllTypes(String blacklistName) {
+ String[] supportedBlacklistTypes = getSupportedBlacklistTypeArray();
+ this.deactivateBlacklistForTypes(blacklistName,supportedBlacklistTypes);
+ }
+
+ private void deactivateBlacklistForTypes(String blacklistName, String[] deactivateForBlacklistTypes) {
+ if (deactivateForBlacklistTypes == null) return;
+
+ for (int blTypes=0; blTypes < deactivateForBlacklistTypes.length; blTypes++) {
+ listManager.removeListFromListslist(deactivateForBlacklistTypes[blTypes] + BLACKLISTS, blacklistName);
+ }
+ }
+
+ private HashSet getSupportedBlacklistTypeSet() {
+ HashSet supportedTypesSet = new HashSet(Arrays.asList(getSupportedBlacklistTypeArray()));
+ return supportedTypesSet;
+ }
+
+ private void checkForKnownBlacklistTypes(String[] types) throws AxisFault {
+ if (types == null) return;
+
+ // get kown blacklist types
+ HashSet supportedTypesSet = getSupportedBlacklistTypeSet();
+
+ // check if we know all types stored in the array
+ for (int i=0; i < types.length; i++) {
+ if (!supportedTypesSet.contains(types[i]))
+ throw new AxisFault("Unknown blaclist type '" + types[i] + "' at position " + i);
+ }
+ }
+
+}
diff --git a/source/de/anomic/soap/services/StatusService.java b/source/de/anomic/soap/services/StatusService.java
index c1f435e2a..feb0ddf45 100644
--- a/source/de/anomic/soap/services/StatusService.java
+++ b/source/de/anomic/soap/services/StatusService.java
@@ -70,7 +70,7 @@ public class StatusService extends AbstractService {
public Document network() throws AxisFault {
try {
// extracting the message context
- extractMessageContext(false);
+ extractMessageContext(NO_AUTHENTICATION);
// generating the template containing the network status information
byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects());
@@ -110,7 +110,7 @@ public class StatusService extends AbstractService {
Integer remotecrawlerqueueCount
) throws Exception {
// extracting the message context
- extractMessageContext(true);
+ extractMessageContext(AUTHENTICATION_NEEDED);
// passing parameters to servlet
serverObjects input = new serverObjects();
diff --git a/source/de/anomic/soap/services/blacklist.wsdl b/source/de/anomic/soap/services/blacklist.wsdl
new file mode 100644
index 000000000..2647b9b7d
--- /dev/null
+++ b/source/de/anomic/soap/services/blacklist.wsdl
@@ -0,0 +1,243 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/de/anomic/soap/services/AbstractServiceTest.java b/test/de/anomic/soap/services/AbstractServiceTest.java
new file mode 100644
index 000000000..50f2230d3
--- /dev/null
+++ b/test/de/anomic/soap/services/AbstractServiceTest.java
@@ -0,0 +1,66 @@
+package de.anomic.soap.services;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.rmi.Remote;
+import java.util.Properties;
+
+import javax.xml.rpc.ServiceException;
+
+import org.apache.axis.client.Stub;
+
+import yacy.soap.status.StatusService;
+import yacy.soap.status.StatusServiceServiceLocator;
+import junit.framework.TestCase;
+
+public abstract class AbstractServiceTest extends TestCase {
+ protected static final String SOAP_HEADER_NAMESPACE = "http://http.anomic.de/header";
+ protected static final String SOAP_HEADER_AUTHORIZATION = "Authorization";
+
+ protected static String authString;
+ protected static String peerPort;
+ protected static Remote service;
+
+ protected void setUp() throws Exception {
+ if (peerPort == null) this.loadConfigProperties();
+ super.setUp();
+ }
+
+ protected abstract void createServiceClass() throws ServiceException;
+
+ protected String getBaseServiceURL() {
+ return "http://localhost:" + peerPort + "/soap/";
+ }
+
+ protected void loadConfigProperties() throws Exception {
+ BufferedInputStream fileInput = null;
+ try {
+ File configFile = new File("DATA/SETTINGS/httpProxy.conf");
+ System.out.println("Reading config file: " + configFile.getAbsoluteFile().toString());
+ fileInput = new BufferedInputStream(new FileInputStream(configFile));
+
+ // load property list
+ Properties peerProperties = new Properties();
+ peerProperties.load(fileInput);
+ fileInput.close();
+
+ // getting admin account auth string
+ authString = peerProperties.getProperty("adminAccountBase64MD5");
+ if (authString == null) throw new Exception("Unable to find authentication information.");
+
+ peerPort = peerProperties.getProperty("port");
+ if (authString == null) throw new Exception("Unable to find peer port information.");
+
+ // creating the service class
+ createServiceClass();
+
+ // setting the authentication header
+ ((Stub)service).setHeader(SOAP_HEADER_NAMESPACE,SOAP_HEADER_AUTHORIZATION,authString);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (fileInput != null) try { fileInput.close(); } catch (Exception e){/* ignore this */}
+ }
+ }
+}
diff --git a/test/de/anomic/soap/services/BlacklistServiceTest.java b/test/de/anomic/soap/services/BlacklistServiceTest.java
new file mode 100644
index 000000000..46c33ada8
--- /dev/null
+++ b/test/de/anomic/soap/services/BlacklistServiceTest.java
@@ -0,0 +1,65 @@
+package de.anomic.soap.services;
+
+import java.rmi.RemoteException;
+
+import javax.xml.rpc.ServiceException;
+
+import org.apache.axis.utils.XMLUtils;
+import org.w3c.dom.Document;
+
+import yacy.soap.blacklist.BlacklistService;
+import yacy.soap.blacklist.BlacklistServiceServiceLocator;
+
+public class BlacklistServiceTest extends AbstractServiceTest {
+
+ protected void createServiceClass() throws ServiceException {
+ // construct Soap object
+ BlacklistServiceServiceLocator locator = new BlacklistServiceServiceLocator();
+ locator.setblacklistEndpointAddress(getBaseServiceURL() + "blacklist");
+
+ service = locator.getblacklist();
+ }
+
+ public void testGetBlacklistList() throws RemoteException {
+ Document xml = ((BlacklistService)service).getBlacklistList();
+ System.out.println(XMLUtils.DocumentToString(xml));
+ }
+
+ public void testBlacklist() throws RemoteException {
+ BlacklistService bl = ((BlacklistService)service);
+
+ // create new blacklist
+ String blacklistName = "junit_test_" + System.currentTimeMillis();
+ bl.createBlacklist(blacklistName,false,null);
+
+ // share blacklist
+ bl.shareBlacklist(blacklistName);
+
+ // getting supported blacklist Types
+ String[] blTypes = bl.getBlacklistTypes();
+
+ // activate blacklist
+ bl.activateBlacklist(blacklistName,blTypes);
+
+ // add blacklist item
+ String item = "http://www.yacy.net";
+ bl.addBlacklistItem(blacklistName,item);
+
+ // getting the blacklist list
+ Document xml = ((BlacklistService)service).getBlacklistList();
+ System.out.println(XMLUtils.DocumentToString(xml));
+
+ // remove blacklist item
+ bl.removeBlacklistItem(blacklistName,item);
+
+ // unshare
+ bl.unshareBlacklist(blacklistName);
+
+ // deactivate for proxy and dht
+ bl.deactivateBlacklist(blacklistName,new String[]{"proxy","dht"});
+
+ // delete blacklist
+ bl.deleteBlacklist(blacklistName);
+ }
+
+}
diff --git a/test/de/anomic/soap/services/StatusServiceTest.java b/test/de/anomic/soap/services/StatusServiceTest.java
index 2b78399fe..f1fd52900 100644
--- a/test/de/anomic/soap/services/StatusServiceTest.java
+++ b/test/de/anomic/soap/services/StatusServiceTest.java
@@ -1,70 +1,32 @@
package de.anomic.soap.services;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.rmi.RemoteException;
-import java.util.Properties;
-import junit.framework.TestCase;
+import javax.xml.rpc.ServiceException;
-import org.apache.axis.client.Stub;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
import yacy.soap.status.StatusService;
import yacy.soap.status.StatusServiceServiceLocator;
-public class StatusServiceTest extends TestCase {
- private static String authString;
- private static String peerPort;
- private static StatusService service;
-
-
- protected void setUp() throws Exception {
- if (peerPort == null) this.loadConfigProperties();
- super.setUp();
- }
-
- private void loadConfigProperties() throws Exception {
- BufferedInputStream fileInput = null;
- try {
- File configFile = new File("DATA/SETTINGS/httpProxy.conf");
- System.out.println("Reading config file: " + configFile.getAbsoluteFile().toString());
- fileInput = new BufferedInputStream(new FileInputStream(configFile));
-
- // load property list
- Properties peerProperties = new Properties();
- peerProperties.load(fileInput);
- fileInput.close();
-
- // getting admin account auth string
- authString = peerProperties.getProperty("adminAccountBase64MD5");
- if (authString == null) throw new Exception("Unable to find authentication information.");
-
- peerPort = peerProperties.getProperty("port");
- if (authString == null) throw new Exception("Unable to find peer port information.");
-
- // construct Soap object
- StatusServiceServiceLocator locator = new StatusServiceServiceLocator();
- locator.setstatusEndpointAddress("http://localhost:" + peerPort + "/soap/status");
-
- service = locator.getstatus();
- ((Stub)service).setHeader("http://http.anomic.de/header","Authorization",authString);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (fileInput != null) try { fileInput.close(); } catch (Exception e){/* ignore this */}
- }
- }
+public class StatusServiceTest extends AbstractServiceTest {
+
+ protected void createServiceClass() throws ServiceException {
+ // construct Soap object
+ StatusServiceServiceLocator locator = new StatusServiceServiceLocator();
+ locator.setstatusEndpointAddress(getBaseServiceURL() + "status");
+
+ service = locator.getstatus();
+ }
public void testNetwork() throws RemoteException {
- Document xml = service.network();
+ Document xml = ((StatusService)service).network();
System.out.println(XMLUtils.DocumentToString(xml));
}
public void testGetQueueStatus() throws RemoteException {
- Document xml = service.getQueueStatus(null,null,null,null);
+ Document xml = ((StatusService)service).getQueueStatus(null,null,null,null);
System.out.println(XMLUtils.DocumentToString(xml));
}
}