From 892b9f2fc4043a15425854ae0ea0701c173cc21f Mon Sep 17 00:00:00 2001 From: theli Date: Sun, 5 Nov 2006 16:46:32 +0000 Subject: [PATCH] *) additional soap function to query peer status git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2920 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../de/anomic/soap/services/AdminService.java | 30 ++++++++-------- .../anomic/soap/services/StatusService.java | 17 ++++++++++ source/de/anomic/soap/services/status.wsdl | 34 +++++++++++++++---- .../soap/services/StatusServiceTest.java | 7 +++- 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/source/de/anomic/soap/services/AdminService.java b/source/de/anomic/soap/services/AdminService.java index c3780c43e..aedefee20 100644 --- a/source/de/anomic/soap/services/AdminService.java +++ b/source/de/anomic/soap/services/AdminService.java @@ -130,7 +130,7 @@ public class AdminService extends AbstractService { * ===================================================================== */ private static final String TEMPLATE_CONFIG_XML = "xml/config_p.xml"; private static final String TEMPLATE_VERSION_XML = "xml/version.xml"; - private static final String TEMPLATE_PROFILE_XML = "ViewProfile.xml"; + private static final String TEMPLATE_PROFILE_XML = "ViewProfile.xml"; /** * This function can be used to set a configuration option @@ -143,7 +143,7 @@ public class AdminService extends AbstractService { if ((key == null)||(key.length() == 0)) throw new IllegalArgumentException("Key must not be null or empty."); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // add key to switchboard if (value == null) value = ""; @@ -164,7 +164,7 @@ public class AdminService extends AbstractService { if (keys.length != values.length) throw new IllegalArgumentException("Invalid input. " + keys.length + " keys but " + values.length + " values received."); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); for (int i=0; i < keys.length; i++) { // get the key @@ -191,7 +191,7 @@ public class AdminService extends AbstractService { if ((key == null)||(key.length() == 0)) throw new IllegalArgumentException("Key must not be null or empty."); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // get the config property return this.switchboard.getConfig(key,null); @@ -208,7 +208,7 @@ public class AdminService extends AbstractService { if ((keys == null)||(keys.length== 0)) throw new IllegalArgumentException("Key array must not be null or empty."); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // get the properties ArrayList returnValues = new ArrayList(keys.length); @@ -242,7 +242,7 @@ public class AdminService extends AbstractService { */ public Document getConfigPropertyList() throws Exception { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // generating the template containing the network status information byte[] result = writeTemplate(TEMPLATE_CONFIG_XML, new serverObjects()); @@ -267,14 +267,14 @@ public class AdminService extends AbstractService { */ public Document getVersion() throws Exception { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // generating the template containing the network status information byte[] result = writeTemplate(TEMPLATE_VERSION_XML, new serverObjects()); // sending back the result to the client return this.convertContentToXML(result); - } + } /** * This function can be used to configure the peer name @@ -286,7 +286,7 @@ public class AdminService extends AbstractService { if ((newName == null)||(newName.length() == 0)) throw new IllegalArgumentException("The peer name must not be null or empty."); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // get the previous name String prevName = this.switchboard.getConfig(PEER_NAME, ""); @@ -325,7 +325,7 @@ public class AdminService extends AbstractService { if (newPort <= 0) throw new IllegalArgumentException("Invalid port number"); // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // get the old value int oldPort = (int) this.switchboard.getConfigLong(PORT, 8080); @@ -349,7 +349,7 @@ public class AdminService extends AbstractService { */ public void enableRemoteProxy(boolean enableProxy) throws AxisFault { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // check for errors String proxyHost = this.switchboard.getConfig(REMOTE_PROXY_HOST, ""); @@ -392,7 +392,7 @@ public class AdminService extends AbstractService { Boolean useProxy4SSL ) throws AxisFault { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); if (proxyHost != null) this.switchboard.setConfig(REMOTE_PROXY_HOST, proxyHost); @@ -425,7 +425,7 @@ public class AdminService extends AbstractService { */ public void shutdownPeer() throws AxisFault { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); this.switchboard.setConfig(RESTART, "false"); @@ -447,7 +447,7 @@ public class AdminService extends AbstractService { Integer maximumAllowedPPM ) throws AxisFault { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // if the ppm was set, change it if (maximumAllowedPPM != null) { @@ -486,7 +486,7 @@ public class AdminService extends AbstractService { Boolean indexReceiveBlockBlacklist ) throws AxisFault { // extracting the message context - extractMessageContext(true); + extractMessageContext(AUTHENTICATION_NEEDED); // index Distribution on/off if (indexDistribution != null) { diff --git a/source/de/anomic/soap/services/StatusService.java b/source/de/anomic/soap/services/StatusService.java index feb0ddf45..1bf0156ad 100644 --- a/source/de/anomic/soap/services/StatusService.java +++ b/source/de/anomic/soap/services/StatusService.java @@ -61,6 +61,7 @@ public class StatusService extends AbstractService { */ private static final String TEMPLATE_NETWORK_XML = "Network.xml"; private static final String TEMPLATE_QUEUES_XML = "xml/queues_p.xml"; + private static final String TEMPLATE_STATUS_XML = "xml/status_p.xml"; /** @@ -126,4 +127,20 @@ public class StatusService extends AbstractService { // sending back the result to the client return this.convertContentToXML(result); } + + /** + * Query status information about this peer + * @return + * @throws Exception + */ + public Document getStatus() throws Exception { + // extracting the message context + extractMessageContext(AUTHENTICATION_NEEDED); + + // generating the template containing the network status information + byte[] result = writeTemplate(TEMPLATE_STATUS_XML, new serverObjects()); + + // sending back the result to the client + return this.convertContentToXML(result); + } } diff --git a/source/de/anomic/soap/services/status.wsdl b/source/de/anomic/soap/services/status.wsdl index 29f1ed443..fb3ac05e9 100644 --- a/source/de/anomic/soap/services/status.wsdl +++ b/source/de/anomic/soap/services/status.wsdl @@ -1,6 +1,6 @@ - + @@ -8,14 +8,14 @@ Built on Nov 16, 2004 (12:19:44 EST)--> - + - - - - + + + + @@ -23,7 +23,17 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + + + + + + + + + + @@ -41,6 +51,16 @@ Built on Nov 16, 2004 (12:19:44 EST)--> + + + + + + + + + + diff --git a/test/de/anomic/soap/services/StatusServiceTest.java b/test/de/anomic/soap/services/StatusServiceTest.java index f1fd52900..7619db922 100644 --- a/test/de/anomic/soap/services/StatusServiceTest.java +++ b/test/de/anomic/soap/services/StatusServiceTest.java @@ -26,7 +26,12 @@ public class StatusServiceTest extends AbstractServiceTest { } public void testGetQueueStatus() throws RemoteException { - Document xml = ((StatusService)service).getQueueStatus(null,null,null,null); + Document xml = ((StatusService)service).getQueueStatus(10,10,10,10); + System.out.println(XMLUtils.DocumentToString(xml)); + } + + public void testStatus() throws RemoteException { + Document xml = ((StatusService)service).getStatus(); System.out.println(XMLUtils.DocumentToString(xml)); } }