From 5c0669429e1eb18fbe26c4cc56c427885de0c2bb Mon Sep 17 00:00:00 2001 From: theli Date: Fri, 17 Nov 2006 19:26:55 +0000 Subject: [PATCH] *) soap: adding function to query the peer list git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2968 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Network.xml | 12 +++ .../anomic/soap/services/StatusService.java | 85 ++++++++++++++++--- source/de/anomic/soap/services/status.wsdl | 40 +++++++-- .../soap/services/StatusServiceTest.java | 5 ++ 4 files changed, 120 insertions(+), 22 deletions(-) diff --git a/htroot/Network.xml b/htroot/Network.xml index fe9565a0a..63c0e0b82 100644 --- a/htroot/Network.xml +++ b/htroot/Network.xml @@ -11,6 +11,18 @@ #[uptime]# #[links]# #[words]# + #[lastSeen]# + #[sI]# + #[rI]# + #[sU]# + #[rU]# + #(complete)# + :: + #[age]# + #[seeds]# + #[connects]# +
#[ip]#:#[port]#
+ #(/complete)# #{/list}# diff --git a/source/de/anomic/soap/services/StatusService.java b/source/de/anomic/soap/services/StatusService.java index 1bf0156ad..a6b3c5755 100644 --- a/source/de/anomic/soap/services/StatusService.java +++ b/source/de/anomic/soap/services/StatusService.java @@ -66,21 +66,78 @@ public class StatusService extends AbstractService { /** * Service used to query the network properties - * @throws AxisFault if the service could not be executed propery. + * @throws Exception */ - public Document network() throws AxisFault { - try { - // extracting the message context - extractMessageContext(NO_AUTHENTICATION); - - // generating the template containing the network status information - byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects()); - - // sending back the result to the client - return this.convertContentToXML(result); - } catch (Exception e) { - throw new AxisFault(e.getMessage()); - } + public Document network() throws Exception { + // extracting the message context + extractMessageContext(NO_AUTHENTICATION); + + // generating the template containing the network status information + byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, new serverObjects()); + + // sending back the result to the client + return this.convertContentToXML(result); + } + + /** + * Returns a list of peers this peer currently knows + * @param peerType the peer types to query. This could be + * + * @param maxCount the maximum amount of records to return + * @param details if detailed informations should be returned + * + * @return a XML document of the following format + *
+     * <?xml version="1.0" encoding="UTF-8"?>
+     * <peers>
+     *   <peer>
+     *     <hash>XXXXXXX</hash>
+     *     <fullname>Peer Name</fullname>
+     *     <version>0.424/01505</version>
+     *     <ppm>0</ppm>
+     *     <uptime>2 days 14:37</uptime>
+     *     <links>-</links>
+     *     <words>-</words>
+     *     <lastseen>48</lastseen>
+     *     <sendWords>-</sendWords>
+     *     <receivedWords>-</receivedWords>
+     *     <sendURLs>-</sendURLs>
+     *     <receivedURLs>-</receivedURLs>    
+     *     <age>369</age>
+     *     <seeds>61</seeds>
+     *     <connects>2</connects>
+     *     <address>127.0.0.1:8080</address>        
+     *   </peer>
+     * </peers>
+     * 
+ * @throws Exception + */ + public Document peerList(String peerType, int maxCount, boolean details) throws Exception { + // extracting the message context + extractMessageContext(NO_AUTHENTICATION); + + if (peerType == null || peerType.length() == 0) throw new IllegalArgumentException("The peer type must not be null or empty."); + if (!(peerType.equalsIgnoreCase("active") || peerType.equalsIgnoreCase("passive") || peerType.equalsIgnoreCase("Potential"))) + throw new IllegalArgumentException("Unknown peer type. Should be (active|passive|potential)"); + + // configuring output mode + serverObjects args = new serverObjects(); + if (peerType.equalsIgnoreCase("active")) args.put("page","1"); + else if (peerType.equalsIgnoreCase("passive")) args.put("page","2"); + else if (peerType.equalsIgnoreCase("potential")) args.put("page","3"); + + // specifying if the detailed list should be returned + if (details) args.put("ip","1"); + + // generating the template containing the network status information + byte[] result = writeTemplate(TEMPLATE_NETWORK_XML, args); + + // 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 fb3ac05e9..b88145db8 100644 --- a/source/de/anomic/soap/services/status.wsdl +++ b/source/de/anomic/soap/services/status.wsdl @@ -1,26 +1,35 @@ + + + + + + - + + + + - + @@ -29,8 +38,8 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + @@ -38,63 +47,78 @@ Built on Apr 22, 2006 (06:55:48 PDT)--> - + + + + + + - + - + + + + + + + + + + + - + - + \ No newline at end of file diff --git a/test/de/anomic/soap/services/StatusServiceTest.java b/test/de/anomic/soap/services/StatusServiceTest.java index 7619db922..7f8f7d9ba 100644 --- a/test/de/anomic/soap/services/StatusServiceTest.java +++ b/test/de/anomic/soap/services/StatusServiceTest.java @@ -34,4 +34,9 @@ public class StatusServiceTest extends AbstractServiceTest { Document xml = ((StatusService)service).getStatus(); System.out.println(XMLUtils.DocumentToString(xml)); } + + public void testPeerList() throws RemoteException { + Document xml = ((StatusService)service).peerList("active",300,true); + System.out.println(XMLUtils.DocumentToString(xml)); + } }