Commit 3d50d118 authored by Emmanuel Duchastenier's avatar Emmanuel Duchastenier Committed by GitHub
Browse files

feat(C4R): remove example resources from distrib (#348)

Closes [RUNTIME-248](https://bonitasoft.atlassian.net/browse/RUNTIME-248)
parent cd88238f
......@@ -163,22 +163,6 @@
<configuration>
<artifactItems>
<!-- Custom pages -->
<artifactItem>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>groovy-page-example</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<destFileName>bonita-groovy-page-example.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>html-page-example</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<destFileName>bonita-html-page-example.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.web.page</groupId>
<artifactId>page-user-task-list</artifactId>
......@@ -227,22 +211,6 @@
<overWrite>true</overWrite>
<destFileName>bonita-theme.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>api-extension-example</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<destFileName>api-extension-example.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>api-extension-viewer</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<destFileName>api-extension-viewer.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.web.page</groupId>
<artifactId>page-user-process-list</artifactId>
......
<assembly>
<id>page-package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/groovy</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/assembly</directory>
<outputDirectory/>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>resources</artifactId>
<version>7.13.0-SNAPSHOT</version>
</parent>
<artifactId>api-extension-example</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.bonitasoft.web</groupId>
<artifactId>bonita-web-extensions</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-json</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.groovy-wslite</groupId>
<artifactId>groovy-wslite</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/groovy</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>page-content</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
<configuration>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>content.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
name=custompage_apiExtensionExample
displayName=REST API extension example
description=REST API extension example archive for Bonita Portal. Included examples: Get/Post, how to use a logger, customize response, call SOAP web service.
#zip is a rest api extension
contentType=apiExtension
#list of api extension in zip
apiExtensions=demoLog,demoHeaders,demoPost,demoXml,demoGet,demoSoap
#Get resource return a simple echo of query parameters
demoGet.method=GET
demoGet.pathTemplate=demo/getExample
demoGet.classFileName=Get.groovy
demoGet.permissions=demoPermission
#Customize response with additional header, cookie and response code
demoHeaders.method=GET
demoHeaders.pathTemplate=demo/headerExample
demoHeaders.classFileName=Index.groovy
demoHeaders.permissions=demoPermission
#Use a provided logger
demoLog.method=GET
demoLog.pathTemplate=demo/logExample
demoLog.classFileName=Log.groovy
demoLog.permissions=demoPermission
#Return an XML content with specific media type and character set
demoXml.method=GET
demoXml.pathTemplate=demo/xmlExample
demoXml.classFileName=Xml.groovy
demoXml.permissions=demoPermission
#Post resources with Json payload and return a simple echo of parameters
demoPost.method=POST
demoPost.pathTemplate=demo/postExample
demoPost.classFileName=Post.groovy
demoPost.permissions=demoPermission
#Call to external SOAP webservice
demoSoap.method=GET
demoSoap.pathTemplate=demo/soapExample
demoSoap.classFileName=Soap.groovy
demoSoap.permissions=demoPermission
is is a REST API extension example archive for Bonita Portal.
You can customize this custom page by modifying the existing resources or by adding or removing some.
Examples provided in the archive:
Customize response with additional header, cookie and response code
Get resource return a simple echo of query parameters
Use a provided logger
Post resources with Json payload and return a simple echo of parameters
Return an XML content with specific media type and character set
Content detail:
Index.groovy Customize response with additional header, cookie and response code
Get.groovy Get resource return a simple echo of query parameters
Log.groovy Use a provided logger
Post.groovy Post resources with Json payload and return a simple echo of parameters
Xml.groovy Return an XML content with specific media type and character set
Soap.groovy Call to external SOAP webservice (requires internet connexion)
xml/demo.xmlxml sample file used by Xml.groovy example
page.properties Contains page metadata (such as name, displayName, description, extension configuration), and is used by the Engine when the platform starts and when a extension is added or updated
readme.txt this file
<?xml version="1.0" ?>
<Собирание версия="1.2-3">
<Объект id="12">
<НомерОбъекта>45-3454-123</НомерОбъекта>
<ВНаличии>123</ВНаличии>
</Объект>
<Объект id="64">
<НомерОбъекта>45-7894-456</НомерОбъекта>
<ВНаличии>123</ВНаличии>
</Объект>
</Собирание>
import groovy.json.JsonBuilder
import javax.servlet.http.HttpServletRequest
import org.bonitasoft.web.extension.rest.*
class Get implements RestApiController {
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
Map<String, String> response = [:]
response.put "response", "hello from get resource"
response.putAll request.parameterMap
apiResponseBuilder.with {
withResponse new JsonBuilder(response).toString()
build()
}
}
}
import groovy.json.JsonBuilder
import org.bonitasoft.web.extension.rest.*
import javax.servlet.http.Cookie
import javax.servlet.http.HttpServletRequest
class Index implements RestApiController {
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
Map<String, String> response = [:]
response.with {
put "cookie added","myCookie"
put "header added","awesome header"
put "response status changed","201"
}
apiResponseBuilder.with {
withResponse(new JsonBuilder(response).toString())
withAdditionalHeader("awesome header", "some value")
withAdditionalCookie(new Cookie("myCookie", "cookie value"))
withResponseStatus(201)
build()
}
}
}
import groovy.json.JsonBuilder
import org.bonitasoft.web.extension.rest.*
import org.slf4j.LoggerFactory
import javax.servlet.http.HttpServletRequest
import org.slf4j.Logger
class Log implements RestApiController {
private static final Logger LOGGER = LoggerFactory.getLogger(Log.class)
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
LOGGER.info "info message from REST API extension example"
LOGGER.debug "debug message from REST API extension example"
LOGGER.error "error message from REST API extension example"
Map<String, Serializable> response = [:]
response.put "response", "hello with log"
response.put "actual logger name", LOGGER.name
apiResponseBuilder.with {
withResponse new JsonBuilder(response).toString()
build()
}
}
}
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import org.bonitasoft.web.extension.rest.*
import javax.servlet.http.HttpServletRequest
class Post implements RestApiController {
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
String joinRequest = request.reader.readLines().join("\n")
Map<String, String> response = [:]
def slurper = new JsonSlurper()
if (joinRequest != null && !joinRequest.empty) {
def requestParameters = slurper.parseText(joinRequest)
response.with{
put "response", "hello from post resource with json payload"
putAll requestParameters
}
apiResponseBuilder.withResponse new JsonBuilder(response).toString()
}
else {
response.put "response", "hello from post resource with empty payload"
apiResponseBuilder.withResponse new JsonBuilder(response).toString()
}
apiResponseBuilder.build()
}
}
import groovy.json.JsonBuilder
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import org.bonitasoft.web.extension.rest.*
import wslite.soap.SOAPClient
import wslite.soap.SOAPResponse
class Soap implements RestApiController{
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
String yearParam = request.getParameter "year"
Map<String, String> result = [:]
if (yearParam == null) {
result.put "error", "the attribute year is missing"
apiResponseBuilder.withResponseStatus(HttpServletResponse.SC_BAD_REQUEST)
} else {
try {
def currentYear = yearParam as int
SOAPClient client = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')
SOAPResponse response = client.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMothersDay') {
body {
GetMothersDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
year(currentYear)
}
}
}
result.put "mothersDay", response.GetMothersDayResponse.GetMothersDayResult.text()
} catch (NumberFormatException e) {
result.put "error", "the attribute year must be an integer"
apiResponseBuilder.withResponseStatus(HttpServletResponse.SC_BAD_REQUEST)
}
}
JsonBuilder builder = new JsonBuilder(result)
apiResponseBuilder.with {
withResponse builder.toString()
build()
}
}
}
import org.bonitasoft.web.extension.rest.*
import javax.servlet.http.HttpServletRequest
class Xml implements RestApiController {
@Override
RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder apiResponseBuilder, RestAPIContext context) {
String xmlResponse
context.resourceProvider.getResourceAsStream("xml/demo.xml").withStream { InputStream s ->
xmlResponse = s.getText()
}
apiResponseBuilder.with {
withResponse(xmlResponse)
withMediaType("application/xml")
withCharacterSet("ISO-8859-5")
build()
}
}
}
<assembly>
<id>page-package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/groovy</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.bonitasoft.distrib</groupId>
<artifactId>resources</artifactId>
<version>7.13.0-SNAPSHOT</version>
</parent>
<artifactId>api-extension-viewer</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>page-content</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<inherited>false</inherited>
<configuration>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>content.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
name=custompage_apiExtensionViewer
displayName=API extension viewer page
description=API extension viewer page generated with Bonita UI designer
resources=[GET|extension/demo/getExample,GET|extension/demo/headerExample,GET|extension/demo/logExample,GET|extension/demo/xmlExample,POST|extension/demo/postExample,GET|extension/demo/soapExample]
contentType=page
.table-hover tr {
cursor: pointer;
}
.component {
margin-bottom: 3px;
margin-top: 3px;
}
/* .component is in col- system, so for widget including .container we set his width to 100% to avoid horizontal scrollbar
if we don't do that, bootstrap will set it's width in px corresponding to resolution
*/
.component .container {
width: 100%;
}
.typeahead-sublist {padding: 0}
.typeahead-sublist li {
list-style: none;
padding: 0 5px;
display: inline-block;
}
input[type=text|email|number|password].ng-invalid.ng-dirty {
border-color: #C00;
border-width: 1px;
}
.control-label--required:after {
content: "*";
color: #C00;
}
/**
* file upload
*/
.file-upload {
position: relative;
overflow: hidden;
.form-control {
z-index: 1;
&[readonly] {
cursor: inherit;
}
}
}
.file-upload-input {
position: absolute;
top: 0;
right: 0;
min-width: 100%;
min-height: 100%;
font-size: 100px;
text-align: right;
filter: alpha(opacity=0);
opacity: 0;
outline: none;
background: white;
cursor: pointer;
display: block;
z-index: 2;
}
.file-upload-input--disabled {
left: 0;
right: auto;
width:0;
height:0;
filter: alpha(opacity=0);
opacity: 0;
z-index: -1;
}
.file-upload-clear{
border: none;
background: transparent;
font-size: 16px;
z-index: 3;
position: absolute;
top: calc(50% - .7em);
right: 2.5em;
color: #666;
padding: .1em .4em;
}
.file-upload-clear:hover {
color: #333;
}