diff --git a/source/de/anomic/soap/services/AdminService.java b/source/de/anomic/soap/services/AdminService.java index 59b35c40e..28ee5451b 100644 --- a/source/de/anomic/soap/services/AdminService.java +++ b/source/de/anomic/soap/services/AdminService.java @@ -68,11 +68,13 @@ public class AdminService extends AbstractService { * Used Plasmaswitchboard config properties * ===================================================================== */ private static final String _10_HTTPD = "10_httpd"; - private static final String _62_REMOTETRIGGEREDCRAWL_BUSYSLEEP = "62_remotetriggeredcrawl_busysleep"; - private static final String _62_REMOTETRIGGEREDCRAWL = "62_remotetriggeredcrawl"; + private static final String RESTART = "restart"; + + // peer properties private static final String PORT = "port"; private static final String PEER_NAME = "peerName"; - private static final String RESTART = "restart"; + + // remote proxy properties private static final String REMOTE_PROXY_USE = "remoteProxyUse"; private static final String REMOTE_PROXY_USE4SSL = "remoteProxyUse4SSL"; private static final String REMOTE_PROXY_USE4YACY = "remoteProxyUse4Yacy"; @@ -81,12 +83,24 @@ public class AdminService extends AbstractService { private static final String REMOTE_PROXY_USER = "remoteProxyUser"; private static final String REMOTE_PROXY_PORT = "remoteProxyPort"; private static final String REMOTE_PROXY_HOST = "remoteProxyHost"; + + // remote triggered crawl properties private static final String CRAWL_RESPONSE = "crawlResponse"; + private static final String _62_REMOTETRIGGEREDCRAWL_BUSYSLEEP = "62_remotetriggeredcrawl_busysleep"; + private static final String _62_REMOTETRIGGEREDCRAWL = "62_remotetriggeredcrawl"; + + // index transfer properties private static final String INDEX_RECEIVE_BLOCK_BLACKLIST = "indexReceiveBlockBlacklist"; private static final String ALLOW_RECEIVE_INDEX = "allowReceiveIndex"; private static final String ALLOW_DISTRIBUTE_INDEX_WHILE_CRAWLING = "allowDistributeIndexWhileCrawling"; private static final String ALLOW_DISTRIBUTE_INDEX = "allowDistributeIndex"; + // message forwarding properties + private static final String MSG_FORWARDING_TO = "msgForwardingTo"; + private static final String MSG_FORWARDING_CMD = "msgForwardingCmd"; + private static final String MSG_FORWARDING_ENABLED = "msgForwardingEnabled"; + private static final String MSG_FORWARDING = "msgForwarding"; + /* ===================================================================== * Used XML Templates @@ -473,7 +487,7 @@ public class AdminService extends AbstractService { public Document getTransferProperties() throws AxisFault, ParserConfigurationException { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // creating XML document Element xmlElement = null; @@ -498,4 +512,75 @@ public class AdminService extends AbstractService { return xmlDoc; } + + /** + * + * @param enableForwarding + * @param forwardingCommand + * @param forwardingTo + * @throws AxisFault + * + * @link Peer Configuration - Message Forwarding + */ + public void setMessageForwarding( + Boolean enableForwarding, + String forwardingCommand, + String forwardingTo + ) throws AxisFault { + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + // index Distribution on/off + if (enableForwarding != null) { + this.switchboard.setConfig(MSG_FORWARDING_ENABLED, enableForwarding.toString()); + } + + if (forwardingCommand != null) { + this.switchboard.setConfig(MSG_FORWARDING_CMD, forwardingCommand); + } + + if (forwardingTo != null) { + this.switchboard.setConfig(MSG_FORWARDING_TO, forwardingTo); + } + } + + /** + * + * @return a XML document of the following format + *
+     * <?xml version="1.0" encoding="UTF-8"?>
+     * <msgForwarding>
+     *   <msgForwardingEnabled>false</msgForwardingEnabled>
+     *   <msgForwardingCmd>/usr/sbin/sendmail</msgForwardingCmd>
+     *   <msgForwardingTo>root@localhost</msgForwardingTo>
+     * </msgForwarding>
+     * 
+ * @throws AxisFault + * @throws ParserConfigurationException + * + * @link Peer Configuration - Message Forwarding + */ + public Document getMessageForwarding() throws AxisFault, ParserConfigurationException { + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + // creating XML document + Element xmlElement = null; + Document xmlDoc = createNewXMLDocument(MSG_FORWARDING); + Element xmlRoot = xmlDoc.getDocumentElement(); + + xmlElement = xmlDoc.createElement(MSG_FORWARDING_ENABLED); + xmlElement.appendChild(xmlDoc.createTextNode(Boolean.toString(this.switchboard.getConfigBool(MSG_FORWARDING_ENABLED,false)))); + xmlRoot.appendChild(xmlElement); + + xmlElement = xmlDoc.createElement(MSG_FORWARDING_CMD); + xmlElement.appendChild(xmlDoc.createTextNode(this.switchboard.getConfig(MSG_FORWARDING_CMD,""))); + xmlRoot.appendChild(xmlElement); + + xmlElement = xmlDoc.createElement(MSG_FORWARDING_TO); + xmlElement.appendChild(xmlDoc.createTextNode(this.switchboard.getConfig(MSG_FORWARDING_TO,""))); + xmlRoot.appendChild(xmlElement); + + return xmlDoc; + } } diff --git a/source/de/anomic/soap/services/BlacklistService.java b/source/de/anomic/soap/services/BlacklistService.java index ca3249e42..e4b2bc04c 100644 --- a/source/de/anomic/soap/services/BlacklistService.java +++ b/source/de/anomic/soap/services/BlacklistService.java @@ -122,7 +122,7 @@ public class BlacklistService extends AbstractService { // check if the blacklist already exists if (blacklistExists(blacklistName)) - throw new AxisFault("Blacklist with name '" + blacklistName + "' already exist."); + throw new AxisFault("Blacklist with name '" + blacklistName + "' already exist."); // creating the new file createBlacklistFile(blacklistName); diff --git a/source/de/anomic/soap/services/admin.wsdl b/source/de/anomic/soap/services/admin.wsdl index 1310f1f3f..2027a405e 100644 --- a/source/de/anomic/soap/services/admin.wsdl +++ b/source/de/anomic/soap/services/admin.wsdl @@ -1,175 +1,197 @@ - + + + - + + + + - - + + - + - + - - + - + + - - - - - + + + + + + + + - + - + + + - + + + + - - + + + - - + + + + + + + + - - - - - - - - - + + + - - - + + + - + - + - + - + - + - + - + + + + + + + + + + - @@ -177,9 +199,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -187,9 +209,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -197,9 +219,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -207,9 +229,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -217,9 +239,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -227,9 +249,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -237,9 +259,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -247,9 +269,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -257,9 +279,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -267,9 +289,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -277,9 +299,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -287,9 +309,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -297,9 +319,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -307,9 +329,29 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + + + + + + + + + + + + + + + + + + + + @@ -317,9 +359,9 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + - @@ -327,5 +369,6 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + \ No newline at end of file diff --git a/test/de/anomic/soap/services/AdminServiceTest.java b/test/de/anomic/soap/services/AdminServiceTest.java new file mode 100644 index 000000000..2e72d923b --- /dev/null +++ b/test/de/anomic/soap/services/AdminServiceTest.java @@ -0,0 +1,66 @@ +package de.anomic.soap.services; + +import java.rmi.RemoteException; +import java.util.HashMap; + +import javax.xml.rpc.ServiceException; +import javax.xml.transform.TransformerException; + +import org.apache.axis.utils.XMLUtils; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; + +import yacy.soap.admin.AdminService; +import yacy.soap.admin.AdminServiceServiceLocator; + +import com.sun.org.apache.xpath.internal.XPathAPI; + +public class AdminServiceTest extends AbstractServiceTest { + + protected void createServiceClass() throws ServiceException { + // construct Soap object + AdminServiceServiceLocator locator = new AdminServiceServiceLocator(); + locator.setadminEndpointAddress(getBaseServiceURL() + "admin"); + + service = locator.getadmin(); + } + + private HashMap getMessageForwardingProperties(Document xml) throws DOMException, TransformerException { + HashMap result = new HashMap(); + + result.put("msgForwardingEnabled",Boolean.valueOf(XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingEnabled").getTextContent())); + result.put("msgForwardingCmd",XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingCmd").getTextContent()); + result.put("msgForwardingTo",XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingTo").getTextContent()); + + return result; + } + + public void testMessageForwarding() throws RemoteException, TransformerException { + // backup old values + HashMap oldValues = getMessageForwardingProperties(((AdminService)service).getMessageForwarding()); + + // set new values + Boolean msgEnabled = Boolean.TRUE; + String msgCmd = "/usr/sbin/sendmail"; + String msgTo = "yacy@localhost"; + ((AdminService)service).setMessageForwarding(msgEnabled.booleanValue(),msgCmd,msgTo); + + // query configured properties + Document xml = ((AdminService)service).getMessageForwarding(); + + // check if values are equal + assertEquals(msgEnabled,Boolean.valueOf(XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingEnabled").getTextContent())); + assertEquals(msgCmd,XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingCmd").getTextContent()); + assertEquals(msgTo,XPathAPI.selectSingleNode(xml,"/msgForwarding/msgForwardingTo").getTextContent()); + + // print it out + System.out.println(XMLUtils.DocumentToString(xml)); + + // set back to old values + ((AdminService)service).setMessageForwarding( + ((Boolean)oldValues.get("msgForwardingEnabled")).booleanValue(), + (String)oldValues.get("msgForwardingCmd"), + (String)oldValues.get("msgForwardingTo") + ); + } +} diff --git a/test/de/anomic/soap/services/ServiceTests.java b/test/de/anomic/soap/services/ServiceTests.java index b53b69349..5b155267b 100644 --- a/test/de/anomic/soap/services/ServiceTests.java +++ b/test/de/anomic/soap/services/ServiceTests.java @@ -8,6 +8,7 @@ public class ServiceTests { public static Test suite() { TestSuite suite = new TestSuite("Test for de.anomic.soap.services"); //$JUnit-BEGIN$ + suite.addTestSuite(AdminServiceTest.class); suite.addTestSuite(ShareServiceTest.class); suite.addTestSuite(StatusServiceTest.class); suite.addTestSuite(BlacklistServiceTest.class);