diff --git a/.github/workflows/workflow-build.yml b/.github/workflows/workflow-build.yml
index 0cdb4f2..d0bcccf 100644
--- a/.github/workflows/workflow-build.yml
+++ b/.github/workflows/workflow-build.yml
@@ -13,7 +13,7 @@ jobs:
outputs:
app_version: ${{steps.get-app-version.outputs.APP_VERSION}}
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- id: get-app-version
name: Get archetype version
run: |
@@ -47,7 +47,7 @@ jobs:
- name: Install Java and Maven
uses: actions/setup-java@v3
with:
- java-version: 11
+ java-version: 17
distribution: 'temurin'
- name: Download latest archetype snapshot
uses: actions/download-artifact@v2
diff --git a/.github/workflows/workflow-create-release.yml b/.github/workflows/workflow-create-release.yml
index 8860212..2761380 100644
--- a/.github/workflows/workflow-create-release.yml
+++ b/.github/workflows/workflow-create-release.yml
@@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Java and Maven
uses: actions/setup-java@v3
with:
- java-version: 11
+ java-version: 17
distribution: 'temurin'
- name: Extract version
diff --git a/package.json b/package.json
index 7cf1961..c6aacbf 100644
--- a/package.json
+++ b/package.json
@@ -1,4 +1,4 @@
{
"name": "bonita-rest-api-extension-archetype",
- "version": "1.6.2"
+ "version": "1.7.0"
}
diff --git a/pom.xml b/pom.xml
index 990e110..accc2da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
org.bonitasoft.archetypes
bonita-rest-api-extension-archetype
- 1.6.2-SNAPSHOT
+ 1.7.0-SNAPSHOT
maven-archetype
Bonita Rest API extension Archetype
Maven archetype to bootstrap a Bonita Rest API extension project
diff --git a/src/main/resources/META-INF/archetype-post-generate.groovy b/src/main/resources/META-INF/archetype-post-generate.groovy
index c0ff47e..fe452ee 100644
--- a/src/main/resources/META-INF/archetype-post-generate.groovy
+++ b/src/main/resources/META-INF/archetype-post-generate.groovy
@@ -12,6 +12,7 @@ def logger = Logger.getLogger("Archetype post generate")
Path projectPath = Paths.get(request.outputDirectory, request.artifactId)
def language = request.properties.get("language")
def installWrapper = Boolean.valueOf(request.properties.get("wrapper"))
+def bonitaVersion = request.properties.get('bonitaVersion')
if (isGroovy(language)) {
prepareGroovyProject(logger, projectPath)
@@ -160,6 +161,21 @@ project.build.plugins.find { it.artifactId == 'maven-assembly-plugin' }?.version
// Remove version for manage compiler plugin
project.build.plugins.find { it.artifactId == 'maven-compiler-plugin' }?.version = null
+if(bonitaVersion
+ && !bonitaVersion.startsWith('7.')
+ && !bonitaVersion.startsWith('8.')
+ && !bonitaVersion.startsWith('9.')) {
+ // Remove property define in parent
+ removeProperty(project, 'groovy-eclipse-compiler.version')
+ removeProperty(project, 'groovy-eclipse-batch.version')
+ // Remove compiler plugin
+ project.build.plugins.removeIf { it.artifactId == 'maven-compiler-plugin' }
+ // Remove groovy plugin repository already define in parent pom
+ project.pluginRepositories.removeIf { it.id == 'groovy' }
+
+}
+
+
// Remove dependency management for bonita bom (should be in parent)
def bonitaBom = project.dependencyManagement.dependencies.find { it.artifactId == 'bonita-runtime-bom' }
if (bonitaBom != null) project.dependencyManagement.dependencies.remove(bonitaBom)
diff --git a/src/main/resources/archetype-resources/README.adoc b/src/main/resources/archetype-resources/README.adoc
index 970df72..c29decf 100644
--- a/src/main/resources/archetype-resources/README.adoc
+++ b/src/main/resources/archetype-resources/README.adoc
@@ -1,9 +1,18 @@
#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
-#set( $bonitaVersionParts = $bonitaVersion.split('\.') )
-#set( $shortBonitaVersion = $bonitaVersionParts.get(0) +'.'+ $bonitaVersionParts.get(1) )
-#set( $after713 = $bonitaVersion.matches('7.(1[3-9]|[2-9][0-9]).*') || !$bonitaVersion.startsWith('7.') )
+#if ( $bonitaVersion.lastIndexOf('.') != $bonitaVersion.indexOf('.'))
+#set( $shortBonitaVersion = $bonitaVersion.substring(0, $bonitaVersion.lastIndexOf('.')) )
+#if ( $shortBonitaVersion.lastIndexOf('.') != $shortBonitaVersion.indexOf('.'))
+#set( $shortBonitaVersion = $shortBonitaVersion.substring(0, $shortBonitaVersion.lastIndexOf('.')) )
+#end
+#elseif ( $bonitaVersion.endsWith('-SNAPSHOT') )
+#set( $shortBonitaVersion = $bonitaVersion.substring(0, $bonitaVersion.indexOf('-SNAPSHOT')) )
+#else
+#set( $shortBonitaVersion = $bonitaVersion )
+#end
+#set( $after713 = $bonitaVersion.matches('7.(1[3-5]).*') || !$bonitaVersion.startsWith('7.') )
+#set( $after10 = !$bonitaVersion.startsWith('7.') && !$bonitaVersion.startsWith('8.') && !$bonitaVersion.startsWith('9.') )
:doctype: book
:toc: left
:toclevels: 3
@@ -18,8 +27,8 @@
:imagesdir: ./doc/images
:short-bonita-version: ${shortBonitaVersion}
-:doc-url: https://documentation.bonitasoft.com/bonita/${shortBonitaVersion}
-:java-version:#if( $after713 ) 11#else 1.8#end
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
+:java-version:#if( $after10 ) 17#elseif ( $after713 ) 11#else 1.8#end
image::yourlogo.png[your logo here]
diff --git a/src/main/resources/archetype-resources/groovy-pom.xml b/src/main/resources/archetype-resources/groovy-pom.xml
index 0238f95..f3abe9c 100644
--- a/src/main/resources/archetype-resources/groovy-pom.xml
+++ b/src/main/resources/archetype-resources/groovy-pom.xml
@@ -1,4 +1,5 @@
-#set( $after713 = $bonitaVersion.matches('7.(1[3-9]|[2-9][0-9]).*') || !$bonitaVersion.startsWith('7.') )
+#set( $after713 = $bonitaVersion.matches('7.(1[3-5]).*') || !$bonitaVersion.startsWith('7.') )
+#set( $after10 = !$bonitaVersion.startsWith('7.') && !$bonitaVersion.startsWith('8.') && !$bonitaVersion.startsWith('9.'))
@@ -12,7 +13,8 @@
- #if( $after713 )
+ #if( $after10 )
+17#elseif ( $after713 )
11#else
8#end
UTF-8
@@ -33,15 +35,19 @@
2.3-groovy-3.0#else
1.3-groovy-2.4#end
1.14.5
- 1.2.11
+ 1.2.12
3.11.0
${java.version}
+ groovy-eclipse-compiler
3.6.0
- 3.1.0
- 3.7.0
- #if( $after713 )
+ 3.2.2
+ #if( $after10 )
+3.9.0#else
+3.7.0#end
+ #if( $after10 )
+3.0.9-03#elseif ( $after713)
3.0.8-01#else
2.4.21-01#end
@@ -163,9 +169,6 @@
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin.version}
-
- groovy-eclipse-compiler
-
org.codehaus.groovy
@@ -197,4 +200,18 @@
+#if( $after10 )
+
+
+ groovy
+ https://groovy.jfrog.io/artifactory/plugins-release/
+
+ true
+
+
+ true
+
+
+
+#end
diff --git a/src/main/resources/archetype-resources/kotlin-pom.xml b/src/main/resources/archetype-resources/kotlin-pom.xml
index fbeadba..86cc45c 100644
--- a/src/main/resources/archetype-resources/kotlin-pom.xml
+++ b/src/main/resources/archetype-resources/kotlin-pom.xml
@@ -1,4 +1,4 @@
-#set( $after713 = $bonitaVersion.matches('7.(1[3-9]|[2-9][0-9]).*') || !$bonitaVersion.startsWith('7.') )
+#set( $after713 = $bonitaVersion.matches('7.(1[3-5]).*') || !$bonitaVersion.startsWith('7.') )
diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml
index c82580c..31f4b99 100644
--- a/src/main/resources/archetype-resources/pom.xml
+++ b/src/main/resources/archetype-resources/pom.xml
@@ -1,4 +1,4 @@
-#set( $after713 = $bonitaVersion.matches('7.(1[3-9]|[2-9][0-9]).*') || !$bonitaVersion.startsWith('7.') )
+#set( $after713 = $bonitaVersion.matches('7.(1[3-5]).*') || !$bonitaVersion.startsWith('7.') )
4.0.0
diff --git a/src/test/resources-filtered/testGroovySubModuleProjectPost10/IT.groovy b/src/test/resources-filtered/testGroovySubModuleProjectPost10/IT.groovy
new file mode 100644
index 0000000..d43a401
--- /dev/null
+++ b/src/test/resources-filtered/testGroovySubModuleProjectPost10/IT.groovy
@@ -0,0 +1,62 @@
+import java.nio.file.Files
+import java.nio.file.Paths
+import java.nio.file.StandardCopyOption
+
+// Run 'mvn install' fisrt and then 'mvn groovy:execute -Dsource=target/test-classes/testGroovySubModuleProject/IT.groovy -Dscope=test' from project root
+
+// Given
+def sourcePath = '${project.basedir}/src/test/resources/testGroovySubModuleProjectPost10/'
+def testPath = '${project.build.testOutputDirectory}/testGroovySubModuleProjectPost10/'
+def sourceParentFolder = "${sourcePath}/module-parent"
+def parentFolder = "${testPath}/module-parent"
+def moduleArtifactId = "my-rest-api"
+
+
+println "[Integration Test] Test generation of sub module ${moduleArtifactId} in folder ${parentFolder}"
+
+// Delete previous run if any
+def moduleFolder = new File("${parentFolder}/${moduleArtifactId}")
+if (moduleFolder.exists()) {
+ Files.deleteIfExists(Paths.get("${parentFolder}/${moduleArtifactId}/pom.xml"))
+ moduleFolder.deleteDir()
+ // Reset the parent pom (whitout sub-module declaration)
+ Files.copy(Paths.get("${sourceParentFolder}/pom.xml"), Paths.get("${parentFolder}/pom.xml"), StandardCopyOption.REPLACE_EXISTING);
+}
+
+// When
+println "Generate sub module ..."
+def sout = new StringBuilder(), serr = new StringBuilder()
+def proc = """mvn archetype:generate -B \
+ -DarchetypeGroupId=org.bonitasoft.archetypes \
+ -DarchetypeArtifactId=bonita-rest-api-extension-archetype \
+ -DarchetypeVersion=${project.version} \
+ -DgroupId=org.company.api \
+ -DartifactId=${moduleArtifactId} \
+ -Dversion=0.0.1-SNAPSHOT \
+ -Dlanguage=groovy \
+ -DbonitaVersion=10.0-SNAPSHOT \
+ -DapiName=myRestApi \
+ -DapiDisplayName=My-REST-API \
+ -DpathTemplate=my-rest-api \
+ -DurlParameters=p,c \
+ -DhttpVerb=GET
+""".execute(null, new File(parentFolder))
+proc.consumeProcessOutput(sout, serr)
+proc.waitForOrKill(10 * 60 * 1000)
+println "out> $sout\nerr> $serr"
+
+// Then
+println "Verifying generation result ..."
+
+assert proc.exitValue() == 0: "Maven archetype execution exit code should be 0"
+
+def parentPomFile = new File("${parentFolder}/pom.xml")
+assert parentPomFile.text.contains("${moduleArtifactId}"): 'Parent pom should declare project as sub module'
+
+def modulePomFile = new File("${parentFolder}/${moduleArtifactId}/pom.xml")
+def referencePomFile = new File("${testPath}/reference/pom.xml")
+assert referencePomFile.text == modulePomFile.text: 'Reference pom and project pom should have the same content'
+
+println "SUCCESS"
+
+
diff --git a/src/test/resources/projects/testDatasourceProject/reference/README.adoc b/src/test/resources/projects/testDatasourceProject/reference/README.adoc
index 78267fd..c459264 100644
--- a/src/test/resources/projects/testDatasourceProject/reference/README.adoc
+++ b/src/test/resources/projects/testDatasourceProject/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.10
-:doc-url: https://documentation.bonitasoft.com/bonita/7.10
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 1.8
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testDatasourceProject/reference/pom.xml b/src/test/resources/projects/testDatasourceProject/reference/pom.xml
index a33fa68..06f7935 100644
--- a/src/test/resources/projects/testDatasourceProject/reference/pom.xml
+++ b/src/test/resources/projects/testDatasourceProject/reference/pom.xml
@@ -24,13 +24,14 @@
1.3-groovy-2.4
1.14.5
- 1.2.11
+ 1.2.12
3.11.0
${java.version}
+ groovy-eclipse-compiler
3.6.0
- 3.1.0
+ 3.2.2
3.7.0
2.4.21-01
@@ -118,9 +119,6 @@
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin.version}
-
- groovy-eclipse-compiler
-
org.codehaus.groovy
diff --git a/src/test/resources/projects/testDatasourceProject10/archetype.properties b/src/test/resources/projects/testDatasourceProject10/archetype.properties
new file mode 100644
index 0000000..dbf6212
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/archetype.properties
@@ -0,0 +1,15 @@
+groupId=com.company.bonitasoft
+artifactId=ds-rest-api
+version=1.0.0-SNAPSHOT
+package=com.company.bonitasoft
+language=groovy
+wrapper=false
+sp=false
+bonitaVersion=10.0.0
+apiName=datasource
+apiDisplayName=Datasource Rest API extension
+apiDesc=A Rest API extension reading a datasource
+httpVerb=GET
+pathTemplate=datasource
+permissionNames=customPermission1,customPermission2
+urlParameters=userId,startDate
diff --git a/src/test/resources/projects/testDatasourceProject10/goal.txt b/src/test/resources/projects/testDatasourceProject10/goal.txt
new file mode 100644
index 0000000..e69de29
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/README.adoc b/src/test/resources/projects/testDatasourceProject10/reference/README.adoc
new file mode 100644
index 0000000..24f2b2d
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/README.adoc
@@ -0,0 +1,121 @@
+:doctype: book
+:toc: left
+:toclevels: 3
+:sectnums:
+:icons: font
+:source-highlighter: highlightjs
+:idprefix:
+:idseparator: -
+:sectlinks:
+:sectanchors:
+:linkcss: false
+:imagesdir: ./doc/images
+
+:short-bonita-version: 10.0
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
+:java-version: 17
+
+image::yourlogo.png[your logo here]
+
+= Datasource Rest API extension
+A Rest API extension reading a datasource
+
+The project **datasource** is a Bonita REST API extension for **Bonita {short-bonita-version}** version **community** written in `groovy` language.
+
+_**TODO**_: A brief description of your project, what it is used for and how does life get
+awesome when someone starts to use it.
+
+== Features
+
+_**TODO**_: What's all the bells and whistles this project can perform?
+
+* What's the main functionality
+* You can also do another thing
+* If you get really randy, you can even do this
+
+== Getting started
+
+_**TODO**_: A quick introduction of the minimal setup you need to get a hello world up &
+running.
+For more details on Bonita REST API extension please refer to {doc-url}/rest-api-extension-archetype[documentation]
+
+== Developing
+_**TODO**_: Here's a brief intro about what a developer must do in order to start developing
+the project further:
+
+Prerequisite:
+
+- a git client
+- a java ( **jdk {java-version}** or higher)
+- maven (optional if you choosed to use https://github.com/takari/maven-wrapper[maven wrapper script] as archetype option)
+
+=== Building
+
+_**TODO**_: If your project needs some additional steps for the developer to build the
+project after some code changes, state them here:
+
+[source,bash]
+----
+git clone https://your.github.com/datasource.git
+cd datasource/
+mvn package
+----
+
+The build should produce a zip archive under the `target/` folder named `ds-rest-api-1.0.0-SNAPSHOT.zip`
+
+_**TODO**_: Here again you should state what actually happens when the code above gets
+executed.
+
+For more details about apache maven, please refer to the https://maven.apache.org/guides/getting-started/[documentation]
+
+=== Deploying / Publishing
+
+_**TODO**_: In case there's some step you have to take that publishes this project to a server, this is the right time to state it.
+
+Take the built artifact `ds-rest-api-1.0.0-SNAPSHOT.zip` and upload it to your Bonita platform (see {doc-url}/rest-api-extension-archetype#_deployment[rest-api-extension deployment])
+
+== Configuration
+
+_**TODO**_: Here you should write what are all of the configurations a user can enter when using the project.
+
+=== page.properties
+
+[source, properties]
+----
+include::src/main/resources/page.properties[]
+----
+
+=== configuration.properties
+
+[source, properties]
+----
+include::src/main/resources/configuration.properties[]
+----
+
+== Contributing
+
+_**TODO**_: Make easy to your team to jump in and start contributing to your project.
+
+These paragraphs are meant to welcome those kind souls to feel that they are
+needed. You should state something like:
+
+"If you'd like to contribute, please fork the repository and use a feature
+branch. Pull requests are warmly welcome."
+
+If there's anything else the developer needs to know (e.g. the code style
+guide), you should link it here. If there's a lot of things to take into
+consideration, it is common to separate this section to its own file called
+`CONTRIBUTING.adoc` (or similar). If so, you should say that it exists here.
+
+== Links
+
+_**TODO**_: Even though this information can be found inside the project on machine-readable
+format like in a .json file, it's good to include a summary of most useful
+links to humans using your project. You can include links like:
+
+. Project homepage: https://your.github.com/awesome-project/
+. Repository: https://github.com/your/awesome-project/
+. Issue tracker: https://github.com/your/awesome-project/issues
+.. In case of sensitive bugs like security vulnerabilities, please contact
+ my@email.com directly instead of using issue tracker. We value your effort
+ to improve the security and privacy of this project!
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/doc/images/yourlogo.png b/src/test/resources/projects/testDatasourceProject10/reference/doc/images/yourlogo.png
new file mode 100644
index 0000000..cc069db
Binary files /dev/null and b/src/test/resources/projects/testDatasourceProject10/reference/doc/images/yourlogo.png differ
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/pom.xml b/src/test/resources/projects/testDatasourceProject10/reference/pom.xml
new file mode 100644
index 0000000..f3b7d64
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/pom.xml
@@ -0,0 +1,163 @@
+
+
+ 4.0.0
+ com.company.bonitasoft
+ ds-rest-api
+ 1.0.0-SNAPSHOT
+
+ Datasource Rest API extension
+ A Rest API extension reading a datasource
+
+
+
+ 17
+ UTF-8
+ UTF-8
+ yyyy.MM.dd-hh.mm
+
+
+ 10.0.0
+
+
+ 2.3-groovy-3.0
+ 1.14.5
+ 1.2.12
+
+
+ 3.11.0
+ ${java.version}
+ groovy-eclipse-compiler
+ 3.6.0
+ 3.2.2
+ 3.9.0
+ 3.0.9-03
+
+
+
+
+
+
+
+ org.bonitasoft.runtime
+ bonita-runtime-bom
+ ${bonita-runtime.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+ org.bonitasoft.web
+ bonita-web-extensions
+ provided
+
+
+
+ org.codehaus.groovy
+ groovy-json
+ provided
+
+
+
+ javax.servlet
+ javax.servlet-api
+ provided
+
+
+ org.slf4j
+ slf4j-api
+ provided
+
+
+
+
+ org.spockframework
+ spock-core
+ ${spock-core.version}
+ test
+
+
+
+ net.bytebuddy
+ byte-buddy
+ ${byte-buddy.version}
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback-classic.version}
+ test
+
+
+
+
+
+ verify
+ src/main/groovy
+ src/test/groovy
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+
+ org.codehaus.groovy
+ groovy-eclipse-compiler
+ ${groovy-eclipse-compiler.version}
+
+
+ org.codehaus.groovy
+ groovy-eclipse-batch
+ ${groovy-eclipse-batch.version}
+
+
+
+
+ maven-assembly-plugin
+ ${maven-assembly-plugin.version}
+
+
+ package
+
+ single
+
+
+ ${project.basedir}/src/assembly
+ false
+
+
+
+
+
+
+
+
+ groovy
+ https://groovy.jfrog.io/artifactory/plugins-release/
+
+ true
+
+
+ true
+
+
+
+
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/assembly/assembly.xml b/src/test/resources/projects/testDatasourceProject10/reference/src/assembly/assembly.xml
new file mode 100644
index 0000000..0781b55
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/assembly/assembly.xml
@@ -0,0 +1,43 @@
+
+ all
+
+ zip
+
+
+ false
+
+
+ src/main/resources
+
+
+ **/*
+
+
+
+ META-INF/maven/${groupId}/${artifactId}
+
+ pom.xml
+
+
+
+ ${project.build.directory}/maven-archiver
+ META-INF/maven/${groupId}/${artifactId}
+
+ pom.properties
+
+
+
+
+
+
+ *:jar
+
+ true
+ runtime
+ lib
+
+
+
\ No newline at end of file
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/main/groovy/com/company/bonitasoft/Index.groovy b/src/test/resources/projects/testDatasourceProject10/reference/src/main/groovy/com/company/bonitasoft/Index.groovy
new file mode 100644
index 0000000..2be90e7
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/main/groovy/com/company/bonitasoft/Index.groovy
@@ -0,0 +1,108 @@
+package com.company.bonitasoft;
+
+import groovy.json.JsonBuilder
+
+import javax.servlet.http.HttpServletRequest
+import javax.servlet.http.HttpServletResponse
+
+import org.apache.http.HttpHeaders
+import org.bonitasoft.web.extension.ResourceProvider
+import org.bonitasoft.web.extension.rest.RestApiResponse
+import org.bonitasoft.web.extension.rest.RestApiResponseBuilder
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import org.bonitasoft.web.extension.rest.RestAPIContext
+import org.bonitasoft.web.extension.rest.RestApiController
+
+import java.time.LocalDate
+
+class Index implements RestApiController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Index.class)
+
+ @Override
+ RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder responseBuilder, RestAPIContext context) {
+ // To retrieve query parameters use the request.getParameter(..) method.
+ // Be careful, parameter values are always returned as String values
+
+ // Retrieve userId parameter
+ def userId = request.getParameter "userId"
+ if (userId == null) {
+ return buildResponse(responseBuilder, HttpServletResponse.SC_BAD_REQUEST,"""{"error" : "the parameter userId is missing"}""")
+ }
+
+ // Retrieve startDate parameter
+ def startDate = request.getParameter "startDate"
+ if (startDate == null) {
+ return buildResponse(responseBuilder, HttpServletResponse.SC_BAD_REQUEST,"""{"error" : "the parameter startDate is missing"}""")
+ }
+
+ // Here is an example of how you can retrieve configuration parameters from a properties file
+ // It is safe to remove this if no configuration is required
+ Properties props = loadProperties("configuration.properties", context.resourceProvider)
+ String paramValue = props["myParameterKey"]
+
+ /*
+ * Execute business logic here
+ *
+ *
+ * Your code goes here
+ *
+ *
+ */
+ // Prepare the result
+ def result = [ "userId" : userId ,"startDate" : startDate , "myParameterKey" : paramValue, "currentDate" : LocalDate.now().toString() ]
+
+ // Send the result as a JSON representation
+ // You may use buildPagedResponse if your result is multiple
+ return buildResponse(responseBuilder, HttpServletResponse.SC_OK, new JsonBuilder(result).toString())
+ }
+
+ /**
+ * Build an HTTP response.
+ *
+ * @param responseBuilder the Rest API response builder
+ * @param httpStatus the status of the response
+ * @param body the response body
+ * @return a RestAPIResponse
+ */
+ RestApiResponse buildResponse(RestApiResponseBuilder responseBuilder, int httpStatus, Serializable body) {
+ return responseBuilder.with {
+ withResponseStatus(httpStatus)
+ withResponse(body)
+ build()
+ }
+ }
+
+ /**
+ * Returns a paged result like Bonita BPM REST APIs.
+ * Build a response with a content-range.
+ *
+ * @param responseBuilder the Rest API response builder
+ * @param body the response body
+ * @param p the page index
+ * @param c the number of result per page
+ * @param total the total number of results
+ * @return a RestAPIResponse
+ */
+ RestApiResponse buildPagedResponse(RestApiResponseBuilder responseBuilder, Serializable body, int p, int c, long total) {
+ return responseBuilder.with {
+ withContentRange(p,c,total)
+ withResponse(body)
+ build()
+ }
+ }
+
+ /**
+ * Load a property file into a java.util.Properties
+ */
+ Properties loadProperties(String fileName, ResourceProvider resourceProvider) {
+ Properties props = new Properties()
+ resourceProvider.getResourceAsStream(fileName).withStream { InputStream s ->
+ props.load s
+ }
+ props
+ }
+
+}
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/configuration.properties b/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/configuration.properties
new file mode 100644
index 0000000..6c146f5
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/configuration.properties
@@ -0,0 +1,2 @@
+#An example of a configuration file containing some parameters
+myParameterKey=bonitasoft.com
\ No newline at end of file
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/page.properties b/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/page.properties
new file mode 100644
index 0000000..a3cea4a
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/main/resources/page.properties
@@ -0,0 +1,38 @@
+#The technical name of the REST API extension
+#Must be URL compliant (alpha-numeric characters with no whitespace) and be prefixed by "custompage_"
+name=custompage_datasource
+
+#Name displayed in the Portal
+displayName=Datasource Rest API extension
+
+#Description displayed in the Portal
+description=A Rest API extension reading a datasource
+
+#Must be apiExtension for a REST API extension
+contentType=apiExtension
+
+#Declare at least one API extension here (comma-separated list)
+apiExtensions=datasource
+
+#For each declared API extension, specify the
+#following properties: method,pathTemplate,classFileName and permissions
+
+#Specify one HTTP verb from GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE
+#GET is the recommended value for a REST API extension.
+#Write operations should be performed by a process.
+datasource.method=GET
+
+#Define the URL path template
+#Resulting URL: ../API/extension/datasource
+datasource.pathTemplate=datasource
+
+#Declare the associated RestAPIController class name
+datasource.className=com.company.bonitasoft.Index
+
+#Declare the permissions list (comma-separated list)
+#For each permission declared, you must map it either to a profile (for example User, Administrator, or a custom profile) or to a specific user.
+#Edit the custom-permissions-mapping.properties configuration file.
+#For example: user|john=[customPermission1,customPermission2] or profile|User=[customPermission1,customPermission2]
+#In production, use the platform-setup tool.
+#In the studio, go to menu Development > REST API Extension > Edit permissions mapping.
+datasource.permissions=customPermission1,customPermission2
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/test/groovy/com/company/bonitasoft/IndexTest.groovy b/src/test/resources/projects/testDatasourceProject10/reference/src/test/groovy/com/company/bonitasoft/IndexTest.groovy
new file mode 100644
index 0000000..8aa46a0
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/test/groovy/com/company/bonitasoft/IndexTest.groovy
@@ -0,0 +1,89 @@
+package com.company.bonitasoft;
+
+import groovy.json.JsonSlurper
+
+import javax.servlet.http.HttpServletRequest
+
+import org.bonitasoft.web.extension.ResourceProvider
+import org.bonitasoft.web.extension.rest.RestApiResponseBuilder
+
+import spock.lang.Specification
+import org.bonitasoft.web.extension.rest.RestAPIContext
+
+import java.time.LocalDate;
+
+/**
+ * @see http://spockframework.github.io/spock/docs/
+ */
+class IndexTest extends Specification {
+
+ // Declare mocks here
+ // Mocks are used to simulate external dependencies behavior
+ def httpRequest = Mock(HttpServletRequest)
+ def resourceProvider = Mock(ResourceProvider)
+ def context = Mock(RestAPIContext)
+
+ /**
+ * You can configure mocks before each tests in the setup method
+ */
+ def setup(){
+ // Simulate access to configuration.properties resource
+ context.resourceProvider >> resourceProvider
+ resourceProvider.getResourceAsStream("configuration.properties") >> IndexTest.class.classLoader.getResourceAsStream("testConfiguration.properties")
+ }
+
+ def should_return_a_json_representation_as_result() {
+ given: "a RestAPIController"
+ def index = new Index()
+ // Simulate a request with a value for each parameter
+ httpRequest.getParameter("userId") >> "aValue1"
+ httpRequest.getParameter("startDate") >> "aValue2"
+
+ when: "Invoking the REST API"
+ def apiResponse = index.doHandle(httpRequest, new RestApiResponseBuilder(), context)
+
+ then: "A JSON representation is returned in response body"
+ def jsonResponse = new JsonSlurper().parseText(apiResponse.response)
+ // Validate returned response
+ apiResponse.httpStatus == 200
+ jsonResponse.userId == "aValue1"
+ jsonResponse.startDate == "aValue2"
+ jsonResponse.myParameterKey == "testValue"
+ jsonResponse.currentDate == LocalDate.now().toString()
+ }
+
+ def should_return_an_error_response_if_userId_is_not_set() {
+ given: "a request without userId"
+ def index = new Index()
+ httpRequest.getParameter("userId") >> null
+ // Other parameters return a valid value
+ httpRequest.getParameter("startDate") >> "aValue2"
+
+ when: "Invoking the REST API"
+ def apiResponse = index.doHandle(httpRequest, new RestApiResponseBuilder(), context)
+
+ then: "A JSON response is returned with a HTTP Bad Request Status (400) and an error message in body"
+ def jsonResponse = new JsonSlurper().parseText(apiResponse.response)
+ // Validate returned response
+ apiResponse.httpStatus == 400
+ jsonResponse.error == "the parameter userId is missing"
+ }
+
+ def should_return_an_error_response_if_startDate_is_not_set() {
+ given: "a request without startDate"
+ def index = new Index()
+ httpRequest.getParameter("startDate") >> null
+ // Other parameters return a valid value
+ httpRequest.getParameter("userId") >> "aValue1"
+
+ when: "Invoking the REST API"
+ def apiResponse = index.doHandle(httpRequest, new RestApiResponseBuilder(), context)
+
+ then: "A JSON response is returned with a HTTP Bad Request Status (400) and an error message in body"
+ def jsonResponse = new JsonSlurper().parseText(apiResponse.response)
+ // Validate returned response
+ apiResponse.httpStatus == 400
+ jsonResponse.error == "the parameter startDate is missing"
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/resources/projects/testDatasourceProject10/reference/src/test/resources/testConfiguration.properties b/src/test/resources/projects/testDatasourceProject10/reference/src/test/resources/testConfiguration.properties
new file mode 100644
index 0000000..11bf9e7
--- /dev/null
+++ b/src/test/resources/projects/testDatasourceProject10/reference/src/test/resources/testConfiguration.properties
@@ -0,0 +1,2 @@
+#An example of a testing configuration file containing some parameters
+myParameterKey=testValue
\ No newline at end of file
diff --git a/src/test/resources/projects/testDatasourceProject7_13/reference/README.adoc b/src/test/resources/projects/testDatasourceProject7_13/reference/README.adoc
index e77efd1..179b9e5 100644
--- a/src/test/resources/projects/testDatasourceProject7_13/reference/README.adoc
+++ b/src/test/resources/projects/testDatasourceProject7_13/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.13
-:doc-url: https://documentation.bonitasoft.com/bonita/7.13
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 11
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testDatasourceProject7_13/reference/pom.xml b/src/test/resources/projects/testDatasourceProject7_13/reference/pom.xml
index dafb458..78183e2 100644
--- a/src/test/resources/projects/testDatasourceProject7_13/reference/pom.xml
+++ b/src/test/resources/projects/testDatasourceProject7_13/reference/pom.xml
@@ -22,13 +22,14 @@
2.3-groovy-3.0
1.14.5
- 1.2.11
+ 1.2.12
3.11.0
${java.version}
+ groovy-eclipse-compiler
3.6.0
- 3.1.0
+ 3.2.2
3.7.0
3.0.8-01
@@ -116,9 +117,6 @@
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin.version}
-
- groovy-eclipse-compiler
-
org.codehaus.groovy
diff --git a/src/test/resources/projects/testJava11Project/reference/README.adoc b/src/test/resources/projects/testJava11Project/reference/README.adoc
index 1568808..26bab76 100644
--- a/src/test/resources/projects/testJava11Project/reference/README.adoc
+++ b/src/test/resources/projects/testJava11Project/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.15
-:doc-url: https://documentation.bonitasoft.com/bonita/7.15
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 11
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testJava11SpProject/reference/README.adoc b/src/test/resources/projects/testJava11SpProject/reference/README.adoc
index 13135d9..2c2715f 100644
--- a/src/test/resources/projects/testJava11SpProject/reference/README.adoc
+++ b/src/test/resources/projects/testJava11SpProject/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.13
-:doc-url: https://documentation.bonitasoft.com/bonita/7.13
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 11
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testJavaSpProject/reference/README.adoc b/src/test/resources/projects/testJavaSpProject/reference/README.adoc
index b80fb2c..d1ff330 100644
--- a/src/test/resources/projects/testJavaSpProject/reference/README.adoc
+++ b/src/test/resources/projects/testJavaSpProject/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.11
-:doc-url: https://documentation.bonitasoft.com/bonita/7.11
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 1.8
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testKotlinProject/reference/README.adoc b/src/test/resources/projects/testKotlinProject/reference/README.adoc
index 89ccb2e..8b7e9aa 100644
--- a/src/test/resources/projects/testKotlinProject/reference/README.adoc
+++ b/src/test/resources/projects/testKotlinProject/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.10
-:doc-url: https://documentation.bonitasoft.com/bonita/7.10
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 1.8
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/projects/testKotlinProject7_13/reference/README.adoc b/src/test/resources/projects/testKotlinProject7_13/reference/README.adoc
index f1f09f8..10a8637 100644
--- a/src/test/resources/projects/testKotlinProject7_13/reference/README.adoc
+++ b/src/test/resources/projects/testKotlinProject7_13/reference/README.adoc
@@ -12,7 +12,7 @@
:imagesdir: ./doc/images
:short-bonita-version: 7.13
-:doc-url: https://documentation.bonitasoft.com/bonita/7.13
+:doc-url: https://documentation.bonitasoft.com/bonita/{short-bonita-version}
:java-version: 11
image::yourlogo.png[your logo here]
diff --git a/src/test/resources/testGroovySubModuleProject/reference/pom.xml b/src/test/resources/testGroovySubModuleProject/reference/pom.xml
index 2f81d1d..6c457e7 100644
--- a/src/test/resources/testGroovySubModuleProject/reference/pom.xml
+++ b/src/test/resources/testGroovySubModuleProject/reference/pom.xml
@@ -12,10 +12,11 @@
My Rest API extension description
1.14.5
+ groovy-eclipse-compiler
3.7.0
3.0.8-01
2.3-groovy-3.0
- 1.2.11
+ 1.2.12
@@ -76,9 +77,6 @@
${groovy-eclipse-batch.version}
-
- groovy-eclipse-compiler
-
maven-assembly-plugin
diff --git a/src/test/resources/testGroovySubModuleProjectPost10/module-parent/pom.xml b/src/test/resources/testGroovySubModuleProjectPost10/module-parent/pom.xml
new file mode 100644
index 0000000..77ffd55
--- /dev/null
+++ b/src/test/resources/testGroovySubModuleProjectPost10/module-parent/pom.xml
@@ -0,0 +1,97 @@
+
+
+
+ 4.0.0
+ com.company.bonitasoft
+ ds-rest-api-parent
+ 1.0.0-SNAPSHOT
+ pom
+
+
+
+ 17
+ UTF-8
+ UTF-8
+ yyyy.MM.dd-hh.mm
+
+
+ 10.0-SNAPSHOT
+
+
+ 3.11.0
+ ${java.version}
+ 3.9.0
+ 3.0.9-03
+ 3.6.0
+ 3.2.2
+
+
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ provided
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ provided
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ provided
+
+
+
+ org.bonitasoft.runtime
+ bonita-runtime-bom
+ ${bonita-runtime.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+
+ maven-compiler-plugin
+
+
+ org.codehaus.groovy
+ groovy-eclipse-compiler
+ ${groovy-eclipse-compiler.version}
+
+
+ org.codehaus.groovy
+ groovy-eclipse-batch
+ ${groovy-eclipse-batch.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire.version}
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ ${maven-surefire.version}
+
+
+ maven-assembly-plugin
+ ${maven-assembly-plugin.version}
+
+
+
+
+
+
diff --git a/src/test/resources/testGroovySubModuleProjectPost10/reference/pom.xml b/src/test/resources/testGroovySubModuleProjectPost10/reference/pom.xml
new file mode 100644
index 0000000..5b334fe
--- /dev/null
+++ b/src/test/resources/testGroovySubModuleProjectPost10/reference/pom.xml
@@ -0,0 +1,81 @@
+
+
+ 4.0.0
+
+ com.company.bonitasoft
+ ds-rest-api-parent
+ 1.0.0-SNAPSHOT
+
+ my-rest-api
+ My-REST-API
+ My Rest API extension description
+
+ 1.14.5
+ groovy-eclipse-compiler
+ 2.3-groovy-3.0
+ 1.2.12
+
+
+
+ org.bonitasoft.web
+ bonita-web-extensions
+ provided
+
+
+ org.codehaus.groovy
+ groovy-json
+ provided
+
+
+ javax.servlet
+ javax.servlet-api
+ provided
+
+
+ org.slf4j
+ slf4j-api
+ provided
+
+
+ org.spockframework
+ spock-core
+ ${spock-core.version}
+ test
+
+
+ net.bytebuddy
+ byte-buddy
+ ${byte-buddy.version}
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback-classic.version}
+ test
+
+
+
+ src/main/groovy
+ src/test/groovy
+ verify
+
+
+ maven-assembly-plugin
+
+
+ package
+
+ single
+
+
+ ${project.basedir}/src/assembly
+ false
+
+
+
+
+
+
+