From 1b7fda12eedaf49aea051531a17b70163f67e3b7 Mon Sep 17 00:00:00 2001 From: theli Date: Wed, 28 Mar 2007 07:34:44 +0000 Subject: [PATCH] *) SOAP: separate function to get the active/passive/potential peer list git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3526 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../anomic/soap/services/StatusService.java | 55 ++++++++- source/de/anomic/soap/services/status.wsdl | 108 +++++++++++++++--- .../soap/services/StatusServiceTest.java | 4 +- 3 files changed, 147 insertions(+), 20 deletions(-) diff --git a/source/de/anomic/soap/services/StatusService.java b/source/de/anomic/soap/services/StatusService.java index 67fb6fa6d..0a7f8f5fb 100644 --- a/source/de/anomic/soap/services/StatusService.java +++ b/source/de/anomic/soap/services/StatusService.java @@ -64,22 +64,69 @@ public class StatusService extends AbstractService { private static final String TEMPLATE_QUEUES_XML = "xml/queues_p.xml"; private static final String TEMPLATE_STATUS_XML = "xml/status_p.xml"; + /* ===================================================================== + * Constants needed to query the network status + * ===================================================================== */ + private static final int NETWORK_OVERVIEW = 0; + private static final int NETWORK_ACTIVE_PEERS = 1; + private static final int NETWORK_PASSIVE_PEERS = 2; + private static final int NETWORK_POTENTIAL_PEERS = 3; /** - * Service used to query the network properties - * @throws Exception + * @return + * @throws Exception + * @deprecated kept for backward compatibility */ public Document network() throws Exception { + return this.getNetworkOverview(); + } + + public Document getNetworkOverview() throws Exception { // extracting the message context extractMessageContext(NO_AUTHENTICATION); + + // return DOM + return getNetworkData(NETWORK_OVERVIEW); + } + + public Document getActivePeers() throws Exception { + // extracting the message context + extractMessageContext(NO_AUTHENTICATION); + + // return DOM + return getNetworkData(NETWORK_ACTIVE_PEERS); + } + + public Document getPassivePeers() throws Exception { + // extracting the message context + extractMessageContext(NO_AUTHENTICATION); + + // return DOM + return getNetworkData(NETWORK_PASSIVE_PEERS); + } + + public Document getPotentialPeers() throws Exception { + // extracting the message context + extractMessageContext(NO_AUTHENTICATION); + + // return DOM + return getNetworkData(NETWORK_POTENTIAL_PEERS); + } + + private Document getNetworkData(int page) throws Exception { + if (page < 0 || page > 3) page = 0; + + serverObjects post = new serverObjects(); + post.put("page", Integer.toString(page)); // generating the template containing the network status information - byte[] result = this.serverContext.writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects(), this.requestHeader); + byte[] result = this.serverContext.writeTemplate(TEMPLATE_NETWORK_XML, post, this.requestHeader); // sending back the result to the client - return this.convertContentToXML(result); + return this.convertContentToXML(result); } + /** * Returns a list of peers this peer currently knows * @param peerType the peer types to query. This could be diff --git a/source/de/anomic/soap/services/status.wsdl b/source/de/anomic/soap/services/status.wsdl index a837c20d9..49695ec88 100644 --- a/source/de/anomic/soap/services/status.wsdl +++ b/source/de/anomic/soap/services/status.wsdl @@ -1,45 +1,67 @@ - - - - - - + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -47,12 +69,30 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> + - + + + + + + + + + + + + + + + + + + @@ -94,6 +134,46 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/de/anomic/soap/services/StatusServiceTest.java b/test/de/anomic/soap/services/StatusServiceTest.java index 7f8f7d9ba..3d8ffa846 100644 --- a/test/de/anomic/soap/services/StatusServiceTest.java +++ b/test/de/anomic/soap/services/StatusServiceTest.java @@ -20,8 +20,8 @@ public class StatusServiceTest extends AbstractServiceTest { service = locator.getstatus(); } - public void testNetwork() throws RemoteException { - Document xml = ((StatusService)service).network(); + public void testNetworkOverview() throws RemoteException { + Document xml = ((StatusService)service).getNetworkOverview(); System.out.println(XMLUtils.DocumentToString(xml)); }