On Fri, Dec 17, 2010 at 14:07, vmassol <platform-notifications(a)xwiki.org> wrote:
> Author: vmassol
> Date: 2010-12-17 14:07:48 +0100 (Fri, 17 Dec 2010)
> New Revision: 33583
>
> Added:
> Â platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolver.java
> Â platform/core/trunk/xwiki-model/src/test/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolverTest.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/java/org/xwiki/rendering/transformation/
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/java/org/xwiki/rendering/transformation/TransformationContextTest.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/MacroContentParser.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/test/java/org/xwiki/rendering/internal/transformation/macro/MacroTransformationContextTest.java
> Removed:
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultMacroContentParser.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/MacroContentParser.java
> Modified:
> Â platform/core/trunk/pom.xml
> Â platform/core/trunk/xwiki-bridge/pom.xml
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentModelBridge.java
> Â platform/core/trunk/xwiki-model/src/main/resources/META-INF/components.txt
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/transformation/TransformationContext.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultBoxMacro.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/resources/META-INF/components.txt
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/main/java/org/xwiki/rendering/internal/macro/include/IncludeMacro.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/IncludeMacroTest.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/transformation/MacroTransformationContext.java
> Â platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/resources/META-INF/components.txt
> Log:
> XWIKI-5807: Add support for relative links/images in included documents
>
> * First implementation. Current limitation: Doesn't work when links are generated by macros in the included document.
>
> Modified: platform/core/trunk/pom.xml
> ===================================================================
> --- platform/core/trunk/pom.xml 2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/pom.xml 2010-12-17 13:07:48 UTC (rev 33583)
> @@ -192,6 +192,8 @@
> Â Â Â Â Â Â Â Â <exclude>**/internal/**</exclude>
> Â Â Â Â Â Â Â Â <exclude>**/test/**</exclude>
> Â Â Â Â Â Â Â Â <!-- To be removed when we release 3.0 -->
> + Â Â Â Â Â Â Â Â <exclude>org/xwiki/bridge/DocumentModelBridge</exclude>
> + Â Â Â Â Â Â Â Â <exclude>org/xwiki/rendering/macro/box/AbstractBoxMacro</exclude>
> Â Â Â Â Â Â Â </excludes>
> Â Â Â Â Â Â </configuration>
> Â Â Â Â Â </plugin>
>
> Modified: platform/core/trunk/xwiki-bridge/pom.xml
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/pom.xml   2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-bridge/pom.xml   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -46,6 +46,11 @@
> Â Â </dependency>
> Â Â <dependency>
> Â Â Â <groupId>org.xwiki.platform</groupId>
> + Â Â Â <artifactId>xwiki-core-rendering-api</artifactId>
> + Â Â Â <version>${project.version}</version>
> + Â Â </dependency>
> + Â Â <dependency>
> + Â Â Â <groupId>org.xwiki.platform</groupId>
> Â Â Â <artifactId>xwiki-core-observation-local</artifactId>
Are you sure you need the implementation ? It should probably be
xwiki-observation-api instead.
> Â Â Â <version>${pom.version}</version>
> Â Â </dependency>
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentModelBridge.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentModelBridge.java   2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentModelBridge.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -20,6 +20,7 @@
> Â package org.xwiki.bridge;
>
> Â import org.xwiki.model.reference.DocumentReference;
> +import org.xwiki.rendering.syntax.Syntax;
>
> Â /**
> Â * Exposes methods for accessing Documents. This is temporary until we remodel the Model classes and the Document
> @@ -78,19 +79,28 @@
> Â Â /**
> Â Â Â * @return the Syntax id representing the syntax used for the current document. For example "xwiki/1.0" represents
> Â Â Â * Â Â Â Â the first version XWiki syntax while "xwiki/2.0" represents version 2.0 of the XWiki Syntax.
> + Â Â * @deprecated since 3.0M1 use {@link #getSyntax()} instead
> Â Â Â */
> + Â Â @Deprecated
> Â Â String getSyntaxId();
> -
> +
> Â Â /**
> + Â Â * @return the Syntax id representing the syntax used for the current document. For example "xwiki/1.0" represents
> + Â Â * Â Â Â Â the first version XWiki syntax while "xwiki/2.0" represents version 2.0 of the XWiki Syntax.
> + Â Â * @since 3.0M1
> + Â Â */
> + Â Â Syntax getSyntax();
> +
> + Â Â /**
> Â Â Â * @return the page to which the document belongs to (eg "WebHome")
> - Â Â * @deprecated since 2.2M1 use {@link #getDocumentReference()} Â instead
> + Â Â * @deprecated since 2.2M1 use {@link #getDocumentReference()} instead
> Â Â Â */
> Â Â @Deprecated
> Â Â String getPageName();
>
> Â Â /**
> Â Â Â * @return the space to which the document belongs to (eg "Main")
> - Â Â * @deprecated since 2.2M1 use {@link #getDocumentReference()} Â instead
> + Â Â * @deprecated since 2.2M1 use {@link #getDocumentReference()} instead
> Â Â Â */
> Â Â @Deprecated
> Â Â String getSpaceName();
>
> Added: platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolver.java
> ===================================================================
> --- platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolver.java               (rev 0)
> +++ platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolver.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,52 @@
> +/*
[...]
> + */
> +package org.xwiki.model.internal.reference;
> +
> +import org.xwiki.component.annotation.Component;
> +import org.xwiki.component.annotation.Requirement;
> +import org.xwiki.model.EntityType;
> +import org.xwiki.model.reference.AttachmentReference;
> +import org.xwiki.model.reference.AttachmentReferenceResolver;
> +import org.xwiki.model.reference.EntityReferenceResolver;
> +
> +/**
> + * Specialized version of {@link org.xwiki.model.reference.EntityReferenceResolver} which can be considered a helper
> + * component to resolve {@link org.xwiki.model.reference.AttachmentReference} objects from their string representation.
> + * The behavior is the one defined in {@link org.xwiki.model.internal.reference.ExplicitStringEntityReferenceResolver}.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +@Component("explicit")
> +public class ExplicitStringAttachmentReferenceResolver implements AttachmentReferenceResolver<String>
> +{
> + Â Â @Requirement("explicit")
> + Â Â private EntityReferenceResolver<String> entityReferenceResolver;
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â * @see org.xwiki.model.reference.AttachmentReferenceResolver#resolve
> + Â Â */
> + Â Â public AttachmentReference resolve(String attachmentReferenceRepresentation, Object... parameters)
> + Â Â {
> + Â Â Â Â return new AttachmentReference(this.entityReferenceResolver.resolve(
> + Â Â Â Â Â Â attachmentReferenceRepresentation, EntityType.ATTACHMENT, parameters));
> + Â Â }
> +}
>
[..]
>
> Added: platform/core/trunk/xwiki-model/src/test/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolverTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-model/src/test/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolverTest.java             (rev 0)
> +++ platform/core/trunk/xwiki-model/src/test/java/org/xwiki/model/internal/reference/ExplicitStringAttachmentReferenceResolverTest.java 2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,58 @@
> +/*
[...]
> + */
> +package org.xwiki.model.internal.reference;
> +
> +import org.junit.Assert;
> +import org.junit.Before;
> +import org.junit.Test;
> +import org.xwiki.component.util.ReflectionUtils;
> +import org.xwiki.model.reference.AttachmentReference;
> +import org.xwiki.model.reference.AttachmentReferenceResolver;
> +import org.xwiki.model.reference.DocumentReference;
> +import org.xwiki.model.reference.DocumentReferenceResolver;
> +
> +/**
> + * Unit tests for {@link org.xwiki.model.internal.reference.ExplicitStringAttachmentReferenceResolver}.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +public class ExplicitStringAttachmentReferenceResolverTest
> +{
> + Â Â private AttachmentReferenceResolver<String> resolver;
> +
> + Â Â @Before
> + Â Â public void setUp() throws Exception
> + Â Â {
> + Â Â Â Â this.resolver = new ExplicitStringAttachmentReferenceResolver();
> + Â Â Â Â ReflectionUtils.setFieldValue(this.resolver, "entityReferenceResolver",
> + Â Â Â Â Â Â new ExplicitStringEntityReferenceResolver());
> + Â Â }
> +
> + Â Â @Test
> + Â Â public void testResolveWithExplicitAttachmentReference()
> + Â Â {
> + Â Â Â Â DocumentReference documentReference = new DocumentReference("wiki", "space", "page");
> + Â Â Â Â AttachmentReference reference = this.resolver.resolve("", new AttachmentReference("file", documentReference));
> +
> + Â Â Â Â Assert.assertEquals("file", reference.getName());
> + Â Â Â Â Assert.assertEquals(documentReference, reference.getDocumentReference());
> + Â Â }
> +}
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/transformation/TransformationContext.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/transformation/TransformationContext.java 2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/transformation/TransformationContext.java 2010-12-17 13:07:48 UTC (rev 33583)
> @@ -28,7 +28,7 @@
> Â * @version $Id$
> Â * @since 2.4M1
> Â */
> -public class TransformationContext
> +public class TransformationContext implements Cloneable
> Â {
> Â Â /**
> Â Â Â * The complete {@link XDOM} of the content currently being transformed.
> @@ -117,4 +117,22 @@
> Â Â {
> Â Â Â Â return syntax;
> Â Â }
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â * @see Object#clone()
> + Â Â */
> + Â Â @Override
> + Â Â public TransformationContext clone()
> + Â Â {
> + Â Â Â Â TransformationContext newContext;
> + Â Â Â Â try {
> + Â Â Â Â Â Â newContext = (TransformationContext) super.clone();
> + Â Â Â Â } catch (CloneNotSupportedException e) {
> + Â Â Â Â Â Â // Should never happen
> + Â Â Â Â Â Â throw new RuntimeException("Failed to clone object", e);
> + Â Â Â Â }
> +
> + Â Â Â Â return newContext;
> + Â Â }
> Â }
>
> Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/java/org/xwiki/rendering/transformation/TransformationContextTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/java/org/xwiki/rendering/transformation/TransformationContextTest.java               (rev 0)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-api/src/test/java/org/xwiki/rendering/transformation/TransformationContextTest.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,54 @@
> +/*
[...]
> + */
> +package org.xwiki.rendering.transformation;
> +
> +import java.util.Arrays;
> +
> +import org.junit.Test;
> +import org.junit.Assert;
> +import org.xwiki.rendering.block.Block;
> +import org.xwiki.rendering.block.WordBlock;
> +import org.xwiki.rendering.block.XDOM;
> +import org.xwiki.rendering.syntax.Syntax;
> +
> +/**
> + * Unit tests for {@link TransformationContext}.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +public class TransformationContextTest
> +{
> + Â Â @Test
> + Â Â public void testClone()
> + Â Â {
> + Â Â Â Â TransformationContext context = new TransformationContext();
> + Â Â Â Â context.setId("id");
> + Â Â Â Â context.setSyntax(Syntax.XWIKI_2_0);
> + Â Â Â Â XDOM xdom = new XDOM(Arrays.<Block>asList(new WordBlock("test")));
> + Â Â Â Â context.setXDOM(xdom);
> +
> + Â Â Â Â TransformationContext newContext = context.clone();
> + Â Â Â Â Assert.assertNotSame(context, newContext);
> + Â Â Â Â Assert.assertEquals("id", newContext.getId());
> + Â Â Â Â Assert.assertEquals(Syntax.XWIKI_2_0, newContext.getSyntax());
> + Â Â Â Â Assert.assertEquals(xdom, newContext.getXDOM());
> + Â Â }
> +}
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultBoxMacro.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultBoxMacro.java    2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultBoxMacro.java    2010-12-17 13:07:48 UTC (rev 33583)
> @@ -67,6 +67,7 @@
> Â Â protected List<Block> parseContent(P parameters, String content, MacroTransformationContext context)
> Â Â Â Â throws MacroExecutionException
> Â Â {
> - Â Â Â Â return getMacroContentParser().parse(content, context.getSyntax(), context.isInline());
> + Â Â Â Â // Don't execute transformations explicitly. They'll be executed on the generated content later on.
> + Â Â Â Â return getMacroContentParser().parse(content, context, false, context.isInline());
> Â Â }
> Â }
>
> Deleted: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultMacroContentParser.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultMacroContentParser.java   2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultMacroContentParser.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -1,88 +0,0 @@
> -/*
[...]
> - */
> -package org.xwiki.rendering.internal.macro.box;
> -
> -import java.io.StringReader;
> -import java.util.List;
> -
> -import org.xwiki.component.annotation.Component;
> -import org.xwiki.component.annotation.Requirement;
> -import org.xwiki.component.manager.ComponentLookupException;
> -import org.xwiki.component.manager.ComponentManager;
> -import org.xwiki.rendering.block.Block;
> -import org.xwiki.rendering.macro.MacroExecutionException;
> -import org.xwiki.rendering.parser.Parser;
> -import org.xwiki.rendering.syntax.Syntax;
> -import org.xwiki.rendering.util.ParserUtils;
> -
> -/**
> - * Default implementation for {@link org.xwiki.rendering.internal.macro.box.MacroContentParser}.
> - *
> - * @version $Id$
> - * @since 2.6RC1
> - */
> -@Component
> -public class DefaultMacroContentParser implements MacroContentParser
> -{
> - Â Â /**
> - Â Â * Used to look up the syntax parser to use for parsing the content.
> - Â Â */
> - Â Â @Requirement
> - Â Â private ComponentManager componentManager;
> -
> - Â Â /**
> - Â Â * Utility to remove the top level paragraph.
> - Â Â */
> - Â Â private ParserUtils parserUtils = new ParserUtils();
> -
> - Â Â /**
> - Â Â * {@inheritDoc}
> - Â Â * @see MacroContentParser#parse(String, org.xwiki.rendering.syntax.Syntax, boolean)
> - Â Â */
> - Â Â public List<Block> parse(String content, Syntax syntax, boolean removeTopLevelParagraph)
> - Â Â Â Â throws MacroExecutionException
> - Â Â {
> - Â Â Â Â try {
> - Â Â Â Â Â Â List<Block> blocks = getSyntaxParser(syntax).parse(new StringReader(content)).getChildren();
> - Â Â Â Â Â Â if (removeTopLevelParagraph) {
> - Â Â Â Â Â Â Â Â this.parserUtils.removeTopLevelParagraph(blocks);
> - Â Â Â Â Â Â }
> - Â Â Â Â Â Â return blocks;
> - Â Â Â Â } catch (Exception e) {
> - Â Â Â Â Â Â throw new MacroExecutionException("Failed to parse content [" + content + "]", e);
> - Â Â Â Â }
> - Â Â }
> -
> - Â Â /**
> - Â Â * Get the parser for the current syntax.
> - Â Â *
> - Â Â * @param syntax the current syntax of the title content
> - Â Â * @return the parser for the current syntax
> - Â Â * @throws org.xwiki.rendering.macro.MacroExecutionException Failed to find source parser.
> - Â Â */
> - Â Â private Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException
> - Â Â {
> - Â Â Â Â try {
> - Â Â Â Â Â Â return this.componentManager.lookup(Parser.class, syntax.toIdString());
> - Â Â Â Â } catch (ComponentLookupException e) {
> - Â Â Â Â Â Â throw new MacroExecutionException("Failed to find source parser for syntax [" + syntax + "]", e);
> - Â Â Â Â }
> - Â Â }
> -}
>
> Deleted: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/MacroContentParser.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/MacroContentParser.java  2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/MacroContentParser.java  2010-12-17 13:07:48 UTC (rev 33583)
> @@ -1,49 +0,0 @@
> -/*
[...]
> - */
> -package org.xwiki.rendering.internal.macro.box;
> -
> -import java.util.List;
> -
> -import org.xwiki.component.annotation.ComponentRole;
> -import org.xwiki.rendering.block.Block;
> -import org.xwiki.rendering.macro.MacroExecutionException;
> -import org.xwiki.rendering.syntax.Syntax;
> -
> -/**
> - * Parses content of a macro field (parameter, macro content) in a given syntax.
> - *
> - * @version $Id$
> - * @since 2.6RC1
> - */
> -@ComponentRole
> -public interface MacroContentParser
> -{
> - Â Â /**
> - Â Â * Parses content of a macro field (parameter, macro content) in a given syntax and optionally remove the top level
> - Â Â * paragraph.
> - Â Â *
> - Â Â * @param content the content to parse
> - Â Â * @param syntax the syntax in which the content is written in
> - Â Â * @param removeTopLevelParagraph whether the top level paragraph should be removed after parsing
> - Â Â * @return the result as a {@link org.xwiki.rendering.block.Block}s
> - Â Â * @throws MacroExecutionException in case of a parsing error
> - Â Â */
> - Â Â List<Block> parse(String content, Syntax syntax, boolean removeTopLevelParagraph) throws MacroExecutionException;
> -}
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java    2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java    2010-12-17 13:07:48 UTC (rev 33583)
> @@ -31,7 +31,7 @@
> Â import org.xwiki.rendering.block.GroupBlock;
> Â import org.xwiki.rendering.block.ImageBlock;
> Â import org.xwiki.rendering.block.NewLineBlock;
> -import org.xwiki.rendering.internal.macro.box.MacroContentParser;
> +import org.xwiki.rendering.internal.macro.MacroContentParser;
> Â import org.xwiki.rendering.listener.Format;
> Â import org.xwiki.rendering.listener.reference.ResourceReference;
> Â import org.xwiki.rendering.listener.reference.ResourceType;
> @@ -137,7 +137,8 @@
> Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â // we add the title, if there is one
> Â Â Â Â Â Â Â Â if (!StringUtils.isEmpty(titleParameter)) {
> - Â Â Â Â Â Â Â Â Â Â boxBlock.addChildren(this.contentParser.parse(titleParameter, context.getSyntax(), true));
> + Â Â Â Â Â Â Â Â Â Â // Don't execute transformations explicitly. They'll be executed on the generated content later on.
> + Â Â Â Â Â Â Â Â Â Â boxBlock.addChildren(this.contentParser.parse(titleParameter, context, false, true));
> Â Â Â Â Â Â Â Â }
> Â Â Â Â Â Â Â Â if (titleBlockList != null) {
> Â Â Â Â Â Â Â Â Â Â boxBlock.addChildren(titleBlockList);
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/resources/META-INF/components.txt
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/resources/META-INF/components.txt   2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/resources/META-INF/components.txt   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -1,2 +1 @@
> -org.xwiki.rendering.internal.macro.box.DefaultBoxMacro
> -org.xwiki.rendering.internal.macro.box.DefaultMacroContentParser
> \ No newline at end of file
> +org.xwiki.rendering.internal.macro.box.DefaultBoxMacro
> \ No newline at end of file
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/main/java/org/xwiki/rendering/internal/macro/include/IncludeMacro.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/main/java/org/xwiki/rendering/internal/macro/include/IncludeMacro.java 2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/main/java/org/xwiki/rendering/internal/macro/include/IncludeMacro.java 2010-12-17 13:07:48 UTC (rev 33583)
> @@ -19,35 +19,37 @@
> Â */
> Â package org.xwiki.rendering.internal.macro.include;
>
> -import java.io.StringReader;
> Â import java.util.HashMap;
> Â import java.util.List;
> Â import java.util.Map;
>
> Â import org.xwiki.bridge.DocumentAccessBridge;
> +import org.xwiki.bridge.DocumentModelBridge;
> Â import org.xwiki.component.annotation.Component;
> Â import org.xwiki.component.annotation.Requirement;
> Â import org.xwiki.component.manager.ComponentManager;
> Â import org.xwiki.context.Execution;
> Â import org.xwiki.context.ExecutionContext;
> Â import org.xwiki.context.ExecutionContextManager;
> +import org.xwiki.model.reference.AttachmentReferenceResolver;
> Â import org.xwiki.model.reference.DocumentReference;
> Â import org.xwiki.model.reference.DocumentReferenceResolver;
> +import org.xwiki.model.reference.EntityReference;
> Â import org.xwiki.model.reference.EntityReferenceSerializer;
> Â import org.xwiki.rendering.block.Block;
> +import org.xwiki.rendering.block.ImageBlock;
> Â import org.xwiki.rendering.block.LinkBlock;
> Â import org.xwiki.rendering.block.MacroMarkerBlock;
> Â import org.xwiki.rendering.block.XDOM;
> +import org.xwiki.rendering.internal.macro.MacroContentParser;
> Â import org.xwiki.rendering.listener.reference.ResourceReference;
> Â import org.xwiki.rendering.listener.reference.ResourceType;
> Â import org.xwiki.rendering.macro.AbstractMacro;
> Â import org.xwiki.rendering.macro.MacroExecutionException;
> Â import org.xwiki.rendering.macro.include.IncludeMacroParameters;
> Â import org.xwiki.rendering.macro.include.IncludeMacroParameters.Context;
> -import org.xwiki.rendering.parser.Parser;
> +import org.xwiki.rendering.syntax.Syntax;
> Â import org.xwiki.rendering.transformation.MacroTransformationContext;
> -import org.xwiki.rendering.transformation.Transformation;
> -import org.xwiki.rendering.transformation.TransformationContext;
>
> Â /**
> Â * @version $Id$
> @@ -86,14 +88,24 @@
> Â Â private DocumentAccessBridge documentAccessBridge;
>
> Â Â /**
> - Â Â * Used to transform relative document links into absolute references when including a document containing links.
> - Â Â * This is required otherwise the links will be resolved at render time in the context of the including document
> - Â Â * instead of in the context of the included document.
> + Â Â * Used to transform the passed document reference macro parameter to a typed {@link DocumentReference} object.
> Â Â Â */
> Â Â @Requirement("current")
> Â Â private DocumentReferenceResolver<String> currentDocumentReferenceResolver;
>
> Â Â /**
> + Â Â * Used to transform relative document links into absolute references relative to the included document.
> + Â Â */
> + Â Â @Requirement("explicit")
> + Â Â private DocumentReferenceResolver<String> explicitDocumentReferenceResolver;
> +
> + Â Â /**
> + Â Â * Used to transform relative attachment links into absolute references relative to the included document.
> + Â Â */
> + Â Â @Requirement("explicit")
> + Â Â private AttachmentReferenceResolver<String> explicitAttachmentReferenceResolver;
> +
> + Â Â /**
> Â Â Â * Used to serialize resolved document links into a string again since the Rendering API only manipulates Strings
> Â Â Â * (done voluntarily to be independent of any wiki engine and not draw XWiki-specific dependencies).
> Â Â Â */
> @@ -101,6 +113,12 @@
> Â Â private EntityReferenceSerializer<String> defaultEntityReferenceSerializer;
>
> Â Â /**
> + Â Â * The parser used to parse included document content.
> + Â Â */
> + Â Â @Requirement
> + Â Â private MacroContentParser contentParser;
> +
> + Â Â /**
> Â Â Â * Default constructor.
> Â Â Â */
> Â Â public IncludeMacro()
> @@ -141,38 +159,39 @@
> Â Â public List<Block> execute(IncludeMacroParameters parameters, String content, MacroTransformationContext context)
> Â Â Â Â throws MacroExecutionException
> Â Â {
> - Â Â Â Â String documentName = parameters.getDocument();
> - Â Â Â Â if (documentName == null) {
> + Â Â Â Â // Step 1: Perform checks
> + Â Â Â Â if (parameters.getDocument() == null) {
> Â Â Â Â Â Â throw new MacroExecutionException(
> Â Â Â Â Â Â Â Â "You must specify a 'document' parameter pointing to the document to include.");
> Â Â Â Â }
>
> - Â Â Â Â DocumentReference documentReference = resolve(context.getCurrentMacroBlock(), documentName);
> + Â Â Â Â DocumentReference includedReference = resolve(context.getCurrentMacroBlock(), parameters.getDocument());
>
> Â Â Â Â if (context.getCurrentMacroBlock() != null) {
> - Â Â Â Â Â Â checkRecursiveInclusion(context.getCurrentMacroBlock(), documentReference);
> + Â Â Â Â Â Â checkRecursiveInclusion(context.getCurrentMacroBlock(), includedReference);
> Â Â Â Â }
>
> - Â Â Â Â Context actualContext = parameters.getContext();
> + Â Â Â Â if (!this.documentAccessBridge.isDocumentViewable(includedReference)) {
> + Â Â Â Â Â Â throw new MacroExecutionException("Current user doesn't have view rights on document ["
> + Â Â Â Â Â Â Â Â + this.defaultEntityReferenceSerializer.serialize(includedReference) + "]");
> + Â Â Â Â }
>
> - Â Â Â Â // Retrieve the included document's content
> - Â Â Â Â String includedContent;
> - Â Â Â Â String includedSyntax;
> + Â Â Â Â Context parametersContext = parameters.getContext();
> +
> + Â Â Â Â // Step 2: Extract included document's content and syntax.
> + Â Â Â Â // TODO: use macro source information to resolve document reference based on the macro source instead
> + Â Â Â Â // of the context
> + Â Â Â Â DocumentModelBridge documentBridge;
> Â Â Â Â try {
> - Â Â Â Â Â Â if (this.documentAccessBridge.isDocumentViewable(documentReference)) {
> - Â Â Â Â Â Â Â Â // TODO: use macro source informations to resolve document reference besed on the macro source instead
> - Â Â Â Â Â Â Â Â // of the context
> - Â Â Â Â Â Â Â Â includedContent = this.documentAccessBridge.getDocumentContent(documentName);
> - Â Â Â Â Â Â Â Â includedSyntax = this.documentAccessBridge.getDocumentSyntaxId(documentName);
> - Â Â Â Â Â Â } else {
> - Â Â Â Â Â Â Â Â throw new MacroExecutionException("Current user doesn't have view rights on document [" + documentName
> - Â Â Â Â Â Â Â Â Â Â + "]");
> - Â Â Â Â Â Â }
> + Â Â Â Â Â Â documentBridge = this.documentAccessBridge.getDocument(includedReference);
> Â Â Â Â } catch (Exception e) {
> - Â Â Â Â Â Â throw new MacroExecutionException("Failed to get content for Document [" + documentName + "]", e);
> + Â Â Â Â Â Â throw new MacroExecutionException("Failed to load Document ["
> + Â Â Â Â Â Â Â Â + this.defaultEntityReferenceSerializer.serialize(includedReference) + "]", e);
> Â Â Â Â }
> + Â Â Â Â String includedContent = documentBridge.getContent();
> + Â Â Â Â Syntax includedSyntax = documentBridge.getSyntax();
>
> - Â Â Â Â List<Block> result;
> + Â Â Â Â // Step 3: Parse and transform the included document's content.
>
> Â Â Â Â // Check the value of the "context" parameter.
> Â Â Â Â //
> @@ -184,30 +203,68 @@
> Â Â Â Â // if CONTEXT_CURRENT, then simply get the included page's content, parse it and return the resulting AST
> Â Â Â Â // (i.e. don't apply any transformations since we don't want any Macro to be executed at this stage since they
> Â Â Â Â // should be executed by the currently running Macro Transformation.
> - Â Â Â Â if (actualContext == Context.NEW) {
> - Â Â Â Â Â Â result =
> - Â Â Â Â Â Â Â Â executeWithNewContext(documentReference, includedContent, includedSyntax, context.getTransformation());
> + Â Â Â Â List<Block> result;
> + Â Â Â Â MacroTransformationContext newContext = context.clone();
> + Â Â Â Â newContext.setSyntax(includedSyntax);
> + Â Â Â Â if (parametersContext == Context.NEW) {
> + Â Â Â Â Â Â // Since the execution happens in a separate context use a different transformation id to ensure it's
> + Â Â Â Â Â Â // isolated (for ex this will ensure that the velocity macros defined in the included document cannot
> + Â Â Â Â Â Â // interfere with the macros in the including document).
> + Â Â Â Â Â Â newContext.setId(this.defaultEntityReferenceSerializer.serialize(includedReference));
> + Â Â Â Â Â Â result = executeWithNewContext(includedReference, includedContent, newContext);
> Â Â Â Â } else {
> - Â Â Â Â Â Â result = executeWithCurrentContext(documentReference, includedContent, includedSyntax);
> + Â Â Â Â Â Â result = executeWithCurrentContext(includedReference, includedContent, newContext);
> Â Â Â Â }
>
> - Â Â Â Â // We need to handle the case when there are relative links specified in the content of the included document.
> - Â Â Â Â // These link references need to be resolved against the document being included and not the including document.
> - Â Â Â Â // TODO: When http://jira.xwiki.org/jira/browse/XWIKI-4802 is implemented it should be possible remove this
> - Â Â Â Â // code portion and instead perform the resolution at render time, using context information.
> - Â Â Â Â XDOM xdom = new XDOM(result);
> + Â Â Â Â // Step 4: Modify relative references.
> + Â Â Â Â resolveRelativeReferences(result, includedReference);
> +
> + Â Â Â Â return result;
> + Â Â }
> +
> + Â Â /**
> + Â Â * We need to handle the case when there are relative links specified in the content of the included document.
> + Â Â * These link references need to be resolved against the document being included and not the including document.
> + Â Â * TODO: When http://jira.xwiki.org/jira/browse/XWIKI-4802 is implemented it should be possible remove this
> + Â Â * code portion and instead perform the resolution at render time, using context information.
> + Â Â *
> + Â Â * @param includedReference reference to the included document
> + Â Â */
> + Â Â private void resolveRelativeReferences(List<Block> blocks, DocumentReference includedReference)
> + Â Â {
> + Â Â Â Â XDOM xdom = new XDOM(blocks);
> +
> + Â Â Â Â // Resolve links
> Â Â Â Â for (LinkBlock block : xdom.getChildrenByType(LinkBlock.class, true)) {
> - Â Â Â Â Â Â ResourceReference reference = block.getReference();
> - Â Â Â Â Â Â if (reference.getType().equals(ResourceType.DOCUMENT)) {
> - Â Â Â Â Â Â Â Â // It's a link to a document, make the reference absolute
> - Â Â Â Â Â Â Â Â String resolvedReference =
> - Â Â Â Â Â Â Â Â Â Â this.defaultEntityReferenceSerializer.serialize(this.currentDocumentReferenceResolver.resolve(
> - Â Â Â Â Â Â Â Â Â Â Â Â reference.getReference()));
> - Â Â Â Â Â Â Â Â reference.setReference(resolvedReference);
> + Â Â Â Â Â Â ResourceReference resourceReference = block.getReference();
> + Â Â Â Â Â Â // Make reference absolute for links to document and attachments.
> + Â Â Â Â Â Â if (resourceReference.getType().equals(ResourceType.DOCUMENT)
> + Â Â Â Â Â Â Â Â || resourceReference.getType().equals(ResourceType.ATTACHMENT))
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â EntityReference entityReference;
> + Â Â Â Â Â Â Â Â if (resourceReference.getType().equals(ResourceType.DOCUMENT)) {
> + Â Â Â Â Â Â Â Â Â Â entityReference = this.explicitDocumentReferenceResolver.resolve(resourceReference.getReference(),
> + Â Â Â Â Â Â Â Â Â Â Â Â includedReference);
> + Â Â Â Â Â Â Â Â } else {
> + Â Â Â Â Â Â Â Â Â Â entityReference = this.explicitAttachmentReferenceResolver.resolve(resourceReference.getReference(),
> + Â Â Â Â Â Â Â Â Â Â Â Â includedReference);
> + Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â String resolvedReference = this.defaultEntityReferenceSerializer.serialize(entityReference);
> + Â Â Â Â Â Â Â Â resourceReference.setReference(resolvedReference);
> Â Â Â Â Â Â }
> Â Â Â Â }
>
> - Â Â Â Â return result;
> + Â Â Â Â // Resolve images
> + Â Â Â Â for (ImageBlock block : xdom.getChildrenByType(ImageBlock.class, true)) {
> + Â Â Â Â Â Â ResourceReference resourceReference = block.getReference();
> + Â Â Â Â Â Â // Make reference absolute for images in documents
> + Â Â Â Â Â Â if (resourceReference.getType().equals(ResourceType.ATTACHMENT)) {
> + Â Â Â Â Â Â Â Â String resolvedReference = this.defaultEntityReferenceSerializer.serialize(
> + Â Â Â Â Â Â Â Â Â Â this.explicitAttachmentReferenceResolver.resolve(resourceReference.getReference(),
> + Â Â Â Â Â Â Â Â Â Â Â Â includedReference));
> + Â Â Â Â Â Â Â Â resourceReference.setReference(resolvedReference);
> + Â Â Â Â Â Â }
> + Â Â Â Â }
> Â Â }
>
> Â Â /**
> @@ -274,13 +331,12 @@
> Â Â Â *
> Â Â Â * @param includedDocumentReference the name of the document to include.
> Â Â Â * @param includedContent the content of the document to include.
> - Â Â * @param includedSyntax the syntax identifier of the provided content.
> - Â Â * @param transformation the macro transformation.
> + Â Â * @param macroContext the transformation context to use to parse/transform the content
> Â Â Â * @return the result of parsing and transformation of the document to include.
> Â Â Â * @throws MacroExecutionException error when parsing content.
> Â Â Â */
> Â Â private List<Block> executeWithNewContext(DocumentReference includedDocumentReference, String includedContent,
> - Â Â Â Â String includedSyntax, Transformation transformation) throws MacroExecutionException
> + Â Â Â Â MacroTransformationContext macroContext) throws MacroExecutionException
> Â Â {
> Â Â Â Â List<Block> result;
>
> @@ -293,8 +349,7 @@
> Â Â Â Â Â Â Map<String, Object> backupObjects = new HashMap<String, Object>();
> Â Â Â Â Â Â try {
> Â Â Â Â Â Â Â Â this.documentAccessBridge.pushDocumentInContext(backupObjects, includedDocumentReference);
> - Â Â Â Â Â Â Â Â result =
> - Â Â Â Â Â Â Â Â Â Â generateIncludedPageDOM(includedDocumentReference, includedContent, includedSyntax, transformation);
> + Â Â Â Â Â Â Â Â result = generateIncludedPageDOM(includedDocumentReference, includedContent, macroContext, true);
> Â Â Â Â Â Â } finally {
> Â Â Â Â Â Â Â Â this.documentAccessBridge.popDocumentFromContext(backupObjects);
> Â Â Â Â Â Â }
> @@ -315,14 +370,14 @@
> Â Â Â *
> Â Â Â * @param includedDocumentReference the name of the document to include.
> Â Â Â * @param includedContent the content of the document to include.
> - Â Â * @param includedSyntax the syntax identifier of the provided content.
> + Â Â * @param macroContext the transformation context to use to parse the content
> Â Â Â * @return the result of parsing and transformation of the document to include.
> Â Â Â * @throws MacroExecutionException error when parsing content.
> Â Â Â */
> Â Â private List<Block> executeWithCurrentContext(DocumentReference includedDocumentReference, String includedContent,
> - Â Â Â Â String includedSyntax) throws MacroExecutionException
> + Â Â Â Â MacroTransformationContext macroContext) throws MacroExecutionException
> Â Â {
> - Â Â Â Â return generateIncludedPageDOM(includedDocumentReference, includedContent, includedSyntax, null);
> + Â Â Â Â return generateIncludedPageDOM(includedDocumentReference, includedContent, macroContext, false);
> Â Â }
>
> Â Â /**
> @@ -330,30 +385,26 @@
> Â Â Â *
> Â Â Â * @param includedDocumentReference the name of the document to include.
> Â Â Â * @param includedContent the content of the document to include.
> - Â Â * @param includedSyntax the syntax identifier of the provided content.
> - Â Â * @param transformation the macro transformation.
> + Â Â * @param macroContext the transformation context to use to parse/transform the content
> + Â Â * @param transform if true then execute transformations
> Â Â Â * @return the result of parsing and transformation of the document to include.
> Â Â Â * @throws MacroExecutionException error when parsing content.
> Â Â Â */
> Â Â private List<Block> generateIncludedPageDOM(DocumentReference includedDocumentReference, String includedContent,
> - Â Â Â Â String includedSyntax, Transformation transformation) throws MacroExecutionException
> + Â Â Â Â MacroTransformationContext macroContext, boolean transform) throws MacroExecutionException
> Â Â {
> - Â Â Â Â XDOM includedDom;
> + Â Â Â Â List<Block> result;
> Â Â Â Â try {
> - Â Â Â Â Â Â Parser parser = this.componentManager.lookup(Parser.class, includedSyntax);
> - Â Â Â Â Â Â includedDom = parser.parse(new StringReader(includedContent));
>
> Â Â Â Â Â Â // Only run Macro transformation when the context is a new one as otherwise we need the macros in the
> Â Â Â Â Â Â // included page to be added to the list of macros on the including page so that they're all sorted
> Â Â Â Â Â Â // and executed in the right order. Note that this works only because the Include macro has the highest
> Â Â Â Â Â Â // execution priority and is thus executed first.
> - Â Â Â Â Â Â if (transformation != null) {
> - Â Â Â Â Â Â Â Â transformation.transform(includedDom, new TransformationContext(includedDom, parser.getSyntax()));
> - Â Â Â Â Â Â }
> + Â Â Â Â Â Â result = this.contentParser.parse(includedContent, macroContext, transform, false);
> Â Â Â Â } catch (Exception e) {
> Â Â Â Â Â Â throw new MacroExecutionException("Failed to parse included page [" + includedDocumentReference + "]", e);
> Â Â Â Â }
>
> - Â Â Â Â return includedDom.getChildren();
> + Â Â Â Â return result;
> Â Â }
> Â }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/IncludeMacroTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/IncludeMacroTest.java   2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/IncludeMacroTest.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -28,6 +28,8 @@
>
> Â import org.jmock.Expectations;
> Â import org.junit.Test;
> +import org.xwiki.bridge.DocumentModelBridge;
> +import org.xwiki.model.reference.AttachmentReference;
> Â import org.xwiki.model.reference.DocumentReference;
> Â import org.xwiki.rendering.block.Block;
> Â import org.xwiki.rendering.block.MacroBlock;
> @@ -73,77 +75,35 @@
> Â Â }
>
> Â Â @Test
> - Â Â public void testIncludeMacroWithNewContext() throws Exception
> + Â Â public void testIncludeMacroWithNewContextShowsVelocityMacrosAreIsolated() throws Exception
> Â Â {
> Â Â Â Â String expected = "beginDocument\n"
> - Â Â Â Â Â Â + "beginMacroMarkerStandalone [velocity] [] [$myvar]\n"
> + Â Â Â Â Â Â + "beginMacroMarkerStandalone [velocity] [] [#testmacro]\n"
> Â Â Â Â Â Â + "beginParagraph\n"
> - Â Â Â Â Â Â + "onWord [hello]\n"
> + Â Â Â Â Â Â + "onSpecialSymbol [#]\n"
> + Â Â Â Â Â Â + "onWord [testmacro]\n"
> Â Â Â Â Â Â + "endParagraph\n"
> - Â Â Â Â Â Â + "endMacroMarkerStandalone [velocity] [] [$myvar]\n"
> + Â Â Â Â Â Â + "endMacroMarkerStandalone [velocity] [] [#testmacro]\n"
> Â Â Â Â Â Â + "endDocument";
>
> - Â Â Â Â // Since it's not in the same context, we verify that a Velocity variable set in the including page is not
> - Â Â Â Â // seen in the included page.
> - Â Â Â Â VelocityManager velocityManager = getComponentManager().lookup(VelocityManager.class);
> - Â Â Â Â StringWriter writer = new StringWriter();
> - Â Â Â Â velocityManager.getVelocityEngine().evaluate(velocityManager.getVelocityContext(), writer, "template",
> - Â Â Â Â Â Â "#set ($myvar = 'hello')");
> + Â Â Â Â // We verify that a Velocity macro set in the including page is not seen in the included page.
> + Â Â Â Â List<Block> blocks = runIncludeMacroWithPreVelocity(Context.NEW, "#macro(testmacro)#end",
> + Â Â Â Â Â Â "{{velocity}}#testmacro{{/velocity}}");
>
> - Â Â Â Â getMockery().checking(new Expectations() {{
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).isDocumentViewable(with(any(DocumentReference.class))); will(returnValue(true));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentContent(with(any(String.class)));
> - Â Â Â Â Â Â Â Â will(returnValue("{{velocity}}$myvar{{/velocity}}"));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentSyntaxId(with(any(String.class)));
> - Â Â Â Â Â Â Â Â will(returnValue(Syntax.XWIKI_2_0.toIdString()));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).pushDocumentInContext(with(any(Map.class)), with(any(DocumentReference.class)));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).popDocumentFromContext(with(any(Map.class)));
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("wiki:Space.Page");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "Space", "Page")));
> - Â Â Â Â }});
> - Â Â Â Â this.includeMacro.setDocumentAccessBridge(this.mockSetup.bridge);
> -
> - Â Â Â Â IncludeMacroParameters parameters = new IncludeMacroParameters();
> - Â Â Â Â parameters.setDocument("wiki:Space.Page");
> - Â Â Â Â parameters.setContext(Context.NEW);
> -
> - Â Â Â Â // Create a Macro transformation context with the Macro transformation object defined so that the include
> - Â Â Â Â // macro can transform included page which is using a new context.
> - Â Â Â Â MacroTransformation macroTransformation =
> - Â Â Â Â Â Â (MacroTransformation) getComponentManager().lookup(Transformation.class, "macro");
> - Â Â Â Â MacroTransformationContext context = new MacroTransformationContext();
> - Â Â Â Â context.setTransformation(macroTransformation);
> -
> - Â Â Â Â List<Block> blocks = this.includeMacro.execute(parameters, null, context);
> -
> Â Â Â Â assertBlocks(expected, blocks, this.rendererFactory);
> Â Â }
>
> Â Â @Test
> - Â Â public void testIncludeMacroWithCurrentContext() throws Exception
> + Â Â public void testIncludeMacroWithCurrentContextShowsVelocityMacrosAreShared() throws Exception
> Â Â {
> Â Â Â Â String expected = "beginDocument\n"
> - Â Â Â Â Â Â + "onMacroStandalone [someMacro] []\n"
> + Â Â Â Â Â Â + "onMacroStandalone [velocity] [] [#testmacro]\n"
> Â Â Â Â Â Â + "endDocument";
>
> - Â Â Â Â getMockery().checking(new Expectations() {{
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).isDocumentViewable(with(any(DocumentReference.class))); will(returnValue(true));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentContent(with(any(String.class)));
> - Â Â Â Â Â Â Â Â will(returnValue("{{someMacro/}}"));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentSyntaxId(with(any(String.class)));
> - Â Â Â Â Â Â Â Â will(returnValue(Syntax.XWIKI_2_0.toIdString()));
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("wiki:Space.Page");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "Space", "Page")));
> - Â Â Â Â }});
> -
> - Â Â Â Â this.includeMacro.setDocumentAccessBridge(mockSetup.bridge);
> + Â Â Â Â // We verify that a Velocity macro set in the including page is seen in the included page.
> + Â Â Â Â List<Block> blocks = runIncludeMacroWithPreVelocity(Context.CURRENT, "#macro(testmacro)#end",
> + Â Â Â Â Â Â "{{velocity}}#testmacro{{/velocity}}");
>
> - Â Â Â Â IncludeMacroParameters parameters = new IncludeMacroParameters();
> - Â Â Â Â parameters.setDocument("wiki:Space.Page");
> - Â Â Â Â parameters.setContext(Context.CURRENT);
> -
> - Â Â Â Â List<Block> blocks = this.includeMacro.execute(parameters, null, new MacroTransformationContext());
> -
> Â Â Â Â assertBlocks(expected, blocks, this.rendererFactory);
> Â Â }
>
> @@ -165,27 +125,30 @@
> Â Â Â * Verify that relative links are made absolute in the XDOM returned by the Include macro.
> Â Â Â */
> Â Â @Test
> - Â Â public void testIncludeMacroWhenIncludingDocumentWithRelativeLinks() throws Exception
> + Â Â public void testIncludeMacroWhenIncludingDocumentWithRelativeReferences() throws Exception
> Â Â {
> Â Â Â Â String expected = "beginDocument\n"
> Â Â Â Â Â Â + "beginParagraph\n"
> - Â Â Â Â Â Â + "beginLink [Typed = [false] Type = [doc] Reference = [wiki:space.page]] [false]\n"
> - Â Â Â Â Â Â + "endLink [Typed = [false] Type = [doc] Reference = [wiki:space.page]] [false]\n"
> + Â Â Â Â Â Â + "beginLink [Typed = [false] Type = [doc] Reference = [includedWiki:includedSpace.page]] [false]\n"
> + Â Â Â Â Â Â + "endLink [Typed = [false] Type = [doc] Reference = [includedWiki:includedSpace.page]] [false]\n"
> + Â Â Â Â Â Â + "onSpace\n"
> + Â Â Â Â Â Â + "beginLink [Typed = [true] Type = [attach] "
> + Â Â Â Â Â Â Â Â + "Reference = [includedWiki:includedSpace.includedPage@test.png]] [false]\n"
> + Â Â Â Â Â Â + "endLink [Typed = [true] Type = [attach] "
> + Â Â Â Â Â Â Â Â + "Reference = [includedWiki:includedSpace.includedPage@test.png]] [false]\n"
> + Â Â Â Â Â Â + "onSpace\n"
> + Â Â Â Â Â Â + "onImage [Typed = [false] Type = [attach] "
> + Â Â Â Â Â Â Â Â + "Reference = [includedWiki:includedSpace.includedPage@test.png]] [true]\n"
> Â Â Â Â Â Â + "endParagraph\n"
> Â Â Â Â Â Â + "endDocument";
>
> + Â Â Â Â setUpDocumentMock("includedWiki:includedSpace.includedPage",
> + Â Â Â Â Â Â new DocumentReference("includedWiki", "includedSpace", "includedPage"),
> + Â Â Â Â Â Â "[[page]] [[attach:test.png]] image:test.png");
> Â Â Â Â getMockery().checking(new Expectations() {{
> Â Â Â Â Â Â oneOf(mockSetup.bridge).isDocumentViewable(with(any(DocumentReference.class))); will(returnValue(true));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentContent("includedWiki:includedSpace.includedPage");
> - Â Â Â Â Â Â Â Â will(returnValue("[[page]]"));
> - Â Â Â Â Â Â oneOf(mockSetup.bridge).getDocumentSyntaxId(with(any(String.class)));
> - Â Â Â Â Â Â Â Â will(returnValue(Syntax.XWIKI_2_0.toIdString()));
> Â Â Â Â Â Â oneOf(mockSetup.bridge).pushDocumentInContext(with(any(Map.class)), with(any(DocumentReference.class)));
> Â Â Â Â Â Â oneOf(mockSetup.bridge).popDocumentFromContext(with(any(Map.class)));
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("page");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "space", "page")));
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("includedWiki:includedSpace.includedPage");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("includedWiki", "includedSpace", "includedPage")));
> Â Â Â Â }});
>
> Â Â Â Â IncludeMacroParameters parameters = new IncludeMacroParameters();
> @@ -201,32 +164,84 @@
> Â Â public void testIncludeMacroWithRecursiveInclude() throws Exception
> Â Â {
> Â Â Â Â getMockery().checking(new Expectations() {{
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("wiki:Space.Page");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "Space", "Page")));
> - Â Â Â Â Â Â oneOf(mockSetup.documentReferenceResolver).resolve("Space.Page");
> - Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "Space", "Page")));
> + Â Â Â Â Â Â allowing(mockSetup.documentReferenceResolver).resolve("wiki:space.page");
> + Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "space", "page")));
> + Â Â Â Â Â Â allowing(mockSetup.documentReferenceResolver).resolve("space.page");
> + Â Â Â Â Â Â Â Â will(returnValue(new DocumentReference("wiki", "space", "page")));
> Â Â Â Â }});
> -
> +
> Â Â Â Â this.includeMacro.setDocumentAccessBridge(mockSetup.bridge);
>
> -     MacroBlock includeMacro = new  MacroBlock("include", Collections.singletonMap("document", "wiki:Space.Page"), false);
> - Â Â Â Â new MacroMarkerBlock("include", Collections.singletonMap("document", "Space.Page"), Collections.<Block>singletonList(includeMacro), false);
> + Â Â Â Â MacroBlock includeMacro =
> + Â Â Â Â Â Â new MacroBlock("include", Collections.singletonMap("document", "wiki:space.page"), false);
> + Â Â Â Â new MacroMarkerBlock("include", Collections.singletonMap("document", "space.page"),
> + Â Â Â Â Â Â Collections.<Block>singletonList(includeMacro), false);
> Â Â Â Â MacroTransformationContext context = new MacroTransformationContext();
> Â Â Â Â context.setCurrentMacroBlock(includeMacro);
>
> Â Â Â Â IncludeMacroParameters parameters = new IncludeMacroParameters();
> - Â Â Â Â parameters.setDocument("wiki:Space.Page");
> + Â Â Â Â parameters.setDocument("wiki:space.page");
> Â Â Â Â parameters.setContext(Context.CURRENT);
>
> - Â Â Â Â List<Block> blocks;
> Â Â Â Â try {
> - Â Â Â Â Â Â blocks = this.includeMacro.execute(parameters, null, context);
> -
> - Â Â Â Â Â Â Assert.fail("The include macro did not checked the recusive inclusion");
> + Â Â Â Â Â Â this.includeMacro.execute(parameters, null, context);
> + Â Â Â Â Â Â Assert.fail("The include macro hasn't checked the recursive inclusion");
> Â Â Â Â } catch (MacroExecutionException expected) {
> Â Â Â Â Â Â if (!expected.getMessage().startsWith("Found recursive inclusion")) {
> Â Â Â Â Â Â Â Â throw expected;
> Â Â Â Â Â Â }
> Â Â Â Â }
> Â Â }
> +
> + Â Â private void setUpDocumentMock(final String resolve, final DocumentReference reference, final String content)
> + Â Â Â Â throws Exception
> + Â Â {
> + Â Â Â Â final DocumentModelBridge mockDocument = getMockery().mock(DocumentModelBridge.class, resolve);
> + Â Â Â Â getMockery().checking(new Expectations() {{
> + Â Â Â Â Â Â allowing(mockSetup.documentReferenceResolver).resolve(resolve);
> + Â Â Â Â Â Â Â Â will(returnValue(reference));
> + Â Â Â Â Â Â allowing(mockSetup.bridge).getDocument(reference); will(returnValue(mockDocument));
> + Â Â Â Â Â Â allowing(mockDocument).getSyntax(); will(returnValue(Syntax.XWIKI_2_0));
> + Â Â Â Â Â Â allowing(mockDocument).getContent(); will(returnValue(content));
> + Â Â Â Â }});
> + Â Â }
> +
> + Â Â private List<Block> runIncludeMacroWithPreVelocity(Context context, String velocity, String includedContent)
> + Â Â Â Â throws Exception
> + Â Â {
> + Â Â Â Â VelocityManager velocityManager = getComponentManager().lookup(VelocityManager.class);
> + Â Â Â Â StringWriter writer = new StringWriter();
> + Â Â Â Â velocityManager.getVelocityEngine().evaluate(velocityManager.getVelocityContext(), writer, "templateId",
> + Â Â Â Â Â Â velocity);
> +
> + Â Â Â Â return runIncludeMacro(context, includedContent);
> + Â Â }
> +
> + Â Â private List<Block> runIncludeMacro(final Context context, String includedContent) throws Exception
> + Â Â {
> + Â Â Â Â setUpDocumentMock("wiki:space.page", new DocumentReference("wiki", "space", "page"), includedContent);
> + Â Â Â Â getMockery().checking(new Expectations() {{
> + Â Â Â Â Â Â allowing(mockSetup.bridge).isDocumentViewable(with(any(DocumentReference.class))); will(returnValue(true));
> + Â Â Â Â Â Â // Verify that push/pop are called when context is NEW
> + Â Â Â Â Â Â if (context == Context.NEW) {
> + Â Â Â Â Â Â Â Â oneOf(mockSetup.bridge).pushDocumentInContext(with(any(Map.class)), with(any(DocumentReference.class)));
> + Â Â Â Â Â Â Â Â oneOf(mockSetup.bridge).popDocumentFromContext(with(any(Map.class)));
> + Â Â Â Â Â Â }
> + Â Â Â Â }});
> + Â Â Â Â this.includeMacro.setDocumentAccessBridge(this.mockSetup.bridge);
> +
> + Â Â Â Â IncludeMacroParameters parameters = new IncludeMacroParameters();
> + Â Â Â Â parameters.setDocument("wiki:space.page");
> + Â Â Â Â parameters.setContext(context);
> +
> + Â Â Â Â // Create a Macro transformation context with the Macro transformation object defined so that the include
> + Â Â Â Â // macro can transform included page which is using a new context.
> + Â Â Â Â MacroTransformation macroTransformation =
> + Â Â Â Â Â Â (MacroTransformation) getComponentManager().lookup(Transformation.class, "macro");
> + Â Â Â Â MacroTransformationContext macroContext = new MacroTransformationContext();
> + Â Â Â Â macroContext.setId("templateId");
> + Â Â Â Â macroContext.setTransformation(macroTransformation);
> +
> + Â Â Â Â return this.includeMacro.execute(parameters, null, macroContext);
> + Â Â }
> Â }
>
> Copied: platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java (from rev 33541, platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/DefaultMacroContentParser.java)
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java               (rev 0)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java   2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,105 @@
> +/*
[...]
> + */
> +package org.xwiki.rendering.internal.macro;
> +
> +import java.io.StringReader;
> +import java.util.List;
> +
> +import org.xwiki.component.annotation.Component;
> +import org.xwiki.component.annotation.Requirement;
> +import org.xwiki.component.manager.ComponentLookupException;
> +import org.xwiki.component.manager.ComponentManager;
> +import org.xwiki.rendering.block.Block;
> +import org.xwiki.rendering.block.XDOM;
> +import org.xwiki.rendering.macro.MacroExecutionException;
> +import org.xwiki.rendering.parser.Parser;
> +import org.xwiki.rendering.syntax.Syntax;
> +import org.xwiki.rendering.transformation.MacroTransformationContext;
> +import org.xwiki.rendering.transformation.TransformationContext;
> +import org.xwiki.rendering.util.ParserUtils;
> +
> +/**
> + * Default implementation for {@link org.xwiki.rendering.internal.macro.MacroContentParser}.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +@Component
> +public class DefaultMacroContentParser implements MacroContentParser
> +{
> + Â Â /**
> + Â Â * Used to look up the syntax parser to use for parsing the content.
> + Â Â */
> + Â Â @Requirement
> + Â Â private ComponentManager componentManager;
> +
> + Â Â /**
> + Â Â * Utility to remove the top level paragraph.
> + Â Â */
> + Â Â private ParserUtils parserUtils = new ParserUtils();
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â * @see MacroContentParser#parse(String, MacroTransformationContext, boolean, boolean)
> + Â Â */
> + Â Â public List<Block> parse(String content, MacroTransformationContext macroContext, boolean transform,
> + Â Â Â Â boolean removeTopLevelParagraph) throws MacroExecutionException
> + Â Â {
> + Â Â Â Â try {
> + Â Â Â Â Â Â List<Block> blocks = getSyntaxParser(macroContext.getSyntax()).parse(
> + Â Â Â Â Â Â Â Â new StringReader(content)).getChildren();
> +
> + Â Â Â Â Â Â if (transform && macroContext.getTransformation() != null) {
> + Â Â Â Â Â Â Â Â XDOM xdom = new XDOM(blocks);
> + Â Â Â Â Â Â Â Â TransformationContext txContext = new TransformationContext(xdom, macroContext.getSyntax());
> + Â Â Â Â Â Â Â Â txContext.setId(macroContext.getId());
> + Â Â Â Â Â Â Â Â try {
> + Â Â Â Â Â Â Â Â Â Â macroContext.getTransformation().transform(xdom, txContext);
> + Â Â Â Â Â Â Â Â } catch (Exception e) {
> + Â Â Â Â Â Â Â Â Â Â throw new MacroExecutionException("Failed to perform transformation", e);
> + Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â blocks = xdom.getChildren();
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â if (removeTopLevelParagraph) {
> + Â Â Â Â Â Â Â Â this.parserUtils.removeTopLevelParagraph(blocks);
> + Â Â Â Â Â Â }
> + Â Â Â Â Â Â return blocks;
> + Â Â Â Â } catch (Exception e) {
> + Â Â Â Â Â Â throw new MacroExecutionException("Failed to parse content [" + content + "]", e);
> + Â Â Â Â }
> + Â Â }
> +
> + Â Â /**
> + Â Â * Get the parser for the current syntax.
> + Â Â *
> + Â Â * @param syntax the current syntax of the title content
> + Â Â * @return the parser for the current syntax
> + Â Â * @throws org.xwiki.rendering.macro.MacroExecutionException Failed to find source parser.
> + Â Â */
> + Â Â private Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException
> + Â Â {
> + Â Â Â Â try {
> + Â Â Â Â Â Â return this.componentManager.lookup(Parser.class, syntax.toIdString());
> + Â Â Â Â } catch (ComponentLookupException e) {
> + Â Â Â Â Â Â throw new MacroExecutionException("Failed to find source parser for syntax [" + syntax + "]", e);
> + Â Â Â Â }
> + Â Â }
> +}
>
> Copied: platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/MacroContentParser.java (from rev 33541, platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/internal/macro/box/MacroContentParser.java)
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/MacroContentParser.java              (rev 0)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/MacroContentParser.java  2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,51 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package org.xwiki.rendering.internal.macro;
> +
> +import java.util.List;
> +
> +import org.xwiki.component.annotation.ComponentRole;
> +import org.xwiki.rendering.block.Block;
> +import org.xwiki.rendering.macro.MacroExecutionException;
> +import org.xwiki.rendering.transformation.MacroTransformationContext;
> +
> +/**
> + * Parses content of a macro field (parameter, macro content) in a given syntax.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +@ComponentRole
> +public interface MacroContentParser
> +{
> + Â Â /**
> + Â Â * Parses content of a macro field (parameter, macro content) in a given syntax and optionally remove the top level
> + Â Â * paragraph.
> + Â Â *
> + Â Â * @param content the content to parse
> + Â Â * @param macroContext the executing Macro context (from which to get the current syntax, etc)
> + Â Â * @param transform if true then executes transformations
> + Â Â * @param removeTopLevelParagraph whether the top level paragraph should be removed after parsing
> + Â Â * @return the result as a {@link org.xwiki.rendering.block.Block}s
> + Â Â * @throws MacroExecutionException in case of a parsing error
> + Â Â */
> + Â Â List<Block> parse(String content, MacroTransformationContext macroContext, boolean transform,
> + Â Â Â Â boolean removeTopLevelParagraph) throws MacroExecutionException;
> +}
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/transformation/MacroTransformationContext.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/transformation/MacroTransformationContext.java  2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/transformation/MacroTransformationContext.java  2010-12-17 13:07:48 UTC (rev 33583)
> @@ -29,7 +29,7 @@
> Â *
> Â * @version $Id$
> Â */
> -public class MacroTransformationContext
> +public class MacroTransformationContext implements Cloneable
> Â {
> Â Â /**
> Â Â Â * The context of the transformation process.
> @@ -181,4 +181,24 @@
> Â Â {
> Â Â Â Â this.transformationContext.setId(id);
> Â Â }
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â * @see Object#clone()
> + Â Â */
> + Â Â @Override
> + Â Â public MacroTransformationContext clone()
> + Â Â {
> + Â Â Â Â MacroTransformationContext newContext;
> + Â Â Â Â try {
> + Â Â Â Â Â Â newContext = (MacroTransformationContext) super.clone();
> + Â Â Â Â } catch (CloneNotSupportedException e) {
> + Â Â Â Â Â Â // Should never happen
> + Â Â Â Â Â Â throw new RuntimeException("Failed to clone object", e);
> + Â Â Â Â }
> +
> + Â Â Â Â newContext.transformationContext = getTransformationContext().clone();
> +
> + Â Â Â Â return newContext;
> + Â Â }
> Â }
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/resources/META-INF/components.txt
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/resources/META-INF/components.txt 2010-12-17 12:25:56 UTC (rev 33582)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/resources/META-INF/components.txt 2010-12-17 13:07:48 UTC (rev 33583)
> @@ -2,5 +2,6 @@
> Â org.xwiki.rendering.internal.macro.DefaultMacroCategoryManager
> Â org.xwiki.rendering.internal.macro.DefaultMacroIdFactory
> Â org.xwiki.rendering.internal.macro.ResourceReferenceConverter
> +org.xwiki.rendering.internal.macro.DefaultMacroContentParser
> Â org.xwiki.rendering.internal.transformation.macro.MacroTransformation
> Â org.xwiki.rendering.internal.transformation.macro.DefaultMacroTransformationConfiguration
>
> Added: platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/test/java/org/xwiki/rendering/internal/transformation/macro/MacroTransformationContextTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/test/java/org/xwiki/rendering/internal/transformation/macro/MacroTransformationContextTest.java                 (rev 0)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/test/java/org/xwiki/rendering/internal/transformation/macro/MacroTransformationContextTest.java     2010-12-17 13:07:48 UTC (rev 33583)
> @@ -0,0 +1,92 @@
> +/*
[...]
> + */
> +package org.xwiki.rendering.internal.transformation.macro;
> +
> +import java.util.Arrays;
> +import java.util.Collections;
> +
> +import org.junit.Assert;
> +import org.junit.Test;
> +import org.xwiki.rendering.block.Block;
> +import org.xwiki.rendering.block.MacroBlock;
> +import org.xwiki.rendering.block.WordBlock;
> +import org.xwiki.rendering.block.XDOM;
> +import org.xwiki.rendering.syntax.Syntax;
> +import org.xwiki.rendering.transformation.MacroTransformationContext;
> +import org.xwiki.rendering.transformation.Transformation;
> +import org.xwiki.rendering.transformation.TransformationContext;
> +import org.xwiki.rendering.transformation.TransformationException;
> +
> +/**
> + * Unit tests for {@link MacroTransformationContext}.
> + *
> + * @version $Id$
> + * @since 3.0M1
> + */
> +public class MacroTransformationContextTest
> +{
> + Â Â @Test
> + Â Â public void testClone()
> + Â Â {
> + Â Â Â Â MacroTransformationContext context = new MacroTransformationContext();
> + Â Â Â Â context.setId("id");
> + Â Â Â Â context.setInline(true);
> + Â Â Â Â context.setSyntax(Syntax.XWIKI_2_0);
> +
> + Â Â Â Â XDOM xdom = new XDOM(Arrays.<Block>asList(new WordBlock("test1")));
> + Â Â Â Â context.setXDOM(xdom);
> +
> + Â Â Â Â MacroBlock macroBlock = new MacroBlock("testmacro", Collections.<String, String>emptyMap(), null, false);
> + Â Â Â Â context.setCurrentMacroBlock(macroBlock);
> +
> + Â Â Â Â Transformation transformation = new Transformation()
> + Â Â Â Â {
> + Â Â Â Â Â Â public int getPriority()
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â throw new RuntimeException("dummy");
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â public void transform(XDOM dom, Syntax syntax) throws TransformationException
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â throw new RuntimeException("dummy");
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â public void transform(Block block, TransformationContext context) throws TransformationException
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â throw new RuntimeException("dummy");
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â public int compareTo(Transformation transformation)
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â throw new RuntimeException("dummy");
> + Â Â Â Â Â Â }
> + Â Â Â Â };
> + Â Â Â Â context.setTransformation(transformation);
> +
> + Â Â Â Â MacroTransformationContext newContext = context.clone();
> + Â Â Â Â Assert.assertNotSame(context, newContext);
> + Â Â Â Â Assert.assertEquals("id", newContext.getId());
> + Â Â Â Â Assert.assertEquals(true, newContext.isInline());
> + Â Â Â Â Assert.assertEquals(Syntax.XWIKI_2_0, newContext.getSyntax());
> + Â Â Â Â Assert.assertEquals(xdom, newContext.getXDOM());
> + Â Â Â Â Assert.assertEquals(macroBlock, newContext.getCurrentMacroBlock());
> + Â Â Â Â Assert.assertEquals(transformation, newContext.getTransformation());
> + Â Â }
> +}
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
>
--
Thomas Mortagne
I would like to deprecate the following methods because they insert and remove content which is
dependent on JRCS for parsing and generation:
XWikiAttachmentArchive#getArchive()
XWikiAttachmentArchive#getArchive(XWikiContext)
XWikiAttachmentArchive#setArchive(byte[])
These are not easily removed because they are needed for the packaging plugin but I think we should
move away from that means of import/export as it contains code (including JRCS) which is memory
inefficient.
Also in the 3.0 cycle, I would like to make private the following methods from XWikiHibernateStore
as they are not used externally and are currently deprecated:
loadXWikiProperty
saveXWikiClass
loadXWikiClass
loadAttachmentList
saveAttachmentList
saveAttachment
injectCustomMappingsInSessionFactory
injectInSessionFactory
isValidCustomMapping
I would like to remove the following methods entirely as they are also deprecated and are not used
at all:
getBatcherStats
resetBatcherStats
deleteXWikiClass
saveXWikiClassProperty
WDYT?
Caleb
The XWiki development team is pleased to announce the release of XWiki
Enterprise 2.7 Release Candidate 1.
The 2.7 release is intended to be the last major release in the 2.x
cycle. As such, this release has stabilization as its primary goal, and
mostly provides bugfixes and minor improvements.
For more information, see the full release notes at:
http://www.xwiki.org/xwiki/bin/Main/ReleaseNotesXWikiEnterprise27RC1
Thanks,
The XWiki dev team.
Hi devs,
I'd like to propose a new macro (not sure how to call it): {{current}}
Usage:
{{current document="wiki:space.page"}}
.... nested blocks....
{{/current}}
What it does:
* Execute the nested blocks in the context of the passed document, i.e. it sets the passed document as the current document in the execution context.
Rationale:
* We have several use cases:
** When we have an include and we want to use relative references (links, images) in the included document
** On the Features page of enterprise.xwiki.org I query extensions.xwiki.org and get the data from one object field which has the format: "attach:...." (or "url:....", etc). I need to make this an image that is resolved based on the page where the information was taken from.
WDYT?
Thanks
-Vincent
Hi devs,
We're starting a new dev cycle (the 3.x one) and we need to start defining the roadmap for 3.0.
Here are some ideas we discussed internally at XWiki SAS. Some of these already have someone assigned and some don't. If you're interested in implementing one of the ideas listed above, please reply to this mail. If you're interested in contributing some other stuff for XE 3.0 please reply to this mail too so that we can put the result of this thread on the XE roadmap page at http://enterprise.xwiki.org/xwiki/bin/view/Main/Roadmap
Note that most of the issue listed are continuation of work already started.
- Extension Manager - Thomas Mortagne
- App within minute - Investigation - By whom?
- Improved page loading - Investigation - By whom?
- Use status - whom?
- Right UI - whom? Sergiu?
- Portlet - Marius
- Multipage export - whom?
- Dashboard - Anca
- Admin/Profile UI improvements - Sergiu
- Attachment Storage - Caleb? (+ Sergiu to help review it)
Marius also expressed interest in improving support for Chrome/Safari/Opera in the WYSIWYG editor (especially for macro edition) + check how it works on IE9 + FF4.
On my side, I'll try to continue working on the xwiki-action, xwiki-url and xwiki-model modules
Proposed Dates:
- 3.0M1: 17th of Jan 2011
- 3.0M2: 7 Feb 2011
- 3.0RC1: 21 Feb 2011
- 3.0Final: 7 March 2011
WDYT?
Thanks
-Vincent
We need to be careful about this. This test proves that you've changed the behavior.
And changing the behavior is an important change. In this case Thomas and I had designed the XHTML renderer so that its output would work with any encoding. I think this is no longer true with your change in http://jira.xwiki.org/jira/browse/XWIKI-5763
To be honest, I'm a bit worried about that change unless you really know what you are doing... especially in XE 2.7 which is the last minor release of the 2.x cycle.
Thanks
-Vincent
On Dec 14, 2010, at 4:23 PM, sdumitriu (SVN) wrote:
> Author: sdumitriu
> Date: 2010-12-14 16:23:00 +0100 (Tue, 14 Dec 2010)
> New Revision: 33381
>
> Modified:
> platform/core/trunk/xwiki-rendering/xwiki-rendering-tests/src/test/resources/simple/encoding/encoding1.test
> Log:
> [misc] Disable a failing test until we decide what should be done with non-ASCII characters
>
> Modified: platform/core/trunk/xwiki-rendering/xwiki-rendering-tests/src/test/resources/simple/encoding/encoding1.test
> ===================================================================
> --- platform/core/trunk/xwiki-rendering/xwiki-rendering-tests/src/test/resources/simple/encoding/encoding1.test 2010-12-14 14:51:26 UTC (rev 33380)
> +++ platform/core/trunk/xwiki-rendering/xwiki-rendering-tests/src/test/resources/simple/encoding/encoding1.test 2010-12-14 15:23:00 UTC (rev 33381)
> @@ -18,6 +18,7 @@
> endParagraph [[param1]=[val(((252)))e]]
> endDocument
> .#-----------------------------------------------------
> -.expect|xhtml/1.0
> +.expect|xhtml/1.0|skip
> +.# TODO: Re-enable this test once we reach a decision about non-ASCII characters
> .#-----------------------------------------------------
> <p> ˜€</p><p param1="valüe"> ˜€</p>
On Tue, Dec 14, 2010 at 15:27, Jerome Velociter <jerome(a)xwiki.com> wrote:
> Thanks...
>
> I think you've forgot to update other events that rely on
> AbstractDocumentEvent. if I remember well there is one in
> xwiki-annotations-core, and maybe some in xwiki-core too.
I did updated xwiki-core ones but forgot some others yes.
>
> On Tue, Dec 14, 2010 at 3:01 PM, tmortagne
> <platform-notifications(a)xwiki.org> wrote:
>> Author: tmortagne
>> Date: 2010-12-14 15:01:28 +0100 (Tue, 14 Dec 2010)
>> New Revision: 33376
>>
>> Added:
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
>> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/
>> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/internal/
>> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
>> Removed:
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
>> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
>> Â platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
>> Modified:
>> Â platform/core/trunk/xwiki-bridge/pom.xml
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
>> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
>> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
>> Â platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
>> Log:
>> XWIKI-5786: Deprecate Document(Save|Update|Delete)Event and add new Document(Created|Updated|Deleted)Event in xwiki-bridge instead
>> Â Â * LegacyEventDispatcher loses document name
>> Â Â * LegacyEventDispatcher should be in an internal package
>> Â Â * AbstractDocumentEvent has nothing to do in xwiki-model
>>
>> Modified: platform/core/trunk/xwiki-bridge/pom.xml
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/pom.xml   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/pom.xml   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -56,13 +56,6 @@
>> Â Â Â Â <!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
>> Â Â Â Â <groupId>org.apache.maven.plugins</groupId>
>> Â Â Â Â <artifactId>maven-checkstyle-plugin</artifactId>
>> - Â Â Â Â <dependencies>
>> - Â Â Â Â Â <dependency>
>> - Â Â Â Â Â Â <groupId>org.xwiki.platform.tools</groupId>
>> - Â Â Â Â Â Â <artifactId>xwiki-verification-resources</artifactId>
>> - Â Â Â Â Â Â <version>${platform.tool.verification.version}</version>
>> - Â Â Â Â Â </dependency>
>> - Â Â Â Â </dependencies>
>> Â Â Â </plugin>
>> Â Â Â <plugin>
>> Â Â Â Â <groupId>org.codehaus.mojo</groupId>
>>
>> Copied: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java (from rev 33375, platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java)
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java               (rev 0)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -0,0 +1,74 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.bridge.event;
>> +
>> +import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
>> +import org.xwiki.model.reference.DocumentReference;
>> +import org.xwiki.observation.event.AbstractFilterableEvent;
>> +import org.xwiki.observation.event.filter.EventFilter;
>> +
>> +/**
>> + * Base class for all document related {@link org.xwiki.observation.event.Event}.
>> + *
>> + * @version $Id$
>> + * @since 2.7RC1
>> + */
>> +public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
>> +{
>> + Â Â /**
>> + Â Â * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
>> + Â Â * changes.
>> + Â Â */
>> + Â Â private static final long serialVersionUID = 1L;
>> +
>> + Â Â /**
>> + Â Â * Used to serialize document name.
>> + Â Â */
>> + Â Â private static final DefaultStringEntityReferenceSerializer SERIALIZER =
>> + Â Â Â Â new DefaultStringEntityReferenceSerializer();
>> +
>> + Â Â /**
>> + Â Â * This event will match any other document event of the same type.
>> + Â Â */
>> + Â Â public AbstractDocumentEvent()
>> + Â Â {
>> + Â Â Â Â super();
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * This event will match only events of the same type affecting the same document.
>> + Â Â *
>> + Â Â * @param documentReference the reference of the document relater to this event
>> + Â Â */
>> + Â Â public AbstractDocumentEvent(DocumentReference documentReference)
>> + Â Â {
>> + Â Â Â Â super(SERIALIZER.serialize(documentReference));
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Constructor using a custom {@link EventFilter}.
>> + Â Â *
>> + Â Â * @param eventFilter the filter to use for matching events
>> + Â Â */
>> + Â Â public AbstractDocumentEvent(EventFilter eventFilter)
>> + Â Â {
>> + Â Â Â Â super(eventFilter);
>> + Â Â }
>> +}
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered after a document is created.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentCreatedEvent extends AbstractDocumentEvent
>> Â {
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered before a document is created.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentCreatingEvent extends AbstractDocumentEvent
>> Â {
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered after a document is deleted.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentDeletedEvent extends AbstractDocumentEvent
>> Â {
>> @@ -43,7 +43,7 @@
>> Â Â Â */
>> Â Â public DocumentDeletedEvent()
>> Â Â {
>> - Â Â Â Â super();
>> +
>> Â Â }
>>
>> Â Â /**
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered before a document is deleted.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentDeletingEvent extends AbstractDocumentEvent
>> Â {
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered after a document is updated.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentUpdatedEvent extends AbstractDocumentEvent
>> Â {
>>
>> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,13 +20,13 @@
>> Â package org.xwiki.bridge.event;
>>
>> Â import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>>
>> Â /**
>> Â * An event triggered before a document is updated.
>> Â *
>> Â * @version $Id$
>> + * @since 2.7RC1
>> Â */
>> Â public class DocumentUpdatingEvent extends AbstractDocumentEvent
>> Â {
>> @@ -35,7 +35,7 @@
>> Â Â Â * changes.
>> Â Â Â */
>> Â Â private static final long serialVersionUID = 1L;
>> -
>> +
>> Â Â /**
>> Â Â Â * Constructor initializing the event filter with an
>> Â Â Â * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
>>
>> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -24,6 +24,7 @@
>> Â import java.util.HashSet;
>> Â import java.util.List;
>>
>> +import org.xwiki.bridge.event.AbstractDocumentEvent;
>> Â import org.xwiki.bridge.event.DocumentCreatedEvent;
>> Â import org.xwiki.bridge.event.DocumentDeletedEvent;
>> Â import org.xwiki.bridge.event.DocumentUpdatedEvent;
>> @@ -39,7 +40,6 @@
>> Â import org.xwiki.model.reference.EntityReferenceSerializer;
>> Â import org.xwiki.observation.EventListener;
>> Â import org.xwiki.observation.ObservationManager;
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.Event;
>>
>> Â /**
>>
>> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,7 +20,7 @@
>> Â */
>> Â package com.xpn.xwiki.internal.event;
>>
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> +import org.xwiki.bridge.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>> Â import org.xwiki.observation.event.filter.FixedNameEventFilter;
>>
>>
>> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -20,7 +20,7 @@
>> Â */
>> Â package com.xpn.xwiki.internal.event;
>>
>> -import org.xwiki.model.event.AbstractDocumentEvent;
>> +import org.xwiki.bridge.event.AbstractDocumentEvent;
>> Â import org.xwiki.observation.event.filter.EventFilter;
>> Â import org.xwiki.observation.event.filter.FixedNameEventFilter;
>>
>>
>> Copied: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java (from rev 33375, platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java)
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java             (rev 0)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -0,0 +1,120 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + *
>> + */
>> +package org.xwiki.legacy.internal;
>> +
>> +import java.util.ArrayList;
>> +import java.util.List;
>> +
>> +import org.xwiki.bridge.event.DocumentCreatedEvent;
>> +import org.xwiki.bridge.event.DocumentDeletedEvent;
>> +import org.xwiki.bridge.event.DocumentUpdatedEvent;
>> +import org.xwiki.component.annotation.Component;
>> +import org.xwiki.component.annotation.Requirement;
>> +import org.xwiki.component.logging.AbstractLogEnabled;
>> +import org.xwiki.component.manager.ComponentLookupException;
>> +import org.xwiki.component.manager.ComponentManager;
>> +import org.xwiki.observation.EventListener;
>> +import org.xwiki.observation.ObservationManager;
>> +import org.xwiki.observation.event.DocumentDeleteEvent;
>> +import org.xwiki.observation.event.DocumentSaveEvent;
>> +import org.xwiki.observation.event.DocumentUpdateEvent;
>> +import org.xwiki.observation.event.Event;
>> +
>> +/**
>> + * An event listener that forwards received events to their corresponding legacy events. This allows depreciated events
>> + * to continue be supported.
>> + *
>> + * @version $Id$
>> + */
>> +@Component("legacyEventDispatcher")
>> +public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
>> +{
>> + Â Â /**
>> + Â Â * Component manager, used to get access to the observation manager that we cannot get injected because of a cyclic
>> + Â Â * dependency.
>> + Â Â */
>> + Â Â @Requirement
>> + Â Â private ComponentManager componentManager;
>> +
>> + Â Â /**
>> + Â Â * Observation manager, used to notify legacy events.
>> + Â Â */
>> + Â Â private ObservationManager observationManager;
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â */
>> + Â Â public String getName()
>> + Â Â {
>> + Â Â Â Â return "legacyEventDispatcher";
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â */
>> + Â Â public List<Event> getEvents()
>> + Â Â {
>> + Â Â Â Â return new ArrayList<Event>()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â add(new DocumentDeletedEvent());
>> + Â Â Â Â Â Â Â Â add(new DocumentCreatedEvent());
>> + Â Â Â Â Â Â Â Â add(new DocumentUpdatedEvent());
>> + Â Â Â Â Â Â }
>> + Â Â Â Â };
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * {@inheritDoc}
>> + Â Â */
>> + Â Â public void onEvent(Event event, Object source, Object data)
>> + Â Â {
>> + Â Â Â Â if (event instanceof DocumentDeletedEvent) {
>> + Â Â Â Â Â Â this.getObservationManager().notify(
>> + Â Â Â Â Â Â Â Â new DocumentDeleteEvent(((DocumentDeletedEvent) event).getEventFilter()), source, data);
>> + Â Â Â Â } else if (event instanceof DocumentCreatedEvent) {
>> + Â Â Â Â Â Â this.getObservationManager().notify(new DocumentSaveEvent(((DocumentCreatedEvent) event).getEventFilter()),
>> + Â Â Â Â Â Â Â Â source, data);
>> + Â Â Â Â } else if (event instanceof DocumentUpdatedEvent) {
>> + Â Â Â Â Â Â this.getObservationManager().notify(
>> + Â Â Â Â Â Â Â Â new DocumentUpdateEvent(((DocumentUpdatedEvent) event).getEventFilter()), source, data);
>> + Â Â Â Â }
>> + Â Â }
>> +
>> + Â Â /**
>> + Â Â * Helper to lazily lookup the observation manager.
>> + Â Â *
>> + Â Â * @return the observation manager
>> + Â Â */
>> + Â Â private ObservationManager getObservationManager()
>> + Â Â {
>> + Â Â Â Â if (this.observationManager != null) {
>> + Â Â Â Â Â Â return this.observationManager;
>> + Â Â Â Â }
>> + Â Â Â Â try {
>> + Â Â Â Â Â Â this.observationManager = this.componentManager.lookup(ObservationManager.class);
>> + Â Â Â Â } catch (ComponentLookupException e) {
>> + Â Â Â Â Â Â this.getLogger().error("Failed to lookup observation manager", e);
>> + Â Â Â Â }
>> + Â Â Â Â return this.observationManager;
>> + Â Â }
>> +
>> +}
>>
>> Deleted: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java   2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java   2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -1,115 +0,0 @@
>> -/*
>> - * See the NOTICE file distributed with this work for additional
>> - * information regarding copyright ownership.
>> - *
>> - * This is free software; you can redistribute it and/or modify it
>> - * under the terms of the GNU Lesser General Public License as
>> - * published by the Free Software Foundation; either version 2.1 of
>> - * the License, or (at your option) any later version.
>> - *
>> - * This software is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> - * Lesser General Public License for more details.
>> - *
>> - * You should have received a copy of the GNU Lesser General Public
>> - * License along with this software; if not, write to the Free
>> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> - *
>> - */
>> -package org.xwiki.observation;
>> -
>> -import java.util.ArrayList;
>> -import java.util.List;
>> -
>> -import org.xwiki.bridge.event.DocumentCreatedEvent;
>> -import org.xwiki.bridge.event.DocumentDeletedEvent;
>> -import org.xwiki.bridge.event.DocumentUpdatedEvent;
>> -import org.xwiki.component.annotation.Component;
>> -import org.xwiki.component.annotation.Requirement;
>> -import org.xwiki.component.logging.AbstractLogEnabled;
>> -import org.xwiki.component.manager.ComponentLookupException;
>> -import org.xwiki.component.manager.ComponentManager;
>> -import org.xwiki.observation.event.DocumentDeleteEvent;
>> -import org.xwiki.observation.event.DocumentSaveEvent;
>> -import org.xwiki.observation.event.DocumentUpdateEvent;
>> -import org.xwiki.observation.event.Event;
>> -
>> -/**
>> - * An event listener that forwards received events to their corresponding legacy events. This allows depreciated events
>> - * to continue be supported.
>> - *
>> - * @version $Id$
>> - */
>> -@Component("legacyEventDispatcher")
>> -public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
>> -{
>> - Â Â /**
>> - Â Â * Component manager, used to get access to the observation manager that we cannot get injected because of a cyclic
>> - Â Â * dependency.
>> - Â Â */
>> - Â Â @Requirement
>> - Â Â private ComponentManager componentManager;
>> -
>> - Â Â /**
>> - Â Â * Observation manager, used to notify legacy events.
>> - Â Â */
>> - Â Â private ObservationManager observationManager;
>> -
>> - Â Â /**
>> - Â Â * {@inheritDoc}
>> - Â Â */
>> - Â Â public String getName()
>> - Â Â {
>> - Â Â Â Â return "legacyEventDispatcher";
>> - Â Â }
>> -
>> - Â Â /**
>> - Â Â * {@inheritDoc}
>> - Â Â */
>> - Â Â public List<Event> getEvents()
>> - Â Â {
>> - Â Â Â Â return new ArrayList<Event>()
>> - Â Â Â Â {
>> - Â Â Â Â Â Â {
>> - Â Â Â Â Â Â Â Â add(new DocumentDeletedEvent());
>> - Â Â Â Â Â Â Â Â add(new DocumentCreatedEvent());
>> - Â Â Â Â Â Â Â Â add(new DocumentUpdatedEvent());
>> - Â Â Â Â Â Â }
>> - Â Â Â Â };
>> - Â Â }
>> -
>> - Â Â /**
>> - Â Â * {@inheritDoc}
>> - Â Â */
>> - Â Â public void onEvent(Event event, Object source, Object data)
>> - Â Â {
>> - Â Â Â Â if (event instanceof DocumentDeletedEvent) {
>> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentDeleteEvent(), source, data);
>> - Â Â Â Â } else if (event instanceof DocumentCreatedEvent) {
>> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentSaveEvent(), source, data);
>> - Â Â Â Â } else if (event instanceof DocumentUpdatedEvent) {
>> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentUpdateEvent(), source, data);
>> - Â Â Â Â }
>> - Â Â }
>> -
>> - Â Â /**
>> - Â Â * Helper to lazily lookup the observation manager.
>> - Â Â *
>> - Â Â * @return the observation manager
>> - Â Â */
>> - Â Â private ObservationManager getObservationManager()
>> - Â Â {
>> - Â Â Â Â if (this.observationManager != null) {
>> - Â Â Â Â Â Â return this.observationManager;
>> - Â Â Â Â }
>> - Â Â Â Â try {
>> - Â Â Â Â Â Â this.observationManager = this.componentManager.lookup(ObservationManager.class);
>> - Â Â Â Â } catch (ComponentLookupException e) {
>> - Â Â Â Â Â Â this.getLogger().error("Failed to lookup observation manager", e);
>> - Â Â Â Â }
>> - Â Â Â Â return this.observationManager;
>> - Â Â }
>> -
>> -}
>>
>> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -27,7 +27,9 @@
>> Â * Base class for all document {@link Event events}.
>> Â *
>> Â * @version $Id$
>> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.AbstractDocumentEvent} instead
>> Â */
>> +@Deprecated
>> Â public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
>> Â {
>> Â Â /**
>> @@ -41,7 +43,7 @@
>> Â Â Â */
>> Â Â public AbstractDocumentEvent()
>> Â Â {
>> - Â Â Â Â super();
>> + Â Â Â Â super();
>> Â Â }
>>
>> Â Â /**
>>
>> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -26,7 +26,7 @@
>> Â * An event triggered when a document is deleted.
>> Â *
>> Â * @version $Id$
>> - * @deprecated use {@link org.xwiki.bridge.event.DocumentDeletedEvent} instead
>> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentDeletedEvent} instead
>> Â */
>> Â @Deprecated
>> Â public class DocumentDeleteEvent extends AbstractDocumentEvent
>>
>> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java  2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java  2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -26,7 +26,7 @@
>> Â * An event triggered when a document is saved for the first time (a new document is created).
>> Â *
>> Â * @version $Id$
>> - * @deprecated use {@link org.xwiki.bridge.event.DocumentCreatedEvent} instead
>> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentCreatedEvent} instead
>> Â */
>> Â @Deprecated
>> Â public class DocumentSaveEvent extends AbstractDocumentEvent
>>
>> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -26,7 +26,7 @@
>> Â * An event triggered when an existing document is saved (updated).
>> Â *
>> Â * @version $Id$
>> - * @deprecated use {@link org.xwiki.bridge.event.DocumentUpdatedEvent} instead
>> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentUpdatedEvent} instead
>> Â */
>> Â @Deprecated
>> Â public class DocumentUpdateEvent extends AbstractDocumentEvent
>>
>> Modified: platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -1 +1 @@
>> -org.xwiki.observation.LegacyEventDispatcher
>> +org.xwiki.legacy.internal.LegacyEventDispatcher
>>
>> Deleted: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java 2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java 2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -1,108 +0,0 @@
>> -/*
>> - * See the NOTICE file distributed with this work for additional
>> - * information regarding copyright ownership.
>> - *
>> - * This is free software; you can redistribute it and/or modify it
>> - * under the terms of the GNU Lesser General Public License as
>> - * published by the Free Software Foundation; either version 2.1 of
>> - * the License, or (at your option) any later version.
>> - *
>> - * This software is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> - * Lesser General Public License for more details.
>> - *
>> - * You should have received a copy of the GNU Lesser General Public
>> - * License along with this software; if not, write to the Free
>> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> - */
>> -package org.xwiki.observation;
>> -
>> -import java.util.Collections;
>> -import java.util.List;
>> -
>> -import junit.framework.Assert;
>> -
>> -import org.junit.Before;
>> -import org.junit.Test;
>> -import org.xwiki.bridge.event.DocumentCreatedEvent;
>> -import org.xwiki.bridge.event.DocumentDeletedEvent;
>> -import org.xwiki.bridge.event.DocumentUpdatedEvent;
>> -import org.xwiki.observation.event.DocumentDeleteEvent;
>> -import org.xwiki.observation.event.DocumentSaveEvent;
>> -import org.xwiki.observation.event.DocumentUpdateEvent;
>> -import org.xwiki.observation.event.Event;
>> -import org.xwiki.test.AbstractComponentTestCase;
>> -
>> -public class LegacyEventDispatcherTest extends AbstractComponentTestCase
>> -{
>> -
>> - Â Â private boolean hasBeenNotified;
>> -
>> - Â Â private ObservationManager om;
>> -
>> - Â Â @Before
>> - Â Â public void setUp() throws Exception
>> - Â Â {
>> - Â Â Â Â this.hasBeenNotified = false;
>> - Â Â Â Â this.om = this.getComponentManager().lookup(ObservationManager.class);
>> - Â Â }
>> -
>> - Â Â @Test
>> - Â Â public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
>> - Â Â {
>> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
>> - Â Â Â Â om.notify(new DocumentDeletedEvent(), new Object());
>> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> - Â Â Â Â // once all matching event listeners have been notified.
>> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
>> - Â Â }
>> -
>> - Â Â @Test
>> - Â Â public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
>> - Â Â {
>> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
>> - Â Â Â Â om.notify(new DocumentCreatedEvent(), new Object());
>> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> - Â Â Â Â // once all matching event listeners have been notified.
>> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
>> - Â Â }
>> -
>> - Â Â @Test
>> - Â Â public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
>> - Â Â {
>> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
>> - Â Â Â Â om.notify(new DocumentUpdatedEvent(), new Object());
>> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> - Â Â Â Â // once all matching event listeners have been notified.
>> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
>> - Â Â }
>> -
>> - Â Â private void registerListenerWithLegacyEvent(final Event event)
>> - Â Â {
>> - Â Â Â Â this.om.addListener(new EventListener()
>> - Â Â Â Â {
>> - Â Â Â Â Â Â public String getName()
>> - Â Â Â Â Â Â {
>> - Â Â Â Â Â Â Â Â return "testLegacyEventDispatchEventListener";
>> - Â Â Â Â Â Â }
>> -
>> - Â Â Â Â Â Â public List<Event> getEvents()
>> - Â Â Â Â Â Â {
>> - Â Â Â Â Â Â Â Â return Collections.<Event> singletonList(event);
>> - Â Â Â Â Â Â }
>> -
>> - Â Â Â Â Â Â public void onEvent(Event event, Object source, Object data)
>> - Â Â Â Â Â Â {
>> - Â Â Â Â Â Â Â Â setNotified();
>> - Â Â Â Â Â Â }
>> -
>> - Â Â Â Â });
>> - Â Â }
>> -
>> - Â Â private void setNotified()
>> - Â Â {
>> - Â Â Â Â this.hasBeenNotified = true;
>> - Â Â }
>> -}
>>
>> Copied: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java (from rev 33375, platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java)
>> ===================================================================
>> --- platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java              (rev 0)
>> +++ platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java  2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -0,0 +1,111 @@
>> +/*
>> + * See the NOTICE file distributed with this work for additional
>> + * information regarding copyright ownership.
>> + *
>> + * This is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU Lesser General Public License as
>> + * published by the Free Software Foundation; either version 2.1 of
>> + * the License, or (at your option) any later version.
>> + *
>> + * This software is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this software; if not, write to the Free
>> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> + */
>> +package org.xwiki.observation.event;
>> +
>> +import java.util.Collections;
>> +import java.util.List;
>> +
>> +import junit.framework.Assert;
>> +
>> +import org.junit.Before;
>> +import org.junit.Test;
>> +import org.xwiki.bridge.event.DocumentCreatedEvent;
>> +import org.xwiki.bridge.event.DocumentDeletedEvent;
>> +import org.xwiki.bridge.event.DocumentUpdatedEvent;
>> +import org.xwiki.model.reference.DocumentReference;
>> +import org.xwiki.observation.EventListener;
>> +import org.xwiki.observation.ObservationManager;
>> +import org.xwiki.observation.event.DocumentDeleteEvent;
>> +import org.xwiki.observation.event.DocumentSaveEvent;
>> +import org.xwiki.observation.event.DocumentUpdateEvent;
>> +import org.xwiki.observation.event.Event;
>> +import org.xwiki.observation.event.filter.EventFilter;
>> +import org.xwiki.observation.event.filter.FixedNameEventFilter;
>> +import org.xwiki.test.AbstractComponentTestCase;
>> +
>> +public class LegacyEventDispatcherTest extends AbstractComponentTestCase
>> +{
>> + Â Â private Event receivedEvent;
>> +
>> + Â Â private ObservationManager om;
>> +
>> + Â Â @Before
>> + Â Â public void setUp() throws Exception
>> + Â Â {
>> + Â Â Â Â this.om = getComponentManager().lookup(ObservationManager.class);
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
>> + Â Â {
>> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
>> + Â Â Â Â this.om.notify(new DocumentDeletedEvent(new DocumentReference("wiki", "space", "name")), new Object());
>> +
>> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> + Â Â Â Â // once all matching event listeners have been notified.
>> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
>> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
>> + Â Â {
>> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
>> + Â Â Â Â this.om.notify(new DocumentCreatedEvent(new DocumentReference("wiki", "space", "name")), new Object());
>> +
>> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> + Â Â Â Â // once all matching event listeners have been notified.
>> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
>> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
>> + Â Â }
>> +
>> + Â Â @Test
>> + Â Â public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
>> + Â Â {
>> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
>> + Â Â Â Â this.om.notify(new DocumentUpdatedEvent(new DocumentReference("wiki", "space", "name")), new Object());
>> +
>> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
>> + Â Â Â Â // once all matching event listeners have been notified.
>> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
>> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
>> + Â Â }
>> +
>> + Â Â private void registerListenerWithLegacyEvent(final Event event)
>> + Â Â {
>> + Â Â Â Â this.om.addListener(new EventListener()
>> + Â Â Â Â {
>> + Â Â Â Â Â Â public String getName()
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â return "testLegacyEventDispatchEventListener";
>> + Â Â Â Â Â Â }
>> +
>> + Â Â Â Â Â Â public List<Event> getEvents()
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â return Collections.<Event> singletonList(event);
>> + Â Â Â Â Â Â }
>> +
>> + Â Â Â Â Â Â public void onEvent(Event event, Object source, Object data)
>> + Â Â Â Â Â Â {
>> + Â Â Â Â Â Â Â Â receivedEvent = event;
>> + Â Â Â Â Â Â }
>> + Â Â Â Â });
>> + Â Â }
>> +}
>>
>>
>> Property changes on: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
>> ___________________________________________________________________
>> Added: svn:keywords
>> Â + Id
>>
>> Deleted: platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
>> ===================================================================
>> --- platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
>> +++ platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
>> @@ -1,68 +0,0 @@
>> -/*
>> - * See the NOTICE file distributed with this work for additional
>> - * information regarding copyright ownership.
>> - *
>> - * This is free software; you can redistribute it and/or modify it
>> - * under the terms of the GNU Lesser General Public License as
>> - * published by the Free Software Foundation; either version 2.1 of
>> - * the License, or (at your option) any later version.
>> - *
>> - * This software is distributed in the hope that it will be useful,
>> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> - * Lesser General Public License for more details.
>> - *
>> - * You should have received a copy of the GNU Lesser General Public
>> - * License along with this software; if not, write to the Free
>> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
>> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
>> - */
>> -package org.xwiki.model.event;
>> -
>> -import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
>> -import org.xwiki.model.reference.DocumentReference;
>> -import org.xwiki.observation.event.AbstractFilterableEvent;
>> -import org.xwiki.observation.event.Event;
>> -import org.xwiki.observation.event.filter.EventFilter;
>> -
>> -/**
>> - * Base class for all document {@link Event events}.
>> - *
>> - * @version $Id$
>> - */
>> -public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
>> -{
>> - Â Â /**
>> - Â Â * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
>> - Â Â * changes.
>> - Â Â */
>> - Â Â private static final long serialVersionUID = 1L;
>> -
>> - Â Â /**
>> - Â Â * This event will match any other document event of the same type.
>> - Â Â */
>> - Â Â public AbstractDocumentEvent()
>> - Â Â {
>> - Â Â Â Â super();
>> - Â Â }
>> -
>> - Â Â /**
>> - Â Â * This event will match only events of the same type affecting the same document.
>> - Â Â *
>> - Â Â * @param documentReference the reference of the document relater to this event
>> - Â Â */
>> - Â Â public AbstractDocumentEvent(DocumentReference documentReference)
>> - Â Â {
>> - Â Â Â Â super(new DefaultStringEntityReferenceSerializer().serialize(documentReference));
>> - Â Â }
>> -
>> - Â Â /**
>> - Â Â * Constructor using a custom {@link EventFilter}.
>> - Â Â *
>> - Â Â * @param eventFilter the filter to use for matching events
>> - Â Â */
>> - Â Â public AbstractDocumentEvent(EventFilter eventFilter)
>> - Â Â {
>> - Â Â Â Â super(eventFilter);
>> - Â Â }
>> -}
>> \ No newline at end of file
>>
>> _______________________________________________
>> notifications mailing list
>> notifications(a)xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/notifications
>>
> _______________________________________________
> devs mailing list
> devs(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
--
Thomas Mortagne
Thanks...
I think you've forgot to update other events that rely on
AbstractDocumentEvent. if I remember well there is one in
xwiki-annotations-core, and maybe some in xwiki-core too.
On Tue, Dec 14, 2010 at 3:01 PM, tmortagne
<platform-notifications(a)xwiki.org> wrote:
> Author: tmortagne
> Date: 2010-12-14 15:01:28 +0100 (Tue, 14 Dec 2010)
> New Revision: 33376
>
> Added:
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/
> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/internal/
> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
> Removed:
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
> Â platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
> Â platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
> Modified:
> Â platform/core/trunk/xwiki-bridge/pom.xml
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
> Â platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
> Â platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
> Â platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
> Log:
> XWIKI-5786: Deprecate Document(Save|Update|Delete)Event and add new Document(Created|Updated|Deleted)Event in xwiki-bridge instead
> Â Â * LegacyEventDispatcher loses document name
> Â Â * LegacyEventDispatcher should be in an internal package
> Â Â * AbstractDocumentEvent has nothing to do in xwiki-model
>
> Modified: platform/core/trunk/xwiki-bridge/pom.xml
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/pom.xml   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/pom.xml   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -56,13 +56,6 @@
> Â Â Â Â <!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
> Â Â Â Â <groupId>org.apache.maven.plugins</groupId>
> Â Â Â Â <artifactId>maven-checkstyle-plugin</artifactId>
> - Â Â Â Â <dependencies>
> - Â Â Â Â Â <dependency>
> - Â Â Â Â Â Â <groupId>org.xwiki.platform.tools</groupId>
> - Â Â Â Â Â Â <artifactId>xwiki-verification-resources</artifactId>
> - Â Â Â Â Â Â <version>${platform.tool.verification.version}</version>
> - Â Â Â Â Â </dependency>
> - Â Â Â Â </dependencies>
> Â Â Â </plugin>
> Â Â Â <plugin>
> Â Â Â Â <groupId>org.codehaus.mojo</groupId>
>
> Copied: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java (from rev 33375, platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java)
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java               (rev 0)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -0,0 +1,74 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package org.xwiki.bridge.event;
> +
> +import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
> +import org.xwiki.model.reference.DocumentReference;
> +import org.xwiki.observation.event.AbstractFilterableEvent;
> +import org.xwiki.observation.event.filter.EventFilter;
> +
> +/**
> + * Base class for all document related {@link org.xwiki.observation.event.Event}.
> + *
> + * @version $Id$
> + * @since 2.7RC1
> + */
> +public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
> +{
> + Â Â /**
> + Â Â * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
> + Â Â * changes.
> + Â Â */
> + Â Â private static final long serialVersionUID = 1L;
> +
> + Â Â /**
> + Â Â * Used to serialize document name.
> + Â Â */
> + Â Â private static final DefaultStringEntityReferenceSerializer SERIALIZER =
> + Â Â Â Â new DefaultStringEntityReferenceSerializer();
> +
> + Â Â /**
> + Â Â * This event will match any other document event of the same type.
> + Â Â */
> + Â Â public AbstractDocumentEvent()
> + Â Â {
> + Â Â Â Â super();
> + Â Â }
> +
> + Â Â /**
> + Â Â * This event will match only events of the same type affecting the same document.
> + Â Â *
> + Â Â * @param documentReference the reference of the document relater to this event
> + Â Â */
> + Â Â public AbstractDocumentEvent(DocumentReference documentReference)
> + Â Â {
> + Â Â Â Â super(SERIALIZER.serialize(documentReference));
> + Â Â }
> +
> + Â Â /**
> + Â Â * Constructor using a custom {@link EventFilter}.
> + Â Â *
> + Â Â * @param eventFilter the filter to use for matching events
> + Â Â */
> + Â Â public AbstractDocumentEvent(EventFilter eventFilter)
> + Â Â {
> + Â Â Â Â super(eventFilter);
> + Â Â }
> +}
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered after a document is created.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentCreatedEvent extends AbstractDocumentEvent
> Â {
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered before a document is created.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentCreatingEvent extends AbstractDocumentEvent
> Â {
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered after a document is deleted.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentDeletedEvent extends AbstractDocumentEvent
> Â {
> @@ -43,7 +43,7 @@
> Â Â Â */
> Â Â public DocumentDeletedEvent()
> Â Â {
> - Â Â Â Â super();
> +
> Â Â }
>
> Â Â /**
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered before a document is deleted.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentDeletingEvent extends AbstractDocumentEvent
> Â {
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered after a document is updated.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentUpdatedEvent extends AbstractDocumentEvent
> Â {
>
> Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,13 +20,13 @@
> Â package org.xwiki.bridge.event;
>
> Â import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
>
> Â /**
> Â * An event triggered before a document is updated.
> Â *
> Â * @version $Id$
> + * @since 2.7RC1
> Â */
> Â public class DocumentUpdatingEvent extends AbstractDocumentEvent
> Â {
> @@ -35,7 +35,7 @@
> Â Â Â * changes.
> Â Â Â */
> Â Â private static final long serialVersionUID = 1L;
> -
> +
> Â Â /**
> Â Â Â * Constructor initializing the event filter with an
> Â Â Â * {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that this event will match any
>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -24,6 +24,7 @@
> Â import java.util.HashSet;
> Â import java.util.List;
>
> +import org.xwiki.bridge.event.AbstractDocumentEvent;
> Â import org.xwiki.bridge.event.DocumentCreatedEvent;
> Â import org.xwiki.bridge.event.DocumentDeletedEvent;
> Â import org.xwiki.bridge.event.DocumentUpdatedEvent;
> @@ -39,7 +40,6 @@
> Â import org.xwiki.model.reference.EntityReferenceSerializer;
> Â import org.xwiki.observation.EventListener;
> Â import org.xwiki.observation.ObservationManager;
> -import org.xwiki.model.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.Event;
>
> Â /**
>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,7 +20,7 @@
> Â */
> Â package com.xpn.xwiki.internal.event;
>
> -import org.xwiki.model.event.AbstractDocumentEvent;
> +import org.xwiki.bridge.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
> Â import org.xwiki.observation.event.filter.FixedNameEventFilter;
>
>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -20,7 +20,7 @@
> Â */
> Â package com.xpn.xwiki.internal.event;
>
> -import org.xwiki.model.event.AbstractDocumentEvent;
> +import org.xwiki.bridge.event.AbstractDocumentEvent;
> Â import org.xwiki.observation.event.filter.EventFilter;
> Â import org.xwiki.observation.event.filter.FixedNameEventFilter;
>
>
> Copied: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java (from rev 33375, platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java)
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java             (rev 0)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -0,0 +1,120 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + *
> + */
> +package org.xwiki.legacy.internal;
> +
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +import org.xwiki.bridge.event.DocumentCreatedEvent;
> +import org.xwiki.bridge.event.DocumentDeletedEvent;
> +import org.xwiki.bridge.event.DocumentUpdatedEvent;
> +import org.xwiki.component.annotation.Component;
> +import org.xwiki.component.annotation.Requirement;
> +import org.xwiki.component.logging.AbstractLogEnabled;
> +import org.xwiki.component.manager.ComponentLookupException;
> +import org.xwiki.component.manager.ComponentManager;
> +import org.xwiki.observation.EventListener;
> +import org.xwiki.observation.ObservationManager;
> +import org.xwiki.observation.event.DocumentDeleteEvent;
> +import org.xwiki.observation.event.DocumentSaveEvent;
> +import org.xwiki.observation.event.DocumentUpdateEvent;
> +import org.xwiki.observation.event.Event;
> +
> +/**
> + * An event listener that forwards received events to their corresponding legacy events. This allows depreciated events
> + * to continue be supported.
> + *
> + * @version $Id$
> + */
> +@Component("legacyEventDispatcher")
> +public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
> +{
> + Â Â /**
> + Â Â * Component manager, used to get access to the observation manager that we cannot get injected because of a cyclic
> + Â Â * dependency.
> + Â Â */
> + Â Â @Requirement
> + Â Â private ComponentManager componentManager;
> +
> + Â Â /**
> + Â Â * Observation manager, used to notify legacy events.
> + Â Â */
> + Â Â private ObservationManager observationManager;
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â */
> + Â Â public String getName()
> + Â Â {
> + Â Â Â Â return "legacyEventDispatcher";
> + Â Â }
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â */
> + Â Â public List<Event> getEvents()
> + Â Â {
> + Â Â Â Â return new ArrayList<Event>()
> + Â Â Â Â {
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â add(new DocumentDeletedEvent());
> + Â Â Â Â Â Â Â Â add(new DocumentCreatedEvent());
> + Â Â Â Â Â Â Â Â add(new DocumentUpdatedEvent());
> + Â Â Â Â Â Â }
> + Â Â Â Â };
> + Â Â }
> +
> + Â Â /**
> + Â Â * {@inheritDoc}
> + Â Â */
> + Â Â public void onEvent(Event event, Object source, Object data)
> + Â Â {
> + Â Â Â Â if (event instanceof DocumentDeletedEvent) {
> + Â Â Â Â Â Â this.getObservationManager().notify(
> + Â Â Â Â Â Â Â Â new DocumentDeleteEvent(((DocumentDeletedEvent) event).getEventFilter()), source, data);
> + Â Â Â Â } else if (event instanceof DocumentCreatedEvent) {
> + Â Â Â Â Â Â this.getObservationManager().notify(new DocumentSaveEvent(((DocumentCreatedEvent) event).getEventFilter()),
> + Â Â Â Â Â Â Â Â source, data);
> + Â Â Â Â } else if (event instanceof DocumentUpdatedEvent) {
> + Â Â Â Â Â Â this.getObservationManager().notify(
> + Â Â Â Â Â Â Â Â new DocumentUpdateEvent(((DocumentUpdatedEvent) event).getEventFilter()), source, data);
> + Â Â Â Â }
> + Â Â }
> +
> + Â Â /**
> + Â Â * Helper to lazily lookup the observation manager.
> + Â Â *
> + Â Â * @return the observation manager
> + Â Â */
> + Â Â private ObservationManager getObservationManager()
> + Â Â {
> + Â Â Â Â if (this.observationManager != null) {
> + Â Â Â Â Â Â return this.observationManager;
> + Â Â Â Â }
> + Â Â Â Â try {
> + Â Â Â Â Â Â this.observationManager = this.componentManager.lookup(ObservationManager.class);
> + Â Â Â Â } catch (ComponentLookupException e) {
> + Â Â Â Â Â Â this.getLogger().error("Failed to lookup observation manager", e);
> + Â Â Â Â }
> + Â Â Â Â return this.observationManager;
> + Â Â }
> +
> +}
>
> Deleted: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java   2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java   2010-12-14 14:01:28 UTC (rev 33376)
> @@ -1,115 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - *
> - */
> -package org.xwiki.observation;
> -
> -import java.util.ArrayList;
> -import java.util.List;
> -
> -import org.xwiki.bridge.event.DocumentCreatedEvent;
> -import org.xwiki.bridge.event.DocumentDeletedEvent;
> -import org.xwiki.bridge.event.DocumentUpdatedEvent;
> -import org.xwiki.component.annotation.Component;
> -import org.xwiki.component.annotation.Requirement;
> -import org.xwiki.component.logging.AbstractLogEnabled;
> -import org.xwiki.component.manager.ComponentLookupException;
> -import org.xwiki.component.manager.ComponentManager;
> -import org.xwiki.observation.event.DocumentDeleteEvent;
> -import org.xwiki.observation.event.DocumentSaveEvent;
> -import org.xwiki.observation.event.DocumentUpdateEvent;
> -import org.xwiki.observation.event.Event;
> -
> -/**
> - * An event listener that forwards received events to their corresponding legacy events. This allows depreciated events
> - * to continue be supported.
> - *
> - * @version $Id$
> - */
> -@Component("legacyEventDispatcher")
> -public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
> -{
> - Â Â /**
> - Â Â * Component manager, used to get access to the observation manager that we cannot get injected because of a cyclic
> - Â Â * dependency.
> - Â Â */
> - Â Â @Requirement
> - Â Â private ComponentManager componentManager;
> -
> - Â Â /**
> - Â Â * Observation manager, used to notify legacy events.
> - Â Â */
> - Â Â private ObservationManager observationManager;
> -
> - Â Â /**
> - Â Â * {@inheritDoc}
> - Â Â */
> - Â Â public String getName()
> - Â Â {
> - Â Â Â Â return "legacyEventDispatcher";
> - Â Â }
> -
> - Â Â /**
> - Â Â * {@inheritDoc}
> - Â Â */
> - Â Â public List<Event> getEvents()
> - Â Â {
> - Â Â Â Â return new ArrayList<Event>()
> - Â Â Â Â {
> - Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â add(new DocumentDeletedEvent());
> - Â Â Â Â Â Â Â Â add(new DocumentCreatedEvent());
> - Â Â Â Â Â Â Â Â add(new DocumentUpdatedEvent());
> - Â Â Â Â Â Â }
> - Â Â Â Â };
> - Â Â }
> -
> - Â Â /**
> - Â Â * {@inheritDoc}
> - Â Â */
> - Â Â public void onEvent(Event event, Object source, Object data)
> - Â Â {
> - Â Â Â Â if (event instanceof DocumentDeletedEvent) {
> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentDeleteEvent(), source, data);
> - Â Â Â Â } else if (event instanceof DocumentCreatedEvent) {
> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentSaveEvent(), source, data);
> - Â Â Â Â } else if (event instanceof DocumentUpdatedEvent) {
> - Â Â Â Â Â Â this.getObservationManager().notify(new DocumentUpdateEvent(), source, data);
> - Â Â Â Â }
> - Â Â }
> -
> - Â Â /**
> - Â Â * Helper to lazily lookup the observation manager.
> - Â Â *
> - Â Â * @return the observation manager
> - Â Â */
> - Â Â private ObservationManager getObservationManager()
> - Â Â {
> - Â Â Â Â if (this.observationManager != null) {
> - Â Â Â Â Â Â return this.observationManager;
> - Â Â Â Â }
> - Â Â Â Â try {
> - Â Â Â Â Â Â this.observationManager = this.componentManager.lookup(ObservationManager.class);
> - Â Â Â Â } catch (ComponentLookupException e) {
> - Â Â Â Â Â Â this.getLogger().error("Failed to lookup observation manager", e);
> - Â Â Â Â }
> - Â Â Â Â return this.observationManager;
> - Â Â }
> -
> -}
>
> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
> @@ -27,7 +27,9 @@
> Â * Base class for all document {@link Event events}.
> Â *
> Â * @version $Id$
> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.AbstractDocumentEvent} instead
> Â */
> +@Deprecated
> Â public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
> Â {
> Â Â /**
> @@ -41,7 +43,7 @@
> Â Â Â */
> Â Â public AbstractDocumentEvent()
> Â Â {
> - Â Â Â Â super();
> + Â Â Â Â super();
> Â Â }
>
> Â Â /**
>
> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -26,7 +26,7 @@
> Â * An event triggered when a document is deleted.
> Â *
> Â * @version $Id$
> - * @deprecated use {@link org.xwiki.bridge.event.DocumentDeletedEvent} instead
> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentDeletedEvent} instead
> Â */
> Â @Deprecated
> Â public class DocumentDeleteEvent extends AbstractDocumentEvent
>
> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java  2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java  2010-12-14 14:01:28 UTC (rev 33376)
> @@ -26,7 +26,7 @@
> Â * An event triggered when a document is saved for the first time (a new document is created).
> Â *
> Â * @version $Id$
> - * @deprecated use {@link org.xwiki.bridge.event.DocumentCreatedEvent} instead
> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentCreatedEvent} instead
> Â */
> Â @Deprecated
> Â public class DocumentSaveEvent extends AbstractDocumentEvent
>
> Modified: platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -26,7 +26,7 @@
> Â * An event triggered when an existing document is saved (updated).
> Â *
> Â * @version $Id$
> - * @deprecated use {@link org.xwiki.bridge.event.DocumentUpdatedEvent} instead
> + * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentUpdatedEvent} instead
> Â */
> Â @Deprecated
> Â public class DocumentUpdateEvent extends AbstractDocumentEvent
>
> Modified: platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -1 +1 @@
> -org.xwiki.observation.LegacyEventDispatcher
> +org.xwiki.legacy.internal.LegacyEventDispatcher
>
> Deleted: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java 2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java 2010-12-14 14:01:28 UTC (rev 33376)
> @@ -1,108 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package org.xwiki.observation;
> -
> -import java.util.Collections;
> -import java.util.List;
> -
> -import junit.framework.Assert;
> -
> -import org.junit.Before;
> -import org.junit.Test;
> -import org.xwiki.bridge.event.DocumentCreatedEvent;
> -import org.xwiki.bridge.event.DocumentDeletedEvent;
> -import org.xwiki.bridge.event.DocumentUpdatedEvent;
> -import org.xwiki.observation.event.DocumentDeleteEvent;
> -import org.xwiki.observation.event.DocumentSaveEvent;
> -import org.xwiki.observation.event.DocumentUpdateEvent;
> -import org.xwiki.observation.event.Event;
> -import org.xwiki.test.AbstractComponentTestCase;
> -
> -public class LegacyEventDispatcherTest extends AbstractComponentTestCase
> -{
> -
> - Â Â private boolean hasBeenNotified;
> -
> - Â Â private ObservationManager om;
> -
> - Â Â @Before
> - Â Â public void setUp() throws Exception
> - Â Â {
> - Â Â Â Â this.hasBeenNotified = false;
> - Â Â Â Â this.om = this.getComponentManager().lookup(ObservationManager.class);
> - Â Â }
> -
> - Â Â @Test
> - Â Â public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
> - Â Â {
> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
> - Â Â Â Â om.notify(new DocumentDeletedEvent(), new Object());
> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> - Â Â Â Â // once all matching event listeners have been notified.
> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
> - Â Â }
> -
> - Â Â @Test
> - Â Â public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
> - Â Â {
> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
> - Â Â Â Â om.notify(new DocumentCreatedEvent(), new Object());
> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> - Â Â Â Â // once all matching event listeners have been notified.
> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
> - Â Â }
> -
> - Â Â @Test
> - Â Â public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
> - Â Â {
> - Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
> - Â Â Â Â om.notify(new DocumentUpdatedEvent(), new Object());
> - Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> - Â Â Â Â // once all matching event listeners have been notified.
> - Â Â Â Â Assert.assertTrue("Should have been notified by legacy event dispatcher", this.hasBeenNotified);
> - Â Â }
> -
> - Â Â private void registerListenerWithLegacyEvent(final Event event)
> - Â Â {
> - Â Â Â Â this.om.addListener(new EventListener()
> - Â Â Â Â {
> - Â Â Â Â Â Â public String getName()
> - Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â return "testLegacyEventDispatchEventListener";
> - Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â public List<Event> getEvents()
> - Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â return Collections.<Event> singletonList(event);
> - Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â public void onEvent(Event event, Object source, Object data)
> - Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â setNotified();
> - Â Â Â Â Â Â }
> -
> - Â Â Â Â });
> - Â Â }
> -
> - Â Â private void setNotified()
> - Â Â {
> - Â Â Â Â this.hasBeenNotified = true;
> - Â Â }
> -}
>
> Copied: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java (from rev 33375, platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java)
> ===================================================================
> --- platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java              (rev 0)
> +++ platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java  2010-12-14 14:01:28 UTC (rev 33376)
> @@ -0,0 +1,111 @@
> +/*
> + * See the NOTICE file distributed with this work for additional
> + * information regarding copyright ownership.
> + *
> + * This is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License as
> + * published by the Free Software Foundation; either version 2.1 of
> + * the License, or (at your option) any later version.
> + *
> + * This software is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this software; if not, write to the Free
> + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> + */
> +package org.xwiki.observation.event;
> +
> +import java.util.Collections;
> +import java.util.List;
> +
> +import junit.framework.Assert;
> +
> +import org.junit.Before;
> +import org.junit.Test;
> +import org.xwiki.bridge.event.DocumentCreatedEvent;
> +import org.xwiki.bridge.event.DocumentDeletedEvent;
> +import org.xwiki.bridge.event.DocumentUpdatedEvent;
> +import org.xwiki.model.reference.DocumentReference;
> +import org.xwiki.observation.EventListener;
> +import org.xwiki.observation.ObservationManager;
> +import org.xwiki.observation.event.DocumentDeleteEvent;
> +import org.xwiki.observation.event.DocumentSaveEvent;
> +import org.xwiki.observation.event.DocumentUpdateEvent;
> +import org.xwiki.observation.event.Event;
> +import org.xwiki.observation.event.filter.EventFilter;
> +import org.xwiki.observation.event.filter.FixedNameEventFilter;
> +import org.xwiki.test.AbstractComponentTestCase;
> +
> +public class LegacyEventDispatcherTest extends AbstractComponentTestCase
> +{
> + Â Â private Event receivedEvent;
> +
> + Â Â private ObservationManager om;
> +
> + Â Â @Before
> + Â Â public void setUp() throws Exception
> + Â Â {
> + Â Â Â Â this.om = getComponentManager().lookup(ObservationManager.class);
> + Â Â }
> +
> + Â Â @Test
> + Â Â public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
> + Â Â {
> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
> + Â Â Â Â this.om.notify(new DocumentDeletedEvent(new DocumentReference("wiki", "space", "name")), new Object());
> +
> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> + Â Â Â Â // once all matching event listeners have been notified.
> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
> + Â Â }
> +
> + Â Â @Test
> + Â Â public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
> + Â Â {
> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
> + Â Â Â Â this.om.notify(new DocumentCreatedEvent(new DocumentReference("wiki", "space", "name")), new Object());
> +
> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> + Â Â Â Â // once all matching event listeners have been notified.
> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
> + Â Â }
> +
> + Â Â @Test
> + Â Â public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
> + Â Â {
> + Â Â Â Â this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
> + Â Â Â Â this.om.notify(new DocumentUpdatedEvent(new DocumentReference("wiki", "space", "name")), new Object());
> +
> + Â Â Â Â // The notification is synchronous, so the following assertion will only be tested
> + Â Â Â Â // once all matching event listeners have been notified.
> + Â Â Â Â Assert.assertNotNull("Should have been notified by legacy event dispatcher", this.receivedEvent);
> + Â Â Â Â Assert.assertEquals("Wrong event filter", "wiki:space.name", ((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
> + Â Â }
> +
> + Â Â private void registerListenerWithLegacyEvent(final Event event)
> + Â Â {
> + Â Â Â Â this.om.addListener(new EventListener()
> + Â Â Â Â {
> + Â Â Â Â Â Â public String getName()
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â return "testLegacyEventDispatchEventListener";
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â public List<Event> getEvents()
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â return Collections.<Event> singletonList(event);
> + Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â public void onEvent(Event event, Object source, Object data)
> + Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â receivedEvent = event;
> + Â Â Â Â Â Â }
> + Â Â Â Â });
> + Â Â }
> +}
>
>
> Property changes on: platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
> ___________________________________________________________________
> Added: svn:keywords
> Â + Id
>
> Deleted: platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
> ===================================================================
> --- platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java    2010-12-14 09:19:33 UTC (rev 33375)
> +++ platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java    2010-12-14 14:01:28 UTC (rev 33376)
> @@ -1,68 +0,0 @@
> -/*
> - * See the NOTICE file distributed with this work for additional
> - * information regarding copyright ownership.
> - *
> - * This is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU Lesser General Public License as
> - * published by the Free Software Foundation; either version 2.1 of
> - * the License, or (at your option) any later version.
> - *
> - * This software is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with this software; if not, write to the Free
> - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
> - * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
> - */
> -package org.xwiki.model.event;
> -
> -import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
> -import org.xwiki.model.reference.DocumentReference;
> -import org.xwiki.observation.event.AbstractFilterableEvent;
> -import org.xwiki.observation.event.Event;
> -import org.xwiki.observation.event.filter.EventFilter;
> -
> -/**
> - * Base class for all document {@link Event events}.
> - *
> - * @version $Id$
> - */
> -public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
> -{
> - Â Â /**
> - Â Â * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class
> - Â Â * changes.
> - Â Â */
> - Â Â private static final long serialVersionUID = 1L;
> -
> - Â Â /**
> - Â Â * This event will match any other document event of the same type.
> - Â Â */
> - Â Â public AbstractDocumentEvent()
> - Â Â {
> - Â Â Â Â super();
> - Â Â }
> -
> - Â Â /**
> - Â Â * This event will match only events of the same type affecting the same document.
> - Â Â *
> - Â Â * @param documentReference the reference of the document relater to this event
> - Â Â */
> - Â Â public AbstractDocumentEvent(DocumentReference documentReference)
> - Â Â {
> - Â Â Â Â super(new DefaultStringEntityReferenceSerializer().serialize(documentReference));
> - Â Â }
> -
> - Â Â /**
> - Â Â * Constructor using a custom {@link EventFilter}.
> - Â Â *
> - Â Â * @param eventFilter the filter to use for matching events
> - Â Â */
> - Â Â public AbstractDocumentEvent(EventFilter eventFilter)
> - Â Â {
> - Â Â Â Â super(eventFilter);
> - Â Â }
> -}
> \ No newline at end of file
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
>