Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump plantuml and xwiki-contrib/parent-platform dependencies and fix TODOs #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ nbproject
.sonar-ide.properties
.clover
*~

.vscode
2 changes: 1 addition & 1 deletion macro-plantuml-macro/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<dependency>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2021.7</version>
<version>1.2024.7</version>
</dependency>
<dependency>
<groupId>org.xwiki.rendering</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;
import org.xwiki.component.annotation.Component;
import org.xwiki.contrib.plantuml.PlantUMLMacroParameters;
import org.xwiki.model.reference.DocumentReference;
Expand Down Expand Up @@ -150,23 +149,7 @@ private List<String> createId(String source, MacroTransformationContext context)
// Find index of the macro in the XDOM to create a unique id.
long index = context.getXDOM().indexOf(context.getCurrentMacroBlock());

// Make sure we don't have a / or \ in the source so that it works on Tomcat by default even if Tomcat is not
// configured to support \ and / in URLs.
// Make "_" and "-" escape characters and thus:
// - replace "_" by "__"
// - replace "-" by "--"
// - replace "\" by "_"
// - replace "/" by "-"
// This keeps the unicity of the source reference.
// TODO: Remove when the parent pom is upgraded to the version of XWiki where
// https://jira.xwiki.org/browse/XWIKI-17515 has been fixed.
String escapedSource = StringUtils.replaceEach(source,
new String[] { ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH },
new String[] { ESCAPE_CHAR_SLASH + ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH + ESCAPE_CHAR_BACKSLASH });
escapedSource = StringUtils.replaceEach(escapedSource, new String[] { "\\", "/" },
new String[] { ESCAPE_CHAR_SLASH, ESCAPE_CHAR_BACKSLASH });

return createId("rendering", "macro", "plantuml", escapedSource, index);
return createId("rendering", "macro", "plantuml", source, index);
}

private String getCurrentSource(MacroTransformationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -93,7 +95,9 @@ public PlantUMLMacro()
{
super("PlantUML", DESCRIPTION, new DefaultContentDescriptor(CONTENT_DESCRIPTION),
PlantUMLMacroParameters.class);
setDefaultCategory(DEFAULT_CATEGORY_CONTENT);
Set<String> defaultCategories = new HashSet<>();
defaultCategories.add(DEFAULT_CATEGORY_CONTENT);
super.setDefaultCategories(defaultCategories);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.xwiki.bridge.DocumentAccessBridge;
import org.xwiki.component.annotation.Component;
import org.xwiki.rendering.macro.MacroExecutionException;
import org.xwiki.resource.ResourceReference;
import org.xwiki.resource.ResourceReferenceSerializer;
import org.xwiki.resource.SerializeResourceReferenceException;
import org.xwiki.resource.UnsupportedResourceReferenceException;
Expand Down Expand Up @@ -64,14 +65,8 @@ public class TemporaryImageWriter implements ImageWriter
@Inject
private TemporaryResourceStore temporaryResourceStore;

// TODO: Once this extension starts depending on XWiki 14.7+, change this to:
// @Inject
// private ResourceReferenceSerializer<ResourceReference, ExtendedURL> resourceReferenceSerializer;
// As it is right now, this is hardcoding the URL scheme and would prevent any other Temporary URL scheme to be
// used.
@Inject
@Named("standard/tmp")
private ResourceReferenceSerializer<TemporaryResourceReference, ExtendedURL> temporaryResourceSerializer;
private ResourceReferenceSerializer<ResourceReference, ExtendedURL> resourceReferenceSerializer;

@Override
public OutputStream getOutputStream(String imageId) throws MacroExecutionException
Expand Down Expand Up @@ -112,7 +107,7 @@ public ExtendedURL getURL(String imageId) throws MacroExecutionException
{
TemporaryResourceReference resourceReference = getTemporaryResourceReference(imageId);
try {
return this.temporaryResourceSerializer.serialize(resourceReference);
return this.resourceReferenceSerializer.serialize(resourceReference);
} catch (SerializeResourceReferenceException | UnsupportedResourceReferenceException e) {
throw new MacroExecutionException(String.format("Failed to compute PlantUML image URL for [%s]",
resourceReference), e);
Expand Down
40 changes: 22 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,32 @@
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<repositories>
<repository>
<id>xwiki-releases</id>
<name>XWiki Releases</name>
<url>https://maven.xwiki.org/releases/</url>
</repository>
<repository>
<id>css4j</id>
<name>CSS4J</name>
<url>https://css4j.github.io/maven</url>
</repository>
</repositories>

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.contrib</groupId>
<artifactId>parent-platform</artifactId>
<version>12.10-1</version>
<version>16.4.2</version>
</parent>
<groupId>org.xwiki.contrib.plantuml</groupId>
<artifactId>macro-plantuml</artifactId>
<version>2.1.2-SNAPSHOT</version>
<packaging>pom</packaging>
<name>PlantUML Macro - Parent POM</name>
<description>Parent POM for Jthe PlantUML modules</description>
<description>Parent POM for the PlantUML modules</description>
<url>http://extensions.xwiki.org/xwiki/bin/view/Extension/JIRA%20Macro</url>
<scm>
<connection>scm:git:git://github.com/xwiki-contrib/macro-plantuml.git</connection>
Expand All @@ -52,6 +66,12 @@
<id>vmassol</id>
<name>Vincent Massol</name>
</developer>
<developer>
<id>dunklecat</id>
<roles>
<role>occasional mantainer</role>
</roles>
</developer>
</developers>
<properties>
<xwiki.issueManagement.jira.id>PLANTUML</xwiki.issueManagement.jira.id>
Expand All @@ -62,20 +82,4 @@
<module>macro-plantuml-macro</module>
<module>macro-plantuml-ui</module>
</modules>
<build>
<pluginManagement>
<plugins>
<!-- TODO: Remove once the parent pom depends on XWiki Commons 13.2RC1+.
See http://jira.xwiki.org/browse/XCOMMONS-2150 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- Specify the version of the code so that it doesn't depend on the Java version used to build XWiki -->
<source>8</source>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>