Skip to content

Commit b7580ae

Browse files
authored
Merge branch 'xwiki:master' into XWIKI-19383
2 parents 018f639 + 405df65 commit b7580ae

File tree

124 files changed

+1769
-1493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+1769
-1493
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ bin
5050
# NetBeans
5151
nbproject
5252

53+
# Visual Studio Code
54+
.vscode
55+
5356
# Gradle Enterprise
5457
.mvn/.gradle-enterprise
5558

.mvn/extensions.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
<extension>
2525
<groupId>com.gradle</groupId>
2626
<artifactId>gradle-enterprise-maven-extension</artifactId>
27-
<version>1.16.5</version>
27+
<version>1.18.1</version>
2828
</extension>
2929
<extension>
3030
<groupId>com.gradle</groupId>
3131
<artifactId>common-custom-user-data-maven-extension</artifactId>
32-
<version>1.11.1</version>
32+
<version>1.12.2</version>
3333
</extension>
3434
</extensions>

pom.xml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
<parent>
2424
<groupId>org.xwiki.commons</groupId>
2525
<artifactId>xwiki-commons-pom</artifactId>
26-
<version>15.3-SNAPSHOT</version>
26+
<version>15.7-SNAPSHOT</version>
2727
<!-- Note: Do not modify the <relativePath> tag here as this can cause issues. See the pom.xml for xwiki-platform
2828
for more details. By using an empty value we force Maven to resolve the parent from the Maven repositories,
2929
see http://maven.apache.org/ref/3.2.3/maven-model/maven.html#class_parent -->
3030
<relativePath/>
3131
</parent>
3232
<groupId>org.xwiki.rendering</groupId>
3333
<artifactId>xwiki-rendering</artifactId>
34-
<version>15.3-SNAPSHOT</version>
34+
<version>15.7-SNAPSHOT</version>
3535
<name>XWiki Rendering - Parent POM</name>
3636
<packaging>pom</packaging>
3737
<description>XWiki Rendering - Parent POM</description>
@@ -143,25 +143,29 @@
143143
<groupId>com.mycila</groupId>
144144
<artifactId>license-maven-plugin</artifactId>
145145
<configuration>
146-
<excludes>
147-
<!-- Unfortunately we need to copy some excludes from the top level POM since Maven or the License plugin
148-
don't merge excludes apparently... -->
149-
<exclude>**/components.txt</exclude>
150-
<exclude>**/goal.txt</exclude>
151-
<exclude>**/it/**/goals.txt</exclude>
152-
<!-- Exclude Rendering Test Data files -->
153-
<exclude>**/*.test</exclude>
154-
<exclude>**/*.in.*txt</exclude>
155-
<exclude>**/*.out.txt</exclude>
156-
<exclude>**/*.inout.txt</exclude>
157-
<exclude>**/*.in.*xml</exclude>
158-
<exclude>**/*.out.xml</exclude>
159-
<exclude>**/*.inout.xml</exclude>
160-
<!-- Exclude Rendering Test framework test data file -->
161-
<exclude>**/ctstest/type/test/test1.inout.xml</exclude>
162-
<!-- l10n doesn't put the license header on the generated translation files. -->
163-
<exclude>**/ApplicationResources_*.properties</exclude>
164-
</excludes>
146+
<licenseSets>
147+
<licenseSet>
148+
<excludes>
149+
<!-- Unfortunately we need to copy some excludes from the top level POM since Maven or the License
150+
plugin don't merge excludes apparently... -->
151+
<exclude>**/components.txt</exclude>
152+
<exclude>**/goal.txt</exclude>
153+
<exclude>**/it/**/goals.txt</exclude>
154+
<!-- Exclude Rendering Test Data files -->
155+
<exclude>**/*.test</exclude>
156+
<exclude>**/*.in.*txt</exclude>
157+
<exclude>**/*.out.txt</exclude>
158+
<exclude>**/*.inout.txt</exclude>
159+
<exclude>**/*.in.*xml</exclude>
160+
<exclude>**/*.out.xml</exclude>
161+
<exclude>**/*.inout.xml</exclude>
162+
<!-- Exclude Rendering Test framework test data file -->
163+
<exclude>**/ctstest/type/test/test1.inout.xml</exclude>
164+
<!-- l10n doesn't put the license header on the generated translation files. -->
165+
<exclude>**/ApplicationResources_*.properties</exclude>
166+
</excludes>
167+
</licenseSet>
168+
</licenseSets>
165169
</configuration>
166170
</plugin>
167171
<plugin>

xwiki-rendering-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
<parent>
2626
<groupId>org.xwiki.rendering</groupId>
2727
<artifactId>xwiki-rendering</artifactId>
28-
<version>15.3-SNAPSHOT</version>
28+
<version>15.7-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>xwiki-rendering-api</artifactId>
3131
<name>XWiki Rendering - Api</name>
3232
<packaging>jar</packaging>
3333
<description>XWiki Rendering - Api</description>
3434
<properties>
35-
<xwiki.jacoco.instructionRatio>0.62</xwiki.jacoco.instructionRatio>
35+
<xwiki.jacoco.instructionRatio>0.63</xwiki.jacoco.instructionRatio>
3636
<!-- Skipping revapi since xwiki-rendering-legacy-api wraps this module and runs checks on it -->
3737
<xwiki.revapi.skip>true</xwiki.revapi.skip>
3838
</properties>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.rendering.internal.listener;
21+
22+
import java.util.List;
23+
import java.util.stream.Collectors;
24+
25+
import javax.inject.Inject;
26+
import javax.inject.Named;
27+
import javax.inject.Provider;
28+
import javax.inject.Singleton;
29+
30+
import org.slf4j.Logger;
31+
import org.xwiki.component.annotation.Component;
32+
import org.xwiki.component.manager.ComponentLookupException;
33+
import org.xwiki.component.manager.ComponentManager;
34+
import org.xwiki.rendering.listener.ListenerProvider;
35+
import org.xwiki.rendering.listener.chaining.ChainingListener;
36+
import org.xwiki.rendering.listener.chaining.ListenerChain;
37+
import org.xwiki.rendering.syntax.Syntax;
38+
39+
import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage;
40+
41+
/**
42+
* Returns a list of {@link ChainingListener} provided by {@link ListenerProvider}.
43+
*
44+
* @version $Id$
45+
* @since 15.3RC1
46+
* @since 14.10.8
47+
*/
48+
@Component(roles = ListenerRegistry.class)
49+
@Singleton
50+
public class ListenerRegistry
51+
{
52+
@Inject
53+
@Named("context")
54+
private Provider<ComponentManager> componentManagerProvider;
55+
56+
@Inject
57+
private Logger logger;
58+
59+
/**
60+
* Return a list of {@link ChainingListener} provided by {@link ListenerProvider}.
61+
*
62+
* @param listenerChain the listener chain in which new listener will be added
63+
* @param action the action performed by the caller ({@link ListenerProvider#PARSE_ACTION} or
64+
* {@link ListenerProvider#RENDER_ACTION})
65+
* @param syntax the syntax of the action (e.g., {@link Syntax#XWIKI_2_1})
66+
* @return the initialized list of {@link ChainingListener}
67+
*/
68+
public List<ChainingListener> getListeners(ListenerChain listenerChain, String action, Syntax syntax)
69+
{
70+
try {
71+
return this.componentManagerProvider.get()
72+
.<ListenerProvider>getInstanceList(ListenerProvider.class)
73+
.stream()
74+
.filter(listenerProvider -> listenerProvider.accept(action, syntax))
75+
.map(listenerProvider -> listenerProvider.getListener(listenerChain))
76+
.collect(Collectors.toList());
77+
} catch (ComponentLookupException e) {
78+
this.logger.warn("Failed to load the list of [{}] for action [{}] and syntax [{}]. Cause [{}].",
79+
ListenerProvider.class, action, syntax, getRootCauseMessage(e));
80+
return List.of();
81+
}
82+
}
83+
}

xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/AbstractResourceReferenceParser.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import javax.inject.Named;
2424
import javax.inject.Provider;
2525

26-
import org.xwiki.component.manager.ComponentLookupException;
2726
import org.xwiki.component.manager.ComponentManager;
2827
import org.xwiki.rendering.parser.ResourceReferenceParser;
2928
import org.xwiki.rendering.wiki.WikiModel;
@@ -36,27 +35,23 @@
3635
*/
3736
public abstract class AbstractResourceReferenceParser implements ResourceReferenceParser
3837
{
38+
@Inject
39+
@Named("context")
40+
protected Provider<ComponentManager> componentManagerProvider;
41+
3942
/**
4043
* Used to verify if we're in wiki mode or not by looking up an implementation of
4144
* {@link org.xwiki.rendering.wiki.WikiModel}.
4245
*/
4346
@Inject
44-
@Named("context")
45-
protected Provider<ComponentManager> componentManagerProvider;
47+
protected Provider<WikiModel> wikiModelProvider;
4648

4749
/**
4850
* @return true if we're in wiki mode (i.e. an implementing class for {@link org.xwiki.rendering.wiki.WikiModel}
4951
* exists)
5052
*/
5153
protected boolean isInWikiMode()
5254
{
53-
boolean result = true;
54-
try {
55-
this.componentManagerProvider.get().getInstance(WikiModel.class);
56-
} catch (ComponentLookupException e) {
57-
result = false;
58-
}
59-
60-
return result;
55+
return this.wikiModelProvider.get() != null;
6156
}
6257
}

xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/Listener.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ default void endListItem(@Default("") Map<String, String> parameters)
386386
* Start of a figure.
387387
*
388388
* @param parameters a generic list of parameters for the figure
389+
* @since 10.2
389390
*/
390391
default void beginFigure(Map<String, String> parameters)
391392
{
@@ -396,6 +397,7 @@ default void beginFigure(Map<String, String> parameters)
396397
* End of a figure.
397398
*
398399
* @param parameters a generic list of parameters for the figure
400+
* @since 10.2
399401
*/
400402
default void endFigure(Map<String, String> parameters)
401403
{
@@ -406,6 +408,7 @@ default void endFigure(Map<String, String> parameters)
406408
* Start of a figure caption.
407409
*
408410
* @param parameters a generic list of parameters for the figure
411+
* @since 10.2
409412
*/
410413
default void beginFigureCaption(Map<String, String> parameters)
411414
{
@@ -416,6 +419,7 @@ default void beginFigureCaption(Map<String, String> parameters)
416419
* End of a figure caption.
417420
*
418421
* @param parameters a generic list of parameters for the figure
422+
* @since 10.2
419423
*/
420424
default void endFigureCaption(Map<String, String> parameters)
421425
{

xwiki-rendering-macros/xwiki-rendering-macro-figure/src/main/java/org/xwiki/rendering/macro/figure/FigureType.java renamed to xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/ListenerProvider.java

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,45 @@
1717
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
1818
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
1919
*/
20-
package org.xwiki.rendering.macro.figure;
20+
package org.xwiki.rendering.listener;
2121

22+
import org.xwiki.component.annotation.Role;
23+
import org.xwiki.rendering.listener.chaining.ChainingListener;
24+
import org.xwiki.rendering.listener.chaining.ListenerChain;
25+
import org.xwiki.rendering.syntax.Syntax;
2226
import org.xwiki.stability.Unstable;
2327

2428
/**
25-
* Allowed figure types.
29+
* Allows to access listener instances.
2630
*
2731
* @version $Id$
28-
* @since 14.9RC1
32+
* @since 15.3RC1
33+
* @since 14.10.8
2934
*/
35+
@Role
3036
@Unstable
31-
public enum FigureType
37+
public interface ListenerProvider
3238
{
3339
/**
34-
* Implicit type, let the type be defined according to the body of the figure.
35-
*
36-
* @see FigureTypeRecognizer
40+
* Parse action identifier.
3741
*/
38-
AUTOMATIC(""),
39-
/**
40-
* Explicit figure type.
41-
*/
42-
FIGURE("figure"),
42+
String PARSE_ACTION = "parse";
4343

4444
/**
45-
* Explicit table type.
45+
* Render action identifier.
4646
*/
47-
TABLE("table");
48-
49-
private String name;
50-
47+
String RENDER_ACTION = "render";
48+
5149
/**
52-
* @param name the name of the figure type (e.g., {@link FigureType#FIGURE})
50+
* @param action the action performed by the listener ("render" or "parse")
51+
* @param syntax the hint of the syntax using for the action
52+
* @return {@code true} when the listener provider can return a listener for the given action and syntaxHint
5353
*/
54-
FigureType(String name)
55-
{
56-
this.name = name;
57-
}
54+
boolean accept(String action, Syntax syntax);
5855

5956
/**
60-
* @return the name of the figure type (e.g., {@link FigureType#FIGURE})
57+
* @param listenerChain the listener chain in which the listener will be included
58+
* @return the listener to add to the listener chain
6159
*/
62-
public String getName()
63-
{
64-
return this.name;
65-
}
60+
ChainingListener getListener(ListenerChain listenerChain);
6661
}

xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/reference/ResourceReference.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class ResourceReference implements Cloneable
6666
private ResourceType type;
6767

6868
/**
69-
* @see #getParameter(String).
69+
* @see #getParameter(String)
7070
*/
7171
private Map<String, String> parameters = new LinkedHashMap<>();
7272

0 commit comments

Comments
 (0)