Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Generate extension list readme file via tooling like we do at Apache Camel #243

Merged
merged 4 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions catalog/camel-quarkus-catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@
</dependencies>
<executions>
<execution>
<!-- prepare the catalog, readme files, etc. -->
<goals>
<goal>prepare-catalog-quarkus</goal>
<goal>prepare-extensions-readme</goal>
</goals>
<phase>process-resources</phase>
</execution>
Expand Down
142 changes: 142 additions & 0 deletions extensions/readme.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
= Components

davsclaus marked this conversation as resolved.
Show resolved Hide resolved
// components: START
Number of Components: 22 in 18 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
| Component | Available From | Description

| link:https://camel.apache.org/components/latest/aws-eks-component.html[AWS EKS] (camel-quarkus-aws-eks) +
`aws-eks:label` | 3.0 | The aws-kms is used for managing Amazon EKS

| link:https://camel.apache.org/components/latest/aws-s3-component.html[AWS S3 Storage Service] (camel-quarkus-aws-s3) +
`aws-s3://bucketNameOrArn` | 2.8 | The aws-s3 component is used for storing and retrieving object from Amazon S3 Storage Service.

| link:https://camel.apache.org/components/latest/aws-sns-component.html[AWS Simple Notification System] (camel-quarkus-aws-sns) +
`aws-sns:topicNameOrArn` | 2.8 | The aws-sns component is used for sending messages to an Amazon Simple Notification Topic.

| link:https://camel.apache.org/components/latest/aws-sqs-component.html[AWS Simple Queue Service] (camel-quarkus-aws-sqs) +
`aws-sqs:queueNameOrArn` | 2.6 | The aws-sqs component is used for sending and receiving messages to Amazon's SQS service.

| link:https://camel.apache.org/components/latest/bean-component.html[Bean] (camel-quarkus-bean) +
`bean:beanName` | 1.0 | The bean component is for invoking Java beans from Camel.

| link:https://camel.apache.org/components/latest/class-component.html[Class] (camel-quarkus-bean) +
`class:beanName` | 2.4 | The class component is for invoking Java classes (Java beans) from Camel.

| link:https://camel.apache.org/components/latest/direct-component.html[Direct] (camel-quarkus-direct) +
`direct:name` | 1.0 | The direct component provides direct, synchronous call to another endpoint from the same CamelContext.

| link:https://camel.apache.org/components/latest/infinispan-component.html[Infinispan] (camel-quarkus-infinispan) +
`infinispan:cacheName` | 2.13 | For reading/writing from/to Infinispan distributed key/value store and data grid.

| link:https://camel.apache.org/components/latest/jdbc-component.html[JDBC] (camel-quarkus-jdbc) +
`jdbc:dataSourceName` | 1.2 | The jdbc component enables you to access databases through JDBC, where SQL queries are sent in the message body.

| link:https://camel.apache.org/components/latest/log-component.html[Log] (camel-quarkus-log) +
`log:loggerName` | 1.1 | The log component logs message exchanges to the underlying logging mechanism.

| link:https://camel.apache.org/components/latest/mail-component.html[Mail] (camel-quarkus-mail) +
`imap:host:port` | 1.0 | To send or receive emails using imap/pop3 or smtp protocols.

| link:https://camel.apache.org/components/latest/microprofile-metrics-component.html[MicroProfile Metrics] (camel-quarkus-microprofile-metrics) +
`microprofile-metrics:metricType:metricName` | 3.0 | Camel metrics exposed with Eclipse MicroProfile Metrics

| link:https://camel.apache.org/components/latest/netty-http-component.html[Netty HTTP] (camel-quarkus-netty-http) +
`netty-http:protocol:host:port/path` | 2.14 | Netty HTTP server and client using the Netty 4.x library.

| link:https://camel.apache.org/components/latest/paho-component.html[Paho] (camel-quarkus-paho) +
`paho:topic` | 2.16 | Component for communicating with MQTT M2M message brokers using Eclipse Paho MQTT Client.

| link:https://camel.apache.org/components/latest/rest-component.html[REST] (camel-quarkus-rest) +
`rest:method:path:uriTemplate` | 2.14 | The rest component is used for either hosting REST services (consumer) or calling external REST services (producer).

| link:https://camel.apache.org/components/latest/rest-api-component.html[REST API] (camel-quarkus-rest) +
`rest-api:path/contextIdPattern` | 2.16 | The rest-api component is used for providing Swagger API of the REST services which has been defined using the rest-dsl in Camel.

| link:https://camel.apache.org/components/latest/salesforce-component.html[Salesforce] (camel-quarkus-salesforce) +
`salesforce:operationName:topicName` | 2.12 | The salesforce component is used for integrating Camel with the massive Salesforce API.

| link:https://camel.apache.org/components/latest/servlet-component.html[Servlet] (camel-quarkus-servlet) +
`servlet:contextPath` | 2.0 | To use a HTTP Servlet as entry for Camel routes when running in a servlet container.

| link:https://camel.apache.org/components/latest/timer-component.html[Timer] (camel-quarkus-timer) +
`timer:timerName` | 1.0 | The timer component is used for generating message exchanges when a timer fires.

| link:https://camel.apache.org/components/latest/twitter-directmessage-component.html[Twitter Direct Message] (camel-quarkus-twitter) +
`twitter-directmessage:user` | 2.10 | The Twitter Direct Message Component consumes/produces user's direct messages.

| link:https://camel.apache.org/components/latest/twitter-search-component.html[Twitter Search] (camel-quarkus-twitter) +
`twitter-search:keywords` | 2.10 | The Twitter Search component consumes search results.

| link:https://camel.apache.org/components/latest/twitter-timeline-component.html[Twitter Timeline] (camel-quarkus-twitter) +
`twitter-timeline:timelineType` | 2.10 | The Twitter Timeline component consumes twitter timeline or update the status of specific user.

|===
// components: END


== Data Formats

// dataformats: START
Number of Data Formats: 3 in 3 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
| Data Format | Available From | Description

| link:https://camel.apache.org/components/latest/csv-dataformat.html[CSV] (camel-quarkus-csv) | 1.3 | The CSV data format is used for handling CSV payloads.

| link:https://camel.apache.org/components/latest/mime-multipart-dataformat.html[MIME Multipart] (camel-quarkus-mail) | 2.17 | The MIME Multipart data format can marshal a Camel message with attachments into a Camel message having a MIME-Multipart message as message body (and no attachments), and vise-versa when unmarshalling.

| link:https://camel.apache.org/components/latest/zipfile-dataformat.html[Zip File] (camel-quarkus-zipfile) | 2.11 | The Zip File data format is a message compression and de-compression format of zip files.
|===
// dataformats: END


== Expression Languages

// languages: START
Number of Languages: 8 in 2 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
| Language | Available From | Description

| link:https://camel.apache.org/components/latest/bean-language.html[Bean method] (camel-quarkus-bean) | 1.3 | To use a Java bean (aka method call) in Camel expressions or predicates.

| link:https://camel.apache.org/components/latest/constant-language.html[Constant] (camel-quarkus-core) | 1.5 | To use a constant value in Camel expressions or predicates. Important: this is a fixed constant value that is only set once during starting up the route, do not use this if you want dynamic values during routing.

| link:https://camel.apache.org/components/latest/exchangeProperty-language.html[ExchangeProperty] (camel-quarkus-core) | 2.0 | To use a Camel Exchange property in expressions or predicates.

| link:https://camel.apache.org/components/latest/file-language.html[File] (camel-quarkus-core) | 1.1 | For expressions and predicates using the file/simple language

| link:https://camel.apache.org/components/latest/header-language.html[Header] (camel-quarkus-core) | 1.5 | To use a Camel Message header in expressions or predicates.

| link:https://camel.apache.org/components/latest/ref-language.html[Ref] (camel-quarkus-core) | 2.8 | Reference to an existing Camel expression or predicate, which is looked up from the Camel registry.

| link:https://camel.apache.org/components/latest/simple-language.html[Simple] (camel-quarkus-core) | 1.1 | To use Camels built-in Simple language in Camel expressions or predicates.

| link:https://camel.apache.org/components/latest/tokenize-language.html[Tokenize] (camel-quarkus-core) | 2.0 | To use Camel message body or header with a tokenizer in Camel expressions or predicates.
|===
// languages: END


== Miscellaneous Components

// others: START
Number of Miscellaneous Components: 3 in 3 JAR artifacts (0 deprecated)

[width="100%",cols="4,1,5",options="header"]
|===
| Component | Available From | Description

| (camel-quarkus-core-cloud) | 0.2 | The Camel Quarkus core cloud module

| (camel-quarkus-platform-http) | 0.2.1 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer

| (camel-quarkus-reactive-executor) | 0.2.1 | To use Quarkus reactive executor with Camel
|===
// others: END

5 changes: 5 additions & 0 deletions tooling/maven/package-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
<artifactId>plexus-build-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-util-json</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.maven;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.camel.util.json.JsonObject;
import org.apache.camel.util.json.Jsoner;

public final class JSonSchemaHelper {

private JSonSchemaHelper() {
}

/**
* Parses the json schema to split it into a list or rows, where each row contains key value pairs with the metadata
*
* @param group the group to parse from such as <tt>component</tt>, <tt>componentProperties</tt>, or <tt>properties</tt>.
* @param json the json
* @return a list of all the rows, where each row is a set of key value pairs with metadata
*/
public static List<Map<String, String>> parseJsonSchema(String group, String json, boolean parseProperties) {
List<Map<String, String>> answer = new ArrayList<>();
if (json == null) {
return answer;
}

// convert into a List<Map<String, String>> structure which is expected as output from this parser
try {
JsonObject output = (JsonObject) Jsoner.deserialize(json);
for (String key : output.keySet()) {
Map<?, ?> row = output.getMap(key);
if (key.equals(group)) {
if (parseProperties) {
// flattern each entry in the row with name as they key, and its value as the content (its a map also)
for (Object obj : row.entrySet()) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
Map<String, String> newRow = new LinkedHashMap<>();
newRow.put("name", entry.getKey().toString());

Map<String, String> newData = transformMap((Map<?, ?>) entry.getValue());
newRow.putAll(newData);
answer.add(newRow);
}
} else {
// flattern each entry in the row as a list of single Map<key, value> elements
Map<?, ?> newData = transformMap(row);
for (Object obj : newData.entrySet()) {
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj;
Map<String, String> newRow = new LinkedHashMap<>();
newRow.put(entry.getKey().toString(), entry.getValue().toString());
answer.add(newRow);
}
}
}
}
} catch (Exception e) {
// wrap parsing exceptions as runtime
throw new RuntimeException("Cannot parse json", e);
}

return answer;
}

private static Map<String, String> transformMap(Map<?, ?> jsonMap) {
Map<String, String> answer = new LinkedHashMap<>();

for (Object rowObj : jsonMap.entrySet()) {
Map.Entry<?, ?> rowEntry = (Map.Entry<?, ?>) rowObj;
// if its a list type then its an enum, and we need to parse it as a single line separated with comma
// to be backwards compatible
Object newValue = rowEntry.getValue();
if (newValue instanceof List) {
List<?> list = (List<?>) newValue;
newValue = list.stream().map(Object::toString)
.collect(Collectors.joining(","));
}
// ensure value is escaped
String value = escapeJson(newValue.toString());
answer.put(rowEntry.getKey().toString(), value);
}

return answer;
}

private static String escapeJson(String value) {
// need to safe encode \r as \\r so its escaped
// need to safe encode \n as \\n so its escaped
// need to safe encode \t as \\t so its escaped
return value
.replaceAll("\\\\r", "\\\\\\r")
.replaceAll("\\\\n", "\\\\\\n")
.replaceAll("\\\\t", "\\\\\\t");
}

/**
* Gets the value with the key in a safe way, eg returning an empty string if there was no value for the key.
*/
public static String getSafeValue(String key, List<Map<String, String>> rows) {
for (Map<String, String> row : rows) {
String value = row.get(key);
if (value != null) {
return value;
}
}
return "";
}

/**
* Gets the value with the key in a safe way, eg returning an empty string if there was no value for the key.
*/
public static String getSafeValue(String key, Map<String, String> rows) {
String value = rows.get(key);
if (value != null) {
return value;
}
return "";
}

public static String getPropertyDefaultValue(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String defaultValue = null;
boolean found = false;
if (row.containsKey("name")) {
found = name.equals(row.get("name"));
}
if (row.containsKey("defaultValue")) {
defaultValue = row.get("defaultValue");
}
if (found) {
return defaultValue;
}
}
return null;
}

public static String getPropertyDescriptionValue(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String description = null;
boolean found = false;
if (row.containsKey("name")) {
found = name.equals(row.get("name"));
}
if (row.containsKey("description")) {
description = row.get("description");
}
if (found) {
return description;
}
}
return null;
}

public static String getPropertyJavaType(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String javaType = null;
boolean found = false;
if (row.containsKey("name")) {
found = name.equals(row.get("name"));
}
if (row.containsKey("javaType")) {
javaType = row.get("javaType");
}
if (found) {
return javaType;
}
}
return null;
}

public static String getPropertyType(List<Map<String, String>> rows, String name) {
for (Map<String, String> row : rows) {
String type = null;
boolean found = false;
if (row.containsKey("name")) {
found = name.equals(row.get("name"));
}
if (row.containsKey("type")) {
type = row.get("type");
}
if (found) {
return type;
}
}
return null;
}

}