r1300 - in xwiki-clients/p2pxwiki: . .settings lib src/main/java/com/xpn/p2pxwiki/communication src/main/java/com/xpn/p2pxwiki/services src/main/java/com/xpn/p2pxwiki/synchronization src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge src/main/java/com/xpn/p2pxwiki/synchronization/protocols src/main/resources src/main/web/WEB-INF src/test/java/com/xpn/p2pxwiki/communication
Sergiu Dumitriu
sdumitriu at users.forge.objectweb.org
Fri Sep 8 14:25:46 CEST 2006
Author: sdumitriu
Date: 2006-09-08 14:25:46 +0200 (Fri, 08 Sep 2006)
New Revision: 1300
Added:
xwiki-clients/p2pxwiki/.settings/org.eclipse.jdt.core.prefs
xwiki-clients/p2pxwiki/lib/3dm-lib.jar
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/DiffMerge.java
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/XMLDiffMerge.java
Modified:
xwiki-clients/p2pxwiki/
xwiki-clients/p2pxwiki/.classpath
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/AbstractHandlerStub.java
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/services/WikiGroup.java
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationHandler.java
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationInterface.java
xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/protocols/SimpleSynchronization.java
xwiki-clients/p2pxwiki/src/main/resources/log4j.properties
xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg
xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/AbstractLocalTest.java
xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/Try.java
Log:
p2pxwiki update
Property changes on: xwiki-clients/p2pxwiki
___________________________________________________________________
Name: svn:ignore
+ build
.settings
Modified: xwiki-clients/p2pxwiki/.classpath
===================================================================
--- xwiki-clients/p2pxwiki/.classpath 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/.classpath 2006-09-08 12:25:46 UTC (rev 1300)
@@ -1,26 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="com/xpn/p2pxwiki/communication/rpc/|com/xpn/p2pxwiki/communication/jxta/" kind="src" path="src/main/java"/>
- <classpathentry excluding="com/xpn/p2pxwiki/communication/RpcLocalTest.java|com/xpn/p2pxwiki/communication/JxtaLocalTest.java|com/xpn/test/p2pxwiki/rpc/|com/xpn/test/p2pxwiki/registry/" kind="src" path="src/test/java"/>
- <classpathentry kind="src" path="resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/swixml.jar"/>
- <classpathentry kind="lib" path="lib/serializer.jar"/>
- <classpathentry kind="lib" path="lib/saxpath.jar"/>
- <classpathentry kind="lib" path="lib/p2psockets-core.jar"/>
- <classpathentry kind="lib" path="lib/p2psockets-apache-xmlrpc.jar"/>
- <classpathentry sourcepath="lib/p2psockets-2.0-r2-apache-xmlrpc-3.0-src.jar" kind="lib" path="lib/p2psockets-2.0-r2-apache-xmlrpc-3.0.jar"/>
- <classpathentry kind="lib" path="lib/org.mortbay.jetty.jar"/>
- <classpathentry kind="lib" path="lib/jxtaext.jar"/>
- <classpathentry kind="lib" path="lib/jxta.jar"/>
- <classpathentry kind="lib" path="lib/jxl.jxta.jar"/>
- <classpathentry kind="lib" path="lib/jdom-1.0.jar"/>
- <classpathentry kind="lib" path="lib/jaxen-jdom.jar"/>
- <classpathentry kind="lib" path="lib/jaxen-core.jar"/>
- <classpathentry kind="lib" path="lib/javax.servlet.jar"/>
- <classpathentry kind="lib" path="lib/bcprov-jdk14.jar"/>
- <classpathentry kind="lib" path="lib/backport-util-concurrent.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/xwiki-trunk"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry excluding="**/,svn/|com/xpn/p2pxwiki/communication/jxta/|com/xpn/p2pxwiki/communication/rpc/|com/xpn/p2pxwiki/registry/|com/xpn/p2pxwiki/replication/|com/xpn/p2pxwiki/examples/" kind="src" path="src/main/java"/>
+ <classpathentry excluding="**/.svn/" kind="src" path="resources"/>
+ <classpathentry excluding="**/.svn/|com/xpn/test/p2pxwiki/registry/|com/xpn/test/p2pxwiki/rpc/" kind="src" path="src/test/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/swixml.jar"/>
+ <classpathentry kind="lib" path="lib/serializer.jar"/>
+ <classpathentry kind="lib" path="lib/saxpath.jar"/>
+ <classpathentry kind="lib" path="lib/p2psockets-core.jar"/>
+ <classpathentry kind="lib" path="lib/org.mortbay.jetty.jar"/>
+ <classpathentry kind="lib" path="lib/jxtaext.jar"/>
+ <classpathentry kind="lib" path="lib/jxta.jar"/>
+ <classpathentry kind="lib" path="lib/jxl.jxta.jar"/>
+ <classpathentry kind="lib" path="lib/jdom-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/jaxen-jdom.jar"/>
+ <classpathentry kind="lib" path="lib/jaxen-core.jar"/>
+ <classpathentry kind="lib" path="lib/javax.servlet.jar"/>
+ <classpathentry kind="lib" path="lib/bcprov-jdk14.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/portlet-api-1.0.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/junit-4.1.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/commons-logging-api-1.1.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/org.suigeneris.jrcs.rcs-0.3.0.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/velocity-1.4.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/org.suigeneris.jrcs.diff-0.3.0.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/hibernate-3.0.3.jar"/>
+ <classpathentry kind="lib" path="lib/p2psockets-2.0-r2-apache-xmlrpc-3.0.jar"/>
+ <classpathentry kind="lib" path="lib/p2psockets-apache-xmlrpc.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/ws-commons-java5-1.0.1.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/ws-commons-util-1.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/backport-util-concurrent.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
+ <classpathentry kind="lib" path="/xwiki/lib/xmlrpc-client-3.0.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/xmlrpc-common-3.0.jar"/>
+ <classpathentry kind="lib" path="/xwiki/lib/xmlrpc-server-3.0.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/xwiki"/>
+ <classpathentry kind="lib" path="lib/3dm-lib.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: xwiki-clients/p2pxwiki/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- xwiki-clients/p2pxwiki/.settings/org.eclipse.jdt.core.prefs 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/.settings/org.eclipse.jdt.core.prefs 2006-09-08 12:25:46 UTC (rev 1300)
@@ -0,0 +1,62 @@
+#Mon Aug 28 17:32:24 GMT 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
Added: xwiki-clients/p2pxwiki/lib/3dm-lib.jar
===================================================================
(Binary files differ)
Property changes on: xwiki-clients/p2pxwiki/lib/3dm-lib.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/AbstractHandlerStub.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/AbstractHandlerStub.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/communication/AbstractHandlerStub.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -24,13 +24,12 @@
if (localObjectMethods && method.getDeclaringClass().equals(Object.class)) {
log.debug("Locally invoking method in class Object: "+method.getName());
return method.invoke(this, args); // call the method on the proxy itself
- } else {
- // on the class level String methodName = pClass.getName() + "." + pMethod.getName();
- // we don't use any TypeConverter ... would it be useful?
- log.debug("Remotely inviking method: "+method.getName());
- String methodName = handlerName + "." + method.getName();
- return execute(methodName, args);
}
+ // on the class level String methodName = pClass.getName() + "." + pMethod.getName();
+ // we don't use any TypeConverter ... would it be useful?
+ log.debug("Remotely inviking method: "+method.getName());
+ String methodName = handlerName + "." + method.getName();
+ return execute(methodName, args);
}
});
}
Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/services/WikiGroup.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/services/WikiGroup.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/services/WikiGroup.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -14,7 +14,7 @@
public interface WikiGroup {
/**
* Returns all the known servers in this group at that moment.
- * The resultset contains all servers that are knwon to host htis wiki
+ * The resultset contains all servers that are knwon to host this wiki
* and be online
*
* @return the list of server names
Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationHandler.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationHandler.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationHandler.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -8,27 +8,37 @@
public class SynchronizationHandler extends BaseRpcHandler
implements RequestInitializableHandler, SynchronizationInterface {
- public Object[] sync(String docName, String language){
- Object[] result = new Object[2];
+ public Object[] sync(String docName, String language, String remoteVersion, String remoteHash){
+ Object[] result;
try{
XWikiContext context = getXWikiContext();
XWikiDocument doc = context.getWiki().getDocument(docName, context)
.getTranslatedDocument(language, context);
- result[0] = doc.getVersion();
- result[1] = doc.getVersionHashCode(getXWikiContext());
+
+ if (!doc.getVersion().equals(remoteVersion)
+ || !(doc.getVersionHashCode(context)).equals(remoteHash)) {
+ result = new Object[1];
+ result[0] = "ok";
+ return result;
+ }
+ int maxVersion = Integer.parseInt(doc.getVersion().substring(doc.getVersion().indexOf(".") + 1));
+ result = new Object[maxVersion + 1];
+ result[0] = "nok";
+ for (int i = 1; i <= maxVersion; ++i){
+ result[i] = context.getWiki().getDocument(doc, "1." + i, context).getVersionHashCode(context);
+ }
}
catch(XWikiException ex){
- result[0] = "";
- result[1] = "";
+ return null;
}
return result;
}
-
+
public Object[] merge(String docName, String language,
- Object[] hashHistory, String lastRemoteVersion){
+ Object[] hashHistory){
XWikiDocument[] documents = null;
Object[] result;
- // documents = merger.mergeBranches()
+ // TODO: documents = merger.mergeBranches()
result = new Object[documents.length];
for(int i = 0; i < documents.length; ++i){
try{
Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationInterface.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationInterface.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/SynchronizationInterface.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -2,9 +2,8 @@
public interface SynchronizationInterface {
- public Object[] sync(String docName, String language);
+ public Object[] sync(String docName, String language, String version, String versionHash);
public Object[] merge(String docName, String language,
- Object[] hashHistory, String lastRemoteVersion);
-
+ Object[] branch);
}
\ No newline at end of file
Added: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/DiffMerge.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/DiffMerge.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/DiffMerge.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -0,0 +1,5 @@
+package com.xpn.p2pxwiki.synchronization.diffmerge;
+
+public interface DiffMerge{
+
+}
Added: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/XMLDiffMerge.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/XMLDiffMerge.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/diffmerge/XMLDiffMerge.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -0,0 +1,130 @@
+package com.xpn.p2pxwiki.synchronization.diffmerge;
+
+import java.text.BreakIterator;
+import java.util.Locale;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+
+public class XMLDiffMerge implements DiffMerge {
+ public static final int LEVEL_NO_CHUNK = 0;
+ public static final int LEVEL_LINE = 1;
+ public static final int LEVEL_SENTENCE = 2;
+ public static final int LEVEL_WORD = 3;
+ public static final int DEFAULT_CHUNK_LEVEL = LEVEL_SENTENCE;
+ protected int level = DEFAULT_CHUNK_LEVEL;
+
+ public XWikiDocument[] mergeBranches(XWikiDocument[] localBranch, XWikiDocument[] remoteBranch) {
+ // Locale locale = new Locale(lastLocalDoc.getRealLanguage());
+ // TODO: chunkText
+ // TODO: call tdm
+ // TODO: dechunkText
+ // TODO: interleave branches
+ // TODO: return result
+ return null;
+ }
+
+ protected String chunkText(String text, Locale locale) {
+ String result = text.replace("&", "&");
+ result = result.replace("<", "<").replace(">", ">");
+ result = chunkLines(result, locale);
+ return "<text>" + result + "</text>";
+ }
+
+ protected String chunkLines(String text, Locale locale) {
+ if (level < LEVEL_LINE) {
+ return text;
+ }
+ StringBuilder result = new StringBuilder();
+ int start = 0;
+ int end = text.indexOf("\n");
+ if (end == 0) {
+ while (end < text.length() && text.charAt(end) == '\n') {
+ end++;
+ }
+ result.append("<para>" + text.substring(start, end) + "</para>");
+ start = end;
+ end = text.indexOf("\n", start + 1);
+ }
+ while (end > 0) {
+ result.append("<para>" + chunkSentences(text.substring(start, end), locale) + "</para>");
+ start = end;
+ while (end < text.length() && text.charAt(end) == '\n') {
+ end++;
+ }
+ result.append("<para>" + text.substring(start, end) + "</para>");
+ start = end;
+ end = text.indexOf("\n", start + 1);
+ }
+ if (start < text.length()) {
+ result.append("<para>" + chunkSentences(text.substring(start), locale) + "</para>");
+ }
+ return result.toString();
+ }
+
+ protected String chunkSentences(String text, Locale locale) {
+ if (level < LEVEL_SENTENCE) {
+ return text;
+ }
+ BreakIterator boundary = BreakIterator.getSentenceInstance(locale);
+ boundary.setText(text);
+ StringBuilder result = new StringBuilder();
+ int start = boundary.first();
+ int end = boundary.next();
+ while (end != BreakIterator.DONE) {
+ result.append("<sentence>" + chunkWords(text.substring(start, end), locale) + "</sentence>");
+ start = end;
+ end = boundary.next();
+ }
+ return result.toString();
+ }
+
+ protected String chunkWords(String text, Locale locale) {
+ if (level < LEVEL_WORD) {
+ return text;
+ }
+ BreakIterator boundary = BreakIterator.getLineInstance(locale);
+ boundary.setText(text);
+ StringBuilder result = new StringBuilder();
+ int start = boundary.first();
+ int end = boundary.next();
+ while (end != BreakIterator.DONE) {
+ result.append("<word>" + text.substring(start, end) + "</word>");
+ start = end;
+ end = boundary.next();
+ }
+ return result.toString();
+ }
+
+ protected String dechunkText(String text, Locale locale) {
+ String result = text.replace("<text>", "").replace("</text>", "");
+ result = result.replace("<para>", "").replace("</para>", "");
+ result = result.replace("<sentence>", "").replace("</sentence>", "");
+ result = result.replace("<word>", "").replace("</word>", "");
+ result = result.replace("<", "<").replace(">", ">");
+ result = result.replace("&", "&");
+ return result;
+ }
+
+ public static void main(String args[]) {
+ //String text = "A long text.\n\n\nAnother line.\n Some more \ntext. And more.\nLine.\n\n";
+ String text = "A <b> long text.\n\n\nAnother line.\n Some & & more \ntext. And more.\nLine.\n\n";
+ XMLDiffMerge m = new XMLDiffMerge();
+ m.level = LEVEL_NO_CHUNK;
+ //System.out.println(m.chunkText(text, Locale.ENGLISH));
+ System.out.println(m.dechunkText(m.chunkText(text, Locale.ENGLISH), Locale.ENGLISH));
+ }
+
+ /**
+ * @return the level
+ */
+ public int getLevel() {
+ return level;
+ }
+
+ /**
+ * @param level the level to set
+ */
+ public void setLevel(int level) {
+ this.level = level;
+ }
+}
Modified: xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/protocols/SimpleSynchronization.java
===================================================================
--- xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/protocols/SimpleSynchronization.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/java/com/xpn/p2pxwiki/synchronization/protocols/SimpleSynchronization.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -49,7 +49,7 @@
this.context = context;
log.debug("Configuring number of threads");
threads = (int) context.getWiki().ParamAsLong(THREADS, DEFAULT_THREADS);
- log.debug("Starting "+threads+" threads");
+ log.debug("Starting " + threads + " threads");
this.threadPool = new Thread[threads];
for (int i = 0; i < threads; ++i) {
threadPool[i] = new Thread(this);
@@ -145,44 +145,50 @@
try {
String docName = element.getDocumentName();
String docLang = element.getDocumentLanguage();
- XWikiDocument doc = this.wiki.getDocument(docName, context)
- .getTranslatedDocument(docLang, context);
+ XWikiDocument doc = this.wiki.getDocument(docName, context).getTranslatedDocument(docLang, context);
HandlerStub connection = ConnectorPlugin.getInstance().getConnection(element.getServerName());
- SynchronizationInterface syncProxy = (SynchronizationInterface)connection
- .getDynamicProxy("synchronization", SynchronizationInterface.class, true);
-
- Object[] response = syncProxy.sync(docName, docLang);
- if (response.length != 2 || !(response[0] instanceof String) || !(response[1] instanceof String)) {
- throw new P2PXWikiException(0, "Invalid response");
+ SynchronizationInterface syncProxy = (SynchronizationInterface) connection.getDynamicProxy("synchronization", SynchronizationInterface.class, true);
+
+ Object[] response = syncProxy.sync(docName, docLang, doc.getVersion(), doc.getVersionHashCode(context));
+ int responseLength = response.length;
+ if (responseLength < 1 || !(response[0] instanceof String)) {
+ throw new P2PXWikiException(P2PXWikiException.REMOTE_CALL, "Invalid response");
}
- String remoteVersion = (String)response[0];
- String remoteHash = (String)response[1];
-
- if (!doc.getVersion().equals(remoteVersion)
- || !(doc.getVersionHashCode(context)).equals(remoteHash)) {
- int crtVersionNumber = Integer.parseInt(doc.getVersion().substring(doc.getVersion().indexOf(".") + 1));
- Object history[] = new Object[crtVersionNumber];
- for (int i = 0; i < crtVersionNumber; ++i) {
- XWikiDocument version = this.wiki.getDocument(doc, "1." + i, context);
- history[i] = version.getVersionHashCode(context);
+ String serverStatusResponse = (String) response[0];
+ if (serverStatusResponse.equals("ok")) {
+ element.setUpdated(false);
+ return;
+ }
+ else if(!serverStatusResponse.equals("nok")){
+ throw new P2PXWikiException(P2PXWikiException.REMOTE_CALL, "Invalid response");
+ }
+
+ int branchPoint = findBranchPoint(doc, response);
+ int crtVersionNumber = Integer.parseInt(doc.getVersion().substring(doc.getVersion().indexOf(".") + 1));
+ Object branch[] = new Object[crtVersionNumber - branchPoint];
+ for (int i = branchPoint; i < crtVersionNumber; ++i) {
+ XWikiDocument version = this.wiki.getDocument(doc, "1." + i, context);
+ branch[i] = version.toXML(true, false, true, false, context);
+ }
+
+ Object[] mergedDocs = syncProxy.merge(docName, docLang, branch);
+
+ for (int i = 0; i < mergedDocs.length; ++i) {
+ try {
+ XWikiDocument docVersion = new XWikiDocument();
+ docVersion.fromXML((String) mergedDocs[i], false);
+ // The documents should be stored exactly as received
+ // Needed in order to preserve the version
+ docVersion.setContentDirty(false);
+ docVersion.setMetaDataDirty(false);
+ this.wiki.saveDocument(docVersion, doc, context);
+ } catch (XWikiException ex) {
+ log.error("XWiki exception", ex);
+ // TODO ... handle it?
}
-
- Object[] mergedDocs = syncProxy.merge(docName, docLang,
- history, doc.toXML(true, false, true, false, context));
-
- for (int i = 0; i < mergedDocs.length; ++i) {
- try{
- XWikiDocument docVersion = new XWikiDocument();
- docVersion.fromXML((String)mergedDocs[i], false);
- this.wiki.saveDocument(docVersion, doc, context);
- } catch(XWikiException ex){
- log.error("XWiki exception", ex);
- // TODO ... handle it?
- }
- }
- element.setUpdated(true);
}
+ element.setUpdated(true);
} catch (P2PXWikiException ex) {
// TODO: This is a serious error. What to do now?
// TODO: Mark the element as synchronized?
@@ -191,6 +197,8 @@
log.error("Cannot communicate with server", ex);
} catch (XWikiException ex) {
log.error("XWiki exception", ex);
+ } catch (ClassCastException ex) {
+ log.error("Invalid response from server", ex);
} catch (Exception ex) {
log.error("Unhandled exception", ex);
}
@@ -212,11 +220,30 @@
}
}
+ protected int findBranchPoint(XWikiDocument doc, Object[] remoteBranch) {
+ int crtVersionNumber = Integer.parseInt(doc.getVersion().substring(doc.getVersion().indexOf(".") + 1));
+ int min = crtVersionNumber < remoteBranch.length - 1 ? crtVersionNumber : remoteBranch.length - 1;
+ int i = 1;
+ try{
+ for (i = 1; i <= min; ++i) {
+ String localVersionHash = wiki.getDocument(doc, "1." + i, context).getVersionHashCode(context);
+ if (!localVersionHash.equals(remoteBranch[i])) {
+ return i;
+ }
+ }
+ }
+ catch(XWikiException ex){
+ log.error("Unhandled exception", ex);
+ return i;
+ }
+ return min;
+ }
+
public void run() {
while (true) {
SynchronizationElement element = pollTask();
doTask(element);
- doneTask(element);
+ doneTask(element);
}
}
}
Modified: xwiki-clients/p2pxwiki/src/main/resources/log4j.properties
===================================================================
--- xwiki-clients/p2pxwiki/src/main/resources/log4j.properties 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/resources/log4j.properties 2006-09-08 12:25:46 UTC (rev 1300)
@@ -1,7 +1,29 @@
-log4j.rootLogger=WARN, A1
-log4j.appender.A1=org.apache.log4j.RollingFileAppender
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-log4j.appender.filer.File=/var/lib/tomcat-5.5/logs/xwiki
-log4j.appender.filer.MaxFileSize=10MB
-log4j.appender.filer.MaxBackupIndex=4
\ No newline at end of file
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %X{url} %c{1}:%M:%L - %m%n
+
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=/var/lib/tomcat-5.5/logs/xwikip2p.log
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=50
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %X{url} %c{1}:%M:%L - %m%n
+
+### root logger option ###
+log4j.rootLogger=warn, stdout, file
+
+### Hibernate logging options ###
+log4j.logger.org.hibernate.SQL=warn
+log4j.logger.org.hibernate=warn
+log4j.logger.org.hibernate.type=warn
+log4j.logger.org.hibernate.ps.PreparedStatementCache=warn
+
+### log XWiki
+log4j.logger.com.xpn.xwiki=warn
+log4j.logger.com.xpn.xwiki.render.XWikiRadeoxRenderEngine=warn
+log4j.logger.org.radeox.macro.BaseLocaleMacro=error
+
+### Deactive struts warning
+log4j.logger.org.apache.struts.util.RequestUtils=error
Modified: xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg
===================================================================
--- xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/main/web/WEB-INF/xwiki.cfg 2006-09-08 12:25:46 UTC (rev 1300)
@@ -1,62 +1,102 @@
-xwiki.version=0.9
-xwiki.base=../../
-#xwiki.store.class=com.xpn.xwiki.store.XWikiRCSFileStore
-#xwiki.store.rcs.path=c:/dev/java/xwiki/src/web/rcs
-xwiki.store.class=com.xpn.xwiki.store.XWikiHibernateStore
-xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml
-xwiki.store.hibernate.updateschema=1
-xwiki.store.hibernate.custommapping=1
-xwiki.monitor=1
-xwiki.plugins=com.xpn.p2pxwiki.communication.ConnectorPlugin,com.xpn.xwiki.plugin.calendar.CalendarPlugin,com.xpn.xwiki.plugin.feed.FeedPlugin,com.xpn.xwiki.plugin.ldap.LDAPPlugin,com.xpn.xwiki.plugin.google.GooglePlugin,com.xpn.xwiki.plugin.flickr.FlickrPlugin,com.xpn.xwiki.plugin.mail.MailPlugin,com.xpn.xwiki.plugin.packaging.PackagePlugin,com.xpn.xwiki.plugin.query.QueryPlugin,com.xpn.xwiki.plugin.graphviz.GraphVizPlugin,com.xpn.xwiki.plugin.svg.SVGPlugin,com.xpn.xwiki.plugin.charts.ChartingPlugin,com.xpn.xwiki.plugin.fileupload.FileUploadPlugin,com.xpn.xwiki.plugin.laszlo.LaszloPlugin
-# Bikas
-# com.xpn.p2pxwiki.client.P2PXWikiRegistryClientPlugin,
-# com.xpn.p2pxwiki.client.P2PXWikiReplicationClientPlugin,
-# Sergiu
+xwiki.version=0.9
+xwiki.base=../../
+#xwiki.store.class=com.xpn.xwiki.store.XWikiRCSFileStore
+#xwiki.store.rcs.path=c:/dev/java/xwiki/src/web/rcs
+xwiki.store.class=com.xpn.xwiki.store.XWikiHibernateStore
+xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml
+xwiki.store.hibernate.updateschema=1
+xwiki.store.hibernate.custommapping=1
+
+## Jcr Store configuration
+#xwiki.store.class=com.xpn.xwiki.store.jcr.XWikiJcrStore
+#xwiki.store.attachment.class=com.xpn.xwiki.store.jcr.XWikiJcrAttachmentStore
+#xwiki.store.versioning.class=com.xpn.xwiki.store.jcr.XWikiJcrPropertyVersioningStore
+#xwiki.store.jcr.mapping=WEB-INF/classes/jcrmapping.xml
+#xwiki.store.jcr.provider=com.xpn.xwiki.store.jcr.JackRabbitJCRProvider
+#xwiki.store.jcr.jackrabbit.repository.config=WEB-INF/classes/jackrabbit/repository.xml
+#xwiki.store.jcr.jackrabbit.repository.path=jackrabbitrepo
+#xwiki.store.jcr.jackrabbit.nodetypes.config=WEB-INF/classes/jackrabbit/nodetypes.cnd
+
+xwiki.store.cache=1
+xwiki.store.cache.capacity=100
+xwiki.monitor=1
+xwiki.plugins=com.xpn.p2pxwiki.communication.ConnectorPlugin,com.xpn.xwiki.monitor.api.MonitorPlugin,com.xpn.xwiki.plugin.calendar.CalendarPlugin,com.xpn.xwiki.plugin.feed.FeedPlugin,com.xpn.xwiki.plugin.ldap.LDAPPlugin,com.xpn.xwiki.plugin.google.GooglePlugin,com.xpn.xwiki.plugin.flickr.FlickrPlugin,com.xpn.xwiki.plugin.mail.MailPlugin,com.xpn.xwiki.plugin.packaging.PackagePlugin,com.xpn.xwiki.plugin.query.QueryPlugin,com.xpn.xwiki.plugin.graphviz.GraphVizPlugin,com.xpn.xwiki.plugin.svg.SVGPlugin,com.xpn.xwiki.plugin.charts.ChartingPlugin,com.xpn.xwiki.plugin.fileupload.FileUploadPlugin,com.xpn.xwiki.plugin.laszlo.LaszloPlugin
+# Bikas
+# com.xpn.p2pxwiki.client.P2PXWikiRegistryClientPlugin,
+# com.xpn.p2pxwiki.client.P2PXWikiReplicationClientPlugin,
+# Sergiu
# com.xpn.p2pxwiki.synchronizer.SynchronizeOnEditPlugin
-
-
-# This parameter allows XWiki to operate in Hosting mode
-# allowing to create multiple wikis having their own database
-# and responding to different URLs
-xwiki.virtual=1
-xwiki.virtual.redirect=http://127.0.0.1:9080/xwiki/bin/Main/ThisWikiDoesNotExist
-
-# This parameter will activate the exo integration
-xwiki.exo=0
-
-xwiki.authentication=form
-xwiki.authentication.validationKey=totototototototototototototototo
-xwiki.authentication.encryptionKey=titititititititititititititititi
-xwiki.authentication.cookiedomains=xwiki.com,wiki.fr
-
-# Stats configuration allows to globally activate/deactivate stats module
-# it is also possible to choose a different stats service to record
-# statistics separately from XWiki
-xwiki.stats=1
-xwiki.stats.default=1
-xwiki.stats.class=com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl
-
-xwiki.encoding=ISO-8859-1
-xwiki.render.macromapping=1
-xwiki.backlinks=1
-
-
-xwiki.superadminpassword=super
-
-xwiki.store.cache=0
-
-#p2pxwiki.connector.network=com.xpn.p2pxwiki.communication.xmlrpc.XmlRpcNetwork
-#p2pxwiki.connector.retry_with_default_network=false
-#
-#p2pxwiki.network.peer_name=86.105.132.60
-#p2pxwiki.network.server_port=8369
-#p2pxwiki.network.connector_factory=com.xpn.p2pxwiki.communication.xmlrpc.XmlRpcConnectionFactory
-#p2pxwiki.network.retry_with_default_connector_factory=false
-
-p2pxwiki.connector.network=com.xpn.p2pxwiki.communication.jxtarpc.JxtaRpcNetwork
-p2pxwiki.connector.retry_with_default_network=false
-
-p2pxwiki.network.peer_name=localPeer
-p2pxwiki.network.server_port=8685
-p2pxwiki.network.connector_factory=com.xpn.p2pxwiki.communication.jxtarpc.JxtaRpcConnectionFactory
-p2pxwiki.network.retry_with_default_connector_factory=false
+# Does not work locally
+# com.xpn.xwiki.plugin.image.ImagePlugin,
+
+
+# This parameter allows XWiki to operate in Hosting mode
+# allowing to create multiple wikis having their own database
+# and responding to different URLs
+xwiki.virtual=1
+xwiki.virtual.redirect=http://127.0.0.1:9080/xwiki/bin/Main/ThisWikiDoesNotExist
+
+# This parameter will activate the exo integration
+xwiki.exo=0
+
+xwiki.authentication=form
+xwiki.authentication.validationKey=totototototototototototototototo
+xwiki.authentication.encryptionKey=titititititititititititititititi
+xwiki.authentication.cookiedomains=xwiki.com,wiki.fr
+
+# Stats configuration allows to globally activate/deactivate stats module
+# it is also possible to choose a different stats service to record
+# statistics separately from XWiki
+xwiki.stats=1
+xwiki.stats.default=1
+xwiki.stats.class=com.xpn.xwiki.stats.impl.XWikiStatsServiceImpl
+
+xwiki.encoding=ISO-8859-1
+xwiki.render.macromapping=1
+xwiki.backlinks=1
+
+xwiki.plugin.graphviz.dotpath=c:/Program Files/ATT/GraphViz/bin/dot.exe
+xwiki.plugin.graphviz.neatopath=c:/Program Files/ATT/GraphViz/bin/neato.exe
+
+xwiki.plugin.laszlo.baseurl=/openlaszlo/xwiki/
+xwiki.plugin.laszlo.path=c:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/openlaszlo/xwiki/
+
+xwiki.plugin.image.cache.capacity=30
+
+## Personal config
+xwiki.superadminpassword=super
+xwiki.authentication.ldap=0
+xwiki.authentication.ldap.server=172.29.116.202
+xwiki.authentication.ldap.check_level=1
+xwiki.authentication.ldap.port=389
+xwiki.authentication.ldap.base_DN=dc=necf,dc=fr
+xwiki.authentication.ldap.bind_DN=cn={0},cn=Users,dc=necf,dc=fr
+xwiki.authentication.ldap.bind_pass={1}
+xwiki.authentication.ldap.UID_attr=sAMAccountName
+xwiki.authentication.ldap.fields_mapping=name=sAMAccountName,last_name=sn,first_name=givenName,fullname=displayName,email=mail,ldap_dn=dn
+
+xwiki.authentication.unauthorized_code=200
+
+# This parameter will activate the sectional editing
+xwiki.section.edit=1
+
+
+## P2PXWiki configuration
+
+# Use xmlrpc over normal tcp/ip sockets
+p2pxwiki.connector.network=com.xpn.p2pxwiki.communication.xmlrpc.XmlRpcNetwork
+p2pxwiki.connector.retry_with_default_network=false
+
+p2pxwiki.network.peer_name=89.34.62.77
+p2pxwiki.network.server_port=8369
+p2pxwiki.network.connector_factory=com.xpn.p2pxwiki.communication.xmlrpc.XmlRpcConnectionFactory
+p2pxwiki.network.retry_with_default_connector_factory=false
+
+# Use xmlrpc over JXTA network
+#p2pxwiki.connector.network=com.xpn.p2pxwiki.communication.jxtarpc.JxtaRpcNetwork
+#p2pxwiki.connector.retry_with_default_network=false
+#
+#p2pxwiki.network.peer_name=localPeer
+#p2pxwiki.network.server_port=8685
+#p2pxwiki.network.connector_factory=com.xpn.p2pxwiki.communication.jxtarpc.JxtaRpcConnectionFactory
+#p2pxwiki.network.retry_with_default_connector_factory=false
Modified: xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/AbstractLocalTest.java
===================================================================
--- xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/AbstractLocalTest.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/AbstractLocalTest.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -1,16 +1,13 @@
package com.xpn.p2pxwiki.communication;
-import org.p2psockets.P2PNetwork;
-
import junit.framework.TestCase;
+import org.p2psockets.P2PNetwork;
+
import com.xpn.p2pxwiki.P2PXWikiException;
-import com.xpn.p2pxwiki.mocks.Hello;
import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiConfig;
import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.web.XWikiEngineContext;
abstract public class AbstractLocalTest extends TestCase {
@@ -22,10 +19,6 @@
private XWiki xwiki;
private ConnectorPlugin plugin;
private HandlerStub stub;
- private XWikiConfig config1;
- private XWikiContext xcontext1;
- private XWiki xwiki1;
- private ConnectorPlugin plugin1;
public AbstractLocalTest(String arg0) {
super(arg0);
Modified: xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/Try.java
===================================================================
--- xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/Try.java 2006-09-08 10:39:53 UTC (rev 1299)
+++ xwiki-clients/p2pxwiki/src/test/java/com/xpn/p2pxwiki/communication/Try.java 2006-09-08 12:25:46 UTC (rev 1300)
@@ -5,14 +5,10 @@
import org.apache.xmlrpc.client.P2PXmlRpcLiteHttpTransportFactory;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.apache.xmlrpc.server.PropertyHandlerMapping;
-import org.apache.xmlrpc.server.XmlRpcServer;
import org.apache.xmlrpc.webserver.P2PServletWebServer;
-import org.apache.xmlrpc.webserver.P2PWebServer;
import org.apache.xmlrpc.webserver.WebServer;
import org.p2psockets.P2PNetwork;
-import com.xpn.p2pxwiki.mocks.HelloHandler;
import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiConfig;
import com.xpn.xwiki.XWikiContext;
More information about the Xwiki-notifications
mailing list