r1178 - in xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki: . client communication communication/jxta communication/rpc examples registry replication rpc

Sergiu Dumitriu sdumitriu at users.forge.objectweb.org
Sat Aug 19 21:55:01 CEST 2006


Author: sdumitriu
Date: 2006-08-19 21:55:01 +0200 (Sat, 19 Aug 2006)
New Revision: 1178

Added:
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/P2PXWikiException.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/BaseClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/RpcClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectionFactory.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManager.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/Network.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaConnectionFactory.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ClientBaseExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RegistryClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ReplicationClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RpcClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryHandlerApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryHandlerPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationClientApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationClientPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationHandlerApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/ReplicationHandlerPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/BaseRpcHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/ConfluenceRpcHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/RpcHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/RpcHandlerPlugin.java
Removed:
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClient.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/P2PXWikiReplicationHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/P2PXWikiReplicationHandlerApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/replication/P2PXWikiReplicationHandlerPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/P2PXWikiBaseRpcHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/P2PXWikiConfluenceRpcHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/P2PXWikiRPCHandler.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/rpc/P2PXWikiRPCHandlerPlugin.java
Modified:
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorApi.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorPlugin.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerStub.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerManager.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerStub.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaNetwork.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcConnectionFactory.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerManager.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerStub.java
   xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcNetwork.java
Log:
Renaming to shorter names (part 3).

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/P2PXWikiException.java (from rev 1175, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java	2006-08-19 19:07:09 UTC (rev 1175)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/P2PXWikiException.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,27 @@
+package com.xpn.p2pxwiki;
+
+import com.xpn.xwiki.plugin.PluginException;
+
+public class P2PXWikiException extends PluginException {
+    private static final long serialVersionUID = 1106138323477622364L;
+	public static final int ERROR_P2PXWIKI_COMMUNICATION = 30999;
+	public static final int ERROR_P2PXWIKI_REMOTECALL = 30998;
+	static String module = "P2PXWiki";
+
+	public P2PXWikiException(int code, String message, Throwable e,
+			Object[] args) {
+		super(module, code, message, e, args);
+	}
+
+	public P2PXWikiException(int code, String message, Throwable e) {
+		super(module, code, message, e, null);
+	}
+
+	public P2PXWikiException(int code, String message) {
+		super(module, code, message, null, null);
+	}
+
+	public P2PXWikiException() {
+		super();
+	}
+}


Property changes on: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/P2PXWikiException.java
___________________________________________________________________
Name: svn:executable
   + *

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/BaseClient.java (from rev 1175, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java	2006-08-19 19:07:09 UTC (rev 1175)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/BaseClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,52 @@
+package com.xpn.p2pxwiki.client;
+
+import com.xpn.p2pxwiki.communication.ConnectorPlugin;
+import com.xpn.p2pxwiki.communication.HandlerStub;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+
+public class BaseClient {
+	protected XWikiContext context;
+	public BaseClient(XWikiContext context){
+		this.context = context;
+	}
+
+	public HandlerStub getConnection(String peer){
+		try{
+			return ((ConnectorPlugin)context.getWiki().getPlugin("p2pxwikiconnector", this.context)).getConnection(peer);
+		}
+		catch(XWikiException ex){
+			return null;
+		}
+	}
+
+	public String login(String username, String password, String wikiserver,
+			String serverHandlerClass) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			String database = ""; /* default database to use on the server */
+			String result = (String) client.execute(serverHandlerClass
+					+ ".login", new Object[] {username, password, database});
+			if (result.length() == 0){
+				return null;
+			}
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public boolean logout(String token, String wikiserver, String serverHandlerClass) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			String database = ""; /* default database to use on the server */
+			Boolean result = (Boolean) client.execute(serverHandlerClass
+					+ ".logout", new Object[] {token, database});
+			return result.booleanValue();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return true;
+	}
+}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiBaseClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,52 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-
-public class P2PXWikiBaseClient {
-	protected XWikiContext context;
-	public P2PXWikiBaseClient(XWikiContext context){
-		this.context = context;
-	}
-
-	public HandlerStub getConnection(String peer){
-		try{
-			return ((ConnectorPlugin)context.getWiki().getPlugin("p2pxwikiconnector", this.context)).getConnection(peer);
-		}
-		catch(XWikiException ex){
-			return null;
-		}
-	}
-
-	public String login(String username, String password, String wikiserver,
-			String serverHandlerClass) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			String database = ""; /* default database to use on the server */
-			String result = (String) client.execute(serverHandlerClass
-					+ ".login", new Object[] {username, password, database});
-			if (result.length() == 0){
-				return null;
-			}
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public boolean logout(String token, String wikiserver, String serverHandlerClass) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			String database = ""; /* default database to use on the server */
-			Boolean result = (Boolean) client.execute(serverHandlerClass
-					+ ".logout", new Object[] {token, database});
-			return result.booleanValue();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return true;
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiException.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,27 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import com.xpn.xwiki.plugin.PluginException;
-
-public class P2PXWikiException extends PluginException {
-    private static final long serialVersionUID = 1106138323477622364L;
-	public static final int ERROR_P2PXWIKI_COMMUNICATION = 30999;
-	public static final int ERROR_P2PXWIKI_REMOTECALL = 30998;
-	static String module = "P2PXWiki";
-
-	public P2PXWikiException(int code, String message, Throwable e,
-			Object[] args) {
-		super(module, code, message, e, args);
-	}
-
-	public P2PXWikiException(int code, String message, Throwable e) {
-		super(module, code, message, e, null);
-	}
-
-	public P2PXWikiException(int code, String message) {
-		super(module, code, message, null, null);
-	}
-
-	public P2PXWikiException() {
-		super();
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,251 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.xwiki.XWikiContext;
-
-/* This class always contacts the wikiserver to fetch the content. caching can be done to serve the client 
- * faster. 
- * 
- * All the calls in this class have an extra argument taking the wikiserver address on which to make the call.
- */
-public class P2PXWikiRPCClient extends P2PXWikiBaseClient {
-	private final static String HANDLERCLASS = "xwikirpc";
-
-	public P2PXWikiRPCClient(XWikiContext context){
-		super(context);
-	}
-
-	/*
-	 * @EXTENSION: Change from plain text password transmission on the network
-	 * 
-	 * login to a wikiserver with a username and password. get a token in return
-	 */
-	public String login(String username, String password, String wikiserver) {
-		return super.login(username, password, wikiserver, HANDLERCLASS);
-	}
-
-	public boolean logout(String token, String wikiserver) {
-		return super.logout(token, wikiserver, HANDLERCLASS);
-	}
-
-	public Vector getSpaces(String token, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(
-					HANDLERCLASS + ".getSpaces", new Object[] {token});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Hashtable getSpace(String token, String spaceKey, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
-					+ ".getSpace", new Object[] {token, spaceKey});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Vector getPages(String token, String spaceKey, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS + ".getPages",
-					new Object[] {token, spaceKey});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Hashtable getPage(String token, String pageId, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
-					+ ".getPage", new Object[] {token, pageId});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Vector getPageHistory(String token, String pageId, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getPageHistory", new Object[] {token, pageId});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Vector search(String token, String query, int maxResults,
-			String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS + ".search",
-					new Object[] {token, query});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public String renderContent(String token, String spaceKey, String pageId,
-			String content, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			String result = (String) client.execute(HANDLERCLASS
-					+ ".renderContent", new Object[] {token, spaceKey, pageId, content});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return "";
-	}
-
-	public Vector getAttachments(String token, String pageId, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAttachments", new Object[] {token, pageId});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Vector getComments(String token, String pageId, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getComments", new Object[] {token, pageId});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public Hashtable storePage(String token, Hashtable pageht, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
-					+ ".storePage", new Object[] {token, pageht});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public void deletePage(String token, String pageId, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			client.execute(HANDLERCLASS + ".deletePage", new Object[] {token, pageId});
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return;
-	}
-
-	public Hashtable getUser(String token, String username, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
-					+ ".getUser", new Object[] {token, username});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public void addUser(String token, Hashtable user, String password,
-			String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			client.execute(HANDLERCLASS + ".addUser", new Object[] {token, user, password});
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return;
-	}
-
-	public void addGroup(String token, String group, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			client.execute(HANDLERCLASS + ".addGroup", new Object[] {token, group});
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return;
-	}
-
-	public Vector getUserGroups(String token, String username, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getUserGroups", new Object[] {token, username});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public void addUserToGroup(String token, String username, String groupname,
-			String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			// FIXME Integer result = (Integer) 
-			client.execute(HANDLERCLASS
-					+ ".addUserToGroup", new Object[] {token, username, groupname});
-			return;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return;
-	}
-
-	public Vector getAllPages(String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAllPages", new Object[] {});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return new Vector();
-	}
-
-	public byte[] getPage(String name, String wikiserver) {
-		HandlerStub client = getConnection(wikiserver);
-		try {
-			byte[] result = (byte[]) client.execute(HANDLERCLASS + ".getPage",
-					new Object[] {name});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return new byte[0];
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClient.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClient.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,106 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.xwiki.XWikiContext;
-
-public class P2PXWikiRegistryClient extends P2PXWikiBaseClient {
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiRegistryClient.class);
-
-	public P2PXWikiRegistryClient(XWikiContext context){
-		super(context);
-	}
-	private String P2PXWIKIREGISTRYADDRESS = ConnectorPlugin.getNetwork().getCanonicalRemoteName("registry");
-
-	private String HANDLERCLASS = "registry";
-
-	public String login(String username, String password) {
-		return super.login(username, password, P2PXWIKIREGISTRYADDRESS,
-				HANDLERCLASS);
-	}
-
-	public boolean logout(String token) {
-		return super.logout(token, P2PXWIKIREGISTRYADDRESS, HANDLERCLASS);
-	}
-
-	public boolean updateRegistry(String token, String wikiname, String IP) {
-		/*
-		 * TODO Talk to the jxta network and find out the registry and update
-		 * the IP of the master wiki, the registry will then check user exists,
-		 * password is correct, check wiki exists, then update the IP
-		 */
-		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
-		try {
-			Boolean res = (Boolean) client.execute(HANDLERCLASS
-					+ ".updateRegistry", new Object[] {token, wikiname, IP});
-			return res.booleanValue();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-
-	/* TODO Api to check a user is going offline and updating the IP */
-
-	/*
-	 * TODO Apis to update the IP of a masterwiki because user is moving to a
-	 * new place on a per wiki basis (which checks that the user is infact the
-	 * master) and contacts the registry All the APIs below are going to be
-	 * JXTA-RPC/RMI. A first cut will be local update assuming we are working at
-	 * the registry.
-	 */
-
-	public boolean updateMasterIP(String token, String wikiname, String IP) {
-		return updateRegistry(token, wikiname, IP);
-	}
-
-	/*
-	 * TODO Assuming that every user machine has a unique single instance of
-	 * p2pxwiki, this means the user name can be used to migrate all locally
-	 * hosted Wiki to new IP in the registry make sure that only the registry
-	 * has the other database and its associated mapping. One way is to make two
-	 * versions of source code, one for the "registry" node and one for others.
-	 * another approach will be to conditionally create db etc.
-	 */
-	/*
-	 * public int updateAllMastersIPbyUser(String token, String IP) { return 0; }
-	 */
-	/*
-	 * TODO This version of the update API allows to migrate a set of wikis
-	 * which were already in an old ip, and owned by the master, to a new IP
-	 */
-	/*
-	 * public int updateAllMastersfromOldIP(String username, String password,
-	 * String oldIP, String newIP) { return 0; }
-	 */
-
-	public String queryRegistry(String wikiname) {
-		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
-		log.error("Going to query for wikiname:"+ wikiname+" using registry:"+ 
-				P2PXWIKIREGISTRYADDRESS); 
-		try {
-			String res = (String) client.execute(HANDLERCLASS
-					+ ".queryRegistry", new Object[] {wikiname});
-			return res;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return "";
-	}
-
-	public boolean existsWikiapp(String wikiapp) {
-		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
-		try {
-			boolean res = ((Boolean) client.execute(HANDLERCLASS
-					+ ".existsWikiapp", new Object[] {wikiapp})).booleanValue();
-			return res;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientApi.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientApi.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientApi.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,36 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.api.Api;
-
-public class P2PXWikiRegistryClientApi extends Api {
-	private P2PXWikiRegistryClient regClient = null;
-
-	public P2PXWikiRegistryClientApi(XWikiContext context) {
-		super(context);
-		regClient = new P2PXWikiRegistryClient(context);
-	}
-
-	/* public apis which can be accessed through a webpage */
-	public boolean existsWikiapp(String wikiapp) {
-		return regClient.existsWikiapp(wikiapp);
-	}
-
-	public boolean updateRegistry(String token, String wikiapp, String IP) {
-		return regClient.updateRegistry(token, wikiapp, IP);
-	}
-
-	public String queryRegistry(String wikiname) {
-		return regClient.queryRegistry(wikiname);
-	}
-
-	/* TODO: add apis to create a user and create a wiki */
-
-	public String login(String username, String password) {
-		return regClient.login(username, password);
-	}
-
-	public boolean logout(String token) {
-		return regClient.logout(token);
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientPlugin.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientPlugin.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRegistryClientPlugin.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,51 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.api.Api;
-import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
-import com.xpn.xwiki.plugin.XWikiPluginInterface;
-
-/**
- * Created by IntelliJ IDEA. User: bikash Date: Aug 19, 2005 Time: 12:31:43 AM
- */
-
-public class P2PXWikiRegistryClientPlugin extends XWikiDefaultPlugin implements
-		XWikiPluginInterface {
-	private static Log log = LogFactory.getFactory().getInstance(
-			com.xpn.p2pxwiki.client.P2PXWikiRegistryClientPlugin.class);
-
-	/*
-	 * virtual address of the registry server, this is used to search in the p2p
-	 * network by p2psockets -- FIXME Comment for what? 
-	 */
-	public P2PXWikiRegistryClientPlugin(String name, String className,
-			XWikiContext context) {
-		super(name, className, context);
-		init(context);
-	}
-
-	public String getName() {
-		return "p2pxwikiregistry";
-	}
-
-	public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) {
-		try {
-			return new P2PXWikiRegistryClientApi(context);
-		} catch (Exception e) {
-			return null;
-		}
-	}
-
-	public void flushCache() {
-	}
-
-	public void init(XWikiContext context) {
-		log.debug("initializing");
-		super.init(context);
-//		P2PXWikiRegistryClientExamples example = new P2PXWikiRegistryClientExamples(); 
-//		example.run(); 
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClient.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClient.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,186 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import java.util.Date;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.xwiki.XWikiContext;
-
-public class P2PXWikiReplicationClient extends P2PXWikiBaseClient {
-	private final String HANDLERCLASS = "replication";
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiReplicationClient.class);
-
-	public P2PXWikiReplicationClient(XWikiContext context){
-		super(context);
-	}
-	public String login(String username, String password, String peerserver) {
-		return super.login(username, password, peerserver, HANDLERCLASS);
-	}
-
-	public boolean logout(String token, String peerserver) {
-		return super.logout(token, peerserver, HANDLERCLASS);
-	}
-
-	public String login(String username, String password) {
-		String peerserver = ConnectorPlugin.getNetwork().getCanonicalLocalName(); 
-		if (peerserver == null) { 
-			log.error("error in getting local JXTA server address: ---ERRROR --- ") ;
-			return null; 
-		}
-		return super.login(username, password, peerserver, HANDLERCLASS);
-	}
-
-	public boolean logout(String token) {
-		String peerserver = ConnectorPlugin.getNetwork().getCanonicalLocalName();
-		if (peerserver == null) { 
-			log.error("error in getting local JXTA server address: ---ERRROR --- ") ;
-			return false; 
-		}
-		return super.logout(token, peerserver, HANDLERCLASS);
-	}
-	
-	/* @TODO: all these calls should take a wikiapp to replicate as an argument */
-
-	public Vector getAllPagesAsXML(String token, String peerserver, String wikiapp) {
-		HandlerStub client = getConnection(peerserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAllPagesAsXML", new Object[] {token, wikiapp});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		/* 
-		 *@EXTENSION: distinguish between 0 result and an error from server 
-		 */  
-		return new Vector(); 
-	}
-
-	/* date is in MMDDYYYY format */
-	public Vector getAllPagesModifiedSinceAsXML(String token, String date,
-			String peerserver, String wikiapp) {
-		HandlerStub client = getConnection(peerserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAllPagesModifiedSinceAsXML", new Object[] {token, date, wikiapp});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return new Vector(); 
-	}
-
-	public Vector getAllPagesModifiedSinceAsXML(String token, long sinceWhen,
-			String peerserver, String wikiapp) {
-		HandlerStub client = getConnection(peerserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAllPagesModifiedSinceAsXML",
-					new Object[] {token, new Long(sinceWhen), wikiapp});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return new Vector(); 
-	}
-	
-	public Vector getAllPagesModifiedSinceAsXML(String token, Date date,
-			String peerserver, String wikiapp) {
-
-		HandlerStub client = getConnection(peerserver);
-		try {
-			Vector result = (Vector) client.execute(HANDLERCLASS
-					+ ".getAllPagesModifiedSinceAsXML", new Object[] {token, date, wikiapp});
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return new Vector(); 
-	}	
-	
-	public boolean replicatePageFromXML(String token, String docXML, String peerserver, String wikiapp) { 
-		HandlerStub client = getConnection(peerserver);
-		try {
-			boolean result = ((Boolean) client.execute(HANDLERCLASS
-					+ ".replicatePageFromXML", new Object[] {token, docXML, wikiapp})).booleanValue();
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-	
-	/* api to replicate locally */ 
-	public boolean replicatePageFromXML(String token, String docsXML, String wikiapp) { 
-		String peerserver = ConnectorPlugin.getNetwork().getCanonicalLocalName();
-		if (peerserver == null) { 
-			log.error("error in getting local JXTA server address: ---ERRROR --- ") ;
-			return false; 
-		}
-		log.debug("connecting to local peer:"+ peerserver+" for replication"); 
-		return replicatePageFromXML(token,docsXML, peerserver, wikiapp); 
-	}
-	
-	/* api to replicate locally */ 
-	public boolean replicateAllPagesFromXML(String token, Vector docsXML, String wikiapp) { 
-		String peerserver = ConnectorPlugin.getNetwork().getCanonicalLocalName(); 
-		if (peerserver == null) { 
-			log.error("error in getting local JXTA server address: ---ERRROR --- ") ;
-			return false; 
-		}
-		log.error("connecting to local peer:"+ peerserver+" for replication"); 
-		return replicateAllPagesFromXML(token,docsXML, peerserver, wikiapp); 
-	}
-	
-	/*
-	 * @EXTENSION: This api has future and testing purpose use when the
-	 * replication can be done at another wiki as well
-	 * 
-	 * local replication is supported by providing the name of the local
-	 * peerserver as the peerserver argument, and a local user token
-	 */
-	public boolean replicateAllPagesFromXML(String token, Vector docsXML,
-			String peerserver, String wikiapp) {
-		log.error("calling replication for "+ peerserver+" and wikiapp "+wikiapp);
-		HandlerStub client = getConnection(peerserver);
-		try {
-			boolean result = ((Boolean) client.execute(HANDLERCLASS
-					+ ".replicateAllPagesFromXML",
-					new Object[] {token, docsXML, wikiapp})).booleanValue();
-			return result;
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-	
-	public boolean replicateAllPagesFromXML(String srctoken,
-			String srcpeer, String srcwiki, String desttoken, 
-			String destpeer, String destwiki) { 
-		log.error("getting all pages from "+ srcpeer+" for wiki: "+ srcwiki); 
-		Vector allPages = getAllPagesAsXML(srctoken,srcpeer,srcwiki); 
-		log.error("got "+allPages.size()+" pages"); 
-		return replicateAllPagesFromXML(desttoken,allPages,destpeer,destwiki); 
-	}
-	
-	public boolean replicateAllPagesFromXML(String srctoken,
-			String srcpeer, String srcwiki, String desttoken, String destwiki) { 
-		
-		Vector allPages = getAllPagesAsXML(srctoken,srcpeer,srcwiki); 
-		
-		return replicateAllPagesFromXML(desttoken,allPages,destwiki); 
-	}
-	
-	public boolean replicateAllPagesModifiedSinceAsXML(String srctoken,
-			String srcpeer, String srcwiki, String sinceDate, String desttoken, 
-			String destpeer, String destwiki) { 
-		Vector allPages = getAllPagesModifiedSinceAsXML(srctoken, sinceDate, srcpeer,srcwiki); 
-		
-		return replicateAllPagesFromXML(desttoken,allPages,destwiki); 
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientApi.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientApi.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientApi.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,95 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import java.util.Date;
-import java.util.Vector;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.api.Api;
-
-public class P2PXWikiReplicationClientApi extends Api {
-	private P2PXWikiReplicationClient repClient = null;
-
-	public P2PXWikiReplicationClientApi(XWikiContext context) {
-		super(context);
-		if (repClient == null)
-			repClient = new P2PXWikiReplicationClient(context);
-	}
-
-	public String login(String username, String password, String peerserver) {
-		return repClient.login(username, password, peerserver);
-	}
-
-	public boolean logout(String token, String peerserver) {
-		return repClient.logout(token, peerserver);
-	}
-
-	/** @TODO: all these calls should take a wikiapp to replicate as an argument */
-
-	public Vector getAllPagesAsXML(String token, String peerserver, String srcwiki) {
-		return repClient.getAllPagesAsXML(token, peerserver, srcwiki);
-	}
-
-	/* date is in MMDDYYYY format */
-	public Vector getAllPagesModifiedSinceAsXML(String token, String date,
-			String peerserver, String srcwiki) {
-		return repClient.getAllPagesModifiedSinceAsXML(token, date, peerserver, srcwiki);
-	}
-
-	public Vector getAllPagesModifiedSinceAsXML(String token, Date date,
-			String peerserver, String srcwiki) {
-		return repClient.getAllPagesModifiedSinceAsXML(token, date, peerserver, srcwiki);
-	}
-
-	/* apis to login to local replicas and getting a token */  
-	public String login(String username, String password) {
-		return repClient.login(username, password);
-	}
-
-	public boolean logout(String token) {
-		return repClient.logout(token);
-	}
-
-	public boolean replicatePageFromXML(String token, String docsXML, String destwiki) { 
-		return repClient.replicatePageFromXML(token,docsXML, destwiki); 
-	}
-	
-	public boolean replicatePageFromXML(String token, String docsXML,
-			String peerserver, String destwiki) {
-		return repClient.replicatePageFromXML(token, docsXML, peerserver, destwiki);
-	}
-	
-	/* api to replicate locally, make sure to pass a token to the  local p2pxwiki */ 
-	public boolean replicateAllPagesFromXML(String token, Vector docsXML, String destwiki) { 
-		return repClient.replicateAllPagesFromXML(token,docsXML, destwiki); 
-	}
-	
-	/*
-	 * @EXTENSION Replicating to any peer is supported ! make sure to pass a token 
-	 * for the appropriate peerserver while doing replication. 
-	 * 
-	 */
-	public boolean replicateAllPagesFromXML(String token, Vector docsXML,
-			String peerserver, String destwiki) {
-		return repClient.replicateAllPagesFromXML(token, docsXML, peerserver, destwiki);
-	}
-	
-	/* single replication api */ 
-	public boolean replicateAllPagesFromXML(String srctoken,
-			String srcpeer, String srcwiki, String desttoken, 
-			String destpeer, String destwiki) {
-		return repClient.replicateAllPagesFromXML(srctoken, srcpeer, srcwiki, desttoken, 
-				destpeer, destwiki);
-	}
-	public boolean replicateAllPagesFromXML(String srctoken,
-			String srcpeer, String srcwiki, String desttoken, 
-			String destwiki) {
-		return repClient.replicateAllPagesFromXML(srctoken, srcpeer, srcwiki, desttoken, 
-				destwiki);
-	}
-	public boolean replicateAllPagesModifiedSinceAsXML(String srctoken,
-			String srcpeer, String srcwiki, String sinceDate, String desttoken, 
-			String destpeer, String destwiki) { 
-		return repClient.replicateAllPagesModifiedSinceAsXML(srctoken,srcpeer,srcwiki, 
-				sinceDate, desttoken, destpeer, destwiki); 
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientPlugin.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientPlugin.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiReplicationClientPlugin.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,43 +0,0 @@
-package com.xpn.p2pxwiki.client;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.api.Api;
-import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
-import com.xpn.xwiki.plugin.XWikiPluginInterface;
-
-public class P2PXWikiReplicationClientPlugin extends XWikiDefaultPlugin
-		implements XWikiPluginInterface {
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiReplicationClientPlugin.class);
-
-	public P2PXWikiReplicationClientPlugin(String name, String className,
-			XWikiContext context) {
-		super(name, className, context);
-		init(context);
-	}
-
-	public String getName() {
-		return "p2pxwikireplication";
-	}
-
-	public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) {
-		try {
-			return new P2PXWikiReplicationClientApi(context);
-		} catch (Exception e) {
-			return null;
-		}
-	}
-
-	public void flushCache() {
-	}
-	
-	public void init(XWikiContext context) {
-		super.init(context);
-		log.debug("initializing");
-//		P2PXWikiReplicationClientExamples examples = new P2PXWikiReplicationClientExamples(); 
-//		examples.run(); 
-	}
-}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/RpcClient.java (from rev 1175, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/P2PXWikiRPCClient.java	2006-08-19 19:07:09 UTC (rev 1175)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/client/RpcClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,251 @@
+package com.xpn.p2pxwiki.client;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import com.xpn.p2pxwiki.communication.HandlerStub;
+import com.xpn.xwiki.XWikiContext;
+
+/* This class always contacts the wikiserver to fetch the content. caching can be done to serve the client 
+ * faster. 
+ * 
+ * All the calls in this class have an extra argument taking the wikiserver address on which to make the call.
+ */
+public class RpcClient extends BaseClient {
+	private final static String HANDLERCLASS = "xwikirpc";
+
+	public RpcClient(XWikiContext context){
+		super(context);
+	}
+
+	/*
+	 * @EXTENSION: Change from plain text password transmission on the network
+	 * 
+	 * login to a wikiserver with a username and password. get a token in return
+	 */
+	public String login(String username, String password, String wikiserver) {
+		return super.login(username, password, wikiserver, HANDLERCLASS);
+	}
+
+	public boolean logout(String token, String wikiserver) {
+		return super.logout(token, wikiserver, HANDLERCLASS);
+	}
+
+	public Vector getSpaces(String token, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(
+					HANDLERCLASS + ".getSpaces", new Object[] {token});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Hashtable getSpace(String token, String spaceKey, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
+					+ ".getSpace", new Object[] {token, spaceKey});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Vector getPages(String token, String spaceKey, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS + ".getPages",
+					new Object[] {token, spaceKey});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Hashtable getPage(String token, String pageId, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
+					+ ".getPage", new Object[] {token, pageId});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Vector getPageHistory(String token, String pageId, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS
+					+ ".getPageHistory", new Object[] {token, pageId});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Vector search(String token, String query, int maxResults,
+			String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS + ".search",
+					new Object[] {token, query});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public String renderContent(String token, String spaceKey, String pageId,
+			String content, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			String result = (String) client.execute(HANDLERCLASS
+					+ ".renderContent", new Object[] {token, spaceKey, pageId, content});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return "";
+	}
+
+	public Vector getAttachments(String token, String pageId, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS
+					+ ".getAttachments", new Object[] {token, pageId});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Vector getComments(String token, String pageId, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS
+					+ ".getComments", new Object[] {token, pageId});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public Hashtable storePage(String token, Hashtable pageht, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
+					+ ".storePage", new Object[] {token, pageht});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public void deletePage(String token, String pageId, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			client.execute(HANDLERCLASS + ".deletePage", new Object[] {token, pageId});
+			return;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return;
+	}
+
+	public Hashtable getUser(String token, String username, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Hashtable result = (Hashtable) client.execute(HANDLERCLASS
+					+ ".getUser", new Object[] {token, username});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public void addUser(String token, Hashtable user, String password,
+			String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			client.execute(HANDLERCLASS + ".addUser", new Object[] {token, user, password});
+			return;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return;
+	}
+
+	public void addGroup(String token, String group, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			client.execute(HANDLERCLASS + ".addGroup", new Object[] {token, group});
+			return;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return;
+	}
+
+	public Vector getUserGroups(String token, String username, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS
+					+ ".getUserGroups", new Object[] {token, username});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public void addUserToGroup(String token, String username, String groupname,
+			String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			// FIXME Integer result = (Integer) 
+			client.execute(HANDLERCLASS
+					+ ".addUserToGroup", new Object[] {token, username, groupname});
+			return;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return;
+	}
+
+	public Vector getAllPages(String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			Vector result = (Vector) client.execute(HANDLERCLASS
+					+ ".getAllPages", new Object[] {});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return new Vector();
+	}
+
+	public byte[] getPage(String name, String wikiserver) {
+		HandlerStub client = getConnection(wikiserver);
+		try {
+			byte[] result = (byte[]) client.execute(HANDLERCLASS + ".getPage",
+					new Object[] {name});
+			return result;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return new byte[0];
+	}
+}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectionFactory.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectionFactory.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,7 @@
+package com.xpn.p2pxwiki.communication;
+
+import com.xpn.p2pxwiki.P2PXWikiException;
+
+public interface ConnectionFactory {
+	HandlerStub getConnection(String peer) throws P2PXWikiException;
+}

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorApi.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorApi.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorApi.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -60,7 +60,7 @@
 		return ConnectorPlugin.getPeerName();
 	}
 	
-	public NetworkInterface getNetwork(){
+	public Network getNetwork(){
 		return ConnectorPlugin.getNetwork();
 	}
 }

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorPlugin.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorPlugin.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/ConnectorPlugin.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -54,7 +54,7 @@
 	public static final String NETWORK_TYPE = "p2pxwiki.connector.network";
 	public static final String DEFAULT_NETWORK_TYPE = "com.xpn.p2pxwiki.communication.jxta.JxtaNetwork";
 	public static final String CONNECTOR_FACTORY = "p2pxwiki.connector.type";
-	public static final String DEFAULT_CONNECTOR_FACTORY = "com.xpn.p2pxwiki.communication.jxta.XmlRpcJxtaRemoteConnectionFactory";
+	public static final String DEFAULT_CONNECTOR_FACTORY = "com.xpn.p2pxwiki.communication.jxta.JxtaConnectionFactory";
 	public static final String HANDLERMANAGER = "p2pxwiki.connector.handler";
 	public static final String DEFAULT_HANDLERMANAGER = "com.xpn.p2pxwiki.communication.jxta.JxtaHandlerManager";
 	public static final String SERVER_PORT = "p2pxwiki.server.port";
@@ -65,9 +65,9 @@
 
 	private static Log log = LogFactory.getFactory().getInstance(ConnectorPlugin.class);
 	private static XWikiCache cache = null;
-	private static NetworkInterface network;
-	private static RemoteConnectionFactoryInterface factory;
-	private static HandlerManagerInterface handlerManager;
+	private static Network network;
+	private static ConnectionFactory factory;
+	private static HandlerManager handlerManager;
 	private static String networkType;
 	private static String connectorType;
 	private static int cacheTime;
@@ -119,7 +119,7 @@
 		networkType = xwiki.Param(NETWORK_TYPE, DEFAULT_NETWORK_TYPE);
 		// TODO: Retry with default network on failure, if this isn't already the default
 		try{
-			network = (NetworkInterface)Class.forName(networkType)
+			network = (Network)Class.forName(networkType)
 				.getMethod("getInstance", (Class[])null).invoke(null, (Object[])null);
 		}
 		catch(ClassNotFoundException ex){
@@ -140,7 +140,7 @@
 		connectorType = xwiki.Param(CONNECTOR_FACTORY, DEFAULT_CONNECTOR_FACTORY);
 		// TODO: Retry with default connector on failure, if this isn't already the default
 		try{
-			factory = (RemoteConnectionFactoryInterface)Class.forName(connectorType)
+			factory = (ConnectionFactory)Class.forName(connectorType)
 				.getMethod("getInstance", (Class[])null).invoke(null, (Object[])null);
 		}
 		catch(ClassNotFoundException ex){
@@ -161,7 +161,7 @@
 		// TODO: Retry with default manager on failure, if this isn't already the default
 		connectorType = xwiki.Param(HANDLERMANAGER, DEFAULT_HANDLERMANAGER);
 		try{
-			handlerManager = (HandlerManagerInterface)Class.forName(connectorType)
+			handlerManager = (HandlerManager)Class.forName(connectorType)
 				.getMethod("getInstance", (Class[])null).invoke(null, (Object[])null);
 		}
 		catch(ClassNotFoundException ex){
@@ -273,7 +273,7 @@
 	/**
 	 * @return the network
 	 */
-	public static NetworkInterface getNetwork() {
+	public static Network getNetwork() {
 		return network;
 	}
 }

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManager.java (from rev 1175, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java	2006-08-19 19:07:09 UTC (rev 1175)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManager.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,21 @@
+package com.xpn.p2pxwiki.communication;
+
+import com.xpn.p2pxwiki.P2PXWikiException;
+
+public interface HandlerManager {
+	/**
+	 * 
+	 * @param handler
+	 * @return true on succcess
+	 * @throws P2PXWikiException
+	 */
+	boolean addHandler(Handler handler) throws P2PXWikiException;
+	
+	/**
+	 * 
+	 * @param handler
+	 * @return true on succcess
+	 * @throws P2PXWikiException
+	 */
+	boolean removeHandler(Handler handler) throws P2PXWikiException;
+}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerManagerInterface.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,21 +0,0 @@
-package com.xpn.p2pxwiki.communication;
-
-import com.xpn.p2pxwiki.client.P2PXWikiException;
-
-public interface HandlerManagerInterface {
-	/**
-	 * 
-	 * @param handler
-	 * @return true on succcess
-	 * @throws P2PXWikiException
-	 */
-	boolean addHandler(Handler handler) throws P2PXWikiException;
-	
-	/**
-	 * 
-	 * @param handler
-	 * @return true on succcess
-	 * @throws P2PXWikiException
-	 */
-	boolean removeHandler(Handler handler) throws P2PXWikiException;
-}

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerStub.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerStub.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/HandlerStub.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,7 +1,7 @@
 package com.xpn.p2pxwiki.communication;
 
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 
 public interface HandlerStub {
 	String getPeerName();

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/Network.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/Network.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,7 @@
+package com.xpn.p2pxwiki.communication;
+
+
+public interface Network {
+	public String getCanonicalLocalName();
+	public String getCanonicalRemoteName(String peer);
+}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/NetworkInterface.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,7 +0,0 @@
-package com.xpn.p2pxwiki.communication;
-
-
-public interface NetworkInterface {
-	public String getCanonicalLocalName();
-	public String getCanonicalRemoteName(String peer);
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/RemoteConnectionFactoryInterface.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,7 +0,0 @@
-package com.xpn.p2pxwiki.communication;
-
-import com.xpn.p2pxwiki.client.P2PXWikiException;
-
-public interface RemoteConnectionFactoryInterface {
-	HandlerStub getConnection(String peer) throws P2PXWikiException;
-}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaConnectionFactory.java (from rev 1177, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaConnectionFactory.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,41 @@
+package com.xpn.p2pxwiki.communication.jxta;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.p2pxwiki.P2PXWikiException;
+import com.xpn.p2pxwiki.communication.HandlerStub;
+import com.xpn.p2pxwiki.communication.ConnectionFactory;
+
+public class JxtaConnectionFactory
+		implements ConnectionFactory {
+	private static Log log = LogFactory.getFactory().getInstance(JxtaConnectionFactory.class);
+
+	protected static JxtaConnectionFactory instance = null;
+	
+	protected JxtaConnectionFactory(){
+		log.debug("constructor");
+		init();
+	}
+
+	protected void init(){
+		log.debug("init");
+		// Nothing to be done here yet
+	}
+
+	/**
+	 * @see com.xpn.p2pxwiki.communication.BasicRemoteConnectionFactory#getConnection(java.lang.String)
+	 */
+	public HandlerStub getConnection(String peer) throws P2PXWikiException {
+		log.debug("getConnection");
+		return new JxtaHandlerStub(peer);
+	}
+
+	public static JxtaConnectionFactory getInstance(){
+		log.debug("getInstance");
+		if(instance == null){
+			instance = new JxtaConnectionFactory();
+		}
+		return instance;
+	}
+}

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerManager.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerManager.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerManager.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -4,12 +4,12 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.xmlrpc.P2PWebServer;
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
 import com.xpn.p2pxwiki.communication.Handler;
-import com.xpn.p2pxwiki.communication.HandlerManagerInterface;
+import com.xpn.p2pxwiki.communication.HandlerManager;
 
-public class JxtaHandlerManager implements HandlerManagerInterface {
+public class JxtaHandlerManager implements HandlerManager {
 	private static Log log = LogFactory.getFactory().getInstance(
 			JxtaHandlerManager.class);
 	private P2PWebServer p2pwebserver;

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerStub.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerStub.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaHandlerStub.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -8,7 +8,7 @@
 import org.apache.xmlrpc.P2PXmlRpcClientLite;
 import org.apache.xmlrpc.XmlRpcException;
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
 import com.xpn.p2pxwiki.communication.HandlerStub;
 
@@ -17,7 +17,7 @@
 	private String peer;
 	private P2PXmlRpcClientLite connection = null;
 
-	public XmlRpcJxtaHandlerStub(String peer){
+	public JxtaHandlerStub(String peer){
 		try {
 			this.peer = peer;
 			this.connection = new P2PXmlRpcClientLite(ConnectorPlugin.getNetwork().getCanonicalRemoteName(peer));

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaNetwork.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaNetwork.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaNetwork.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -5,9 +5,9 @@
 import org.p2psockets.P2PNetwork;
 
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.communication.NetworkInterface;
+import com.xpn.p2pxwiki.communication.Network;
 
-public class JxtaNetwork implements NetworkInterface{
+public class JxtaNetwork implements Network{
 	private static Log log = LogFactory.getFactory().getInstance(JxtaNetwork.class);
 	private static String networkName = "JXTA:P2PXWikiNetwork";
 	private static boolean inited = false;

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/jxta/JxtaRemoteConnectionFactory.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,41 +0,0 @@
-package com.xpn.p2pxwiki.communication.jxta;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.client.P2PXWikiException;
-import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.p2pxwiki.communication.RemoteConnectionFactoryInterface;
-
-public class XmlRpcJxtaRemoteConnectionFactory
-		implements RemoteConnectionFactoryInterface {
-	private static Log log = LogFactory.getFactory().getInstance(XmlRpcJxtaRemoteConnectionFactory.class);
-
-	protected static XmlRpcJxtaRemoteConnectionFactory instance = null;
-	
-	protected XmlRpcJxtaRemoteConnectionFactory(){
-		log.debug("constructor");
-		init();
-	}
-
-	protected void init(){
-		log.debug("init");
-		// Nothing to be done here yet
-	}
-
-	/**
-	 * @see com.xpn.p2pxwiki.communication.BasicRemoteConnectionFactory#getConnection(java.lang.String)
-	 */
-	public HandlerStub getConnection(String peer) throws P2PXWikiException {
-		log.debug("getConnection");
-		return new JxtaHandlerStub(peer);
-	}
-
-	public static XmlRpcJxtaRemoteConnectionFactory getInstance(){
-		log.debug("getInstance");
-		if(instance == null){
-			instance = new XmlRpcJxtaRemoteConnectionFactory();
-		}
-		return instance;
-	}
-}

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcConnectionFactory.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcConnectionFactory.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcConnectionFactory.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -3,12 +3,12 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 import com.xpn.p2pxwiki.communication.HandlerStub;
-import com.xpn.p2pxwiki.communication.RemoteConnectionFactoryInterface;
+import com.xpn.p2pxwiki.communication.ConnectionFactory;
 
 public class RpcConnectionFactory 
-		implements RemoteConnectionFactoryInterface {
+		implements ConnectionFactory {
 	private static Log log = LogFactory.getFactory().getInstance(RpcConnectionFactory.class);
 
 	protected static RpcConnectionFactory instance = null;

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerManager.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerManager.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerManager.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -4,12 +4,12 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.xmlrpc.WebServer;
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
 import com.xpn.p2pxwiki.communication.Handler;
-import com.xpn.p2pxwiki.communication.HandlerManagerInterface;
+import com.xpn.p2pxwiki.communication.HandlerManager;
 
-public class RpcHandlerManager implements HandlerManagerInterface {
+public class RpcHandlerManager implements HandlerManager {
 	private static Log log = LogFactory.getFactory().getInstance(RpcHandlerManager.class);
 	private WebServer webserver;
 	

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerStub.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerStub.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcHandlerStub.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -8,7 +8,7 @@
 import org.apache.xmlrpc.XmlRpcClientLite;
 import org.apache.xmlrpc.XmlRpcException;
 
-import com.xpn.p2pxwiki.client.P2PXWikiException;
+import com.xpn.p2pxwiki.P2PXWikiException;
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
 import com.xpn.p2pxwiki.communication.HandlerStub;
 

Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcNetwork.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcNetwork.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/rpc/RpcNetwork.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -7,9 +7,9 @@
 import org.apache.commons.logging.LogFactory;
 
 import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.communication.NetworkInterface;
+import com.xpn.p2pxwiki.communication.Network;
 
-public class RpcNetwork implements NetworkInterface{
+public class RpcNetwork implements Network{
 	private static Log log = LogFactory.getFactory().getInstance(RpcNetwork.class);
 	private static boolean inited = false;
 	
@@ -28,7 +28,7 @@
 	}
 
 	/**
-	 * @see com.xpn.p2pxwiki.communication.NetworkInterface#getCanonicalLocalName()
+	 * @see com.xpn.p2pxwiki.communication.Network#getCanonicalLocalName()
 	 * FIXME: This should be written differently. How?
 	 */
 	public String getCanonicalLocalName() {

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ClientBaseExamples.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ClientBaseExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,15 @@
+package com.xpn.p2pxwiki.examples;
+
+import com.xpn.xwiki.XWikiContext;
+
+public class ClientBaseExamples {
+	String peerAddress; 
+	XWikiContext context = null;
+
+	public void initJXTA()  { 
+		peerAddress = "http://testclient.p2pxwiki.com"; 
+		if (context == null) { 
+			context = new XWikiContext(); 
+		} 
+	}
+}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiClientBaseExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,15 +0,0 @@
-package com.xpn.p2pxwiki.examples;
-
-import com.xpn.xwiki.XWikiContext;
-
-public class P2PXWikiClientBaseExamples {
-	String peerAddress; 
-	XWikiContext context = null;
-
-	public void initJXTA()  { 
-		peerAddress = "http://testclient.p2pxwiki.com"; 
-		if (context == null) { 
-			context = new XWikiContext(); 
-		} 
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,42 +0,0 @@
-package com.xpn.p2pxwiki.examples;
-
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.client.P2PXWikiRPCClient;
-
-public class P2PXWikiRPCClientExamples extends P2PXWikiClientBaseExamples {
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiRPCClientExamples.class);
-	
-	public void test() { 
-		P2PXWikiRPCClient rpcClient = new P2PXWikiRPCClient(context);
-		log.error("getting all wikipage names");
-		
-		String token = rpcClient.login("bikash", "bikash", "registry");
-		log.error("got token: " + token
-				+ " after login in to RPCHandler class at the registry");
-		
-		Vector res = rpcClient.getAllPages("registry");
-		log.error("got " + res.size() + " entries for all the pages");
-		for (int i = 0; i < res.size(); i++) {
-			log.error(((String) res.get(i))+"");
-		}
-	}
-	
-	public void run() { 
-		test() ; 
-	}
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		P2PXWikiRPCClientExamples examples = new P2PXWikiRPCClientExamples(); 
-		examples.initJXTA(); 
-		examples.run(); 
-	}
-
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,80 +0,0 @@
-package com.xpn.p2pxwiki.examples;
-
-import junit.framework.Assert;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.client.P2PXWikiRegistryClient;
-
-/* this is an example of stand-alone client which uses the registryclient side apis. This is for 
- * demonstration purposes
- *  */ 
-public class P2PXWikiRegistryClientExamples extends P2PXWikiClientBaseExamples {
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiRegistryClientExamples.class);
-
-	
-	/* @TODO: refactor it to a junit test */
-	public void test() {
-		String q = "bikash.p2pxwiki.com";
-		String ip1 = "130.207.5.200";
-		String ip2 = "130.207.4.300";
-		P2PXWikiRegistryClient reg = new P2PXWikiRegistryClient(context);
-
-		String dummyToken = "dummy";
-		log.error("result of querying: " + q + " is:--"
-				+ (ip1 = reg.queryRegistry(q)) + "--");
-		log.error("updating registry with " + q + " and ip = " + ip2);
-		boolean result = reg.updateRegistry(dummyToken, q, ip2);
-		Assert.assertTrue(result == false);
-		log.error("update to the registry failed, as expected"); 
-		log.error("result of querying: " + q + " is:--" + reg.queryRegistry(q)
-				+ "--");
-	
-		log.error("updating registry with " + q + " and ip = " + ip2);
-		result = reg.updateMasterIP(dummyToken, q, ip2);
-		Assert.assertTrue(result == false); 
-
-		log.error("trying to login as user guest");
-		String token = reg.login("guest", "guest");
-		
-    Assert.assertTrue(token.length() > 0); 
-		log.error("login as guest successful!!");
-		
-		log.error("trying to login as user bikash");
-		token = reg.login("bikash", "bikash"); 
-		
-		if (token != null)
-			log.error("login as bikash successful!!");
-		else
-			log.error("login as bikash failed!!");
-		
-		if (token != null) {
-			log.error("trying to update the registry with username bikash");
-			boolean res = reg.updateRegistry(token, q, ip1);
-      Assert.assertTrue(res == true); 
-			log.error("update successful");
-			
-			log.error("result of querying after update of: " + q + " is:--"
-					+ reg.queryRegistry(q) + "--");
-		}
-		System.out.println("test done !! ");
-	}
-	
-
-	
-	public void run() { 
-		test() ; 
-	}
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		P2PXWikiRegistryClientExamples examples = new P2PXWikiRegistryClientExamples(); 
-		examples.initJXTA(); 
-		examples.run(); 
-	}
-
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,72 +0,0 @@
-package com.xpn.p2pxwiki.examples;
-
-import java.util.Date;
-import java.util.Vector;
-
-import junit.framework.Assert;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.xpn.p2pxwiki.client.P2PXWikiReplicationClient;
-import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-
-
-public class P2PXWikiReplicationClientExamples extends P2PXWikiClientBaseExamples {
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiReplicationClientExamples.class);
-
-
-	public void test() { 
-		P2PXWikiReplicationClient client = new P2PXWikiReplicationClient(context);
-		String wikiserver = "registry"; 
-		
-		log.error("trying to login as user bikash");
-		String token = client.login("bikash", "bikash", wikiserver);
-		
-    Assert.assertTrue(token != null); 
-			log.error("login as bikash successful!!");
-	
-		Vector allXML = client.getAllPagesAsXML(token,wikiserver, "http://bikash.p2pxwiki.com"); 
-		log.error("got "+allXML.size()+" entries from the wiki at: "+ wikiserver ); 
-		log.error("address of local jxta peer is : "+ ConnectorPlugin.getNetwork().getCanonicalLocalName());
-	
-		token = client.login("Admin","admin"); 
-		log.error("result of loggin in to local peer as Admin for replication is token:"+ token);
-		log.error("trying replication: will see that all pages exist !"); 
-		
-		boolean res = client.replicateAllPagesFromXML(token,allXML, "http://bikash.p2pxwiki.com"); 
-		log.error("tried replication, got result: "+ res); 
-		
-		log.error("WARN:: Trying to copy all the contents from bikash's wiki to db ludovic locally !!! "); 
-		
-		res = client.replicateAllPagesFromXML(token,allXML,"http://ludovic.p2pxwiki.com"); 
-		log.error("tried replication to db ludovic, got result: "+ res); 
-		
-	/*  try individually  	
-		for(int  i = 0; i < allXML.size(); i++) { 
-			log.error("client trying to replicate doc #"+i ); 
-			boolean res = client.replicatePageFromXML(token, (String) allXML.get(i)); 
-			log.error("tried replication #"+i+" , got result: "+ res); 
-		}
-		*/ 
-		
-		allXML = client.getAllPagesModifiedSinceAsXML(token,new Date(),wikiserver, "http://bikash.p2pxwiki.com"); 
-		log.error("got "+allXML.size()+" entries modified since Now from the wiki at: "+ wikiserver );
-	}
-	
-	public void run() { 
-		test() ; 
-	}
-	
-	/**
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		P2PXWikiReplicationClientExamples examples = new P2PXWikiReplicationClientExamples(); 
-		examples.initJXTA(); 
-		examples.run(); 
-	}
-
-
-}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RegistryClientExamples.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRegistryClientExamples.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RegistryClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,80 @@
+package com.xpn.p2pxwiki.examples;
+
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.p2pxwiki.registry.RegistryClient;
+
+/* this is an example of stand-alone client which uses the registryclient side apis. This is for 
+ * demonstration purposes
+ *  */ 
+public class RegistryClientExamples extends ClientBaseExamples {
+	private static Log log = LogFactory.getFactory().getInstance(
+			RegistryClientExamples.class);
+
+	
+	/* @TODO: refactor it to a junit test */
+	public void test() {
+		String q = "bikash.p2pxwiki.com";
+		String ip1 = "130.207.5.200";
+		String ip2 = "130.207.4.300";
+		RegistryClient reg = new RegistryClient(context);
+
+		String dummyToken = "dummy";
+		log.error("result of querying: " + q + " is:--"
+				+ (ip1 = reg.queryRegistry(q)) + "--");
+		log.error("updating registry with " + q + " and ip = " + ip2);
+		boolean result = reg.updateRegistry(dummyToken, q, ip2);
+		Assert.assertTrue(result == false);
+		log.error("update to the registry failed, as expected"); 
+		log.error("result of querying: " + q + " is:--" + reg.queryRegistry(q)
+				+ "--");
+	
+		log.error("updating registry with " + q + " and ip = " + ip2);
+		result = reg.updateMasterIP(dummyToken, q, ip2);
+		Assert.assertTrue(result == false); 
+
+		log.error("trying to login as user guest");
+		String token = reg.login("guest", "guest");
+		
+    Assert.assertTrue(token.length() > 0); 
+		log.error("login as guest successful!!");
+		
+		log.error("trying to login as user bikash");
+		token = reg.login("bikash", "bikash"); 
+		
+		if (token != null)
+			log.error("login as bikash successful!!");
+		else
+			log.error("login as bikash failed!!");
+		
+		if (token != null) {
+			log.error("trying to update the registry with username bikash");
+			boolean res = reg.updateRegistry(token, q, ip1);
+      Assert.assertTrue(res == true); 
+			log.error("update successful");
+			
+			log.error("result of querying after update of: " + q + " is:--"
+					+ reg.queryRegistry(q) + "--");
+		}
+		System.out.println("test done !! ");
+	}
+	
+
+	
+	public void run() { 
+		test() ; 
+	}
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		RegistryClientExamples examples = new RegistryClientExamples(); 
+		examples.initJXTA(); 
+		examples.run(); 
+	}
+
+}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ReplicationClientExamples.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiReplicationClientExamples.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/ReplicationClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,72 @@
+package com.xpn.p2pxwiki.examples;
+
+import java.util.Date;
+import java.util.Vector;
+
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.p2pxwiki.communication.ConnectorPlugin;
+import com.xpn.p2pxwiki.replication.ReplicationClient;
+
+
+public class ReplicationClientExamples extends ClientBaseExamples {
+	private static Log log = LogFactory.getFactory().getInstance(
+			ReplicationClientExamples.class);
+
+
+	public void test() { 
+		ReplicationClient client = new ReplicationClient(context);
+		String wikiserver = "registry"; 
+		
+		log.error("trying to login as user bikash");
+		String token = client.login("bikash", "bikash", wikiserver);
+		
+    Assert.assertTrue(token != null); 
+			log.error("login as bikash successful!!");
+	
+		Vector allXML = client.getAllPagesAsXML(token,wikiserver, "http://bikash.p2pxwiki.com"); 
+		log.error("got "+allXML.size()+" entries from the wiki at: "+ wikiserver ); 
+		log.error("address of local jxta peer is : "+ ConnectorPlugin.getNetwork().getCanonicalLocalName());
+	
+		token = client.login("Admin","admin"); 
+		log.error("result of loggin in to local peer as Admin for replication is token:"+ token);
+		log.error("trying replication: will see that all pages exist !"); 
+		
+		boolean res = client.replicateAllPagesFromXML(token,allXML, "http://bikash.p2pxwiki.com"); 
+		log.error("tried replication, got result: "+ res); 
+		
+		log.error("WARN:: Trying to copy all the contents from bikash's wiki to db ludovic locally !!! "); 
+		
+		res = client.replicateAllPagesFromXML(token,allXML,"http://ludovic.p2pxwiki.com"); 
+		log.error("tried replication to db ludovic, got result: "+ res); 
+		
+	/*  try individually  	
+		for(int  i = 0; i < allXML.size(); i++) { 
+			log.error("client trying to replicate doc #"+i ); 
+			boolean res = client.replicatePageFromXML(token, (String) allXML.get(i)); 
+			log.error("tried replication #"+i+" , got result: "+ res); 
+		}
+		*/ 
+		
+		allXML = client.getAllPagesModifiedSinceAsXML(token,new Date(),wikiserver, "http://bikash.p2pxwiki.com"); 
+		log.error("got "+allXML.size()+" entries modified since Now from the wiki at: "+ wikiserver );
+	}
+	
+	public void run() { 
+		test() ; 
+	}
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		ReplicationClientExamples examples = new ReplicationClientExamples(); 
+		examples.initJXTA(); 
+		examples.run(); 
+	}
+
+
+}

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RpcClientExamples.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/P2PXWikiRPCClientExamples.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/examples/RpcClientExamples.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,42 @@
+package com.xpn.p2pxwiki.examples;
+
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.p2pxwiki.client.RpcClient;
+
+public class RpcClientExamples extends ClientBaseExamples {
+	private static Log log = LogFactory.getFactory().getInstance(
+			RpcClientExamples.class);
+	
+	public void test() { 
+		RpcClient rpcClient = new RpcClient(context);
+		log.error("getting all wikipage names");
+		
+		String token = rpcClient.login("bikash", "bikash", "registry");
+		log.error("got token: " + token
+				+ " after login in to RPCHandler class at the registry");
+		
+		Vector res = rpcClient.getAllPages("registry");
+		log.error("got " + res.size() + " entries for all the pages");
+		for (int i = 0; i < res.size(); i++) {
+			log.error(((String) res.get(i))+"");
+		}
+	}
+	
+	public void run() { 
+		test() ; 
+	}
+	
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		RpcClientExamples examples = new RpcClientExamples(); 
+		examples.initJXTA(); 
+		examples.run(); 
+	}
+
+}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,413 +0,0 @@
-package com.xpn.p2pxwiki.registry;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-import com.xpn.p2pxwiki.communication.Handler;
-import com.xpn.p2pxwiki.rpc.P2PXWikiRPCHandler;
-import com.xpn.xwiki.XWiki;
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.objects.classes.BaseClass;
-import com.xpn.xwiki.store.XWikiHibernateStore;
-import com.xpn.xwiki.web.XWikiEngineContext;
-import com.xpn.xwiki.web.XWikiRequest;
-import com.xpn.xwiki.web.XWikiResponse;
-
-public class P2PXWikiRegistryHandler extends P2PXWikiRPCHandler implements Handler{
-	private static Log log = LogFactory.getFactory().getInstance(
-			P2PXWikiRegistryHandler.class);
-
-	private final int DEFAULT_DOMAIN_ID = 1;
-
-	private final int DEFAULT_TTL = 120;
-
-	private final String DEFAULT_TYPE = "A";
-	private final String PLUGIN_NAME = "registry";
-
-	private static Map virtualWikiMap = new HashMap();
-
-	public P2PXWikiRegistryHandler(XWikiRequest request,
-			XWikiResponse response, XWikiEngineContext econtext) {
-		super(request, response, econtext);
-	}
-
-	public String getName(){
-		return PLUGIN_NAME; 
-	}
-
-	/* registry by default is maintained in the xwiki database, so 
-	 * init method is passed "" as argument 
-	 */
-	public boolean existsWikiapp(String wikiapp) {
-		try {
-			XWikiContext context = init("");
-			return existsWikiapp(wikiapp, context);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-
-	/* modelled after XWiki.findWikiServer */
-	private static String findWikiServer(String host, XWikiContext context) {
-		String wikiserver = (String) virtualWikiMap.get(host);
-		if (wikiserver != null)
-			return wikiserver;
-
-		String hql = ", BaseObject as obj, StringProperty as prop where obj.name="
-				+ context.getWiki().getFullNameSQL()
-				+ " and obj.className='XWiki.XWikiServerClass' and prop.id.id = obj.id "
-				+ "and prop.id.name = 'server' and prop.value='" + host + "'";
-		try {
-			List list = context.getWiki().getStore().searchDocumentsNames(hql,
-					context);
-			if ((list == null) || (list.size() == 0))
-				return null;
-			String docname = (String) list.get(0);
-			if (!docname.startsWith("XWiki.XWikiServer"))
-				return null;
-			wikiserver = docname.substring("XWiki.XWikiServer".length())
-					.toLowerCase();
-			virtualWikiMap.put(host, wikiserver);
-			return wikiserver;
-		} catch (XWikiException e) {
-			return null;
-		}
-	}
-
-	private XWikiDocument checkDocument(String wikiapp, XWikiContext context) {
-		try {
-			XWiki xwiki = context.getWiki();
-			if (!xwiki.isVirtual()) {
-				log.error("Not using Virtual Wiki !!!");
-				return null;
-			}
-			if (xwiki.isVirtual()) {
-				String host = "";
-				try {
-					String fullapp = wikiapp;
-					if (fullapp.length() > 0 && fullapp.indexOf(":") == -1)
-						fullapp = "http://" + fullapp;
-					URL requestURL = new URL(fullapp);
-					host = requestURL.getHost();
-				} catch (Exception e) {
-				}
-				;
-
-				log.error("looking for a server document for host: " + host);
-				if (host.equals(""))
-					return null;
-
-				String appname = findWikiServer(host, context);
-				log.error("Checking for the existance of appname:" + appname);
-				if (appname == null) {
-					return null;
-				}
-
-				// Check if this appname exists in the Database
-				String serverwikipage = XWiki.getServerWikiPage(appname);
-				XWikiDocument doc = xwiki.getDocument(serverwikipage, context);
-				if (doc.isNew()) {
-					/* document doesn't exist */
-					log.error("there is no document corresponding to appname: "
-							+ appname);
-					return null;
-				}
-				return doc;
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return null;
-	}
-
-	public BaseClass getServerClass(XWikiContext context) {
-		XWikiDocument doc;
-		boolean needsUpdate = false;
-		try {
-			doc = context.getWiki().getDocument("XWiki.XWikiServerClass",
-					context);
-		} catch (Exception e) {
-			doc = new XWikiDocument();
-			doc.setWeb("XWiki");
-			doc.setName("XWikiServerClass");
-			needsUpdate = true;
-		}
-		BaseClass bclass = doc.getxWikiClass();
-		if (context.get("initdone") != null)
-			return bclass;
-		log.error("Creating a new Server Class document.");
-		bclass.setName("XWiki.XWikiServerClass");
-		needsUpdate |= bclass.addTextField("owner", "Owner", 30);
-		needsUpdate |= bclass.addTextField("server", "Server", 30);
-		String content = doc.getContent();
-		if ((content == null) || (content.equals(""))) {
-			needsUpdate = true;
-			doc.setContent("1 XWiki Servers");
-		}
-		try {
-			if (needsUpdate)
-				context.getWiki().saveDocument(doc, context);
-		} catch (Exception e) {
-			e.printStackTrace();
-			return null;
-		}
-		return bclass;
-	}
-
-	public boolean createServerClass(String wikiName, String wikiAdmin,
-			String wikiUrl, String description, String wikilanguage,
-			XWikiContext context) {
-		XWiki wiki = context.getWiki();
-		String wikiServerPage = "XWikiServer"
-				+ wikiName.substring(0, 1).toUpperCase()
-				+ wikiName.substring(1);
-		try {
-			XWikiDocument serverdoc = wiki.getDocument("XWiki", wikiServerPage,
-					context);
-			if (serverdoc.isNew()) {
-				serverdoc.setStringValue("XWiki.XWikiServerClass", "server",
-						wikiUrl);
-				serverdoc.setLargeStringValue("XWiki.XWikiServerClass",
-						"owner", wikiAdmin);
-				if (description != null)
-					serverdoc.setStringValue("XWiki.XWikiServerClass",
-							"description", description);
-				if (wikilanguage != null)
-					serverdoc.setStringValue("XWiki.XWikiServerClass",
-							"language", wikilanguage);
-				serverdoc
-						.setContent("#includeForm(\"XWiki.XWikiServerForm\")\n");
-				serverdoc.setParent("XWiki.XWikiServerClass");
-				wiki.saveDocument(serverdoc, context);
-				return true;
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			return false;
-		}
-		return false;
-	}
-
-	/*
-	 * check whether the user is the owner of the wiki at the wikiapp : modelled
-	 * after XWiki.getXWiki method
-	 * 
-	 * wikiapp is the name of the host. @TODO: Return appropriate error codes
-	 * (document is new/not virtual wiki etc)
-	 */
-
-	private boolean checkWikiMaster(String wikiapp, String user,
-			XWikiContext context) {
-		XWikiDocument doc = checkDocument(wikiapp, context);
-		if (doc == null)
-			return false;
-		String wikiOwner = doc
-				.getStringValue("XWiki.XWikiServerClass", "owner");
-		if (wikiOwner.indexOf(":") != -1)
-			wikiOwner = wikiOwner.substring(wikiOwner.indexOf(":") + 1);
-		log
-				.error("found the owner of wiki " + wikiapp + " to be: "
-						+ wikiOwner);
-		if (user.startsWith("XWiki"))
-			user = user.substring(user.indexOf(".") + 1);
-		if (wikiOwner.startsWith("XWiki"))
-			wikiOwner = wikiOwner.substring(wikiOwner.indexOf(".") + 1);
-		log.error("comparing wikiowner:" + wikiOwner + " with user:" + user);
-		if (wikiOwner.equalsIgnoreCase(user))
-			return true;
-		return false;
-	}
-
-	public boolean updateRegistry(String token, String wikiapp, String IP) {
-		try {
-			XWikiContext context = init("");
-			return updateRegistry(token, wikiapp, IP, context);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return false;
-	}
-
-	public boolean existsWikiapp(String wikiapp, XWikiContext context) {
-		boolean bTransaction = true;
-		XWikiHibernateStore hibstore = null;
-		try {
-			hibstore = context.getWiki().getHibernateStore();
-			bTransaction = bTransaction && hibstore.beginTransaction(context);
-			Session session = hibstore.getSession(context);
-			Query existQuery = session
-					.createQuery("select r.name from DNSRecords as r "
-							+ "where r.name = :name and r.type = :type and r.domainId = :domainId");
-			existQuery.setString("name", wikiapp);
-			existQuery.setString("type", DEFAULT_TYPE);
-			existQuery.setInteger("domainId", DEFAULT_DOMAIN_ID);
-
-			Iterator it = existQuery.list().iterator();
-			while (it.hasNext()) {
-				String name = (String) it.next();
-				if (wikiapp.equals(name)) {
-					log.error("found Wikiapp:" + wikiapp
-							+ " in dnsrecords, yeah..");
-					return true;
-				}
-			}
-			return false;
-		} catch (Exception e) {
-			e.printStackTrace();
-		} finally {
-			try {
-				if (bTransaction)
-					hibstore.endTransaction(context, false);
-			} catch (Exception e) {
-			}
-		}
-		return false;
-	}
-
-	/*
-	 * @TODO: This function updates all the ips with a given wikiapp, if the
-	 * wikiapp exists. The reason is that the registry is maintaining a list of
-	 * masters only which is unique at present per wiki.
-	 * 
-	 * 
-	 * @TODO: Return more appropriate return codes (like authentication failure,
-	 * wiki already exists etc)
-	 */
-
-	public boolean updateRegistry(String token, String wikiapp, String IP,
-			XWikiContext context) {
-		boolean bTransaction = true;
-		XWikiHibernateStore hibstore = null;
-		boolean result = false;
-
-		// Verify authentication token
-		if (!checkToken(token, context)) {
-			log.error("Authentication token verification failed for token "
-					+ token + "\n");
-			return false;
-		}
-		String username = context.getUser();
-		// check that user is the owner of the wiki before updating the ip
-		log.error("checking if user: " + username
-				+ " is the owner of the wiki: " + wikiapp);
-		XWikiDocument serverDoc = checkDocument(wikiapp, context);
-		if (serverDoc != null && (!checkWikiMaster(wikiapp, username, context))) {
-			log.error("user: " + username
-					+ " is not the owner of the wikiapp: " + wikiapp
-					+ " , update failed");
-			return false;
-		}
-		try {
-			hibstore = context.getWiki().getHibernateStore();
-			bTransaction = bTransaction && hibstore.beginTransaction(context);
-			Session session = hibstore.getSession(context);
-			Query existQuery = session
-					.createQuery("select r from DNSRecords as r "
-							+ "where r.name = :name and r.type = :type and r.domainId = :domainId");
-			existQuery.setString("name", wikiapp);
-			existQuery.setString("type", DEFAULT_TYPE);
-			existQuery.setInteger("domainId", DEFAULT_DOMAIN_ID);
-			log.error("about to perform sql query");
-			Iterator it = existQuery.list().iterator();
-			log.error("performed query, checking results");
-			if (!it.hasNext()) {
-				log
-						.error("updating the registry with a *new record* for wikiapp"
-								+ wikiapp + " and ip = " + IP);
-				DNSRecords newrecord = new DNSRecords();
-				newrecord.setDomainId(new Integer(DEFAULT_DOMAIN_ID));
-				newrecord.setName(wikiapp);
-				newrecord.setContent(IP);
-				newrecord.setType(DEFAULT_TYPE);
-				newrecord.setTtl(new Integer(DEFAULT_TTL));
-				session.save(newrecord);
-				/* create a new serverclass too */
-				result = createServerClass(username, username, wikiapp,
-						username + "'s p2pxwiki", null, context);
-				if (result)
-					log.error("successfully created server class for wiki "
-							+ wikiapp);
-				else
-					log.error("failed to create server class for wiki"
-							+ wikiapp);
-			} else {
-				while (it.hasNext()) {
-					DNSRecords record = (DNSRecords) it.next();
-					if (wikiapp.equals(record.getName())) {
-						log
-								.error("updating the registry with an *Existing record* for wikiapp"
-										+ wikiapp + " and ip = " + IP);
-						record.setContent(IP);
-						session.update(record);
-					}
-				}
-			}
-			session.flush();
-			result = true;
-		} catch (Exception e) {
-			e.printStackTrace();
-		} finally {
-			try {
-				if (bTransaction) {
-					hibstore.endTransaction(context, true);
-				}
-			} catch (Exception e) {
-			}
-		}
-		return result;
-	}
-
-	public String queryRegistry(String wikiname) {
-		try {
-			XWikiContext context = init("");
-			return queryRegistry(wikiname, context);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return "";
-	}
-
-	public String queryRegistry(String wikiname, XWikiContext context) {
-		boolean bTransaction = true;
-		XWikiHibernateStore hibstore = null;
-
-		try {
-			hibstore = context.getWiki().getHibernateStore();
-			bTransaction = bTransaction && hibstore.beginTransaction(context);
-			Session session = hibstore.getSession(context);
-			Query selectQuery = session
-					.createQuery("select r.content from DNSRecords as r "
-							+ "where r.name = :name and r.type =:type and r.domainId=:domainId");
-			selectQuery.setString("name", wikiname);
-			selectQuery.setString("type", DEFAULT_TYPE);
-			selectQuery.setInteger("domainId", DEFAULT_DOMAIN_ID);
-			Iterator it = selectQuery.list().iterator();
-			/*
-			 * @TODO : Load balancing for multiple IPs for same wiki : right now
-			 * return the first one
-			 */
-			if (it.hasNext())
-				return (String) it.next();
-		} catch (Exception e) {
-			e.printStackTrace();
-		} finally {
-			try {
-				if (bTransaction)
-					hibstore.endTransaction(context, false);
-			} catch (Exception e) {
-			}
-		}
-		return "";
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerApi.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerApi.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerApi.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,42 +0,0 @@
-package com.xpn.p2pxwiki.registry;
-
-import com.xpn.p2pxwiki.communication.Handler;
-import com.xpn.xwiki.web.XWikiEngineContext;
-import com.xpn.xwiki.web.XWikiRequest;
-import com.xpn.xwiki.web.XWikiResponse;
-
-public class P2PXWikiRegistryHandlerApi implements Handler{
-	private P2PXWikiRegistryHandler registryHandler;
-
-	public P2PXWikiRegistryHandlerApi(XWikiRequest request,
-			XWikiResponse response, XWikiEngineContext econtext) {
-		registryHandler = new P2PXWikiRegistryHandler(request, response,
-				econtext);
-	}
-
-	public String getName(){
-		return registryHandler.getName();
-	}
-
-	public boolean existsWikiapp(String wikiapp) {
-		return registryHandler.existsWikiapp(wikiapp);
-	}
-
-	public boolean updateRegistry(String token, String wikiapp, String IP) {
-		return registryHandler.updateRegistry(token, wikiapp, IP);
-	}
-
-	public String queryRegistry(String wikiname) {
-		return registryHandler.queryRegistry(wikiname);
-	}
-
-	/* @EXTENSIONS: add apis to create a user and create a wiki */
-	/* the wikiapp should be "" for the registry */ 
-	public String login(String username, String password, String wikiapp) {
-		return registryHandler.login(username, password, wikiapp);
-	}
-
-	public boolean logout(String token, String wikiapp) {
-		return registryHandler.logout(token, wikiapp);
-	}
-}

Deleted: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerPlugin.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerPlugin.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandlerPlugin.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -1,76 +0,0 @@
-package com.xpn.p2pxwiki.registry;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.xmlrpc.XmlRpc;
-
-import com.xpn.p2pxwiki.communication.ConnectorPlugin;
-import com.xpn.p2pxwiki.utils.P2PXWikiEngineContext;
-import com.xpn.p2pxwiki.utils.P2PXWikiRequest;
-import com.xpn.p2pxwiki.utils.P2PXWikiResponse;
-import com.xpn.xwiki.XWiki;
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
-import com.xpn.xwiki.plugin.XWikiPluginInterface;
-
-/* The registry plugin will only be installed at the central registry */
-public class P2PXWikiRegistryHandlerPlugin extends XWikiDefaultPlugin implements
-		XWikiPluginInterface {
-	/*
-	 * virtual name (maps to http://www.name.peer in the p2p network) and port
-	 * of the registry server, this is used to search in the p2p network by
-	 * p2psockets
-	 */
-
-	private P2PXWikiEngineContext econtext = null;
-	private P2PXWikiRequest request = null;
-	private P2PXWikiResponse response = null;
-	private static Log log = LogFactory.getFactory().getInstance(
-			com.xpn.p2pxwiki.registry.P2PXWikiRegistryHandlerPlugin.class);
-
-	public P2PXWikiRegistryHandlerPlugin(String name, String className,
-			XWikiContext context) {
-		super(name, className, context);
-		init(context);
-	}
-
-	public String getName() {
-		return "p2pxwikiregistryhandlerplugin";
-	}
-
-	public void flushCache() {
-	}
-
-	public void init(XWikiContext context) {
-		super.init(context);
-		log.error("We are inside the init method of p2pxwikiRegistry Plugin !!!");
-		XmlRpc.setKeepAlive(true);
-		//P2PXWikiRPCCommons.initJxta(P2PXWikiRPCCommons.getJxtaXWikiRegistryHost(),context);
-		try {
-			if (context.get("p2pxwikijxtaenginecontext") == null) {
-				XWiki wiki = context.getWiki();
-				econtext = new P2PXWikiEngineContext();
-				econtext.setAttribute("xwiki", wiki);
-				context.put("p2pxwikijxtaenginecontext", econtext);
-			} else
-				econtext = (P2PXWikiEngineContext) context.get("p2pxwikijxtaenginecontext");
-
-			if (context.get("p2pxwikijxtarequest") == null) {
-				request = new P2PXWikiRequest();
-				context.put("p2pxwikijxtarequest", request);
-			} else
-				request = (P2PXWikiRequest) context.get("p2pxwikijxtarequest");
-
-			if (context.get("p2pxwikijxtaresponse") == null) {
-				response = new P2PXWikiResponse();
-				context.put("p2pxwikijxtaresponse", response);
-			} else
-				response = (P2PXWikiResponse) context.get("p2pxwikijxtaresponse");
-
-			ConnectorPlugin connector = (ConnectorPlugin)context.getWiki().getPlugin("p2pxwikiconnector", context);
-			connector.addHandler(new P2PXWikiRegistryHandlerApi(request, response, econtext));
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-}

Added: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClient.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClient.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClient.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,107 @@
+package com.xpn.p2pxwiki.registry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.p2pxwiki.client.BaseClient;
+import com.xpn.p2pxwiki.communication.ConnectorPlugin;
+import com.xpn.p2pxwiki.communication.HandlerStub;
+import com.xpn.xwiki.XWikiContext;
+
+public class RegistryClient extends BaseClient {
+	private static Log log = LogFactory.getFactory().getInstance(
+			RegistryClient.class);
+
+	public RegistryClient(XWikiContext context){
+		super(context);
+	}
+	private String P2PXWIKIREGISTRYADDRESS = ConnectorPlugin.getNetwork().getCanonicalRemoteName("registry");
+
+	private String HANDLERCLASS = "registry";
+
+	public String login(String username, String password) {
+		return super.login(username, password, P2PXWIKIREGISTRYADDRESS,
+				HANDLERCLASS);
+	}
+
+	public boolean logout(String token) {
+		return super.logout(token, P2PXWIKIREGISTRYADDRESS, HANDLERCLASS);
+	}
+
+	public boolean updateRegistry(String token, String wikiname, String IP) {
+		/*
+		 * TODO Talk to the jxta network and find out the registry and update
+		 * the IP of the master wiki, the registry will then check user exists,
+		 * password is correct, check wiki exists, then update the IP
+		 */
+		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
+		try {
+			Boolean res = (Boolean) client.execute(HANDLERCLASS
+					+ ".updateRegistry", new Object[] {token, wikiname, IP});
+			return res.booleanValue();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	/* TODO Api to check a user is going offline and updating the IP */
+
+	/*
+	 * TODO Apis to update the IP of a masterwiki because user is moving to a
+	 * new place on a per wiki basis (which checks that the user is infact the
+	 * master) and contacts the registry All the APIs below are going to be
+	 * JXTA-RPC/RMI. A first cut will be local update assuming we are working at
+	 * the registry.
+	 */
+
+	public boolean updateMasterIP(String token, String wikiname, String IP) {
+		return updateRegistry(token, wikiname, IP);
+	}
+
+	/*
+	 * TODO Assuming that every user machine has a unique single instance of
+	 * p2pxwiki, this means the user name can be used to migrate all locally
+	 * hosted Wiki to new IP in the registry make sure that only the registry
+	 * has the other database and its associated mapping. One way is to make two
+	 * versions of source code, one for the "registry" node and one for others.
+	 * another approach will be to conditionally create db etc.
+	 */
+	/*
+	 * public int updateAllMastersIPbyUser(String token, String IP) { return 0; }
+	 */
+	/*
+	 * TODO This version of the update API allows to migrate a set of wikis
+	 * which were already in an old ip, and owned by the master, to a new IP
+	 */
+	/*
+	 * public int updateAllMastersfromOldIP(String username, String password,
+	 * String oldIP, String newIP) { return 0; }
+	 */
+
+	public String queryRegistry(String wikiname) {
+		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
+		log.error("Going to query for wikiname:"+ wikiname+" using registry:"+ 
+				P2PXWIKIREGISTRYADDRESS); 
+		try {
+			String res = (String) client.execute(HANDLERCLASS
+					+ ".queryRegistry", new Object[] {wikiname});
+			return res;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return "";
+	}
+
+	public boolean existsWikiapp(String wikiapp) {
+		HandlerStub client = getConnection(P2PXWIKIREGISTRYADDRESS);
+		try {
+			boolean res = ((Boolean) client.execute(HANDLERCLASS
+					+ ".existsWikiapp", new Object[] {wikiapp})).booleanValue();
+			return res;
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+}


Property changes on: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClient.java
___________________________________________________________________
Name: svn:executable
   + *

Added: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientApi.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientApi.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientApi.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,36 @@
+package com.xpn.p2pxwiki.registry;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.api.Api;
+
+public class RegistryClientApi extends Api {
+	private RegistryClient regClient = null;
+
+	public RegistryClientApi(XWikiContext context) {
+		super(context);
+		regClient = new RegistryClient(context);
+	}
+
+	/* public apis which can be accessed through a webpage */
+	public boolean existsWikiapp(String wikiapp) {
+		return regClient.existsWikiapp(wikiapp);
+	}
+
+	public boolean updateRegistry(String token, String wikiapp, String IP) {
+		return regClient.updateRegistry(token, wikiapp, IP);
+	}
+
+	public String queryRegistry(String wikiname) {
+		return regClient.queryRegistry(wikiname);
+	}
+
+	/* TODO: add apis to create a user and create a wiki */
+
+	public String login(String username, String password) {
+		return regClient.login(username, password);
+	}
+
+	public boolean logout(String token) {
+		return regClient.logout(token);
+	}
+}


Property changes on: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientApi.java
___________________________________________________________________
Name: svn:executable
   + *

Added: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientPlugin.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientPlugin.java	2006-08-19 19:22:10 UTC (rev 1177)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientPlugin.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,51 @@
+package com.xpn.p2pxwiki.registry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.api.Api;
+import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
+import com.xpn.xwiki.plugin.XWikiPluginInterface;
+
+/**
+ * Created by IntelliJ IDEA. User: bikash Date: Aug 19, 2005 Time: 12:31:43 AM
+ */
+
+public class RegistryClientPlugin extends XWikiDefaultPlugin implements
+		XWikiPluginInterface {
+	private static Log log = LogFactory.getFactory().getInstance(
+			com.xpn.p2pxwiki.registry.RegistryClientPlugin.class);
+
+	/*
+	 * virtual address of the registry server, this is used to search in the p2p
+	 * network by p2psockets -- FIXME Comment for what? 
+	 */
+	public RegistryClientPlugin(String name, String className,
+			XWikiContext context) {
+		super(name, className, context);
+		init(context);
+	}
+
+	public String getName() {
+		return "p2pxwikiregistry";
+	}
+
+	public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context) {
+		try {
+			return new RegistryClientApi(context);
+		} catch (Exception e) {
+			return null;
+		}
+	}
+
+	public void flushCache() {
+	}
+
+	public void init(XWikiContext context) {
+		log.debug("initializing");
+		super.init(context);
+//		RegistryClientExamples example = new RegistryClientExamples(); 
+//		example.run(); 
+	}
+}


Property changes on: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryClientPlugin.java
___________________________________________________________________
Name: svn:executable
   + *

Copied: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryHandler.java (from rev 1174, xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java)
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/P2PXWikiRegistryHandler.java	2006-08-19 17:25:17 UTC (rev 1174)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/registry/RegistryHandler.java	2006-08-19 19:55:01 UTC (rev 1178)
@@ -0,0 +1,413 @@
+package com.xpn.p2pxwiki.registry;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+import com.xpn.p2pxwiki.communication.Handler;
+import com.xpn.p2pxwiki.rpc.RpcHandler;
+import com.xpn.xwiki.XWiki;
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.classes.BaseClass;
+import com.xpn.xwiki.store.XWikiHibernateStore;
+import com.xpn.xwiki.web.XWikiEngineContext;
+import com.xpn.xwiki.web.XWikiRequest;
+import com.xpn.xwiki.web.XWikiResponse;
+
+public class RegistryHandler extends RpcHandler implements Handler{
+	private static Log log = LogFactory.getFactory().getInstance(
+			RegistryHandler.class);
+
+	private final int DEFAULT_DOMAIN_ID = 1;
+
+	private final int DEFAULT_TTL = 120;
+
+	private final String DEFAULT_TYPE = "A";
+	private final String PLUGIN_NAME = "registry";
+
+	private static Map virtualWikiMap = new HashMap();
+
+	public RegistryHandler(XWikiRequest request,
+			XWikiResponse response, XWikiEngineContext econtext) {
+		super(request, response, econtext);
+	}
+
+	public String getName(){
+		return PLUGIN_NAME; 
+	}
+
+	/* registry by default is maintained in the xwiki database, so 
+	 * init method is passed "" as argument 
+	 */
+	public boolean existsWikiapp(String wikiapp) {
+		try {
+			XWikiContext context = init("");
+			return existsWikiapp(wikiapp, context);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	/* modelled after XWiki.findWikiServer */
+	private static String findWikiServer(String host, XWikiContext context) {
+		String wikiserver = (String) virtualWikiMap.get(host);
+		if (wikiserver != null)
+			return wikiserver;
+
+		String hql = ", BaseObject as obj, StringProperty as prop where obj.name="
+				+ context.getWiki().getFullNameSQL()
+				+ " and obj.className='XWiki.XWikiServerClass' and prop.id.id = obj.id "
+				+ "and prop.id.name = 'server' and prop.value='" + host + "'";
+		try {
+			List list = context.getWiki().getStore().searchDocumentsNames(hql,
+					context);
+			if ((list == null) || (list.size() == 0))
+				return null;
+			String docname = (String) list.get(0);
+			if (!docname.startsWith("XWiki.XWikiServer"))
+				return null;
+			wikiserver = docname.substring("XWiki.XWikiServer".length())
+					.toLowerCase();
+			virtualWikiMap.put(host, wikiserver);
+			return wikiserver;
+		} catch (XWikiException e) {
+			return null;
+		}
+	}
+
+	private XWikiDocument checkDocument(String wikiapp, XWikiContext context) {
+		try {
+			XWiki xwiki = context.getWiki();
+			if (!xwiki.isVirtual()) {
+				log.error("Not using Virtual Wiki !!!");
+				return null;
+			}
+			if (xwiki.isVirtual()) {
+				String host = "";
+				try {
+					String fullapp = wikiapp;
+					if (fullapp.length() > 0 && fullapp.indexOf(":") == -1)
+						fullapp = "http://" + fullapp;
+					URL requestURL = new URL(fullapp);
+					host = requestURL.getHost();
+				} catch (Exception e) {
+				}
+				;
+
+				log.error("looking for a server document for host: " + host);
+				if (host.equals(""))
+					return null;
+
+				String appname = findWikiServer(host, context);
+				log.error("Checking for the existance of appname:" + appname);
+				if (appname == null) {
+					return null;
+				}
+
+				// Check if this appname exists in the Database
+				String serverwikipage = XWiki.getServerWikiPage(appname);
+				XWikiDocument doc = xwiki.getDocument(serverwikipage, context);
+				if (doc.isNew()) {
+					/* document doesn't exist */
+					log.error("there is no document corresponding to appname: "
+							+ appname);
+					return null;
+				}
+				return doc;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public BaseClass getServerClass(XWikiContext context) {
+		XWikiDocument doc;
+		boolean needsUpdate = false;
+		try {
+			doc = context.getWiki().getDocument("XWiki.XWikiServerClass",
+					context);
+		} catch (Exception e) {
+			doc = new XWikiDocument();
+			doc.setWeb("XWiki");
+			doc.setName("XWikiServerClass");
+			needsUpdate = true;
+		}
+		BaseClass bclass = doc.getxWikiClass();
+		if (context.get("initdone") != null)
+			return bclass;
+		log.error("Creating a new Server Class document.");
+		bclass.setName("XWiki.XWikiServerClass");
+		needsUpdate |= bclass.addTextField("owner", "Owner", 30);
+		needsUpdate |= bclass.addTextField("server", "Server", 30);
+		String content = doc.getContent();
+		if ((content == null) || (content.equals(""))) {
+			needsUpdate = true;
+			doc.setContent("1 XWiki Servers");
+		}
+		try {
+			if (needsUpdate)
+				context.getWiki().saveDocument(doc, context);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+		return bclass;
+	}
+
+	public boolean createServerClass(String wikiName, String wikiAdmin,
+			String wikiUrl, String description, String wikilanguage,
+			XWikiContext context) {
+		XWiki wiki = context.getWiki();
+		String wikiServerPage = "XWikiServer"
+				+ wikiName.substring(0, 1).toUpperCase()
+				+ wikiName.substring(1);
+		try {
+			XWikiDocument serverdoc = wiki.getDocument("XWiki", wikiServerPage,
+					context);
+			if (serverdoc.isNew()) {
+				serverdoc.setStringValue("XWiki.XWikiServerClass", "server",
+						wikiUrl);
+				serverdoc.setLargeStringValue("XWiki.XWikiServerClass",
+						"owner", wikiAdmin);
+				if (description != null)
+					serverdoc.setStringValue("XWiki.XWikiServerClass",
+							"description", description);
+				if (wikilanguage != null)
+					serverdoc.setStringValue("XWiki.XWikiServerClass",
+							"language", wikilanguage);
+				serverdoc
+						.setContent("#includeForm(\"XWiki.XWikiServerForm\")\n");
+				serverdoc.setParent("XWiki.XWikiServerClass");
+				wiki.saveDocument(serverdoc, context);
+				return true;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			return false;
+		}
+		return false;
+	}
+
+	/*
+	 * check whether the user is the owner of the wiki at the wikiapp : modelled
+	 * after XWiki.getXWiki method
+	 * 
+	 * wikiapp is the name of the host. @TODO: Return appropriate error codes
+	 * (document is new/not virtual wiki etc)
+	 */
+
+	private boolean checkWikiMaster(String wikiapp, String user,
+			XWikiContext context) {
+		XWikiDocument doc = checkDocument(wikiapp, context);
+		if (doc == null)
+			return false;
+		String wikiOwner = doc
+				.getStringValue("XWiki.XWikiServerClass", "owner");
+		if (wikiOwner.indexOf(":") != -1)
+			wikiOwner = wikiOwner.substring(wikiOwner.indexOf(":") + 1);
+		log
+				.error("found the owner of wiki " + wikiapp + " to be: "
+						+ wikiOwner);
+		if (user.startsWith("XWiki"))
+			user = user.substring(user.indexOf(".") + 1);
+		if (wikiOwner.startsWith("XWiki"))
+			wikiOwner = wikiOwner.substring(wikiOwner.indexOf(".") + 1);
+		log.error("comparing wikiowner:" + wikiOwner + " with user:" + user);
+		if (wikiOwner.equalsIgnoreCase(user))
+			return true;
+		return false;
+	}
+
+	public boolean updateRegistry(String token, String wikiapp, String IP) {
+		try {
+			XWikiContext context = init("");
+			return updateRegistry(token, wikiapp, IP, context);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	public boolean existsWikiapp(String wikiapp, XWikiContext context) {
+		boolean bTransaction = true;
+		XWikiHibernateStore hibstore = null;
+		try {
+			hibstore = context.getWiki().getHibernateStore();
+			bTransaction = bTransaction && hibstore.beginTransaction(context);
+			Session session = hibstore.getSession(context);
+			Query existQuery = session
+					.createQuery("select r.name from DNSRecords as r "
+							+ "where r.name = :name and r.type = :type and r.domainId = :domainId");
+			existQuery.setString("name", wikiapp);
+			existQuery.setString("type", DEFAULT_TYPE);
+			existQuery.setInteger("domainId", DEFAULT_DOMAIN_ID);
+
+			Iterator it = existQuery.list().iterator();
+			while (it.hasNext()) {
+				String name = (String) it.next();
+				if (wikiapp.equals(name)) {
+					log.error("found Wikiapp:" + wikiapp
+							+ " in dnsrecords, yeah..");
+					return true;
+				}
+			}
+			return false;
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (bTransaction)
+					hibstore.endTransaction(context, false);
+			} catch (Exception e) {
+			}
+		}
+		return false;
+	}
+
+	/*
+	 * @TODO: This function updates all the ips with a given wikiapp, if the
+	 * wikiapp exists. The reason is that the registry is maintaining a list of
+	 * masters only which is unique at present per wiki.
+	 * 
+	 * 
+	 * @TODO: Return more appropriate return codes (like authentication failure,
+	 * wiki already exists etc)
+	 */
+
+	public boolean updateRegistry(String token, String wikiapp, String IP,
+			XWikiContext context) {
+		boolean bTransaction = true;
+		XWikiHibernateStore hibstore = null;
+		boolean result = false;
+
+		// Verify authentication token
+		if (!checkToken(token, context)) {
+			log.error("Authentication token verification failed for token "
+					+ token + "\n");
+			return false;
+		}
+		String username = context.getUser();
+		// check that user is the owner of the wiki before updating the ip
+		log.error("checking if user: " + username
+				+ " is the owner of the wiki: " + wikiapp);
+		XWikiDocument serverDoc = checkDocument(wikiapp, context);
+		if (serverDoc != null && (!checkWikiMaster(wikiapp, username, context))) {
+			log.error("user: " + username
+					+ " is not the owner of the wikiapp: " + wikiapp
+					+ " , update failed");
+			return false;
+		}
+		try {
+			hibstore = context.getWiki().getHibernateStore();
+			bTransaction = bTransaction && hibstore.beginTransaction(context);
+			Session session = hibstore.getSession(context);
+			Query existQuery = session
+					.createQuery("select r from DNSRecords as r "
+							+ "where r.name = :name and r.type = :type and r.domainId = :domainId");
+			existQuery.setString("name", wikiapp);
+			existQuery.setString("type", DEFAULT_TYPE);
+			existQuery.setInteger("domainId", DEFAULT_DOMAIN_ID);
+			log.error("about to perform sql query");
+			Iterator it = existQuery.list().iterator();
+			log.error("performed query, checking results");
+			if (!it.hasNext()) {
+				log
+						.error("updating the registry with a *new record* for wikiapp"
+								+ wikiapp + " and ip = " + IP);
+				DNSRecords newrecord = new DNSRecords();
+				newrecord.setDomainId(new Integer(DEFAULT_DOMAIN_ID));
+				newrecord.setName(wikiapp);
+				newrecord.setContent(IP);
+				newrecord.setType(DEFAULT_TYPE);
+				newrecord.setTtl(new Integer(DEFAULT_TTL));
+				session.save(newrecord);
+