From e37a86bfcff6ab88a0aee76d2ed6c05d52a81e0d Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Fri, 13 Oct 2023 17:47:38 +0200 Subject: [PATCH 01/17] build: move to java11 update compiler target remove lombok usage working on #296 --- addon-scrollversions/pom.xml | 28 +++++- .../ScrollVersionsConfluenceService.java | 89 +++++++++---------- .../scrollversions/model/ScrollVersions.java | 24 ++++- ...sionsConfluenceServiceIntegrationTest.java | 23 +++-- .../scrollversions/ScrollVersionsTest.java | 17 ++-- core/pom.xml | 17 +--- .../org/bsc/confluence/ConfluenceProxy.java | 23 +++-- .../org/bsc/confluence/ParentChildTuple.java | 24 ++++- .../org/bsc/confluence/model/SiteFactory.java | 4 +- .../bsc/confluence/model/SiteProcessor.java | 28 ++++-- .../bsc/markdown/MarkdownVisitorHelper.java | 6 +- core/src/main/java9/module-info.java | 1 - .../org/bsc/markdown/flexmark/SiteTest.java | 60 +++++++++---- .../org/bsc/markdown/pegdown/SiteTest.java | 49 +++++++--- gitlog+jira/pom.xml | 2 +- plugin-reporting/pom.xml | 58 +----------- .../mojo/AbstractConfluenceDeployMojo.java | 5 +- .../org/bsc/mojo/ConfluenceDeleteMojo.java | 3 +- .../org/bsc/mojo/ConfluenceExportMojo.java | 11 ++- pom.xml | 22 ++--- processor-commonmark/pom.xml | 2 +- .../CommonmarkConfluenceWikiVisitor.java | 9 +- .../src/main/java9/module-info.java | 1 - processor-freemarker/pom.xml | 66 +------------- .../FreemarkerPreprocessorImplTest.java | 7 +- service-rest-api/pom.xml | 2 +- .../rest/AbstractRestConfluence.java | 29 +++--- service-xmlrpc-api/pom.xml | 2 +- test-plugin/pom.xml | 2 +- test-publishing/pom.xml | 2 +- 30 files changed, 293 insertions(+), 323 deletions(-) diff --git a/addon-scrollversions/pom.xml b/addon-scrollversions/pom.xml index 1bb069c5..e43904c0 100644 --- a/addon-scrollversions/pom.xml +++ b/addon-scrollversions/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 @@ -28,6 +28,13 @@ ${project.version} + + org.projectlombok + lombok + 1.18.16 + provided + + @@ -42,6 +49,25 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + + -Xlint:unchecked + -Xlint:deprecation + + + + org.projectlombok + lombok + 1.18.22 + + + + + + diff --git a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java index 751b91b0..d902e992 100644 --- a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java +++ b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java @@ -1,8 +1,6 @@ package org.bsc.confluence.rest.scrollversions; import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.java.Log; -import lombok.val; import okhttp3.*; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.rest.RESTConfluenceService; @@ -28,9 +26,8 @@ import static java.util.concurrent.CompletableFuture.completedFuture; import static java.util.stream.Collectors.toList; -@Log( topic = "confluence-maven-plugin" ) public class ScrollVersionsConfluenceService implements ConfluenceService { - +private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("confluence-maven-plugin"); enum ChangeType { ADD_VERSION("Modify"), REMOVE_VERSION("Remove"); @@ -65,7 +62,7 @@ public ScrollVersionsConfluenceService( String confluenceUrl, this.versionName = versionName; try { - val regex = "/rest/api(/?)$"; + final var regex = "/rest/api(/?)$"; this.scrollVersionsUrl = new URL(confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0")); } catch (MalformedURLException e) { throw new IllegalArgumentException("invalid Scroll Versions url", e); @@ -88,7 +85,7 @@ private HttpUrl.Builder urlBuilder() { private Request.Builder requestBuilder() { - val credentials = getCredentials(); + final var credentials = getCredentials(); return new Request.Builder() .header("Authorization", okhttp3.Credentials.basic(credentials.username, credentials.password)) .header("X-Atlassian-Token", "nocheck"); @@ -130,12 +127,12 @@ CompletableFuture getCurrentVersion(String spaceKe CompletableFuture> getScrollVersions(String spaceKey) { - val httpUrl = + final var httpUrl = urlBuilder() .addPathSegment("versions") .addPathSegment(spaceKey) .build(); - val request = requestBuilder() + final var request = requestBuilder() .url(httpUrl) .get() .build(); @@ -143,14 +140,14 @@ CompletableFuture> getScrollVersions(String s //debug( "getScrollVersions( '%s' )",spaceKey ); return delegate.fromRequestAsync(request).thenCompose( response -> { - val futureResult = new CompletableFuture>(); + final var futureResult = new CompletableFuture>(); return ofNullable(response.body()).map(b -> { try { - val responseBodyString = b.string(); + final var responseBodyString = b.string(); //trace( "getScrollVersions response\n%s", responseBodyString ); - val result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Version[].class); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Version[].class); futureResult.complete(asList(result)); @@ -175,15 +172,15 @@ CompletableFuture> getScrollVersions(String s */ CompletableFuture> getVersionsPages(String spaceKey, String queryArg, String value) { - val httpUrl = + final var httpUrl = urlBuilder() .addPathSegment("page") .addPathSegment(spaceKey) .build(); - val body = RequestBody.create(format(REQUEST_BODY_FORMAT, queryArg, value), JSON_MEDIA_TYPE ); + final var body = RequestBody.create(format(REQUEST_BODY_FORMAT, queryArg, value), JSON_MEDIA_TYPE ); - val request = requestBuilder() + final var request = requestBuilder() .url(httpUrl) .post(body) .build(); @@ -191,13 +188,13 @@ CompletableFuture> getVersionsPages(String space //debug( "getVersionPage( '%s', '%', '%s')",spaceKey, queryArg, value ); return delegate.fromRequestAsync(request).thenCompose( response -> { - val futureResult = new CompletableFuture>(); + final var futureResult = new CompletableFuture>(); return ofNullable(response.body()).map( b -> { try { - val responseBodyString = b.string(); + final var responseBodyString = b.string(); //trace( "getVersionsPages response\n%s", responseBodyString ); - val result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); futureResult.complete( asList(result) ); @@ -223,15 +220,15 @@ CompletableFuture> getVersionsPages(String space */ CompletableFuture> getVersionPage(String spaceKey, String title) { - val httpUrl = + final var httpUrl = urlBuilder() .addPathSegment("page") .addPathSegment(spaceKey) .build(); - val body = RequestBody.create(format(REQUEST_BODY_FORMAT, "scrollPageTitle", title), JSON_MEDIA_TYPE ); + final var body = RequestBody.create(format(REQUEST_BODY_FORMAT, "scrollPageTitle", title), JSON_MEDIA_TYPE ); - val request = requestBuilder() + final var request = requestBuilder() .url(httpUrl) .post(body) .build(); @@ -239,13 +236,13 @@ CompletableFuture> getVersionPage(Stri //debug( "getVersionPage( '%s', '%s')",spaceKey, title ); return delegate.fromRequestAsync(request).thenCompose( response -> { - val futureResult = new CompletableFuture>(); + final var futureResult = new CompletableFuture>(); return ofNullable(response.body()).map( b -> { try { - val responseBodyString = b.string(); + final var responseBodyString = b.string(); //trace( "getVersionPage response\n%s", responseBodyString ); - val result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); if( result == null || result.length == 0 ) { futureResult.complete( Optional.empty() ); @@ -256,11 +253,11 @@ CompletableFuture> getVersionPage(Stri futureResult.complete( Optional.of( ScrollVersions.Model.PageResult.of( result[0], emptyList())) ); } else { - val masterPage = Arrays.stream(result).filter( p -> p.isMasterPage() ).findFirst(); + final var masterPage = Arrays.stream(result).filter( p -> p.isMasterPage() ).findFirst(); futureResult.complete( masterPage.map( mp -> { - val versionPages = Arrays.stream(result).filter( p -> !p.isMasterPage() ).collect(toList()); + final var versionPages = Arrays.stream(result).filter( p -> !p.isMasterPage() ).collect(toList()); return Optional.of( ScrollVersions.Model.PageResult.of( mp, versionPages ) ); }).orElse( Optional.empty())); } @@ -312,20 +309,20 @@ CompletableFuture> getVersionPage(Stri */ CompletableFuture createVersionPage(String spaceKey, Model.ID masterPageId, String title, ScrollVersions.Model.Version version) { - val httpUrl = + final var httpUrl = urlBuilder() .addPathSegment("page") .addPathSegment("new") .addPathSegment(spaceKey) .build(); - val body = new FormBody.Builder() + final var body = new FormBody.Builder() .add("parentConfluenceId", masterPageId.toString() ) .add( "versionId", version.getId() ) .add( "pageTitle", title ) .build(); - val request = requestBuilder() + final var request = requestBuilder() .url(httpUrl) .post(body) .build(); @@ -333,13 +330,13 @@ CompletableFuture createVersionPage(String s //debug( "createVersionPage( '%s', '%d', '%s', '%s')",spaceKey, masterPageId, title, version.getName() ); return delegate.fromRequestAsync(request).thenCompose( response -> { - val futureResult = new CompletableFuture(); + final var futureResult = new CompletableFuture(); return ofNullable(response.body()).map( b -> { try { - val responseBodyString = b.string(); + final var responseBodyString = b.string(); //debug( "createVersionPage response\n%s", responseBodyString ); - val result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); futureResult.complete( result ); @@ -366,20 +363,20 @@ CompletableFuture createVersionPage(String s */ CompletableFuture manageVersionPage(Model.ID masterPageId, String title, ScrollVersions.Model.Version version, ChangeType changeType ) { - val httpUrl = + final var httpUrl = urlBuilder() .addPathSegment("page") .addPathSegment("modify") .build(); - val body = new FormBody.Builder() + final var body = new FormBody.Builder() .add("masterPageId", masterPageId.toString() ) .add( "pageTitle", title) .add( "versionId", version.getId() ) .add( "changeType", changeType.typeName ) .build(); - val request = requestBuilder() + final var request = requestBuilder() .url(httpUrl) .post(body) .build(); @@ -387,14 +384,14 @@ CompletableFuture manageVersionPage(Model.ID //debug( "manageVersionPage( '%s', '%s', '%s', '%s')",masterPageId, title, version.getName(), changeType.typeName ); return delegate.fromRequestAsync(request).thenCompose( response -> { - val futureResult = new CompletableFuture(); + final var futureResult = new CompletableFuture(); return ofNullable(response.body()).map( b -> { try { - val responseBodyString = b.string(); + final var responseBodyString = b.string(); //trace( "manageVersionPage response\n%s", responseBodyString ); - val result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); futureResult.complete( result ); @@ -432,7 +429,7 @@ private CompletableFuture toResult(Model.Page page throw new IllegalArgumentException(format("page [%s] is not a result type! %s", page.getTitle(), page,getClass().getName() )); // debug( "page [%s] is not a result type! %s", page.getTitle(), page,getClass().getName() ); // -// val result = new ScrollVersions.Model.Result() { +// final var result = new ScrollVersions.Model.Result() { // // @Override // public Model.ID getMasterPageId() { @@ -451,7 +448,7 @@ private CompletableFuture toResult(Model.Page page * @return */ static CompletableFuture completeExceptionally( Throwable ex ) { - val future = new CompletableFuture(); + final var future = new CompletableFuture(); future.completeExceptionally( ex ); return future; } @@ -469,9 +466,9 @@ private Optional cast( Optional s ) { private static Pattern vesrsionsTitlePattern = Pattern.compile( "^[\\.](.+)\\sv(.+)$"); private String decodeTitle( String title ) { - val m = vesrsionsTitlePattern.matcher(title); + final var m = vesrsionsTitlePattern.matcher(title); - val result = (m.matches()) + final var result = (m.matches()) ? m.group(1) : title; //debug( "decodeTitle('%s')='%s'", title, result ); @@ -487,7 +484,7 @@ private String encodeTitle( String title, ScrollVersions.Model.Version version ) } private boolean isVersion( String title, ScrollVersions.Model.Version version ) { - val m = vesrsionsTitlePattern.matcher(title); + final var m = vesrsionsTitlePattern.matcher(title); return ( m.matches() ) ? m.group(2).equals( version.getName() ) @@ -517,7 +514,7 @@ public Model.Page newPage(Model.ID id, String space, String title, int version ) * @return */ private CompletableFuture storeVersionedPage(ScrollVersions.Model.NewPageResult newPage, Storage content, ScrollVersions.Model.Version version ) { - val title = newPage.getScrollPageTitle(); + final var title = newPage.getScrollPageTitle(); newPage.setScrollPageTitle( encodeTitle(title, version ) ); // update title if it is not versioned @@ -590,7 +587,7 @@ public CompletableFuture> getDescendents(Model.ID pageId cast(page.map( pp -> toResult(pp) .thenCompose( result -> delegate.getDescendents( result.getMasterPageId())) .thenApply( result -> { - val list = result.stream() + final var list = result.stream() .filter( p -> isVersion(p.getTitle(), currentVersion.get())) .filter( p -> pageId.compareTo(p.getId())!=0) .collect( toList() ); @@ -617,7 +614,7 @@ public CompletableFuture> getPageByTitle(M public CompletableFuture removePage(Model.Page parentPage, String title) { //debug( "removePage( parent.title:[%s], title:[%s])", parentPage.getTitle(), title ); - val getPage = getPage( parentPage.getSpace(), title ); + final var getPage = getPage( parentPage.getSpace(), title ); if( removeHard ) { return getPage @@ -647,7 +644,7 @@ public CompletableFuture removePage(Model.Page parentPage, String title public CompletableFuture removePage(Model.ID pageId) { //debug( "removePage( pageId:[%s])", pageId ); - val getPage = getPage(pageId); + final var getPage = getPage(pageId); if( removeHard ) { return getPage diff --git a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/model/ScrollVersions.java b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/model/ScrollVersions.java index 5ff5ed8e..762d07e2 100644 --- a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/model/ScrollVersions.java +++ b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/model/ScrollVersions.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; -import lombok.Value; import org.bsc.confluence.ConfluenceService; import java.util.List; @@ -81,10 +80,27 @@ class ConfluencePage { } - @Value(staticConstructor = "of") class PageResult implements ConfluenceService.Model.Page, Result { - ScrollVersions.Model.Page masterPage; - List versionPages; + final ScrollVersions.Model.Page masterPage; + final List versionPages; + + public Page getMasterPage() { + return masterPage; + } + + public List getVersionPages() { + return versionPages; + } + + + public static PageResult of(ScrollVersions.Model.Page masterPage, List versionPage ) { + return new PageResult(masterPage, versionPage); + } + + private PageResult(ScrollVersions.Model.Page masterPage, List versionPages) { + this.masterPage = masterPage; + this.versionPages = versionPages; + } private Page resolvePage() { return (versionPages.isEmpty() || versionPages.size() > 1 ) diff --git a/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceServiceIntegrationTest.java b/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceServiceIntegrationTest.java index be3e3d1f..2b29df04 100644 --- a/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceServiceIntegrationTest.java +++ b/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceServiceIntegrationTest.java @@ -7,7 +7,6 @@ import static java.util.Collections.emptyMap; -import lombok.val; import org.bsc.confluence.ConfluenceService; import org.bsc.ssl.SSLCertificateInfo; import org.junit.jupiter.api.BeforeAll; @@ -31,22 +30,22 @@ private static void trace(String message, Object...args ) { @BeforeAll public static void clearSpace() { - val ssl = new SSLCertificateInfo(); + final var ssl = new SSLCertificateInfo(); - val service = new ScrollVersionsConfluenceService( + final var service = new ScrollVersionsConfluenceService( "http://localhost:8090/rest/api", "alpha", new ConfluenceService.Credentials( "admin", "admin", emptyMap()), ssl); - val space = "SVTS"; + final var space = "SVTS"; clearSpace( service, space).join(); } private static CompletableFuture sleep( TimeUnit timeunit, long unit ) { - val result = new CompletableFuture(); + final var result = new CompletableFuture(); try { timeunit.sleep( unit); result.complete(null); @@ -58,7 +57,7 @@ private static CompletableFuture sleep( TimeUnit timeunit, long unit ) { } public static CompletableFuture clearSpace(final ScrollVersionsConfluenceService service, final String space ) { - val unversioned = service.getVersionsPages(space, "isUnversioned", "true") + final var unversioned = service.getVersionsPages(space, "isUnversioned", "true") .thenAccept(p -> { p.forEach(u -> { debug("unversioned [%s]", u.getConfluencePageTitle()); @@ -67,7 +66,7 @@ public static CompletableFuture clearSpace(final ScrollVersionsConfluenceS .join(); }); }); - val versioned = service.getVersionsPages(space, "pageType", "change") + final var versioned = service.getVersionsPages(space, "pageType", "change") .thenAccept(p -> { p.forEach(u -> { debug("versioned [%s]", u.getConfluencePageTitle()); @@ -77,7 +76,7 @@ public static CompletableFuture clearSpace(final ScrollVersionsConfluenceS }); }); - val masters = service.getVersionsPages(space, "pageType", "masterPage") + final var masters = service.getVersionsPages(space, "pageType", "masterPage") .thenAccept(p -> { p.forEach(u -> { debug("master [%s]", u.getConfluencePageTitle()); @@ -87,7 +86,7 @@ public static CompletableFuture clearSpace(final ScrollVersionsConfluenceS }); }); - val page = "Topic 1"; + final var page = "Topic 1"; CompletableFuture createFirstPage = service.getScrollVersions(space) @@ -109,15 +108,15 @@ public static CompletableFuture clearSpace(final ScrollVersionsConfluenceS @BeforeEach public void createService() { - val ssl = new SSLCertificateInfo(); + final var ssl = new SSLCertificateInfo(); - val service = new ScrollVersionsConfluenceService( + final var service = new ScrollVersionsConfluenceService( "http://localhost:8090/rest/api", "alpha", new ConfluenceService.Credentials( "admin", "admin", emptyMap()), ssl); - val space = "SVTS"; + final var space = "SVTS"; } @Test diff --git a/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsTest.java b/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsTest.java index 079cc918..9763eb13 100644 --- a/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsTest.java +++ b/addon-scrollversions/src/test/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsTest.java @@ -1,6 +1,5 @@ package org.bsc.confluence.rest.scrollversions; -import lombok.val; import org.junit.jupiter.api.Test; import java.util.regex.Pattern; @@ -20,22 +19,22 @@ public void fromConfluenceToScrollVersionsUrl() { final String regex = "/rest/api(/?)$"; { - val confluenceUrl = "http://localhost:8090/rest/api"; - val scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); + final var confluenceUrl = "http://localhost:8090/rest/api"; + final var scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); assertEquals( "http://localhost:8090/rest/scroll-versions/1.0", scrollVersionsUrl ); } { - val confluenceUrl = "http://localhost:8090/rest/api/"; - val scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); + final var confluenceUrl = "http://localhost:8090/rest/api/"; + final var scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); assertEquals( "http://localhost:8090/rest/scroll-versions/1.0", scrollVersionsUrl ); } { - val confluenceUrl = "http://localhost:8090/rest/api/xxx/rest/api"; - val scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); + final var confluenceUrl = "http://localhost:8090/rest/api/xxx/rest/api"; + final var scrollVersionsUrl = confluenceUrl.replaceAll(regex, "/rest/scroll-versions/1.0"); assertEquals( "http://localhost:8090/rest/api/xxx/rest/scroll-versions/1.0", scrollVersionsUrl ); } @@ -44,9 +43,9 @@ public void fromConfluenceToScrollVersionsUrl() { @Test public void decodeScrollVersionsTitle() { - val p = Pattern.compile( "^[\\.](.+)\\sv(.+)$"); + final var p = Pattern.compile( "^[\\.](.+)\\sv(.+)$"); - val m = p.matcher(".Parent - Issue#194 valpha"); + final var m = p.matcher(".Parent - Issue#194 valpha"); assertTrue( m.matches() ); assertEquals( "Parent - Issue#194", m.group(1)); diff --git a/core/pom.xml b/core/pom.xml index e736fb83..19087ffa 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 @@ -113,21 +113,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - - - install - - javadoc - - - false - - - - diff --git a/core/src/main/java/org/bsc/confluence/ConfluenceProxy.java b/core/src/main/java/org/bsc/confluence/ConfluenceProxy.java index 5cb013bb..73bb3dc9 100644 --- a/core/src/main/java/org/bsc/confluence/ConfluenceProxy.java +++ b/core/src/main/java/org/bsc/confluence/ConfluenceProxy.java @@ -5,20 +5,29 @@ */ package org.bsc.confluence; -import lombok.Value; /** * * @author bsorrentino */ -@Value(staticConstructor="of") public class ConfluenceProxy { - public String host; - public int port; + final public String host; + final public int port; - public String userName; - public String password; - public String nonProxyHosts; + final public String userName; + final public String password; + final public String nonProxyHosts; + private ConfluenceProxy( String host, int port, String userName, String password, String nonProxyHosts) { + this.host = host; + this.port = port; + this.userName = userName; + this.password = password; + this.nonProxyHosts = nonProxyHosts; + } + + public static ConfluenceProxy of( String host, int port, String userName, String password, String nonProxyHosts) { + return new ConfluenceProxy( host, port, userName, password, nonProxyHosts); + } } diff --git a/core/src/main/java/org/bsc/confluence/ParentChildTuple.java b/core/src/main/java/org/bsc/confluence/ParentChildTuple.java index 3f8dac6a..653acaa3 100644 --- a/core/src/main/java/org/bsc/confluence/ParentChildTuple.java +++ b/core/src/main/java/org/bsc/confluence/ParentChildTuple.java @@ -1,11 +1,27 @@ package org.bsc.confluence; -import lombok.Value; import java.util.Optional; -@Value(staticConstructor="of") public class ParentChildTuple { - ConfluenceService.Model.Page parent; - Optional child; + private final ConfluenceService.Model.Page parent; + private final ConfluenceService.Model.Page child; + + public ConfluenceService.Model.Page getParent() { return parent; } + + public Optional getChild() { return Optional.ofNullable(child); } + + ParentChildTuple( ConfluenceService.Model.Page parent, ConfluenceService.Model.Page child) { + this.parent = parent; + this.child = child; + } + + public static ParentChildTuple of(ConfluenceService.Model.Page parent, ConfluenceService.Model.Page child) { + return new ParentChildTuple(parent, child); + } + + @Deprecated + public static ParentChildTuple of(ConfluenceService.Model.Page parent, Optional child) { + return new ParentChildTuple(parent, child.orElse(null)); + } } diff --git a/core/src/main/java/org/bsc/confluence/model/SiteFactory.java b/core/src/main/java/org/bsc/confluence/model/SiteFactory.java index e939ca5b..0c69dc68 100644 --- a/core/src/main/java/org/bsc/confluence/model/SiteFactory.java +++ b/core/src/main/java/org/bsc/confluence/model/SiteFactory.java @@ -9,7 +9,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import lombok.extern.java.Log; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.bsc.preprocessor.SiteProcessorService; @@ -28,8 +27,9 @@ */ public interface SiteFactory { - @Log final class LogHolder { + + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogHolder.class.getName()); } interface Folder { diff --git a/core/src/main/java/org/bsc/confluence/model/SiteProcessor.java b/core/src/main/java/org/bsc/confluence/model/SiteProcessor.java index dbe1abe2..28bfaf2e 100644 --- a/core/src/main/java/org/bsc/confluence/model/SiteProcessor.java +++ b/core/src/main/java/org/bsc/confluence/model/SiteProcessor.java @@ -1,7 +1,5 @@ package org.bsc.confluence.model; -import lombok.NonNull; -import lombok.Value; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceService.Model; @@ -23,12 +21,28 @@ public class SiteProcessor { - @Value(staticConstructor="of") + public static class PageContent { - @NonNull - String content; - @NonNull - Storage.Representation type; + final String content; + final Storage.Representation type; + + public String getContent() { + return content; + } + + public Storage.Representation getType() { + return type; + } + + public static PageContent of( String content, Storage.Representation type ) { + return new PageContent( content, type ); + } + private PageContent( String content, Storage.Representation type ) { + requireNonNull(content); + requireNonNull(type); + this.content = content; + this.type = type; + } /** * use {@link #getInputStream(Charset)} diff --git a/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java b/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java index 2e29b303..9269b614 100644 --- a/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java +++ b/core/src/main/java/org/bsc/markdown/MarkdownVisitorHelper.java @@ -1,6 +1,5 @@ package org.bsc.markdown; -import lombok.NonNull; import org.bsc.confluence.FileExtension; import org.bsc.confluence.model.Site; @@ -8,6 +7,7 @@ import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.regex.Matcher; @@ -181,7 +181,9 @@ public static boolean isConfluenceVariable( String text ) { * @param text * @return */ - public static Matcher parseConfluenceMacro( @NonNull String text ) { + public static Matcher parseConfluenceMacro( String text ) { + // GUARD + Objects.requireNonNull(text); return confluenceMacroWithContentPattern.matcher(text); } diff --git a/core/src/main/java9/module-info.java b/core/src/main/java9/module-info.java index c169071e..ec47a41c 100644 --- a/core/src/main/java9/module-info.java +++ b/core/src/main/java9/module-info.java @@ -1,6 +1,5 @@ open module maven.confluence.core { - requires lombok; //requires okhttp3; requires org.apache.commons.codec; diff --git a/deprecated/processor-flexmark/src/test/java/org/bsc/markdown/flexmark/SiteTest.java b/deprecated/processor-flexmark/src/test/java/org/bsc/markdown/flexmark/SiteTest.java index eb995bb3..407acb58 100644 --- a/deprecated/processor-flexmark/src/test/java/org/bsc/markdown/flexmark/SiteTest.java +++ b/deprecated/processor-flexmark/src/test/java/org/bsc/markdown/flexmark/SiteTest.java @@ -1,7 +1,5 @@ package org.bsc.markdown.flexmark; -import lombok.Data; -import lombok.val; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService.Model; import org.bsc.confluence.model.Site; @@ -28,11 +26,35 @@ */ public class SiteTest implements SiteFactory.Model { - @Data(staticConstructor="of") + static class TestPage implements Model.Page { - final String title; - final String space; + String title; + String space; + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSpace() { + return space; + } + + public void setSpace(String space) { + this.space = space; + } + + public static final TestPage of(String title, String space ) { + return new TestPage( title, space ); + } + + private TestPage( String title, String space ) { + this.title = title; + this.space = space; + } @Override public Model.ID getId() { @@ -56,7 +78,7 @@ public int getVersion() { @Override public Site createSiteFromModel(Map variables) { - val path = Paths.get("src", "test", "resources", "site.yaml"); + final var path = Paths.get("src", "test", "resources", "site.yaml"); try { return createFrom( path.toFile(), variables); } catch (Exception e) { @@ -87,12 +109,12 @@ public void validateName() { @Test public void shouldSupportRefLink() throws IOException { - val parentPageTitle = Optional.of("Test"); - val stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md"); + final var parentPageTitle = Optional.of("Test"); + final var stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md"); assertNull( stream ); - val content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNull( content ); - val converted = content.split("\n+"); + final var converted = content.split("\n+"); int i = 2; @@ -110,13 +132,13 @@ public void shouldSupportImgRefLink() throws IOException { final Model.Page page = TestPage.of( "${page.title}", "spaceKey"); - val parentPageTitle = Optional.of("Test IMG"); + final var parentPageTitle = Optional.of("Test IMG"); - val stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md"); + final var stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md"); assertNull( stream ); - val content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle); + final var content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle); assertNull( content ); - val converted = content.split("\n+"); + final var converted = content.split("\n+"); int i = 2; assertTrue(converted[i++].contains("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon!")); @@ -130,11 +152,11 @@ public void shouldSupportImgRefLink() throws IOException { @Test public void shouldSupportSimpleNode() throws IOException { - val parentPageTitle = Optional.of("Test"); + final var parentPageTitle = Optional.of("Test"); final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md"); assertNull( stream ); - val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNull( converted ); assertTrue("All forms of HRules should be supported", converted.contains("----\n1\n----\n2\n----\n3\n----\n4\n----")); @@ -149,11 +171,11 @@ public void shouldSupportSimpleNode() throws IOException { @Test public void shouldCreateSpecificNoticeBlock() throws IOException { - val parentPageTitle = Optional.of("Test Macro"); + final var parentPageTitle = Optional.of("Test Macro"); - val stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md"); + final var stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md"); assertNotNull( stream ); - val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNotNull( converted ); assertTrue(converted.contains("{info:title=About me}\n") ); diff --git a/deprecated/processor-pegdown/src/test/java/org/bsc/markdown/pegdown/SiteTest.java b/deprecated/processor-pegdown/src/test/java/org/bsc/markdown/pegdown/SiteTest.java index 6d69f57c..b4a4932e 100644 --- a/deprecated/processor-pegdown/src/test/java/org/bsc/markdown/pegdown/SiteTest.java +++ b/deprecated/processor-pegdown/src/test/java/org/bsc/markdown/pegdown/SiteTest.java @@ -1,7 +1,5 @@ package org.bsc.markdown.pegdown; -import lombok.Data; -import lombok.val; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService.Model; import org.bsc.confluence.model.Site; @@ -28,11 +26,34 @@ */ public class SiteTest implements SiteFactory.Model { - @Data(staticConstructor="of") static class TestPage implements Model.Page { final String title; final String space; + public static final TestPage of(String title, String space ) { + return new TestPage( title, space ); + } + + private TestPage( String title, String space ) { + this.title = title; + this.space = space; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + String getSpace() { + return space; + } + + public void setSpace(String space) { + this.space = space; + } @Override public Model.ID getId() { @@ -56,7 +77,7 @@ public int getVersion() { @Override public Site createSiteFromModel(Map variables) { - val path = Paths.get("src", "test", "resources", "site.yaml"); + final var path = Paths.get("src", "test", "resources", "site.yaml"); try { return createFrom( path.toFile(), variables); } catch (Exception e) { @@ -87,12 +108,12 @@ public void validateName() { @Test public void shouldSupportRefLink() throws IOException { - val parentPageTitle = Optional.of("Test"); - val stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md"); + final var parentPageTitle = Optional.of("Test"); + final var stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md"); assertNotNull( stream ); - val content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNotNull( content ); - val converted = content.split("\n+"); + final var converted = content.split("\n+"); int i = 2; assertEquals( format("* This is a relative link to another page [SECOND PAGE|%s - page 2|].", parentPageTitle.get()), converted[i++] ); @@ -109,11 +130,11 @@ public void shouldSupportImgRefLink() throws IOException { final Model.Page page = TestPage.of( "${page.title}", "spaceKey"); - final val parentPageTitle = Optional.of("Test IMG"); + final final var parentPageTitle = Optional.of("Test IMG"); final InputStream stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md"); assertNotNull( stream ); - val content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle); + final var content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle); assertNotNull( content ); final String converted[] = content.split("\n+"); @@ -129,11 +150,11 @@ public void shouldSupportImgRefLink() throws IOException { @Test public void shouldSupportSimpleNode() throws IOException { - val parentPageTitle = Optional.of("Test"); + final var parentPageTitle = Optional.of("Test"); final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md"); assertNotNull( stream ); - val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNotNull( converted ); assertTrue(converted.contains("----\n1\n----\n2\n----\n3\n----\n4\n----"), "All forms of HRules should be supported" ); @@ -148,11 +169,11 @@ public void shouldSupportSimpleNode() throws IOException { @Test public void shouldCreateSpecificNoticeBlock() throws IOException { - val parentPageTitle = Optional.of("Test Macro"); + final var parentPageTitle = Optional.of("Test Macro"); final InputStream stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md"); assertNotNull( stream ); - val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); + final var converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle); assertNotNull( converted ); assertTrue( converted.contains("{info:title=About me}\n") ); diff --git a/gitlog+jira/pom.xml b/gitlog+jira/pom.xml index ce78723e..2832101f 100644 --- a/gitlog+jira/pom.xml +++ b/gitlog+jira/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 diff --git a/plugin-reporting/pom.xml b/plugin-reporting/pom.xml index 93d585fd..219e072d 100755 --- a/plugin-reporting/pom.xml +++ b/plugin-reporting/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT @@ -74,23 +74,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - - compile-java-8 - - compile - - - - ${project.basedir}/src/main/java - - - - - org.apache.maven.plugins maven-jar-plugin @@ -307,45 +290,6 @@ - - java9above - - [9,) - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - compile-java-9 - compile - - compile - - - 9 - - ${project.basedir}/src/main/java - ${project.basedir}/src/main/java9 - - - --add-modules=java.xml.bind - - ${project.build.outputDirectory}/META-INF/versions/9 - - - - - - - - - - - report diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java b/plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java index 23d24255..db2fdacb 100644 --- a/plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java +++ b/plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java @@ -5,7 +5,6 @@ package org.bsc.mojo; import biz.source_code.miniTemplator.MiniTemplator; -import lombok.val; import org.apache.commons.lang.StringUtils; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -617,7 +616,7 @@ private void generateAttachments(final ConfluenceService confluence, Site site, try { if (!Files.isDirectory(attachmentPath)) { - val result = generateAttachment(confluence, site, confluencePage, attachment).get(); + final var result = generateAttachment(confluence, site, confluencePage, attachment).get(); getLog().debug(format("generated attachment: %s", result.toString())); } else { @@ -637,7 +636,7 @@ private void generateAttachments(final ConfluenceService confluence, Site site, fileAttachment.setContentType(attachment.getContentType()); } - val result = generateAttachment(confluence, site, confluencePage, fileAttachment).get(); + final var result = generateAttachment(confluence, site, confluencePage, fileAttachment).get(); getLog().debug(format("generated attachment: %s", result.toString())); } diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java b/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java index b70a6025..5741804a 100644 --- a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java +++ b/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java @@ -4,7 +4,6 @@ */ package org.bsc.mojo; -import lombok.val; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; @@ -89,7 +88,7 @@ private boolean deletePage(ConfluenceService confluence) { Optional optStartPageTitle = empty(); if( isSiteDescriptorValid() ) { - val site = createSiteFromModel(getSiteModelVariables()); + final var site = createSiteFromModel(getSiteModelVariables()); optStartPageTitle = ofNullable( site.getHome().getName()); } diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java b/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java index 55a81d7e..787465dc 100644 --- a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java +++ b/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java @@ -6,7 +6,6 @@ package org.bsc.mojo; -import lombok.val; import org.apache.commons.io.FileUtils; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -66,13 +65,13 @@ public class ConfluenceExportMojo extends AbstractBaseConfluenceMojo { private CompletableFuture exportPage(ConfluenceService confluence, Model.Page parentPage ) { - val result = new CompletableFuture(); + final var result = new CompletableFuture(); - val exfmt = ExportFormat.valueOf( outputType.toUpperCase() ); + final var exfmt = ExportFormat.valueOf( outputType.toUpperCase() ); outputFile = ofNullable(outputFile).orElseGet( () -> { - val fileName = format("%s.%s", pageTitle, exfmt.name().toLowerCase()); + final var fileName = format("%s.%s", pageTitle, exfmt.name().toLowerCase()); final java.io.File file = ofNullable(outputDirectory) @@ -85,9 +84,9 @@ private CompletableFuture exportPage(ConfluenceService confluence, Model.P try { FileUtils.forceMkdir( new java.io.File(outputFile.getParent()) ); - val url = ConfluenceService.Protocol.XMLRPC.removeFrom(ConfluenceExportMojo.super.getEndPoint()); + final var url = ConfluenceService.Protocol.XMLRPC.removeFrom(ConfluenceExportMojo.super.getEndPoint()); - val exporter = + final var exporter = new ConfluenceExportDecorator( confluence, url ); exporter.exportPage(parentPage.getSpace(), diff --git a/pom.xml b/pom.xml index c7d34777..3bbdf84d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent pom - 7.13 + 8.0-SNAPSHOT CONFLUENCE-REPORTING::Parent Maven's plugin that allow to generate "project's documentation" directly to confluence allowing, in the same time, to keep in-sync both project & documentation @@ -85,8 +85,8 @@ 1.5.2 UTF-8 - 1.8 - 1.8 + 11 + 11 1.6.0 @@ -222,12 +222,6 @@ - - org.projectlombok - lombok - 1.18.16 - provided - org.junit.jupiter @@ -305,7 +299,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.2 + 3.6.0 @@ -319,13 +313,6 @@ -Xlint:unchecked -Xlint:deprecation - - - org.projectlombok - lombok - 1.18.22 - - @@ -382,6 +369,7 @@ -Xdoclint:none ${project.build.directory}/apidocs + false diff --git a/processor-commonmark/pom.xml b/processor-commonmark/pom.xml index 26f94303..ce89a0f9 100644 --- a/processor-commonmark/pom.xml +++ b/processor-commonmark/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 diff --git a/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java b/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java index 366f9d41..a86d19c2 100644 --- a/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java +++ b/processor-commonmark/src/main/java/org/bsc/markdown/commonmark/CommonmarkConfluenceWikiVisitor.java @@ -1,6 +1,5 @@ package org.bsc.markdown.commonmark; -import lombok.NonNull; import org.bsc.markdown.MarkdownParserContext; import org.bsc.markdown.MarkdownVisitorHelper; import org.bsc.markdown.commonmark.extension.NoticeBlock; @@ -11,10 +10,7 @@ import org.commonmark.ext.gfm.tables.*; import org.commonmark.node.*; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.Stack; +import java.util.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -107,7 +103,8 @@ public static String escapeMarkdownText( Node node, String text ) { * @param text * @return */ - public static Matcher parseHTMLComment( @NonNull String text ) { + public static Matcher parseHTMLComment( String text ) { + Objects.requireNonNull(text); return isHTMLCommentPattern.matcher(text); } diff --git a/processor-commonmark/src/main/java9/module-info.java b/processor-commonmark/src/main/java9/module-info.java index d3e2ff04..3a03cb80 100644 --- a/processor-commonmark/src/main/java9/module-info.java +++ b/processor-commonmark/src/main/java9/module-info.java @@ -1,7 +1,6 @@ module confluence.markdown.processor.commonmark { requires maven.confluence.core; - requires lombok; requires org.commonmark; requires org.commonmark.ext.gfm.strikethrough; requires org.commonmark.ext.gfm.tables; diff --git a/processor-freemarker/pom.xml b/processor-freemarker/pom.xml index 1c09374a..c9909986 100644 --- a/processor-freemarker/pom.xml +++ b/processor-freemarker/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent - 7.13 + 8.0-SNAPSHOT maven-confluence-processor-freemarker CONFLUENCE-REPORTING::Freemaker::Processor @@ -33,68 +33,4 @@ - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - compile-java-8 - - compile - - - - ${project.basedir}/src/main/java - - - - - - - - - - - java9above - - [9,) - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - compile-java-9 - compile - - compile - - - 9 - - ${project.basedir}/src/main/java - ${project.basedir}/src/main/java9 - - - - ${project.build.outputDirectory}/META-INF/versions/9 - - - - - - - - - - - - diff --git a/processor-freemarker/src/test/java/org/bsc/confluence/preprocessor/freemarker/FreemarkerPreprocessorImplTest.java b/processor-freemarker/src/test/java/org/bsc/confluence/preprocessor/freemarker/FreemarkerPreprocessorImplTest.java index d40d87ab..acf02fff 100644 --- a/processor-freemarker/src/test/java/org/bsc/confluence/preprocessor/freemarker/FreemarkerPreprocessorImplTest.java +++ b/processor-freemarker/src/test/java/org/bsc/confluence/preprocessor/freemarker/FreemarkerPreprocessorImplTest.java @@ -10,7 +10,6 @@ import java.nio.file.Paths; import java.util.Map; -import lombok.val; import org.bsc.preprocessor.freemarker.FreemarkerPreprocessorImpl; import org.junit.jupiter.api.Test; @@ -37,10 +36,10 @@ public void variableTest() throws IOException, URISyntaxException { } private void testInternal(String resourceName) throws URISyntaxException, IOException { - val p = new FreemarkerPreprocessorImpl(); - val readInput = read(resourceName + ".input"); + final var p = new FreemarkerPreprocessorImpl(); + final var readInput = read(resourceName + ".input"); final Map varInput = singletonMap("key", singletonMap("innerKey", "value1")); - val readOutput = read(resourceName + ".output"); + final var readOutput = read(resourceName + ".output"); assertEquals(readOutput, p.process(readInput, varInput).join() ); } diff --git a/service-rest-api/pom.xml b/service-rest-api/pom.xml index 9642cf63..7ef78ad1 100644 --- a/service-rest-api/pom.xml +++ b/service-rest-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 diff --git a/service-rest-api/src/main/test/java/org/bsc/confluence/rest/AbstractRestConfluence.java b/service-rest-api/src/main/test/java/org/bsc/confluence/rest/AbstractRestConfluence.java index 935a3c90..733e8f07 100644 --- a/service-rest-api/src/main/test/java/org/bsc/confluence/rest/AbstractRestConfluence.java +++ b/service-rest-api/src/main/test/java/org/bsc/confluence/rest/AbstractRestConfluence.java @@ -5,9 +5,6 @@ */ package org.bsc.confluence.rest; -import lombok.Value; -import lombok.val; -import lombok.var; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceService.Model; import org.bsc.confluence.ConfluenceService.Storage; @@ -29,10 +26,18 @@ import static org.junit.Assert.fail; -@Value(staticConstructor="of") class PageTuple2 { - ConfluenceService.Model.Page page1; - ConfluenceService.Model.Page page2; + final ConfluenceService.Model.Page page1; + final ConfluenceService.Model.Page page2; + + private PageTuple2( Model.Page page1, Model.Page page2) { + this.page1 = page1; + this.page2 = page2; + } + + public static PageTuple2 of(Model.Page page1, Model.Page page2) { + return new PageTuple2(page1, page2); + } } /** @@ -118,16 +123,16 @@ public void dummy() {} @Test public void test101_getOrCreatePageAndStoreWiki() throws Exception { - val title = Pages.MyPage2.name(); + final var title = Pages.MyPage2.name(); - val p = service.getOrCreatePage(spaceKey, getParentPageTitle(), title).get(); + final var p = service.getOrCreatePage(spaceKey, getParentPageTitle(), title).get(); int version = p.getVersion(); assertThat( p, notNullValue()); assertThat(p.getSpace(), equalTo(spaceKey)); assertThat( version > 0, is(true)); - val content = new StringBuilder() + final var content = new StringBuilder() .append("h1.") .append(" TEST ") .append(System.currentTimeMillis()).append('\n') @@ -135,7 +140,7 @@ public void test101_getOrCreatePageAndStoreWiki() throws Exception { .append("*'wiki' \"wiki\"*") .toString(); - val p1 = service.storePage(p, Storage.of(content, Storage.Representation.WIKI)).get(); + final var p1 = service.storePage(p, Storage.of(content, Storage.Representation.WIKI)).get(); assertThat( p1, notNullValue()); assertThat( p1.getSpace(), equalTo(spaceKey)); @@ -183,7 +188,7 @@ public void test101_getOrCreatePageAndStoreWiki() throws Exception { @Test public void test102_getOrCreatePageAndStoreStorage() throws Exception { - val title = Pages.MyPage3.name(); + final var title = Pages.MyPage3.name(); final PageTuple2 result = service.getOrCreatePage(spaceKey, getParentPageTitle(), title) @@ -223,7 +228,7 @@ public void test103_getDescendentsTest() throws Exception { assertThat( page.isPresent(), equalTo(true) ); - val descendents = service.getDescendents( page.get().getId() ).join(); + final var descendents = service.getDescendents( page.get().getId() ).join(); assertThat( descendents, notNullValue() ); assertThat( descendents.isEmpty(), is(false) ); diff --git a/service-xmlrpc-api/pom.xml b/service-xmlrpc-api/pom.xml index c4ead193..0a6c7d55 100644 --- a/service-xmlrpc-api/pom.xml +++ b/service-xmlrpc-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 diff --git a/test-plugin/pom.xml b/test-plugin/pom.xml index 7f40e622..76709fc4 100644 --- a/test-plugin/pom.xml +++ b/test-plugin/pom.xml @@ -6,7 +6,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT diff --git a/test-publishing/pom.xml b/test-publishing/pom.xml index 3e58047e..31185d96 100644 --- a/test-publishing/pom.xml +++ b/test-publishing/pom.xml @@ -3,7 +3,7 @@ maven-confluence-parent org.bsc.maven - 7.13 + 8.0-SNAPSHOT 4.0.0 From f425bdc7b31b22b05e1a19c55272de13e2eb7cd6 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Fri, 13 Oct 2023 18:02:07 +0200 Subject: [PATCH 02/17] docs: update javadoc --- .../confluence/rest/AbstractRESTConfluenceService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java index ba6e36a8..81bc6a6d 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java @@ -26,9 +26,11 @@ import static java.lang.String.format; /** - * - * @author softphone - */ + * AbstractRESTConfluenceService is an abstract class that implements the IdHelper interface. + * It provides common functionality for making REST API calls to Confluence + * Sub-classes need to implement getCredentials() and urlBuilder() to provide + * the necessary information for making API calls. +*/ public abstract class AbstractRESTConfluenceService implements IdHelper { private static final String EXPAND = "space,version,container"; From 13f5b5fc00053428e2f87197b0778e77bf866a9d Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Sun, 15 Oct 2023 19:44:30 +0200 Subject: [PATCH 03/17] refactor: start replacing OkHttp with built-ih Http Client working on #296 --- .../rest/AbstractRESTConfluenceService.java | 287 +++++++++--------- .../rest/RESTConfluenceService.java | 22 +- 2 files changed, 158 insertions(+), 151 deletions(-) diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java index 81bc6a6d..46560ced 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java @@ -5,7 +5,7 @@ */ package org.bsc.confluence.rest; -import okhttp3.*; +import okhttp3.HttpUrl; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceUtils; @@ -16,14 +16,20 @@ import javax.json.stream.JsonParsingException; import java.io.IOException; import java.io.Reader; -import java.util.List; -import java.util.Optional; +import java.io.StringReader; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; import static java.lang.String.format; +import static java.util.Collections.emptyMap; /** * AbstractRESTConfluenceService is an abstract class that implements the IdHelper interface. @@ -35,17 +41,17 @@ public abstract class AbstractRESTConfluenceService implements IdHelper { private static final String EXPAND = "space,version,container"; - protected final OkHttpClient.Builder client = new OkHttpClient.Builder(); + protected HttpClient client = HttpClient.newHttpClient(); public abstract ConfluenceService.Credentials getCredentials(); - protected abstract HttpUrl.Builder urlBuilder(); + protected abstract URI urlBuilder() throws URISyntaxException; @SuppressWarnings("serial") public static class ServiceException extends Error { - public final Response res; + public final HttpResponse res; - public ServiceException(String message, Response res ) { + public ServiceException(String message, HttpResponse res ) { super(message); this.res = res; } @@ -57,110 +63,86 @@ public ServiceException(String message, Response res ) { * @param req * @return */ - public CompletableFuture fromRequestAsync( final Request req ) { - - final CompletableFuture result = new CompletableFuture(); - - client.build().newCall(req).enqueue( new Callback() { - - @Override - public void onResponse(Call call, Response res) throws IOException { - if( !res.isSuccessful() ) { - - result.completeExceptionally( - new ServiceException( - format("error: %s\n%s", - res.toString(), - res.body().string()), - res)); - return; - } - - result.complete(res); - - } - - @Override - public void onFailure(Call call, IOException e) { - result.completeExceptionally( e ); - } - - }); - - return result; - + public CompletableFuture> fromRequestAsync(final HttpRequest req ) { + + return client.sendAsync(req, HttpResponse.BodyHandlers.ofString()) + .thenApply( (res) -> { + int statusCode = res.statusCode(); + if (statusCode >= 300 ) { + throw new ServiceException( + format("error: %s\n%s\n%s", req.uri(), res,res.body()), res); + } + return res; + }); } - public void fromRequest(final Request req, final String description, Consumer consumer) { + public void fromRequest(final HttpRequest req, final String description, Consumer> consumer) { - try(final Response res = client.build().newCall(req).execute()) { + try{ + final HttpResponse res = client.send( req , HttpResponse.BodyHandlers.ofString()); - if( !res.isSuccessful() ) { - throw new ServiceException( - format("error: %s\n%s\n%s", description, res.toString(),res.body().string()), res); + int statusCode = res.statusCode(); + if (statusCode >= 300 ) { + throw new ServiceException( + format("error: %s\n%s\n%s", description, res,res.body()), res); } consumer.accept(res); - } catch (IOException ex) { + } catch (Exception ex) { throw new Error(ex); } } - protected void fromUrlGET( final HttpUrl url, final String description, Consumer consumer ) { - final Request req = new Request.Builder() - .url( url ) - .get() + protected void fromUrlGET(final URI url, final String description, Consumer> consumer ) { + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() .build(); fromRequest(req, description, consumer); } - protected void fromUrlDELETE( final HttpUrl url, final String description, Consumer consumer ) { - final Request req = new Request.Builder() - .url( url ) - .delete() + protected void fromUrlDELETE( final URI url, final String description, Consumer> consumer ) { + final var req = HttpRequest.newBuilder() + .uri(url) + .DELETE() .build(); fromRequest(req, description, consumer); } - protected void fromUrlPOST( final HttpUrl url, RequestBody inputBody, final String description, Consumer consumer ) { - final Request req = new Request.Builder() - .header("X-Atlassian-Token","nocheck") - .url( url ) - .post( inputBody) + protected void fromUrlPOST(final URI url, HttpRequest.BodyPublisher inputBody, final String description, Consumer> consumer ) { + final var req = HttpRequest.newBuilder() + .uri(url) + .POST( inputBody ) .build(); fromRequest(req, description, consumer); } - protected void fromUrlPUT( final HttpUrl url, RequestBody inputBody, final String description, Consumer consumer ) { - final Request req = new Request.Builder() + protected void fromUrlPUT( final URI url, HttpRequest.BodyPublisher inputBody, final String description, Consumer> consumer ) { + final var req = HttpRequest.newBuilder() .header("X-Atlassian-Token","nocheck") - .url( url ) - .put( inputBody) + .uri( url ) + .PUT( inputBody) .build(); fromRequest(req, description, consumer); } - protected void debugBody( Response res ) { - - final ResponseBody body = res.body(); + protected void debugBody( HttpResponse res ) { - try { - System.out.printf( "BODY\n%s\n", new String(body.bytes()) ); - } catch (IOException e) { - System.out.printf( "READ BODY EXCEPTION\n%s\n", e.getMessage() ); - } + final var body = res.body(); + System.out.printf( "BODY\n%s\n", body ); } - protected Stream mapToStream( Response res) { + protected Stream mapToStream( HttpResponse res) { + + final var body = res.body(); - try (final ResponseBody body = res.body(); - final Reader r = body.charStream(); + try( final Reader r = new StringReader(body); final JsonReader rdr = Json.createReader(r) ) { @@ -189,16 +171,14 @@ protected Stream mapToStream( Response res) { } - protected JsonObject mapToObject(Response res ) { - final ResponseBody body = res.body(); + protected JsonObject mapToObject(HttpResponse res ) { + final var body = res.body(); - try (Reader r = body.charStream()) { + try (Reader r = new StringReader(body)) { final JsonReader rdr = Json.createReader(r); - final JsonObject root = rdr.readObject(); - - return root; + return rdr.readObject(); } catch (IOException ex) { @@ -206,15 +186,55 @@ protected JsonObject mapToObject(Response res ) { } }; + private URI buildUrl( List path, Map query) { + + try { + final var url = urlBuilder(); + + final var previousPath = url.getPath(); + var newPath = previousPath; + if( !path.isEmpty() ) { + newPath = String.join("/", path); + + if (previousPath != null) { + newPath = format("%s/%s", previousPath, newPath); + } + } + + final var previousQuery = url.getQuery(); + var newQuery = previousQuery; + if( !query.isEmpty() ) { + newQuery = query.entrySet().stream() + .map(kv -> format("%s=%s", kv.getKey(), kv.getValue())) + .collect(Collectors.joining("&")); + + if (previousQuery != null) { + newQuery = format("%s&%s", previousQuery, newQuery); + } + } + + return new URI( + url.getScheme(), + url.getUserInfo(), + url.getHost(), + url.getPort(), + newPath, // path + newQuery, // query + url.getFragment() + ); + + } + catch( URISyntaxException ex ) { + throw new Error(ex); + } + + + } protected CompletableFuture> findPageById( final String id ) { final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addQueryParameter("expand", EXPAND) - .build(); + final var url = buildUrl( List.of( "content", id ), Map.of( "expand", EXPAND )); fromUrlGET( url, "find page", res -> result.complete(Stream.of(res).flatMap(this::mapToStream).findFirst()) ); @@ -226,12 +246,11 @@ protected CompletableFuture> findPageById( final String id protected CompletableFuture> findPages( final String spaceKey, final String title ) { final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addQueryParameter("spaceKey", spaceKey) - .addQueryParameter("title", title) - .addQueryParameter("expand", EXPAND) - .build(); + + final var url = buildUrl( + List.of( "content" ), + Map.of( "spaceKey", spaceKey, "title", title, "expand", EXPAND )); + fromUrlGET( url, "find pages", res -> result.complete( Stream.of(res).flatMap(this::mapToStream).collect( Collectors.toList()))); return result; @@ -241,13 +260,9 @@ protected CompletableFuture> descendantPages( final long id ) { final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(String.valueOf(id)) - //.addPathSegments("descendant/page") - .addPathSegments("child/page") - .addQueryParameter("expand", EXPAND) - .build(); + final var url = buildUrl( + List.of( "content", String.valueOf(id), "child", "page" ), + Map.of( "expand", EXPAND )); fromUrlGET( url, "get descendant pages", res -> result.complete( @@ -265,12 +280,11 @@ protected CompletableFuture> descendantPages( final long id ) { protected CompletableFuture> childrenPages( final String id ) { final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addPathSegments("child/page") - .addQueryParameter("expand", EXPAND) - .build(); + + final var url = buildUrl( + List.of( "content", id, "child", "page" ), + Map.of( "expand", EXPAND )); + fromUrlGET( url, "get children pages", res -> result.complete(Stream.of(res).flatMap(this::mapToStream).collect( Collectors.toList() ))); @@ -291,11 +305,11 @@ public CompletableFuture> findPage( final String spaceKey, protected CompletableFuture deletePageById( final String id ) { final CompletableFuture result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - //.addQueryParameter("status", "") - .build(); + + final var url = buildUrl( + List.of( "content",id ), + emptyMap()); + fromUrlDELETE( url, "delete page", res -> result.complete(true) ); return result; @@ -313,9 +327,9 @@ public final CompletableFuture> createPage( final JsonObjec final RequestBody inputBody = RequestBody.create(inputData.toString(), storageFormat); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .build(); + final var url = buildUrl( + List.of( "content" ), + emptyMap()); fromUrlPOST(url, inputBody, "create page", res -> result.complete(Stream.of(res).map(this::mapToObject).findFirst())); @@ -331,10 +345,9 @@ protected CompletableFuture> updatePage( final String pageI final RequestBody inputBody = RequestBody.create(inputData.toString(), storageFormat); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(pageId) - .build(); + final var url = buildUrl( + List.of( "content", pageId ), + emptyMap()); fromUrlPUT(url, inputBody, "update page", res -> result.complete(Stream.of(res).map(this::mapToObject).findFirst())); @@ -370,11 +383,9 @@ protected final CompletableFuture addLabels( String id, String ...labels final RequestBody inputBody = RequestBody.create(inputData.toString(), storageFormat); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addPathSegment("label") - .build(); + final var url = buildUrl( + List.of( "content", id, "label" ), + emptyMap()); fromUrlPOST(url, inputBody, "add label", res -> result.complete(null)); @@ -385,12 +396,9 @@ protected CompletableFuture> getAttachments( final String id ) final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addPathSegments("child/attachment") - .addQueryParameter("expand", EXPAND) - .build(); + final var url = buildUrl( + List.of( "content", id, "child", "attachment" ), + Map.of( "expand", EXPAND )); fromUrlGET( url, "get attachments", res -> result.complete( Stream.of(res).flatMap(this::mapToStream).collect(Collectors.toList()))); @@ -402,13 +410,9 @@ protected CompletableFuture> getAttachment( final String id, fi final CompletableFuture> result = new CompletableFuture<>(); - final HttpUrl url = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addPathSegments("child/attachment") - .addQueryParameter("filename", fileName) - .addQueryParameter("expand", EXPAND) - .build(); + final var url = buildUrl( + List.of( "content", id, "child", "attachment" ), + Map.of( "filename", fileName, "expand", EXPAND )); fromUrlGET( url, "get attachment", res -> result.complete(Stream.of(res).flatMap(this::mapToStream).collect(Collectors.toList()))); @@ -435,17 +439,16 @@ protected CompletableFuture> addAttachment( final String id, fi .addFormDataPart("file", att.getFileName(), fileBody) .build(); - final HttpUrl.Builder builder = urlBuilder() - .addPathSegment("content") - .addPathSegment(id) - .addPathSegments("child/attachment"); - if( att.getId() != null ) { - builder.addPathSegment( att.getId() ) - .addPathSegment("data"); + final var path = ( att.getId() != null ) ? + List.of( "content", id, "child", "attachment", att.getId(), "data" ) : + List.of( "content", id, "child", "attachment"); + + final var url = buildUrl( + path, + emptyMap()); - } - fromUrlPOST(builder.build(), inputBody, "create attachment", res -> + fromUrlPOST(url, inputBody, "create attachment", res -> result.complete( Stream.of(res).flatMap( post -> (att.getId() != null) ? Stream.of(mapToObject(post)) diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java index 6692532c..54d3dfc6 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java @@ -5,7 +5,6 @@ */ package org.bsc.confluence.rest; -import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import org.bsc.confluence.ConfluenceService; @@ -20,6 +19,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -149,7 +150,7 @@ public final CompletableFuture createPageByTitle(String spaceKey, St * @return */ @Override - protected HttpUrl.Builder urlBuilder() { + protected URI urlBuilder() throws URISyntaxException { int port = endpoint.getPort(); port = (port > -1) ? port : endpoint.getDefaultPort(); @@ -158,13 +159,16 @@ protected HttpUrl.Builder urlBuilder() { path = (path.startsWith("/")) ? path.substring(1) : path; - return new HttpUrl.Builder() - .scheme(endpoint.getProtocol()) - .host(endpoint.getHost()) - .port(port) - .addPathSegments(path) - //.addPathSegments(ConfluenceService.Protocol.REST.path()) - ; + return new URI( + endpoint.getProtocol(), + null, // user info, + endpoint.getHost(), + port, + path, + null, // query + null // fragment + ); + } @Override From 6347e579e1b0a2f9f15af2c20fd332032137eab1 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Sun, 15 Oct 2023 23:36:27 +0200 Subject: [PATCH 04/17] refactor: continue replacing OkHttp with built-ih Http Client working on #296 --- pom.xml | 6 +- service-rest-api/pom.xml | 2 + .../rest/AbstractRESTConfluenceService.java | 183 ++++++++++-------- .../rest/RESTConfluenceService.java | 99 +++++++--- 4 files changed, 176 insertions(+), 114 deletions(-) diff --git a/pom.xml b/pom.xml index 3bbdf84d..36bc28a2 100644 --- a/pom.xml +++ b/pom.xml @@ -30,15 +30,11 @@ test-publishing test-plugin processor-freemarker - addon-scrollversions processor-commonmark gitlog+jira service-rest-api service-xmlrpc-api - + scm:git:https://github.com/bsorrentino/maven-confluence-plugin.git diff --git a/service-rest-api/pom.xml b/service-rest-api/pom.xml index 7ef78ad1..ca71b99b 100644 --- a/service-rest-api/pom.xml +++ b/service-rest-api/pom.xml @@ -17,11 +17,13 @@ + com.squareup.okhttp3 okhttp + org.bsc.maven maven-confluence-core diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java index 46560ced..2005e33d 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java @@ -5,7 +5,6 @@ */ package org.bsc.confluence.rest; -import okhttp3.HttpUrl; import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceUtils; @@ -22,7 +21,11 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import java.util.*; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -41,7 +44,7 @@ public abstract class AbstractRESTConfluenceService implements IdHelper { private static final String EXPAND = "space,version,container"; - protected HttpClient client = HttpClient.newHttpClient(); + protected HttpClient client; public abstract ConfluenceService.Credentials getCredentials(); @@ -58,13 +61,47 @@ public ServiceException(String message, HttpResponse res ) { } + public static class MultiPartBodyBuilder { + private final StringBuilder formData = new StringBuilder(); + private static final String LINE_FEED = "\r\n"; + public final String boundary = UUID.randomUUID().toString(); + + public MultiPartBodyBuilder addFormDataPart( final String name, final String value ) { + formData + .append( "--").append(boundary).append(LINE_FEED) + .append( "Content-Disposition: form-data; name=\"").append(name).append("\"").append(LINE_FEED).append(LINE_FEED) + //.append( "Content-Type: text/plain; charset=UTF-8").append(LINE_FEED).append(LINE_FEED) + .append(value).append(LINE_FEED) + ; + return this; + } + + public MultiPartBodyBuilder addFormFilePart( final String fieldName, final String fileName, final String mimeType, final java.io.InputStream data ) throws IOException { + + formData + .append("--").append(boundary).append(LINE_FEED) + .append(format("Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"", fieldName, fileName)).append(LINE_FEED) + .append(format("Content-Type: %s", mimeType)).append(LINE_FEED).append(LINE_FEED) + .append( IOUtils.toCharArray(data, StandardCharsets.UTF_8) ).append(LINE_FEED) + .append("--").append(boundary).append(LINE_FEED) + ; + + return this; + } + + public String build() { + return formData.toString(); + } + } + /** * * @param req * @return */ - public CompletableFuture> fromRequestAsync(final HttpRequest req ) { + protected CompletableFuture> fromRequestAsync(final HttpRequest.Builder reqBuilder) { + final var req = reqBuilder.build(); return client.sendAsync(req, HttpResponse.BodyHandlers.ofString()) .thenApply( (res) -> { int statusCode = res.statusCode(); @@ -76,10 +113,11 @@ public CompletableFuture> fromRequestAsync(final HttpReques }); } - public void fromRequest(final HttpRequest req, final String description, Consumer> consumer) { + protected void fromRequest(final HttpRequest.Builder reqBuilder, final String description, Consumer> consumer) { try{ - final HttpResponse res = client.send( req , HttpResponse.BodyHandlers.ofString()); + + final HttpResponse res = client.send( reqBuilder.build() , HttpResponse.BodyHandlers.ofString()); int statusCode = res.statusCode(); if (statusCode >= 300 ) { @@ -94,50 +132,15 @@ public void fromRequest(final HttpRequest req, final String description, Consume } - protected void fromUrlGET(final URI url, final String description, Consumer> consumer ) { + private void fromUrlGET(final URI url, final String description, Consumer> consumer ) { final var req = HttpRequest.newBuilder() .uri(url) .GET() - .build(); - - fromRequest(req, description, consumer); - } - - protected void fromUrlDELETE( final URI url, final String description, Consumer> consumer ) { - final var req = HttpRequest.newBuilder() - .uri(url) - .DELETE() - .build(); + ; fromRequest(req, description, consumer); } - protected void fromUrlPOST(final URI url, HttpRequest.BodyPublisher inputBody, final String description, Consumer> consumer ) { - final var req = HttpRequest.newBuilder() - .uri(url) - .POST( inputBody ) - .build(); - - fromRequest(req, description, consumer); - } - - protected void fromUrlPUT( final URI url, HttpRequest.BodyPublisher inputBody, final String description, Consumer> consumer ) { - final var req = HttpRequest.newBuilder() - .header("X-Atlassian-Token","nocheck") - .uri( url ) - .PUT( inputBody) - .build(); - - fromRequest(req, description, consumer); - } - - protected void debugBody( HttpResponse res ) { - - final var body = res.body(); - System.out.printf( "BODY\n%s\n", body ); - - } - protected Stream mapToStream( HttpResponse res) { final var body = res.body(); @@ -310,7 +313,12 @@ protected CompletableFuture deletePageById( final String id ) { List.of( "content",id ), emptyMap()); - fromUrlDELETE( url, "delete page", res -> result.complete(true) ); + final var req = HttpRequest.newBuilder() + .uri(url) + .DELETE() + ; + + fromRequest(req, "delete page", res -> result.complete(true) ); return result; } @@ -323,15 +331,19 @@ protected CompletableFuture deletePageById( final String id ) { public final CompletableFuture> createPage( final JsonObject inputData ) { final CompletableFuture> result = new CompletableFuture<>(); - final MediaType storageFormat = MediaType.parse("application/json"); - - final RequestBody inputBody = RequestBody.create(inputData.toString(), storageFormat); + final var inputBody = HttpRequest.BodyPublishers.ofString(inputData.toString(), StandardCharsets.UTF_8); final var url = buildUrl( List.of( "content" ), emptyMap()); - fromUrlPOST(url, inputBody, "create page", res -> + final var req = HttpRequest.newBuilder() + .header("Content-Type", "application/json") + .uri(url) + .POST( inputBody ) + ; + + fromRequest(req, "create page", res -> result.complete(Stream.of(res).map(this::mapToObject).findFirst())); return result; @@ -341,15 +353,20 @@ protected CompletableFuture> updatePage( final String pageI final CompletableFuture> result = new CompletableFuture<>(); - final MediaType storageFormat = MediaType.parse("application/json"); - - final RequestBody inputBody = RequestBody.create(inputData.toString(), storageFormat); + final var inputBody = HttpRequest.BodyPublishers.ofString(inputData.toString(), StandardCharsets.UTF_8); final var url = buildUrl( List.of( "content", pageId ), emptyMap()); - fromUrlPUT(url, inputBody, "update page", res -> + final var req = HttpRequest.newBuilder() + .header("X-Atlassian-Token","nocheck") + .header("Content-Type", "application/json") + .uri( url ) + .PUT( inputBody) + ; + + fromRequest(req, "update page", res -> result.complete(Stream.of(res).map(this::mapToObject).findFirst())); return result; @@ -378,16 +395,19 @@ protected final CompletableFuture addLabels( String id, String ...labels final JsonArray inputData = inputBuilder.build(); - final MediaType storageFormat = MediaType.parse("application/json"); - - final RequestBody inputBody = - RequestBody.create(inputData.toString(), storageFormat); + final var inputBody = HttpRequest.BodyPublishers.ofString(inputData.toString(), StandardCharsets.UTF_8); final var url = buildUrl( List.of( "content", id, "label" ), emptyMap()); - fromUrlPOST(url, inputBody, "add label", res -> result.complete(null)); + final var req = HttpRequest.newBuilder() + .header("Content-Type", "application/json") + .uri(url) + .POST( inputBody ) + ; + + fromRequest(req, "add label", res -> result.complete(null)); return result; } @@ -420,40 +440,41 @@ protected CompletableFuture> getAttachment( final String id, fi return result; } + protected CompletableFuture> addAttachment( final String id, final Attachment att, final java.io.InputStream data ) { final CompletableFuture> result = new CompletableFuture<>(); - final RequestBody fileBody; - try { - fileBody = RequestBody.create( IOUtils.toByteArray(data), MediaType.parse(att.getContentType()) ); - } catch (IOException ex) { - throw new Error( ex ); - } - - final RequestBody inputBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart("comment", att.getComment()) - .addFormDataPart("minorEdit", "true") - .addFormDataPart("file", att.getFileName(), fileBody) - .build(); - - final var path = ( att.getId() != null ) ? + var formData = new MultiPartBodyBuilder() + .addFormDataPart( "comment", att.getComment() ) + .addFormDataPart( "minorEdit", "true" ) + .addFormFilePart( "file", att.getFileName(), att.getContentType(), data) + ; + final var path = ( att.getId() != null ) ? List.of( "content", id, "child", "attachment", att.getId(), "data" ) : List.of( "content", id, "child", "attachment"); - final var url = buildUrl( - path, - emptyMap()); + final var url = buildUrl( + path, + emptyMap()); + + final var req = HttpRequest.newBuilder() + .headers("Content-Type","multipart/form-data","boundary",formData.boundary) + .uri(url) + .POST( HttpRequest.BodyPublishers.ofString(formData.build(), StandardCharsets.UTF_8) ) + ; + fromRequest(req, "create page", res -> + result.complete( Stream.of(res).flatMap( post -> + (att.getId() != null) + ? Stream.of(mapToObject(post)) + : mapToStream(post)) + .collect( Collectors.toList() ))); - fromUrlPOST(url, inputBody, "create attachment", res -> - result.complete( Stream.of(res).flatMap( post -> - (att.getId() != null) - ? Stream.of(mapToObject(post)) - : mapToStream(post)) - .collect( Collectors.toList() ))); + } catch (IOException ex) { + result.completeExceptionally(ex); + } return result; diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java index 54d3dfc6..0b5c2c7a 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java @@ -5,8 +5,6 @@ */ package org.bsc.confluence.rest; -import okhttp3.OkHttpClient; -import okhttp3.Request; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.rest.model.Attachment; import org.bsc.confluence.rest.model.Blogpost; @@ -16,15 +14,22 @@ import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; +import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; +import java.net.*; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.time.Duration; +import java.util.Base64; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -43,9 +48,9 @@ public enum ContentType {page, blogpost} final java.net.URL endpoint; - static { - Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE); - } +// static { +// Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE); +// } /** * @param url @@ -72,32 +77,70 @@ public RESTConfluenceService(String url, Credentials credentials, SSLCertificate this.credentials = credentials; - client.connectTimeout(ConfluenceService.getConnectTimeout(TimeUnit.SECONDS), TimeUnit.SECONDS); - client.writeTimeout(ConfluenceService.getWriteTimeout(TimeUnit.SECONDS), TimeUnit.SECONDS); - client.readTimeout(ConfluenceService.getReadTimeout(TimeUnit.SECONDS), TimeUnit.SECONDS); + var clientBuilder = HttpClient.newBuilder() + .connectTimeout(Duration.ofSeconds(ConfluenceService.getConnectTimeout(TimeUnit.SECONDS))) + ; + // client.writeTimeout(ConfluenceService.getWriteTimeout(TimeUnit.SECONDS), TimeUnit.SECONDS); + // client.readTimeout(ConfluenceService.getReadTimeout(TimeUnit.SECONDS), TimeUnit.SECONDS); if (!sslInfo.isIgnore() && "https".equals(this.endpoint.getProtocol())) { - client.hostnameVerifier(sslInfo.getHostnameVerifier()) - .sslSocketFactory(sslInfo.getSSLSocketFactory(), sslInfo.getTrustManager()) - ; + try { + var sslContext = SSLContext.getInstance("TLSv1.3"); + sslContext.init(null, null, null); + + clientBuilder.sslContext( sslContext ); + + } catch (NoSuchAlgorithmException | KeyManagementException e) { + throw new Error(e); + } + + +// clientBuilder.hostnameVerifier(sslInfo.getHostnameVerifier()) +// .sslSocketFactory(sslInfo.getSSLSocketFactory(), sslInfo.getTrustManager()) +// ; } // Use interceptor which transparently adds credentials and HTTP headers for each request - client.addInterceptor(chain -> { - Request.Builder requestBuilder = chain.request().newBuilder(); - if (credentials.username != null) { - final String credential = - okhttp3.Credentials.basic(credentials.username, credentials.password); - requestBuilder.header("Authorization", credential); - } - if (!credentials.httpHeaders.isEmpty()) { - credentials.httpHeaders.entrySet().forEach(entry -> - requestBuilder.header(entry.getKey(), entry.getValue())); - } - return chain.proceed(requestBuilder.build()); - }); +// clientBuilder.addInterceptor(chain -> { +// Request.Builder requestBuilder = chain.request().newBuilder(); +// if (credentials.username != null) { +// final String credential = +// okhttp3.Credentials.basic(credentials.username, credentials.password); +// requestBuilder.header("Authorization", credential); +// } +// if (!credentials.httpHeaders.isEmpty()) { +// credentials.httpHeaders.entrySet().forEach(entry -> +// requestBuilder.header(entry.getKey(), entry.getValue())); +// } +// return chain.proceed(requestBuilder.build()); +// }); + + client = clientBuilder.build(); + } + private HttpRequest.Builder processHeaderBeforeRequest( HttpRequest.Builder reqBuilder ) { + if (credentials.username != null) { + final String credential = + "Basic " + Base64.getEncoder().encodeToString((credentials.username + ":" + credentials.password).getBytes()); + reqBuilder.header("Authorization", credential); + } + if (!credentials.httpHeaders.isEmpty()) { + credentials.httpHeaders.forEach(reqBuilder::header); + } + + return reqBuilder; + } + + @Override + protected void fromRequest(HttpRequest.Builder reqBuilder, String description, Consumer> consumer) { + processHeaderBeforeRequest(reqBuilder); + super.fromRequest(reqBuilder, description, consumer); + } + + @Override + protected CompletableFuture> fromRequestAsync(HttpRequest.Builder reqBuilder) { + return super.fromRequestAsync(processHeaderBeforeRequest(reqBuilder)); } @SuppressWarnings("unchecked") @@ -157,7 +200,7 @@ protected URI urlBuilder() throws URISyntaxException { String path = endpoint.getPath(); - path = (path.startsWith("/")) ? path.substring(1) : path; + // path = (path.startsWith("/")) ? path.substring(1) : path; return new URI( endpoint.getProtocol(), From 20a8d9fede25454d2f77f189d733f690a5e2ce9e Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Mon, 16 Oct 2023 17:55:19 +0200 Subject: [PATCH 05/17] refactor: complete replacing OkHttp with built-ih Http Client resolve #296 --- .../ScrollVersionsConfluenceService.java | 240 ++++++---- .../kotlin/org/bsc/reporting/Issue133Test.kt | 65 ++- pom.xml | 8 +- service-rest-api/pom.xml | 7 - .../rest/AbstractRESTConfluenceService.java | 218 ++++----- .../org/bsc/confluence/rest/FormBody.java | 37 ++ .../rest/MultipartFormDataBodyPublisher.java | 444 ++++++++++++++++++ .../rest/RESTConfluenceService.java | 2 +- 8 files changed, 764 insertions(+), 257 deletions(-) create mode 100644 service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java create mode 100644 service-rest-api/src/main/java/org/bsc/confluence/rest/MultipartFormDataBodyPublisher.java diff --git a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java index d902e992..f89694f0 100644 --- a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java +++ b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java @@ -1,8 +1,8 @@ package org.bsc.confluence.rest.scrollversions; import com.fasterxml.jackson.databind.ObjectMapper; -import okhttp3.*; import org.bsc.confluence.ConfluenceService; +import org.bsc.confluence.rest.FormBody; import org.bsc.confluence.rest.RESTConfluenceService; import org.bsc.confluence.rest.scrollversions.model.ScrollVersions; import org.bsc.ssl.SSLCertificateInfo; @@ -10,10 +10,12 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; +import java.net.http.HttpRequest; +import java.nio.charset.StandardCharsets; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import java.util.regex.Pattern; @@ -39,8 +41,6 @@ enum ChangeType { } } - - static final MediaType JSON_MEDIA_TYPE = MediaType.parse("application/json; charset=utf-8"); static final String REQUEST_BODY_FORMAT = "[{\"queryArg\": \"%s\", \"value\": \"%s\"}]"; final RESTConfluenceService delegate; @@ -72,23 +72,31 @@ public ScrollVersionsConfluenceService( String confluenceUrl, } - private HttpUrl.Builder urlBuilder() { + private URI urlBuilder() throws URISyntaxException { int port = scrollVersionsUrl.getPort(); port = (port > -1 ) ? port : scrollVersionsUrl.getDefaultPort(); - return new HttpUrl.Builder().scheme(scrollVersionsUrl.getProtocol()) - .host(scrollVersionsUrl.getHost()) - .port(port) - .addPathSegments(scrollVersionsUrl.getPath().replaceAll("^/+", "")); - } - - - private Request.Builder requestBuilder() { - final var credentials = getCredentials(); - return new Request.Builder() - .header("Authorization", okhttp3.Credentials.basic(credentials.username, credentials.password)) - .header("X-Atlassian-Token", "nocheck"); + return new URI( + scrollVersionsUrl.getProtocol(), + null, // user info, + scrollVersionsUrl.getHost(), + port, + scrollVersionsUrl.getPath(), + null, // query + null // fragment + ); + } + + + private HttpRequest.Builder newRequestBuilder() { +// final var credentials = getCredentials(); +// final String auth = +// "Basic " + Base64.getEncoder().encodeToString((credentials.username + ":" + credentials.password).getBytes()); + return HttpRequest.newBuilder() + //.header("Authorization", auth) + .header("X-Atlassian-Token", "nocheck") + ; } /** @@ -114,9 +122,6 @@ CompletableFuture getCurrentVersion(String spaceKe completeExceptionally( new Exception(format("version [%s] doesn't exists!", versionName)) ) ) )); - - - } /** @@ -126,43 +131,46 @@ CompletableFuture getCurrentVersion(String spaceKe */ CompletableFuture> getScrollVersions(String spaceKey) { + try { + var url = RESTConfluenceService.buildUrl( + urlBuilder(), + List.of("versions", spaceKey), + Map.of()); - final var httpUrl = - urlBuilder() - .addPathSegment("versions") - .addPathSegment(spaceKey) - .build(); - final var request = requestBuilder() - .url(httpUrl) - .get() - .build(); + final var request = newRequestBuilder() + .uri(url) + .GET(); - //debug( "getScrollVersions( '%s' )",spaceKey ); - return delegate.fromRequestAsync(request).thenCompose( response -> { + //debug( "getScrollVersions( '%s' )",spaceKey ); + return delegate.fromRequestAsync(request).thenCompose(response -> { - final var futureResult = new CompletableFuture>(); + final var futureResult = new CompletableFuture>(); - return ofNullable(response.body()).map(b -> { + return ofNullable(response.body()).map(responseBodyString -> { - try { - final var responseBodyString = b.string(); - //trace( "getScrollVersions response\n%s", responseBodyString ); - final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Version[].class); + try { - futureResult.complete(asList(result)); + //trace( "getScrollVersions response\n%s", responseBodyString ); + final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Version[].class); - } catch (IOException e) { - futureResult.completeExceptionally(e); - } + futureResult.complete(asList(result)); - return futureResult; + } catch (IOException e) { + futureResult.completeExceptionally(e); + } - }).orElseGet(() -> { - futureResult.completeExceptionally(new Exception("could not retrieve versions info!")); - return futureResult; - }); + return futureResult; - }); + }).orElseGet(() -> { + futureResult.completeExceptionally(new Exception("could not retrieve versions info!")); + return futureResult; + }); + + }); + } + catch( URISyntaxException e ) { + return CompletableFuture.failedFuture(e); + } } /** @@ -172,38 +180,46 @@ CompletableFuture> getScrollVersions(String s */ CompletableFuture> getVersionsPages(String spaceKey, String queryArg, String value) { - final var httpUrl = - urlBuilder() - .addPathSegment("page") - .addPathSegment(spaceKey) - .build(); + URI url; + + try { + url = RESTConfluenceService.buildUrl( + urlBuilder(), + List.of( "page", spaceKey), + Map.of()) + ; + } + catch( URISyntaxException e ) { + return CompletableFuture.failedFuture(e); + } - final var body = RequestBody.create(format(REQUEST_BODY_FORMAT, queryArg, value), JSON_MEDIA_TYPE ); + final var body = HttpRequest.BodyPublishers.ofString(format(REQUEST_BODY_FORMAT, queryArg, value), StandardCharsets.UTF_8); - final var request = requestBuilder() - .url(httpUrl) - .post(body) - .build(); + final var request = newRequestBuilder() + .header("Content-Type", "application/json") + .uri(url) + .POST(body) + ; //debug( "getVersionPage( '%s', '%', '%s')",spaceKey, queryArg, value ); - return delegate.fromRequestAsync(request).thenCompose( response -> { + return delegate.fromRequestAsync(request).thenCompose(response -> { final var futureResult = new CompletableFuture>(); - return ofNullable(response.body()).map( b -> { + return ofNullable(response.body()).map(responseBodyString -> { try { - final var responseBodyString = b.string(); + //trace( "getVersionsPages response\n%s", responseBodyString ); final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); - futureResult.complete( asList(result) ); + futureResult.complete(asList(result)); } catch (IOException e) { - futureResult.completeExceptionally( e ); + futureResult.completeExceptionally(e); } return futureResult; - }).orElseGet( () -> { + }).orElseGet(() -> { futureResult.completeExceptionally(new Exception("could not retrieve versions info!s")); return futureResult; }); @@ -220,27 +236,34 @@ CompletableFuture> getVersionsPages(String space */ CompletableFuture> getVersionPage(String spaceKey, String title) { - final var httpUrl = - urlBuilder() - .addPathSegment("page") - .addPathSegment(spaceKey) - .build(); + URI url; + + try { + url = RESTConfluenceService.buildUrl( + urlBuilder(), + List.of("page", spaceKey), + Map.of()); + } + catch( URISyntaxException e ) { + return CompletableFuture.failedFuture(e); + } - final var body = RequestBody.create(format(REQUEST_BODY_FORMAT, "scrollPageTitle", title), JSON_MEDIA_TYPE ); + final var body = HttpRequest.BodyPublishers.ofString(format(REQUEST_BODY_FORMAT, "scrollPageTitle", title), StandardCharsets.UTF_8); - final var request = requestBuilder() - .url(httpUrl) - .post(body) - .build(); + final var request = newRequestBuilder() + .header("Content-Type", "application/json") + .uri(url) + .POST(body) + ; //debug( "getVersionPage( '%s', '%s')",spaceKey, title ); return delegate.fromRequestAsync(request).thenCompose( response -> { final var futureResult = new CompletableFuture>(); - return ofNullable(response.body()).map( b -> { + return ofNullable(response.body()).map( responseBodyString -> { try { - final var responseBodyString = b.string(); + //trace( "getVersionPage response\n%s", responseBodyString ); final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.Page[].class); @@ -309,32 +332,38 @@ CompletableFuture> getVersionPage(Stri */ CompletableFuture createVersionPage(String spaceKey, Model.ID masterPageId, String title, ScrollVersions.Model.Version version) { - final var httpUrl = - urlBuilder() - .addPathSegment("page") - .addPathSegment("new") - .addPathSegment(spaceKey) - .build(); + URI url; + + try { + url = RESTConfluenceService.buildUrl( + urlBuilder(), + List.of("page", "new", spaceKey), + Map.of()); + } + catch( URISyntaxException e ) { + return CompletableFuture.failedFuture(e); + } final var body = new FormBody.Builder() .add("parentConfluenceId", masterPageId.toString() ) .add( "versionId", version.getId() ) .add( "pageTitle", title ) - .build(); + .build() + ; - final var request = requestBuilder() - .url(httpUrl) - .post(body) - .build(); + final var request = newRequestBuilder() + .header("Content-Type", FormBody.getContentType()) + .uri(url) + .POST(body) + ; //debug( "createVersionPage( '%s', '%d', '%s', '%s')",spaceKey, masterPageId, title, version.getName() ); return delegate.fromRequestAsync(request).thenCompose( response -> { final var futureResult = new CompletableFuture(); - return ofNullable(response.body()).map( b -> { + return ofNullable(response.body()).map( responseBodyString -> { try { - final var responseBodyString = b.string(); //debug( "createVersionPage response\n%s", responseBodyString ); final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); @@ -362,33 +391,38 @@ CompletableFuture createVersionPage(String s * @return */ CompletableFuture manageVersionPage(Model.ID masterPageId, String title, ScrollVersions.Model.Version version, ChangeType changeType ) { + URI url; - final var httpUrl = - urlBuilder() - .addPathSegment("page") - .addPathSegment("modify") - .build(); + try { + url = RESTConfluenceService.buildUrl( + urlBuilder(), + List.of("page", "modify"), + Map.of()); + } + catch( URISyntaxException e ) { + return CompletableFuture.failedFuture(e); + } final var body = new FormBody.Builder() .add("masterPageId", masterPageId.toString() ) .add( "pageTitle", title) .add( "versionId", version.getId() ) .add( "changeType", changeType.typeName ) - .build(); - - final var request = requestBuilder() - .url(httpUrl) - .post(body) - .build(); + .build() + ; + final var request = newRequestBuilder() + .header("Content-Type", FormBody.getContentType()) + .uri(url) + .POST(body) + ; //debug( "manageVersionPage( '%s', '%s', '%s', '%s')",masterPageId, title, version.getName(), changeType.typeName ); return delegate.fromRequestAsync(request).thenCompose( response -> { final var futureResult = new CompletableFuture(); - return ofNullable(response.body()).map( b -> { + return ofNullable(response.body()).map( responseBodyString -> { try { - final var responseBodyString = b.string(); //trace( "manageVersionPage response\n%s", responseBodyString ); final var result = objectMapper.readValue(responseBodyString, ScrollVersions.Model.NewPageResult.class); diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt b/plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt index 1ae468ad..00a7cde3 100644 --- a/plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt +++ b/plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt @@ -5,13 +5,12 @@ */ package org.bsc.reporting - -import okhttp3.HttpUrl -import org.junit.jupiter.api.Assertions +import org.bsc.confluence.rest.RESTConfluenceService import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.net.MalformedURLException +import java.net.URI import java.net.URISyntaxException import java.net.URL @@ -27,14 +26,20 @@ class Issue133Test { @Test fun htttpUrlBuilderWithoutPort() { - assertThrows(IllegalArgumentException::class.java) { + assertThrows(URISyntaxException::class.java) { val endpoint = URL("http://localhost/confluence") assertEquals(-1, endpoint.port) - /*final HttpUrl.Builder builder = */HttpUrl.Builder() - .scheme(endpoint.protocol) - .host(endpoint.host) - .port(endpoint.port) - .addPathSegments("rest/api") + + URI( + endpoint.protocol, + null, // user info, + endpoint.host, + endpoint.port, + "rest/api", + null, // query + null // fragment + ); + } } @@ -47,14 +52,21 @@ class Issue133Test { port = if (port > -1) port else endpoint.defaultPort var path = endpoint.path path = if (path.startsWith("/")) path.substring(1) else path - val builder = HttpUrl.Builder() - .scheme(endpoint.protocol) - .host(endpoint.host) - .port(port) + + val uri = URI( + endpoint.protocol, + null, // user info, + endpoint.host, + port, + null, + null, // query + null // fragment + ); + assertEquals("confluence", path) - val url = builder - .addPathSegments(path) //.addPathSegments("rest/api") - .build() + + val url = RESTConfluenceService.buildUrl( uri, listOf( path ), mapOf() ); + assertEquals(endpoint, URL(url.toString())) } @@ -67,14 +79,21 @@ class Issue133Test { port = if (port > -1) port else endpoint.defaultPort var path = endpoint.path path = if (path.startsWith("/")) path.substring(1) else path - val builder = HttpUrl.Builder() - .scheme(endpoint.protocol) - .host(endpoint.host) - .port(port) + + val uri = URI( + endpoint.protocol, + null, // user info, + endpoint.host, + port, + path, + null, // query + null // fragment + ); + assertTrue(path.isEmpty()) - val url = builder - .addPathSegments(path) //.addPathSegments("rest/api") - .build() + + val url = RESTConfluenceService.buildUrl( uri, listOf( path ), mapOf() ); + assertEquals(endpoint, URL(url.toString())) } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 36bc28a2..72cc9360 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ gitlog+jira service-rest-api service-xmlrpc-api - + addon-scrollversions scm:git:https://github.com/bsorrentino/maven-confluence-plugin.git @@ -172,12 +172,6 @@ 3.1 - - com.squareup.okhttp3 - okhttp - 4.7.2 - - commons-io commons-io diff --git a/service-rest-api/pom.xml b/service-rest-api/pom.xml index ca71b99b..17f59743 100644 --- a/service-rest-api/pom.xml +++ b/service-rest-api/pom.xml @@ -17,13 +17,6 @@ - - - com.squareup.okhttp3 - okhttp - - - org.bsc.maven maven-confluence-core diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java index 2005e33d..c812791d 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/AbstractRESTConfluenceService.java @@ -5,7 +5,6 @@ */ package org.bsc.confluence.rest; -import org.apache.commons.io.IOUtils; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceUtils; import org.bsc.confluence.rest.model.Attachment; @@ -18,6 +17,7 @@ import java.io.StringReader; import java.net.URI; import java.net.URISyntaxException; +import java.net.URLEncoder; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -61,45 +60,12 @@ public ServiceException(String message, HttpResponse res ) { } - public static class MultiPartBodyBuilder { - private final StringBuilder formData = new StringBuilder(); - private static final String LINE_FEED = "\r\n"; - public final String boundary = UUID.randomUUID().toString(); - - public MultiPartBodyBuilder addFormDataPart( final String name, final String value ) { - formData - .append( "--").append(boundary).append(LINE_FEED) - .append( "Content-Disposition: form-data; name=\"").append(name).append("\"").append(LINE_FEED).append(LINE_FEED) - //.append( "Content-Type: text/plain; charset=UTF-8").append(LINE_FEED).append(LINE_FEED) - .append(value).append(LINE_FEED) - ; - return this; - } - - public MultiPartBodyBuilder addFormFilePart( final String fieldName, final String fileName, final String mimeType, final java.io.InputStream data ) throws IOException { - - formData - .append("--").append(boundary).append(LINE_FEED) - .append(format("Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"", fieldName, fileName)).append(LINE_FEED) - .append(format("Content-Type: %s", mimeType)).append(LINE_FEED).append(LINE_FEED) - .append( IOUtils.toCharArray(data, StandardCharsets.UTF_8) ).append(LINE_FEED) - .append("--").append(boundary).append(LINE_FEED) - ; - - return this; - } - - public String build() { - return formData.toString(); - } - } - /** * - * @param req + * @param reqBuilder * @return */ - protected CompletableFuture> fromRequestAsync(final HttpRequest.Builder reqBuilder) { + public CompletableFuture> fromRequestAsync(final HttpRequest.Builder reqBuilder) { final var req = reqBuilder.build(); return client.sendAsync(req, HttpResponse.BodyHandlers.ofString()) @@ -132,15 +98,6 @@ protected void fromRequest(final HttpRequest.Builder reqBuilder, final String de } - private void fromUrlGET(final URI url, final String description, Consumer> consumer ) { - final var req = HttpRequest.newBuilder() - .uri(url) - .GET() - ; - - fromRequest(req, description, consumer); - } - protected Stream mapToStream( HttpResponse res) { final var body = res.body(); @@ -189,49 +146,50 @@ protected JsonObject mapToObject(HttpResponse res ) { } }; - private URI buildUrl( List path, Map query) { + public static URI buildUrl( URI url, List path, Map query) throws URISyntaxException { - try { - final var url = urlBuilder(); + final var previousPath = url.getPath(); + var newPath = previousPath; + if( !path.isEmpty() ) { + newPath = String.join("/", path); - final var previousPath = url.getPath(); - var newPath = previousPath; - if( !path.isEmpty() ) { - newPath = String.join("/", path); - - if (previousPath != null) { - newPath = format("%s/%s", previousPath, newPath); - } + if (previousPath != null) { + newPath = format("%s/%s", previousPath, newPath); } + } - final var previousQuery = url.getQuery(); - var newQuery = previousQuery; - if( !query.isEmpty() ) { - newQuery = query.entrySet().stream() - .map(kv -> format("%s=%s", kv.getKey(), kv.getValue())) - .collect(Collectors.joining("&")); + final var previousQuery = url.getQuery(); + var newQuery = previousQuery; + if( !query.isEmpty() ) { + newQuery = query.entrySet().stream() + .map(kv -> format("%s=%s", kv.getKey(), kv.getValue())) + .collect(Collectors.joining("&")); - if (previousQuery != null) { - newQuery = format("%s&%s", previousQuery, newQuery); - } + if (previousQuery != null) { + newQuery = format("%s&%s", previousQuery, newQuery); } + } - return new URI( - url.getScheme(), - url.getUserInfo(), - url.getHost(), - url.getPort(), - newPath, // path - newQuery, // query - url.getFragment() - ); + return new URI( + url.getScheme(), + url.getUserInfo(), + url.getHost(), + url.getPort(), + newPath, // path + newQuery, // query + url.getFragment() + ); + + } + + private URI buildUrl( List path, Map query) { + try { + return buildUrl( urlBuilder(), path, query ); } catch( URISyntaxException ex ) { throw new Error(ex); } - - } protected CompletableFuture> findPageById( final String id ) { @@ -239,7 +197,12 @@ protected CompletableFuture> findPageById( final String id final CompletableFuture> result = new CompletableFuture<>(); final var url = buildUrl( List.of( "content", id ), Map.of( "expand", EXPAND )); - fromUrlGET( url, "find page", res -> + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req, "find page", res -> result.complete(Stream.of(res).flatMap(this::mapToStream).findFirst()) ); return result; @@ -254,8 +217,14 @@ protected CompletableFuture> findPages( final String spaceKey, List.of( "content" ), Map.of( "spaceKey", spaceKey, "title", title, "expand", EXPAND )); - fromUrlGET( url, "find pages", res -> + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req,"find pages", res -> result.complete( Stream.of(res).flatMap(this::mapToStream).collect( Collectors.toList()))); + return result; } @@ -267,14 +236,19 @@ protected CompletableFuture> descendantPages( final long id ) { List.of( "content", String.valueOf(id), "child", "page" ), Map.of( "expand", EXPAND )); - fromUrlGET( url, "get descendant pages", res -> + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req, "get descendant pages", res -> result.complete( Stream.of(res).flatMap(this::mapToStream) - .flatMap( o -> { - final long childId = IdHelper.getId( o ); - return Stream.concat(Stream.of(o), descendantPages(childId).join().stream()) ; - }) - .collect( Collectors.toList() ))); + .flatMap( o -> { + final long childId = IdHelper.getId( o ); + return Stream.concat(Stream.of(o), descendantPages(childId).join().stream()) ; + }) + .collect( Collectors.toList() ))); return result ; @@ -288,8 +262,13 @@ protected CompletableFuture> childrenPages( final String id ) { List.of( "content", id, "child", "page" ), Map.of( "expand", EXPAND )); - fromUrlGET( url, "get children pages", res -> - result.complete(Stream.of(res).flatMap(this::mapToStream).collect( Collectors.toList() ))); + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req, "get children pages", res -> + result.complete(Stream.of(res).flatMap(this::mapToStream).collect( Collectors.toList() ))); return result; } @@ -420,7 +399,12 @@ protected CompletableFuture> getAttachments( final String id ) List.of( "content", id, "child", "attachment" ), Map.of( "expand", EXPAND )); - fromUrlGET( url, "get attachments", res -> + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req, "get attachments", res -> result.complete( Stream.of(res).flatMap(this::mapToStream).collect(Collectors.toList()))); return result; @@ -434,7 +418,12 @@ protected CompletableFuture> getAttachment( final String id, fi List.of( "content", id, "child", "attachment" ), Map.of( "filename", fileName, "expand", EXPAND )); - fromUrlGET( url, "get attachment", res -> + final var req = HttpRequest.newBuilder() + .uri(url) + .GET() + ; + + fromRequest(req, "get attachment", res -> result.complete(Stream.of(res).flatMap(this::mapToStream).collect(Collectors.toList()))); return result; @@ -445,36 +434,33 @@ protected CompletableFuture> addAttachment( final String id, fi final CompletableFuture> result = new CompletableFuture<>(); - try { - var formData = new MultiPartBodyBuilder() - .addFormDataPart( "comment", att.getComment() ) - .addFormDataPart( "minorEdit", "true" ) - .addFormFilePart( "file", att.getFileName(), att.getContentType(), data) - ; - final var path = ( att.getId() != null ) ? - List.of( "content", id, "child", "attachment", att.getId(), "data" ) : - List.of( "content", id, "child", "attachment"); - - final var url = buildUrl( - path, - emptyMap()); - - final var req = HttpRequest.newBuilder() - .headers("Content-Type","multipart/form-data","boundary",formData.boundary) - .uri(url) - .POST( HttpRequest.BodyPublishers.ofString(formData.build(), StandardCharsets.UTF_8) ) + var bodyPublisher = new MultipartFormDataBodyPublisher() + .add( "comment", att.getComment() ) + .add( "minorEdit", "true") + .addStream( "file", att.getFileName(), () -> data, att.getContentType() ) ; - fromRequest(req, "create page", res -> - result.complete( Stream.of(res).flatMap( post -> - (att.getId() != null) - ? Stream.of(mapToObject(post)) - : mapToStream(post)) - .collect( Collectors.toList() ))); + final var path = ( att.getId() != null ) ? + List.of( "content", id, "child", "attachment", att.getId(), "data" ) : + List.of( "content", id, "child", "attachment"); - } catch (IOException ex) { - result.completeExceptionally(ex); - } + final var url = buildUrl( + path, + emptyMap()); + + final var req = HttpRequest.newBuilder() + .header("X-Atlassian-Token","nocheck") + .headers("Content-Type", bodyPublisher.contentType()) + .uri(url) + .POST( bodyPublisher ) + ; + + fromRequest(req, "create page", res -> + result.complete( Stream.of(res).flatMap( post -> + (att.getId() != null) + ? Stream.of(mapToObject(post)) + : mapToStream(post)) + .collect( Collectors.toList() ))); return result; diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java new file mode 100644 index 00000000..c49ec6a4 --- /dev/null +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java @@ -0,0 +1,37 @@ +package org.bsc.confluence.rest; + +import java.net.URLEncoder; +import java.net.http.HttpRequest; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.lang.String.format; + +public final class FormBody { + public static String getContentType() { + return "application/x-www-form-urlencoded"; + } + + static public class Builder { + + private final Map fields = new HashMap<>(); + + public Builder add( String name, String value ) { + fields.put(name,value); + return this; + } + + public HttpRequest.BodyPublisher build() { + return HttpRequest.BodyPublishers.ofString( + fields.entrySet().stream() + .map(kv -> format("%s=%s", + URLEncoder.encode(kv.getKey(), StandardCharsets.UTF_8), + URLEncoder.encode(kv.getValue(), StandardCharsets.UTF_8))) + .collect(Collectors.joining("&")) + ); + } + + } +} diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/MultipartFormDataBodyPublisher.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/MultipartFormDataBodyPublisher.java new file mode 100644 index 00000000..dc93ea0b --- /dev/null +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/MultipartFormDataBodyPublisher.java @@ -0,0 +1,444 @@ +package org.bsc.confluence.rest; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.net.http.HttpRequest.BodyPublisher; +import java.net.http.HttpRequest.BodyPublishers; +import java.nio.ByteBuffer; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Formatter; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.Random; +import java.util.concurrent.Flow.Subscriber; +import java.util.function.Supplier; +import java.util.StringJoiner; + +/** + * multipart/form-data BodyPublisher. + * + * inspired by + * ... + * + */ +public class MultipartFormDataBodyPublisher implements BodyPublisher { + private static String nextBoundary() { + var random = new BigInteger(128, new Random()); + try (var formatter = new Formatter()) { + return formatter.format("-----------------------------%039d", random).toString(); + } + } + + private final String boundary = nextBoundary(); + private final List parts = new ArrayList<>(); + private Charset charset; + private final BodyPublisher delegate = BodyPublishers.ofInputStream( + () -> Channels.newInputStream(new MultipartFormDataChannel(this.boundary, this.parts, this.charset))); + + /** + * Construct {@link MultipartFormDataBodyPublisher} + */ + public MultipartFormDataBodyPublisher() { + this(StandardCharsets.UTF_8); + } + + /** + * Construct {@link MultipartFormDataBodyPublisher} + * + * @param charset + * character encoding + */ + public MultipartFormDataBodyPublisher(Charset charset) { + this.charset = charset; + } + + private MultipartFormDataBodyPublisher add(Part part) { + this.parts.add(part); + return this; + } + + /** + * Add part. + * + * @param name + * field name + * @param value + * field value + * @return this + */ + public MultipartFormDataBodyPublisher add(String name, String value) { + return this.add(new StringPart(name, value, this.charset)); + } + + /** + * Add part. Content using specified path. + * + * @param name + * field name + * @param path + * field value + * @return this + */ + public MultipartFormDataBodyPublisher addFile(String name, Path path) { + return this.add(new FilePart(name, path)); + } + + /** + * Add part. Content using specified path. + * + * @param name + * field name + * @param path + * field value + * @param contentType + * Content-Type + * @return this + */ + public MultipartFormDataBodyPublisher addFile(String name, Path path, String contentType) { + return this.add(new FilePart(name, path, contentType)); + } + + /** + * Add part with {@link InputStream} + * + * @param name + * field name + * @param filename + * file name + * @param supplier + * field value + * @return this + */ + public MultipartFormDataBodyPublisher addStream(String name, String filename, Supplier supplier) { + return this.add(new StreamPart(name, filename, () -> Channels.newChannel(supplier.get()))); + } + + /** + * Add part with {@link InputStream} + * + * @param name + * field name + * @param filename + * file name + * @param supplier + * field value + * @param contentType + * Content-Type + * @return this + */ + public MultipartFormDataBodyPublisher addStream(String name, String filename, Supplier supplier, + String contentType) { + return this.add(new StreamPart(name, filename, () -> Channels.newChannel(supplier.get()), contentType)); + } + + /** + * Add part with {@link ReadableByteChannel} + * + * @param name + * field name + * @param filename + * file name + * @param supplier + * field value + * @return this + */ + public MultipartFormDataBodyPublisher addChannel(String name, String filename, + Supplier supplier) { + return this.add(new StreamPart(name, filename, supplier)); + } + + /** + * Add part with {@link ReadableByteChannel} + * + * @param name + * field name + * @param filename + * file name + * @param supplier + * field value + * @param contentType + * Content-Type + * @return this + */ + public MultipartFormDataBodyPublisher addChannel(String name, String filename, + Supplier supplier, String contentType) { + return this.add(new StreamPart(name, filename, supplier, contentType)); + } + + /** + * Get Content-Type + * + * @return Content-Type + */ + public String contentType() { + try (var formatter = new Formatter()) { + return formatter.format("multipart/form-data; boundary=%s", this.boundary).toString(); + } + } + + @Override + public void subscribe(Subscriber s) { + delegate.subscribe(s); + } + + @Override + public long contentLength() { + return delegate.contentLength(); + } + +} + +interface Part { + String name(); + + default Optional filename() { + return Optional.empty(); + } + + default Optional contentType() { + return Optional.empty(); + } + + ReadableByteChannel open() throws IOException; +} + +class StringPart implements Part { + private final String name; + private final String value; + private final Charset charset; + + StringPart(String name, String value, Charset charset) { + this.name = name; + this.value = value; + this.charset = charset; + } + + @Override + public String name() { + return this.name; + } + + @Override + public ReadableByteChannel open() throws IOException { + var input = new ByteArrayInputStream(this.value.getBytes(this.charset)); + return Channels.newChannel(input); + } +} + +class StreamPart implements Part { + private final String name; + private final String filename; + private final Supplier supplier; + private final String contentType; + + StreamPart(String name, String filename, Supplier supplier, String contentType) { + this.name = name; + this.filename = filename; + this.supplier = supplier; + this.contentType = contentType; + } + + StreamPart(String name, String filename, Supplier supplier) { + this(name, filename, supplier, "application/octet-stream"); + } + + @Override + public String name() { + return this.name; + } + + @Override + public Optional filename() { + return Optional.of(filename); + } + + @Override + public Optional contentType() { + return Optional.of(this.contentType); + } + + @Override + public ReadableByteChannel open() throws IOException { + return this.supplier.get(); + } +} + +class FilePart implements Part { + private final String name; + private final Path path; + private final String contentType; + + FilePart(String name, Path path, String contentType) { + this.name = name; + this.path = path; + this.contentType = contentType; + } + + FilePart(String name, Path path) { + this(name, path, "application/octet-stream"); + } + + @Override + public String name() { + return this.name; + } + + @Override + public Optional filename() { + return Optional.of(this.path.getFileName().toString()); + } + + @Override + public Optional contentType() { + return Optional.of(this.contentType); + } + + @Override + public ReadableByteChannel open() throws IOException { + return Files.newByteChannel(this.path); + } +} + +enum State { + Boundary, Headers, Body, Done, +} + +class MultipartFormDataChannel implements ReadableByteChannel { + private static final Charset LATIN1 = StandardCharsets.ISO_8859_1; + private boolean closed = false; + private State state = State.Boundary; + private final String boundary; + private final Iterator parts; + private ByteBuffer buf = ByteBuffer.allocate(0); + private Part current = null; + private ReadableByteChannel channel = null; + private final Charset charset; + + MultipartFormDataChannel(String boundary, Iterable parts, Charset charset) { + this.boundary = boundary; + this.parts = parts.iterator(); + this.charset = charset; + } + + @Override + public void close() throws IOException { + if (this.channel != null) { + this.channel.close(); + this.channel = null; + } + this.closed = true; + } + + @Override + public boolean isOpen() { + return !this.closed; + } + + @Override + public int read(ByteBuffer buf) throws IOException { + while (true) { + if (this.buf.hasRemaining()) { + var n = Math.min(this.buf.remaining(), buf.remaining()); + var slice = this.buf.slice(); + slice.limit(n); + buf.put(slice); + this.buf.position(this.buf.position() + n); + return n; + } + + switch (this.state) { + case Boundary: + if (this.parts.hasNext()) { + this.current = this.parts.next(); + this.buf = ByteBuffer.wrap(("--" + this.boundary + "\r\n").getBytes(LATIN1)); + this.state = State.Headers; + } else { + this.buf = ByteBuffer.wrap(("--" + this.boundary + "--\r\n").getBytes(LATIN1)); + this.state = State.Done; + } + break; + + case Headers: + this.buf = ByteBuffer.wrap(this.currentHeaders().getBytes(this.charset)); + this.state = State.Body; + break; + + case Body: + if (this.channel == null) { + this.channel = this.current.open(); + } + + var n = this.channel.read(buf); + if (n == -1) { + this.channel.close(); + this.channel = null; + this.buf = ByteBuffer.wrap("\r\n".getBytes(LATIN1)); + this.state = State.Boundary; + } else { + return n; + } + break; + + case Done: + return -1; + } + } + } + + static String escape(String s) { + return s.replaceAll("\"", "\\\""); + } + + String currentHeaders() { + var current = this.current; + + if (current == null) { + throw new IllegalStateException(); + } + + var contentType = current.contentType(); + var filename = current.filename(); + if (contentType.isPresent() && filename.isPresent()) { + var format = new StringJoiner("\r\n", "", "\r\n") + .add("Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"").add("Content-Type: %s") + .toString(); + try (var formatter = new Formatter()) { + return formatter + .format(format, escape(current.name()), escape(filename.get()), escape(contentType.get())) + .toString() + "\r\n"; // FIXME + } + + } else if (contentType.isPresent()) { + var format = new StringJoiner("\r\n", "", "\r\n").add("Content-Disposition: form-data; name=\"%s\"") + .add("Content-Type: %s").toString(); + try (var formatter = new Formatter()) { + return formatter.format(format, escape(current.name()), escape(contentType.get())).toString() + "\r\n"; // FIXME + // escape + } + + } else if (filename.isPresent()) { + var format = new StringJoiner("\r\n", "", "\r\n") + .add("Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"").toString(); + try (var formatter = new Formatter()) { + return formatter.format(format, escape(current.name()), escape(filename.get())).toString() + "\r\n"; // FIXME + // escape + } + + } else { + var format = new StringJoiner("\r\n", "", "\r\n").add("Content-Disposition: form-data; name=\"%s\"") + .toString(); + try (var formatter = new Formatter()) { + return formatter.format(format, escape(current.name())).toString() + "\r\n"; // FIXME escape + } + } + } +} \ No newline at end of file diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java index 0b5c2c7a..c76231d7 100644 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/RESTConfluenceService.java @@ -139,7 +139,7 @@ protected void fromRequest(HttpRequest.Builder reqBuilder, String description, C } @Override - protected CompletableFuture> fromRequestAsync(HttpRequest.Builder reqBuilder) { + public CompletableFuture> fromRequestAsync(HttpRequest.Builder reqBuilder) { return super.fromRequestAsync(processHeaderBeforeRequest(reqBuilder)); } From 1ebd081d36d10706634954b34db171f9ea166bbc Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Mon, 16 Oct 2023 17:58:05 +0200 Subject: [PATCH 06/17] build: update action to work on java11 #296 --- .github/workflows/deploy-snapshot.yaml | 4 ++-- .github/workflows/deploy.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-snapshot.yaml b/.github/workflows/deploy-snapshot.yaml index 1433263c..22559049 100644 --- a/.github/workflows/deploy-snapshot.yaml +++ b/.github/workflows/deploy-snapshot.yaml @@ -22,10 +22,10 @@ jobs: - uses: actions/checkout@v2 with: ref: develop - - name: Set up JDK 9 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 9 + java-version: 11 - name: Build with Maven env: diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a5a6e4f4..0d5ad7ba 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v2 with: ref: master - - name: Set up JDK 9 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 9 + java-version: 11 - name: GPG Setup env: GPG_KEY_BASE64: ${{ secrets.GPG_KEY_BASE64 }} From bbf698047c72ea9897ddff8e7fadfa8fd6d1f606 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Tue, 17 Oct 2023 10:05:50 +0200 Subject: [PATCH 07/17] feat: replace FormBody with a BodyPublisher #296 --- .../ScrollVersionsConfluenceService.java | 33 +++++++-------- .../org/bsc/confluence/rest/FormBody.java | 37 ----------------- .../rest/FormUrlEncodedBodyPublisher.java | 41 +++++++++++++++++++ 3 files changed, 58 insertions(+), 53 deletions(-) delete mode 100644 service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java create mode 100644 service-rest-api/src/main/java/org/bsc/confluence/rest/FormUrlEncodedBodyPublisher.java diff --git a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java index f89694f0..18a5f103 100644 --- a/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java +++ b/addon-scrollversions/src/main/java/org/bsc/confluence/rest/scrollversions/ScrollVersionsConfluenceService.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.bsc.confluence.ConfluenceService; -import org.bsc.confluence.rest.FormBody; +import org.bsc.confluence.rest.FormUrlEncodedBodyPublisher; import org.bsc.confluence.rest.RESTConfluenceService; import org.bsc.confluence.rest.scrollversions.model.ScrollVersions; import org.bsc.ssl.SSLCertificateInfo; @@ -15,7 +15,10 @@ import java.net.URL; import java.net.http.HttpRequest; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.logging.Level; import java.util.regex.Pattern; @@ -344,15 +347,14 @@ CompletableFuture createVersionPage(String s return CompletableFuture.failedFuture(e); } - final var body = new FormBody.Builder() - .add("parentConfluenceId", masterPageId.toString() ) - .add( "versionId", version.getId() ) - .add( "pageTitle", title ) - .build() - ; + final var body = new FormUrlEncodedBodyPublisher( Map.of( + "parentConfluenceId", masterPageId.toString(), + "versionId", version.getId(), + "pageTitle", title + )); final var request = newRequestBuilder() - .header("Content-Type", FormBody.getContentType()) + .header("Content-Type", body.getContentType()) .uri(url) .POST(body) ; @@ -403,16 +405,15 @@ CompletableFuture manageVersionPage(Model.ID return CompletableFuture.failedFuture(e); } - final var body = new FormBody.Builder() - .add("masterPageId", masterPageId.toString() ) - .add( "pageTitle", title) - .add( "versionId", version.getId() ) - .add( "changeType", changeType.typeName ) - .build() + final var body = new FormUrlEncodedBodyPublisher( Map.of( + "masterPageId", masterPageId.toString(), + "pageTitle", title, + "versionId", version.getId(), + "changeType", changeType.typeName)) ; final var request = newRequestBuilder() - .header("Content-Type", FormBody.getContentType()) + .header("Content-Type", body.getContentType()) .uri(url) .POST(body) ; diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java deleted file mode 100644 index c49ec6a4..00000000 --- a/service-rest-api/src/main/java/org/bsc/confluence/rest/FormBody.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.bsc.confluence.rest; - -import java.net.URLEncoder; -import java.net.http.HttpRequest; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -import static java.lang.String.format; - -public final class FormBody { - public static String getContentType() { - return "application/x-www-form-urlencoded"; - } - - static public class Builder { - - private final Map fields = new HashMap<>(); - - public Builder add( String name, String value ) { - fields.put(name,value); - return this; - } - - public HttpRequest.BodyPublisher build() { - return HttpRequest.BodyPublishers.ofString( - fields.entrySet().stream() - .map(kv -> format("%s=%s", - URLEncoder.encode(kv.getKey(), StandardCharsets.UTF_8), - URLEncoder.encode(kv.getValue(), StandardCharsets.UTF_8))) - .collect(Collectors.joining("&")) - ); - } - - } -} diff --git a/service-rest-api/src/main/java/org/bsc/confluence/rest/FormUrlEncodedBodyPublisher.java b/service-rest-api/src/main/java/org/bsc/confluence/rest/FormUrlEncodedBodyPublisher.java new file mode 100644 index 00000000..c8df9839 --- /dev/null +++ b/service-rest-api/src/main/java/org/bsc/confluence/rest/FormUrlEncodedBodyPublisher.java @@ -0,0 +1,41 @@ +package org.bsc.confluence.rest; + +import java.net.http.HttpRequest; +import java.net.URLEncoder; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.concurrent.Flow; +import java.util.stream.Collectors; + +import static java.lang.String.format; + +public class FormUrlEncodedBodyPublisher implements HttpRequest.BodyPublisher { + + private final byte[] data; + + public final String getContentType() { + return "application/x-www-form-urlencoded"; + } + public FormUrlEncodedBodyPublisher(Map fields) { + + data = fields.entrySet().stream() + .map(kv -> format("%s=%s", + URLEncoder.encode(kv.getKey(), StandardCharsets.UTF_8), + URLEncoder.encode(kv.getValue(), StandardCharsets.UTF_8))) + .collect(Collectors.joining("&")) + .getBytes(StandardCharsets.UTF_8);; + + } + + @Override + public long contentLength() { + return data.length; + } + + @Override + public void subscribe(Flow.Subscriber subscriber) { + subscriber.onNext(ByteBuffer.wrap(data)); + subscriber.onComplete(); + } +} From a15cc05c180b42c28f9f7d4d23266622cad264f4 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Tue, 17 Oct 2023 10:11:10 +0200 Subject: [PATCH 08/17] refactor: isolate xmlrpc-client, commons-httpclient deps in xmlrpc module --- pom.xml | 12 ------------ service-xmlrpc-api/pom.xml | 11 +++++++---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 72cc9360..9755057e 100644 --- a/pom.xml +++ b/pom.xml @@ -160,18 +160,6 @@ test - - org.apache.xmlrpc - xmlrpc-client - 3.1.3 - - - - commons-httpclient - commons-httpclient - 3.1 - - commons-io commons-io diff --git a/service-xmlrpc-api/pom.xml b/service-xmlrpc-api/pom.xml index 0a6c7d55..faa377c5 100644 --- a/service-xmlrpc-api/pom.xml +++ b/service-xmlrpc-api/pom.xml @@ -16,14 +16,17 @@ - - commons-httpclient - commons-httpclient - org.apache.xmlrpc xmlrpc-client + 3.1.3 + + + + commons-httpclient + commons-httpclient + 3.1 From 26cb771d7677dd5dea4cac1c70b383ad59b8acbf Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:15:57 +0100 Subject: [PATCH 09/17] refactor: rename module from plugin-reporting to mojo --- {plugin-reporting => mojo}/pom.xml | 0 .../bsc/confluence/ConfluenceServiceFactory.java | 0 .../org/bsc/mojo/AbstractBaseConfluenceMojo.java | 0 .../bsc/mojo/AbstractBaseConfluenceSiteMojo.java | 0 .../org/bsc/mojo/AbstractConfluenceDeployMojo.java | 0 .../java/org/bsc/mojo/ConfluenceBlogpostMojo.java | 0 .../java/org/bsc/mojo/ConfluenceDeleteMojo.java | 0 .../java/org/bsc/mojo/ConfluenceDeployMojo.java | 0 .../java/org/bsc/mojo/ConfluenceExportMojo.java | 0 .../main/java/org/bsc/mojo/DeployStateSupport.java | 0 .../org/bsc/mojo/configuration/DeployStateInfo.java | 0 .../mojo/configuration/MarkdownProcessorInfo.java | 0 .../bsc/mojo/configuration/ScrollVersionsInfo.java | 0 .../main/java/org/bsc/reporting/model/Child.java | 0 .../bsc/reporting/plugin/ConfluenceWikiWriter.java | 0 .../plugin/PluginConfluenceDocGenerator.java | 0 .../reporting/renderer/DependenciesRenderer.java | 0 .../org/bsc/reporting/renderer/PluginsRenderer.java | 0 .../reporting/renderer/ProjectSummaryRenderer.java | 0 .../bsc/reporting/renderer/ProjectTeamRenderer.java | 0 .../renderer/ReportingResolutionListener.java | 0 .../org/bsc/reporting/renderer/ScmRenderer.java | 0 .../java/org/bsc/reporting/sink/ConfluenceSink.java | 0 .../java/org/bsc/reporting/sink/SinkDelegate.java | 0 .../src/main/resources/commons-logging.properties | 0 .../main/resources/defaultPluginTemplate.confluence | 0 .../src/main/resources/defaultTemplate.confluence | 0 .../src/main/resources/plugin-report.properties | 0 .../src/main/resources/plugin-report_de.properties | 0 .../src/main/resources/plugin-report_fr.properties | 0 .../src/main/resources/plugin-report_sv.properties | 0 .../main/resources/project-info-report.properties | 0 .../src/site/apt/usage_deprecated.apt | 0 .../src/site/confluence/dependencies.confluence | 0 .../src/site/confluence/index.confluence | 0 .../src/site/confluence/index.md | 0 .../src/site/confluence/markdown_guide.confluence | 0 .../src/site/confluence/site.xml | 0 .../src/site/confluence/usage.confluence | 0 .../src/site/markdown/markdown_guide.md | 0 .../src/site/markdown/markdown_processor_guide.md | 0 .../src/site/markdown/site_json_guide.md | 0 .../src/site/markdown/site_processor_guide.md | 0 .../src/site/markdown/site_xml_guide.md | 0 .../src/site/markdown/site_yaml_guide.md | 0 .../src/site/markdown/storageformat_guide.md | 0 .../src/site/markdown/usage.md | 0 .../site/resources/Notation Guide - Confluence.html | 0 .../Notation Guide - Confluence_files/add.gif | Bin .../Notation Guide - Confluence_files/biggrin.gif | Bin .../Notation Guide - Confluence_files/blue-yes.gif | Bin .../Notation Guide - Confluence_files/check(1).gif | Bin .../Notation Guide - Confluence_files/check.gif | Bin .../com.atlassian.auiplugin-ajs.js | 0 .../com.atlassian.auiplugin-jquery-base.js | 0 .../com.atlassian.auiplugin-jquery.js | 0 .../Notation Guide - Confluence_files/combined.css | 0 .../confluence.web.resources-atlassian-effects.js | 0 .../confluence.web.resources-master-styles.css | 0 .../confluence.web.resources-notation-help.js | 0 .../Notation Guide - Confluence_files/error(1).gif | Bin .../Notation Guide - Confluence_files/error.gif | Bin .../forbidden(1).gif | Bin .../Notation Guide - Confluence_files/forbidden.gif | Bin .../Notation Guide - Confluence_files/gray-yes.gif | Bin .../Notation Guide - Confluence_files/green-yes.gif | Bin .../help_16(1).gif | Bin .../Notation Guide - Confluence_files/help_16.gif | Bin .../Notation Guide - Confluence_files/home_16.gif | Bin .../indicator.html | 0 .../information(1).gif | Bin .../information.gif | Bin .../Notation Guide - Confluence_files/lightbulb.gif | Bin .../lightbulb_on.gif | Bin .../Notation Guide - Confluence_files/linkext7.gif | Bin .../mail_small.gif | Bin .../Notation Guide - Confluence_files/pdf.gif | Bin .../Notation Guide - Confluence_files/plus.gif | Bin .../Notation Guide - Confluence_files/rss.gif | Bin .../Notation Guide - Confluence_files/sad.gif | Bin .../Notation Guide - Confluence_files/smile.gif | Bin .../Notation Guide - Confluence_files/spacer.gif | Bin .../Notation Guide - Confluence_files/star_blue.gif | Bin .../star_green.gif | Bin .../Notation Guide - Confluence_files/star_red.gif | Bin .../star_yellow.gif | Bin .../Notation Guide - Confluence_files/tasklist.png | Bin .../thumbs_down.gif | Bin .../Notation Guide - Confluence_files/thumbs_up.gif | Bin .../Notation Guide - Confluence_files/tongue.gif | Bin .../Notation Guide - Confluence_files/user_12.gif | Bin .../Notation Guide - Confluence_files/user_16.gif | Bin .../warning(1).gif | Bin .../Notation Guide - Confluence_files/warning.gif | Bin .../Notation Guide - Confluence_files/wink.gif | Bin .../src/site/resources/images/gitlog-sample02.png | Bin .../src/site/resources/images/noticeblock.png | Bin {plugin-reporting => mojo}/src/site/site.xml | 0 .../test/kotlin/org/bsc/reporting/CharsetTest.kt | 0 .../src/test/kotlin/org/bsc/reporting/FileIOTest.kt | 0 .../test/kotlin/org/bsc/reporting/Issue133Test.kt | 0 .../test/kotlin/org/bsc/reporting/ParseTextTest.kt | 0 .../src/test/kotlin/org/bsc/reporting/SiteTest.kt | 0 .../renderer/GitLogJiraIssuesRendererTest.kt | 0 .../src/test/resources/conf-icon-64.png | Bin .../src/test/resources/site.xml | 0 .../src/test/resources/test-pom.xml | 0 107 files changed, 0 insertions(+), 0 deletions(-) rename {plugin-reporting => mojo}/pom.xml (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/confluence/ConfluenceServiceFactory.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/AbstractBaseConfluenceMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/AbstractBaseConfluenceSiteMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/ConfluenceBlogpostMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/DeployStateSupport.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/configuration/DeployStateInfo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/configuration/MarkdownProcessorInfo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/mojo/configuration/ScrollVersionsInfo.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/model/Child.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java (100%) rename {plugin-reporting => mojo}/src/main/java/org/bsc/reporting/sink/SinkDelegate.java (100%) rename {plugin-reporting => mojo}/src/main/resources/commons-logging.properties (100%) rename {plugin-reporting => mojo}/src/main/resources/defaultPluginTemplate.confluence (100%) rename {plugin-reporting => mojo}/src/main/resources/defaultTemplate.confluence (100%) rename {plugin-reporting => mojo}/src/main/resources/plugin-report.properties (100%) rename {plugin-reporting => mojo}/src/main/resources/plugin-report_de.properties (100%) rename {plugin-reporting => mojo}/src/main/resources/plugin-report_fr.properties (100%) rename {plugin-reporting => mojo}/src/main/resources/plugin-report_sv.properties (100%) rename {plugin-reporting => mojo}/src/main/resources/project-info-report.properties (100%) rename {plugin-reporting => mojo}/src/site/apt/usage_deprecated.apt (100%) rename {plugin-reporting => mojo}/src/site/confluence/dependencies.confluence (100%) rename {plugin-reporting => mojo}/src/site/confluence/index.confluence (100%) rename {plugin-reporting => mojo}/src/site/confluence/index.md (100%) rename {plugin-reporting => mojo}/src/site/confluence/markdown_guide.confluence (100%) rename {plugin-reporting => mojo}/src/site/confluence/site.xml (100%) rename {plugin-reporting => mojo}/src/site/confluence/usage.confluence (100%) rename {plugin-reporting => mojo}/src/site/markdown/markdown_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/markdown_processor_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/site_json_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/site_processor_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/site_xml_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/site_yaml_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/storageformat_guide.md (100%) rename {plugin-reporting => mojo}/src/site/markdown/usage.md (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence.html (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/add.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/biggrin.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/blue-yes.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/check(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/check.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-ajs.js (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery-base.js (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery.js (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/combined.css (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-atlassian-effects.js (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-master-styles.css (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-notation-help.js (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/error(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/error.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/forbidden(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/forbidden.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/gray-yes.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/green-yes.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/help_16(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/help_16.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/home_16.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/indicator.html (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/information(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/information.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/lightbulb.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/lightbulb_on.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/linkext7.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/mail_small.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/pdf.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/plus.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/rss.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/sad.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/smile.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/spacer.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/star_blue.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/star_green.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/star_red.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/star_yellow.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/tasklist.png (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/thumbs_down.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/thumbs_up.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/tongue.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/user_12.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/user_16.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/warning(1).gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/warning.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/Notation Guide - Confluence_files/wink.gif (100%) rename {plugin-reporting => mojo}/src/site/resources/images/gitlog-sample02.png (100%) rename {plugin-reporting => mojo}/src/site/resources/images/noticeblock.png (100%) rename {plugin-reporting => mojo}/src/site/site.xml (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/CharsetTest.kt (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/FileIOTest.kt (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/Issue133Test.kt (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/ParseTextTest.kt (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/SiteTest.kt (100%) rename {plugin-reporting => mojo}/src/test/kotlin/org/bsc/reporting/renderer/GitLogJiraIssuesRendererTest.kt (100%) rename {plugin-reporting => mojo}/src/test/resources/conf-icon-64.png (100%) rename {plugin-reporting => mojo}/src/test/resources/site.xml (100%) rename {plugin-reporting => mojo}/src/test/resources/test-pom.xml (100%) diff --git a/plugin-reporting/pom.xml b/mojo/pom.xml similarity index 100% rename from plugin-reporting/pom.xml rename to mojo/pom.xml diff --git a/plugin-reporting/src/main/java/org/bsc/confluence/ConfluenceServiceFactory.java b/mojo/src/main/java/org/bsc/confluence/ConfluenceServiceFactory.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/confluence/ConfluenceServiceFactory.java rename to mojo/src/main/java/org/bsc/confluence/ConfluenceServiceFactory.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/AbstractBaseConfluenceMojo.java b/mojo/src/main/java/org/bsc/mojo/AbstractBaseConfluenceMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/AbstractBaseConfluenceMojo.java rename to mojo/src/main/java/org/bsc/mojo/AbstractBaseConfluenceMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/AbstractBaseConfluenceSiteMojo.java b/mojo/src/main/java/org/bsc/mojo/AbstractBaseConfluenceSiteMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/AbstractBaseConfluenceSiteMojo.java rename to mojo/src/main/java/org/bsc/mojo/AbstractBaseConfluenceSiteMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java b/mojo/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java rename to mojo/src/main/java/org/bsc/mojo/AbstractConfluenceDeployMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceBlogpostMojo.java b/mojo/src/main/java/org/bsc/mojo/ConfluenceBlogpostMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceBlogpostMojo.java rename to mojo/src/main/java/org/bsc/mojo/ConfluenceBlogpostMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java b/mojo/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java rename to mojo/src/main/java/org/bsc/mojo/ConfluenceDeleteMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java b/mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java rename to mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java b/mojo/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java rename to mojo/src/main/java/org/bsc/mojo/ConfluenceExportMojo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/DeployStateSupport.java b/mojo/src/main/java/org/bsc/mojo/DeployStateSupport.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/DeployStateSupport.java rename to mojo/src/main/java/org/bsc/mojo/DeployStateSupport.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/configuration/DeployStateInfo.java b/mojo/src/main/java/org/bsc/mojo/configuration/DeployStateInfo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/configuration/DeployStateInfo.java rename to mojo/src/main/java/org/bsc/mojo/configuration/DeployStateInfo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/configuration/MarkdownProcessorInfo.java b/mojo/src/main/java/org/bsc/mojo/configuration/MarkdownProcessorInfo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/configuration/MarkdownProcessorInfo.java rename to mojo/src/main/java/org/bsc/mojo/configuration/MarkdownProcessorInfo.java diff --git a/plugin-reporting/src/main/java/org/bsc/mojo/configuration/ScrollVersionsInfo.java b/mojo/src/main/java/org/bsc/mojo/configuration/ScrollVersionsInfo.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/mojo/configuration/ScrollVersionsInfo.java rename to mojo/src/main/java/org/bsc/mojo/configuration/ScrollVersionsInfo.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/model/Child.java b/mojo/src/main/java/org/bsc/reporting/model/Child.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/model/Child.java rename to mojo/src/main/java/org/bsc/reporting/model/Child.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java b/mojo/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java rename to mojo/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java b/mojo/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java rename to mojo/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java b/mojo/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java rename to mojo/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java b/mojo/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java rename to mojo/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java b/mojo/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java rename to mojo/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java b/mojo/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java rename to mojo/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java b/mojo/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java rename to mojo/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java b/mojo/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java rename to mojo/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java b/mojo/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java rename to mojo/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java diff --git a/plugin-reporting/src/main/java/org/bsc/reporting/sink/SinkDelegate.java b/mojo/src/main/java/org/bsc/reporting/sink/SinkDelegate.java similarity index 100% rename from plugin-reporting/src/main/java/org/bsc/reporting/sink/SinkDelegate.java rename to mojo/src/main/java/org/bsc/reporting/sink/SinkDelegate.java diff --git a/plugin-reporting/src/main/resources/commons-logging.properties b/mojo/src/main/resources/commons-logging.properties similarity index 100% rename from plugin-reporting/src/main/resources/commons-logging.properties rename to mojo/src/main/resources/commons-logging.properties diff --git a/plugin-reporting/src/main/resources/defaultPluginTemplate.confluence b/mojo/src/main/resources/defaultPluginTemplate.confluence similarity index 100% rename from plugin-reporting/src/main/resources/defaultPluginTemplate.confluence rename to mojo/src/main/resources/defaultPluginTemplate.confluence diff --git a/plugin-reporting/src/main/resources/defaultTemplate.confluence b/mojo/src/main/resources/defaultTemplate.confluence similarity index 100% rename from plugin-reporting/src/main/resources/defaultTemplate.confluence rename to mojo/src/main/resources/defaultTemplate.confluence diff --git a/plugin-reporting/src/main/resources/plugin-report.properties b/mojo/src/main/resources/plugin-report.properties similarity index 100% rename from plugin-reporting/src/main/resources/plugin-report.properties rename to mojo/src/main/resources/plugin-report.properties diff --git a/plugin-reporting/src/main/resources/plugin-report_de.properties b/mojo/src/main/resources/plugin-report_de.properties similarity index 100% rename from plugin-reporting/src/main/resources/plugin-report_de.properties rename to mojo/src/main/resources/plugin-report_de.properties diff --git a/plugin-reporting/src/main/resources/plugin-report_fr.properties b/mojo/src/main/resources/plugin-report_fr.properties similarity index 100% rename from plugin-reporting/src/main/resources/plugin-report_fr.properties rename to mojo/src/main/resources/plugin-report_fr.properties diff --git a/plugin-reporting/src/main/resources/plugin-report_sv.properties b/mojo/src/main/resources/plugin-report_sv.properties similarity index 100% rename from plugin-reporting/src/main/resources/plugin-report_sv.properties rename to mojo/src/main/resources/plugin-report_sv.properties diff --git a/plugin-reporting/src/main/resources/project-info-report.properties b/mojo/src/main/resources/project-info-report.properties similarity index 100% rename from plugin-reporting/src/main/resources/project-info-report.properties rename to mojo/src/main/resources/project-info-report.properties diff --git a/plugin-reporting/src/site/apt/usage_deprecated.apt b/mojo/src/site/apt/usage_deprecated.apt similarity index 100% rename from plugin-reporting/src/site/apt/usage_deprecated.apt rename to mojo/src/site/apt/usage_deprecated.apt diff --git a/plugin-reporting/src/site/confluence/dependencies.confluence b/mojo/src/site/confluence/dependencies.confluence similarity index 100% rename from plugin-reporting/src/site/confluence/dependencies.confluence rename to mojo/src/site/confluence/dependencies.confluence diff --git a/plugin-reporting/src/site/confluence/index.confluence b/mojo/src/site/confluence/index.confluence similarity index 100% rename from plugin-reporting/src/site/confluence/index.confluence rename to mojo/src/site/confluence/index.confluence diff --git a/plugin-reporting/src/site/confluence/index.md b/mojo/src/site/confluence/index.md similarity index 100% rename from plugin-reporting/src/site/confluence/index.md rename to mojo/src/site/confluence/index.md diff --git a/plugin-reporting/src/site/confluence/markdown_guide.confluence b/mojo/src/site/confluence/markdown_guide.confluence similarity index 100% rename from plugin-reporting/src/site/confluence/markdown_guide.confluence rename to mojo/src/site/confluence/markdown_guide.confluence diff --git a/plugin-reporting/src/site/confluence/site.xml b/mojo/src/site/confluence/site.xml similarity index 100% rename from plugin-reporting/src/site/confluence/site.xml rename to mojo/src/site/confluence/site.xml diff --git a/plugin-reporting/src/site/confluence/usage.confluence b/mojo/src/site/confluence/usage.confluence similarity index 100% rename from plugin-reporting/src/site/confluence/usage.confluence rename to mojo/src/site/confluence/usage.confluence diff --git a/plugin-reporting/src/site/markdown/markdown_guide.md b/mojo/src/site/markdown/markdown_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/markdown_guide.md rename to mojo/src/site/markdown/markdown_guide.md diff --git a/plugin-reporting/src/site/markdown/markdown_processor_guide.md b/mojo/src/site/markdown/markdown_processor_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/markdown_processor_guide.md rename to mojo/src/site/markdown/markdown_processor_guide.md diff --git a/plugin-reporting/src/site/markdown/site_json_guide.md b/mojo/src/site/markdown/site_json_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/site_json_guide.md rename to mojo/src/site/markdown/site_json_guide.md diff --git a/plugin-reporting/src/site/markdown/site_processor_guide.md b/mojo/src/site/markdown/site_processor_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/site_processor_guide.md rename to mojo/src/site/markdown/site_processor_guide.md diff --git a/plugin-reporting/src/site/markdown/site_xml_guide.md b/mojo/src/site/markdown/site_xml_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/site_xml_guide.md rename to mojo/src/site/markdown/site_xml_guide.md diff --git a/plugin-reporting/src/site/markdown/site_yaml_guide.md b/mojo/src/site/markdown/site_yaml_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/site_yaml_guide.md rename to mojo/src/site/markdown/site_yaml_guide.md diff --git a/plugin-reporting/src/site/markdown/storageformat_guide.md b/mojo/src/site/markdown/storageformat_guide.md similarity index 100% rename from plugin-reporting/src/site/markdown/storageformat_guide.md rename to mojo/src/site/markdown/storageformat_guide.md diff --git a/plugin-reporting/src/site/markdown/usage.md b/mojo/src/site/markdown/usage.md similarity index 100% rename from plugin-reporting/src/site/markdown/usage.md rename to mojo/src/site/markdown/usage.md diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence.html b/mojo/src/site/resources/Notation Guide - Confluence.html similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence.html rename to mojo/src/site/resources/Notation Guide - Confluence.html diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/add.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/add.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/add.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/add.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/biggrin.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/biggrin.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/biggrin.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/biggrin.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/blue-yes.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/blue-yes.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/blue-yes.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/blue-yes.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/check(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/check(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/check(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/check(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/check.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/check.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/check.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/check.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-ajs.js b/mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-ajs.js similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-ajs.js rename to mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-ajs.js diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery-base.js b/mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery-base.js similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery-base.js rename to mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery-base.js diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery.js b/mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery.js similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery.js rename to mojo/src/site/resources/Notation Guide - Confluence_files/com.atlassian.auiplugin-jquery.js diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/combined.css b/mojo/src/site/resources/Notation Guide - Confluence_files/combined.css similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/combined.css rename to mojo/src/site/resources/Notation Guide - Confluence_files/combined.css diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-atlassian-effects.js b/mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-atlassian-effects.js similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-atlassian-effects.js rename to mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-atlassian-effects.js diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-master-styles.css b/mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-master-styles.css similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-master-styles.css rename to mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-master-styles.css diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-notation-help.js b/mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-notation-help.js similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-notation-help.js rename to mojo/src/site/resources/Notation Guide - Confluence_files/confluence.web.resources-notation-help.js diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/error(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/error(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/error(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/error(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/error.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/error.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/error.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/error.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/forbidden(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/forbidden(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/forbidden(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/forbidden(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/forbidden.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/forbidden.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/forbidden.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/forbidden.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/gray-yes.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/gray-yes.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/gray-yes.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/gray-yes.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/green-yes.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/green-yes.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/green-yes.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/green-yes.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/help_16(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/help_16(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/help_16(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/help_16(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/help_16.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/help_16.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/help_16.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/help_16.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/home_16.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/home_16.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/home_16.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/home_16.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/indicator.html b/mojo/src/site/resources/Notation Guide - Confluence_files/indicator.html similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/indicator.html rename to mojo/src/site/resources/Notation Guide - Confluence_files/indicator.html diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/information(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/information(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/information(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/information(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/information.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/information.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/information.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/information.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/lightbulb.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/lightbulb.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/lightbulb.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/lightbulb.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/lightbulb_on.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/lightbulb_on.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/lightbulb_on.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/lightbulb_on.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/linkext7.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/linkext7.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/linkext7.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/linkext7.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/mail_small.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/mail_small.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/mail_small.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/mail_small.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/pdf.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/pdf.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/pdf.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/pdf.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/plus.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/plus.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/plus.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/plus.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/rss.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/rss.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/rss.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/rss.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/sad.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/sad.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/sad.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/sad.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/smile.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/smile.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/smile.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/smile.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/spacer.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/spacer.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/spacer.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/spacer.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_blue.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/star_blue.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_blue.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/star_blue.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_green.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/star_green.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_green.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/star_green.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_red.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/star_red.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_red.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/star_red.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_yellow.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/star_yellow.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/star_yellow.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/star_yellow.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/tasklist.png b/mojo/src/site/resources/Notation Guide - Confluence_files/tasklist.png similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/tasklist.png rename to mojo/src/site/resources/Notation Guide - Confluence_files/tasklist.png diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/thumbs_down.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/thumbs_down.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/thumbs_down.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/thumbs_down.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/thumbs_up.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/thumbs_up.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/thumbs_up.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/thumbs_up.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/tongue.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/tongue.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/tongue.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/tongue.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/user_12.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/user_12.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/user_12.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/user_12.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/user_16.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/user_16.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/user_16.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/user_16.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/warning(1).gif b/mojo/src/site/resources/Notation Guide - Confluence_files/warning(1).gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/warning(1).gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/warning(1).gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/warning.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/warning.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/warning.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/warning.gif diff --git a/plugin-reporting/src/site/resources/Notation Guide - Confluence_files/wink.gif b/mojo/src/site/resources/Notation Guide - Confluence_files/wink.gif similarity index 100% rename from plugin-reporting/src/site/resources/Notation Guide - Confluence_files/wink.gif rename to mojo/src/site/resources/Notation Guide - Confluence_files/wink.gif diff --git a/plugin-reporting/src/site/resources/images/gitlog-sample02.png b/mojo/src/site/resources/images/gitlog-sample02.png similarity index 100% rename from plugin-reporting/src/site/resources/images/gitlog-sample02.png rename to mojo/src/site/resources/images/gitlog-sample02.png diff --git a/plugin-reporting/src/site/resources/images/noticeblock.png b/mojo/src/site/resources/images/noticeblock.png similarity index 100% rename from plugin-reporting/src/site/resources/images/noticeblock.png rename to mojo/src/site/resources/images/noticeblock.png diff --git a/plugin-reporting/src/site/site.xml b/mojo/src/site/site.xml similarity index 100% rename from plugin-reporting/src/site/site.xml rename to mojo/src/site/site.xml diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/CharsetTest.kt b/mojo/src/test/kotlin/org/bsc/reporting/CharsetTest.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/CharsetTest.kt rename to mojo/src/test/kotlin/org/bsc/reporting/CharsetTest.kt diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/FileIOTest.kt b/mojo/src/test/kotlin/org/bsc/reporting/FileIOTest.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/FileIOTest.kt rename to mojo/src/test/kotlin/org/bsc/reporting/FileIOTest.kt diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt b/mojo/src/test/kotlin/org/bsc/reporting/Issue133Test.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/Issue133Test.kt rename to mojo/src/test/kotlin/org/bsc/reporting/Issue133Test.kt diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/ParseTextTest.kt b/mojo/src/test/kotlin/org/bsc/reporting/ParseTextTest.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/ParseTextTest.kt rename to mojo/src/test/kotlin/org/bsc/reporting/ParseTextTest.kt diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/SiteTest.kt b/mojo/src/test/kotlin/org/bsc/reporting/SiteTest.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/SiteTest.kt rename to mojo/src/test/kotlin/org/bsc/reporting/SiteTest.kt diff --git a/plugin-reporting/src/test/kotlin/org/bsc/reporting/renderer/GitLogJiraIssuesRendererTest.kt b/mojo/src/test/kotlin/org/bsc/reporting/renderer/GitLogJiraIssuesRendererTest.kt similarity index 100% rename from plugin-reporting/src/test/kotlin/org/bsc/reporting/renderer/GitLogJiraIssuesRendererTest.kt rename to mojo/src/test/kotlin/org/bsc/reporting/renderer/GitLogJiraIssuesRendererTest.kt diff --git a/plugin-reporting/src/test/resources/conf-icon-64.png b/mojo/src/test/resources/conf-icon-64.png similarity index 100% rename from plugin-reporting/src/test/resources/conf-icon-64.png rename to mojo/src/test/resources/conf-icon-64.png diff --git a/plugin-reporting/src/test/resources/site.xml b/mojo/src/test/resources/site.xml similarity index 100% rename from plugin-reporting/src/test/resources/site.xml rename to mojo/src/test/resources/site.xml diff --git a/plugin-reporting/src/test/resources/test-pom.xml b/mojo/src/test/resources/test-pom.xml similarity index 100% rename from plugin-reporting/src/test/resources/test-pom.xml rename to mojo/src/test/resources/test-pom.xml From d8e8430bd9941e56704e1ffb10e29a0fee344120 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:16:18 +0100 Subject: [PATCH 10/17] refactor(core): update module url --- core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index 19087ffa..9e84b08e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -12,7 +12,7 @@ maven-confluence-core CONFLUENCE-REPORTING::Core maven confluence plugin - core project - http://code.google.com/p/maven-confluence-plugin/ + https://github.com/bsorrentino/maven-confluence-plugin scm:git:https://github.com/bsorrentino/maven-confluence-reporting-plugin.git From 6040da26f29083288fe807be08b5f92778fa6fd0 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:57:42 +0100 Subject: [PATCH 11/17] refactor: move package move renderer, sink package from mojo to plugin-report module --- plugin-report/pom.xml | 51 +++++++++++++++++++ .../org/bsc}/plugin/ConfluenceWikiWriter.java | 2 +- .../plugin/PluginConfluenceDocGenerator.java | 33 ++++++------ .../renderer/DependenciesRenderer.java | 3 +- .../bsc/plugin}/renderer/PluginsRenderer.java | 3 +- .../renderer/ProjectSummaryRenderer.java | 3 +- .../plugin}/renderer/ProjectTeamRenderer.java | 3 +- .../renderer/ReportingResolutionListener.java | 3 +- .../org/bsc/plugin}/renderer/ScmRenderer.java | 4 +- .../org/bsc/plugin}/sink/ConfluenceSink.java | 2 +- .../org/bsc/plugin}/sink/SinkDelegate.java | 3 +- 11 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 plugin-report/pom.xml rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc}/plugin/ConfluenceWikiWriter.java (98%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc}/plugin/PluginConfluenceDocGenerator.java (97%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/DependenciesRenderer.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/PluginsRenderer.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/ProjectSummaryRenderer.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/ProjectTeamRenderer.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/ReportingResolutionListener.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/renderer/ScmRenderer.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/sink/ConfluenceSink.java (99%) rename {mojo/src/main/java/org/bsc/reporting => plugin-report/src/main/java/org/bsc/plugin}/sink/SinkDelegate.java (97%) diff --git a/plugin-report/pom.xml b/plugin-report/pom.xml new file mode 100644 index 00000000..15a07ca8 --- /dev/null +++ b/plugin-report/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + + org.bsc.maven + maven-confluence-parent + 8.0-SNAPSHOT + + + confluence-plugin-report + CONFLUENCE-REPORTING::Plugin-Report + maven confluence plugin - plugin report + https://github.com/bsorrentino/maven-confluence-plugin + + + UTF-8 + + + + + org.apache.maven + maven-plugin-api + + + org.bsc.maven + maven-confluence-core + ${project.version} + compile + + + org.apache.maven.plugin-tools + maven-plugin-tools-api + + + org.apache.maven.plugin-tools + maven-plugin-tools-generators + + + org.apache.maven + maven-project + 2.2.1 + compile + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.4 + compile + + + diff --git a/mojo/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java b/plugin-report/src/main/java/org/bsc/plugin/ConfluenceWikiWriter.java similarity index 98% rename from mojo/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java rename to plugin-report/src/main/java/org/bsc/plugin/ConfluenceWikiWriter.java index 9946986f..b7ba1112 100644 --- a/mojo/src/main/java/org/bsc/reporting/plugin/ConfluenceWikiWriter.java +++ b/plugin-report/src/main/java/org/bsc/plugin/ConfluenceWikiWriter.java @@ -1,4 +1,4 @@ -package org.bsc.reporting.plugin; +package org.bsc.plugin; import java.io.File; import java.io.FileNotFoundException; diff --git a/mojo/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java b/plugin-report/src/main/java/org/bsc/plugin/PluginConfluenceDocGenerator.java similarity index 97% rename from mojo/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java rename to plugin-report/src/main/java/org/bsc/plugin/PluginConfluenceDocGenerator.java index 310fa020..81e14f81 100644 --- a/mojo/src/main/java/org/bsc/reporting/plugin/PluginConfluenceDocGenerator.java +++ b/plugin-report/src/main/java/org/bsc/plugin/PluginConfluenceDocGenerator.java @@ -1,18 +1,4 @@ -package org.bsc.reporting.plugin; - -import static org.bsc.confluence.ConfluenceHtmlUtils.replaceHTML; -import static org.bsc.reporting.plugin.ConfluenceWikiWriter.createAnchor; -import static org.bsc.reporting.plugin.ConfluenceWikiWriter.createLinkToAnchor; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; +package org.bsc.plugin; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; @@ -20,13 +6,26 @@ import org.apache.maven.tools.plugin.PluginToolsRequest; import org.apache.maven.tools.plugin.generator.Generator; import org.apache.maven.tools.plugin.generator.GeneratorException; -import org.bsc.confluence.ConfluenceHtmlUtils; import org.bsc.confluence.ConfluenceService; import org.bsc.confluence.ConfluenceService.Model; import org.bsc.confluence.ConfluenceService.Storage; import org.bsc.confluence.ConfluenceService.Storage.Representation; import org.codehaus.plexus.util.StringUtils; +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +import static org.bsc.confluence.ConfluenceHtmlUtils.replaceHTML; +import static org.bsc.plugin.ConfluenceWikiWriter.createAnchor; +import static org.bsc.plugin.ConfluenceWikiWriter.createLinkToAnchor; + /** * * @author Sorrentino @@ -424,7 +423,7 @@ private List getParametersByRequired(boolean required, List list = new ArrayList(); + final List list = new ArrayList<>(); for (Parameter parameter : parameterList) { if (parameter.isRequired() == required) { diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/DependenciesRenderer.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/DependenciesRenderer.java index 07b402c8..95dd0ad1 100755 --- a/mojo/src/main/java/org/bsc/reporting/renderer/DependenciesRenderer.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/DependenciesRenderer.java @@ -1,4 +1,5 @@ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; + import java.util.ArrayList; import java.util.Collections; diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/PluginsRenderer.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/PluginsRenderer.java index 19222f30..4f23769c 100644 --- a/mojo/src/main/java/org/bsc/reporting/renderer/PluginsRenderer.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/PluginsRenderer.java @@ -3,7 +3,8 @@ * and open the template in the editor. */ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; + import java.util.ArrayList; import java.util.Collections; diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectSummaryRenderer.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectSummaryRenderer.java index 7f177ba1..78b2be81 100755 --- a/mojo/src/main/java/org/bsc/reporting/renderer/ProjectSummaryRenderer.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectSummaryRenderer.java @@ -1,4 +1,5 @@ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; + import java.util.Locale; diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectTeamRenderer.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectTeamRenderer.java index 1a687a79..1ffe207a 100644 --- a/mojo/src/main/java/org/bsc/reporting/renderer/ProjectTeamRenderer.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/ProjectTeamRenderer.java @@ -1,4 +1,5 @@ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; + /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/ReportingResolutionListener.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/ReportingResolutionListener.java index 1afdfdcf..53f8cf8d 100755 --- a/mojo/src/main/java/org/bsc/reporting/renderer/ReportingResolutionListener.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/ReportingResolutionListener.java @@ -1,4 +1,5 @@ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; + import java.util.ArrayList; import java.util.Collection; diff --git a/mojo/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java b/plugin-report/src/main/java/org/bsc/plugin/renderer/ScmRenderer.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java rename to plugin-report/src/main/java/org/bsc/plugin/renderer/ScmRenderer.java index f77508b8..1c3260ab 100755 --- a/mojo/src/main/java/org/bsc/reporting/renderer/ScmRenderer.java +++ b/plugin-report/src/main/java/org/bsc/plugin/renderer/ScmRenderer.java @@ -1,4 +1,4 @@ -package org.bsc.reporting.renderer; +package org.bsc.plugin.renderer; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -40,7 +40,7 @@ import java.util.List; import java.util.Locale; import org.apache.maven.report.projectinfo.AbstractProjectInfoRenderer; -import org.bsc.reporting.sink.ConfluenceSink; +import org.bsc.plugin.sink.ConfluenceSink; /** * Scm renderer class diff --git a/mojo/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java b/plugin-report/src/main/java/org/bsc/plugin/sink/ConfluenceSink.java similarity index 99% rename from mojo/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java rename to plugin-report/src/main/java/org/bsc/plugin/sink/ConfluenceSink.java index 2571814b..da26a7d0 100644 --- a/mojo/src/main/java/org/bsc/reporting/sink/ConfluenceSink.java +++ b/plugin-report/src/main/java/org/bsc/plugin/sink/ConfluenceSink.java @@ -1,4 +1,4 @@ -package org.bsc.reporting.sink; +package org.bsc.plugin.sink; import java.io.PrintWriter; import java.io.Writer; diff --git a/mojo/src/main/java/org/bsc/reporting/sink/SinkDelegate.java b/plugin-report/src/main/java/org/bsc/plugin/sink/SinkDelegate.java similarity index 97% rename from mojo/src/main/java/org/bsc/reporting/sink/SinkDelegate.java rename to plugin-report/src/main/java/org/bsc/plugin/sink/SinkDelegate.java index 1b314235..7b233fd2 100644 --- a/mojo/src/main/java/org/bsc/reporting/sink/SinkDelegate.java +++ b/plugin-report/src/main/java/org/bsc/plugin/sink/SinkDelegate.java @@ -1,4 +1,5 @@ -package org.bsc.reporting.sink; +package org.bsc.plugin.sink; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; From e4cc2fda67e84720d663bdafe6d9aee488a89171 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:58:16 +0100 Subject: [PATCH 12/17] refactor: update import --- .../java/org/bsc/mojo/ConfluenceDeployMojo.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java b/mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java index 3502831c..be6b9980 100644 --- a/mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java +++ b/mojo/src/main/java/org/bsc/mojo/ConfluenceDeployMojo.java @@ -51,15 +51,11 @@ import org.bsc.confluence.ParentChildTuple; import org.bsc.confluence.model.Site; import org.bsc.mojo.configuration.MarkdownProcessorInfo; -import org.bsc.reporting.plugin.PluginConfluenceDocGenerator; +import org.bsc.plugin.PluginConfluenceDocGenerator; +import org.bsc.plugin.renderer.*; +import org.bsc.plugin.sink.ConfluenceSink; import org.bsc.reporting.renderer.CalculateRuleForSinceTagName; -import org.bsc.reporting.renderer.DependenciesRenderer; import org.bsc.reporting.renderer.GitLogJiraIssuesRenderer; -import org.bsc.reporting.renderer.ProjectSummaryRenderer; -import org.bsc.reporting.renderer.ProjectTeamRenderer; -import org.bsc.reporting.renderer.ReportingResolutionListener; -import org.bsc.reporting.renderer.ScmRenderer; -import org.bsc.reporting.sink.ConfluenceSink; import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.i18n.I18N; @@ -657,9 +653,6 @@ public String getName(Locale locale) { return "confluence"; } - - - ///////////////////////////////////////////////////////// /// /// PLUGIN SECTION From ef1a7bba76c0e81418f9c3358d4945e4e4a597c8 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:58:29 +0100 Subject: [PATCH 13/17] refactor: add new module --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9755057e..f1fee63a 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ core - plugin-reporting + mojo test-publishing test-plugin processor-freemarker @@ -35,6 +35,7 @@ service-rest-api service-xmlrpc-api addon-scrollversions + plugin-report scm:git:https://github.com/bsorrentino/maven-confluence-plugin.git From a3a2ba9ae723b4184c0ad07eaf113dae82afea93 Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 15 Feb 2024 19:58:43 +0100 Subject: [PATCH 14/17] chore: clean code --- mojo/pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mojo/pom.xml b/mojo/pom.xml index 219e072d..11f2d2d6 100755 --- a/mojo/pom.xml +++ b/mojo/pom.xml @@ -166,17 +166,26 @@ maven-confluence-core ${project.version} + org.bsc.maven confluence-xmlrpc-api ${project.version} + org.bsc.maven confluence-rest-api ${project.version} + + org.bsc.maven + confluence-plugin-report + ${project.version} + + + - - - com.github.github - site-maven-plugin - 0.12 - - Creating site for ${project.artifactId} ${project.version} - github - maven-confluence-plugin - bsorrentino - - - - - site - - site - - - - - - - - - - confluence @@ -388,6 +351,42 @@ + + diff --git a/site-deploy.sh b/site-deploy.sh index 1e2ae6ba..415f8d06 100755 --- a/site-deploy.sh +++ b/site-deploy.sh @@ -1,5 +1,5 @@ #!/bin/sh -mvn site:site --projects plugin-reporting +mvn site:site --projects mojo mvn javadoc:javadoc --projects core -DreportOutputDirectory=$(pwd)/plugin-reporting/target/site/core/apidocs -mvn -Preport --projects plugin-reporting site +mvn -Preport --projects mojo site From 08e11cf9887e17acf27130427b5c6c7ad7be0f0e Mon Sep 17 00:00:00 2001 From: bsorrentino Date: Thu, 29 Feb 2024 18:18:17 +0100 Subject: [PATCH 17/17] build: move to next version --- addon-scrollversions/pom.xml | 2 +- core/pom.xml | 2 +- gitlog+jira/pom.xml | 2 +- mojo/pom.xml | 2 +- plugin-report/pom.xml | 2 +- pom.xml | 2 +- processor-commonmark/pom.xml | 2 +- processor-freemarker/pom.xml | 2 +- service-rest-api/pom.xml | 2 +- service-xmlrpc-api/pom.xml | 2 +- test-plugin/pom.xml | 2 +- test-publishing/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/addon-scrollversions/pom.xml b/addon-scrollversions/pom.xml index e43904c0..45aa7cbb 100644 --- a/addon-scrollversions/pom.xml +++ b/addon-scrollversions/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/core/pom.xml b/core/pom.xml index 9e84b08e..6de114dc 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/gitlog+jira/pom.xml b/gitlog+jira/pom.xml index 2832101f..f5b4713d 100644 --- a/gitlog+jira/pom.xml +++ b/gitlog+jira/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/mojo/pom.xml b/mojo/pom.xml index 64aac5b8..82bfef27 100755 --- a/mojo/pom.xml +++ b/mojo/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 diff --git a/plugin-report/pom.xml b/plugin-report/pom.xml index 15a07ca8..a0ddb7d0 100644 --- a/plugin-report/pom.xml +++ b/plugin-report/pom.xml @@ -4,7 +4,7 @@ org.bsc.maven maven-confluence-parent - 8.0-SNAPSHOT + 8.0-beta1 confluence-plugin-report diff --git a/pom.xml b/pom.xml index f1fee63a..f424d6ef 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent pom - 8.0-SNAPSHOT + 8.0-beta1 CONFLUENCE-REPORTING::Parent Maven's plugin that allow to generate "project's documentation" directly to confluence allowing, in the same time, to keep in-sync both project & documentation diff --git a/processor-commonmark/pom.xml b/processor-commonmark/pom.xml index ce89a0f9..86d592f6 100644 --- a/processor-commonmark/pom.xml +++ b/processor-commonmark/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/processor-freemarker/pom.xml b/processor-freemarker/pom.xml index c9909986..d56c31e7 100644 --- a/processor-freemarker/pom.xml +++ b/processor-freemarker/pom.xml @@ -5,7 +5,7 @@ org.bsc.maven maven-confluence-parent - 8.0-SNAPSHOT + 8.0-beta1 maven-confluence-processor-freemarker CONFLUENCE-REPORTING::Freemaker::Processor diff --git a/service-rest-api/pom.xml b/service-rest-api/pom.xml index 17f59743..05f8d7cf 100644 --- a/service-rest-api/pom.xml +++ b/service-rest-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/service-xmlrpc-api/pom.xml b/service-xmlrpc-api/pom.xml index faa377c5..06e75a64 100644 --- a/service-xmlrpc-api/pom.xml +++ b/service-xmlrpc-api/pom.xml @@ -5,7 +5,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0 diff --git a/test-plugin/pom.xml b/test-plugin/pom.xml index 76709fc4..a21feb3d 100644 --- a/test-plugin/pom.xml +++ b/test-plugin/pom.xml @@ -6,7 +6,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 diff --git a/test-publishing/pom.xml b/test-publishing/pom.xml index 31185d96..cadb32f0 100644 --- a/test-publishing/pom.xml +++ b/test-publishing/pom.xml @@ -3,7 +3,7 @@ maven-confluence-parent org.bsc.maven - 8.0-SNAPSHOT + 8.0-beta1 4.0.0