You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/02/07 16:02:22 UTC
[1/2] camel git commit: The validate goal should only check Camel
component json files and also skip connectors which is a facade
Repository: camel
Updated Branches:
refs/heads/mention a419ffe7c -> 8c9d459d3
The validate goal should only check Camel component json files and also skip connectors which is a facade
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55e92a47
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55e92a47
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55e92a47
Branch: refs/heads/mention
Commit: 55e92a47086c6862b9e847331829fea09dad4b58
Parents: a419ffe
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 7 16:56:20 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 7 16:56:20 2017 +0100
----------------------------------------------------------------------
.../maven/packaging/ValidateComponentMojo.java | 34 ++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/55e92a47/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
index 2c6b2c1..654bd0e 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/ValidateComponentMojo.java
@@ -17,6 +17,9 @@
package org.apache.camel.maven.packaging;
import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.util.Set;
import java.util.TreeSet;
@@ -27,6 +30,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.sonatype.plexus.build.incremental.BuildContext;
+import static org.apache.camel.maven.packaging.PackageHelper.loadText;
import static org.apache.camel.maven.packaging.StringHelper.indentCollection;
import static org.apache.camel.maven.packaging.ValidateHelper.asName;
import static org.apache.camel.maven.packaging.ValidateHelper.validate;
@@ -95,9 +99,8 @@ public class ValidateComponentMojo extends AbstractMojo {
if (!validate) {
getLog().info("Validation disabled");
} else {
-
final Set<File> jsonFiles = new TreeSet<File>();
- PackageHelper.findJsonFiles(outDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
+ PackageHelper.findJsonFiles(outDir, jsonFiles, new CamelComponentsFileFilter());
boolean failed = false;
for (File file : jsonFiles) {
@@ -139,4 +142,31 @@ public class ValidateComponentMojo extends AbstractMojo {
}
}
+ private class CamelComponentsFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+
+ // skip connector metadata
+ if ("camel-connector-schema.json".equals(pathname.getName()) || "camel-component-schema.json".equals(pathname.getName())) {
+ return false;
+ }
+
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a components json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"component\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("component.properties"));
+ }
+ }
+
}
[2/2] camel git commit: Fixed camel-connector to support
componentOptions as well.
Posted by da...@apache.org.
Fixed camel-connector to support componentOptions as well.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8c9d459d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8c9d459d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8c9d459d
Branch: refs/heads/mention
Commit: 8c9d459d36de054e9fae2e901ad38a9bb18173cd
Parents: 55e92a4
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 7 17:02:10 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 7 17:02:10 2017 +0100
----------------------------------------------------------------------
.../camel/maven/connector/ConnectorMojo.java | 44 ++++++++++++++++----
.../main/resources/camel-connector-schema.json | 4 ++
2 files changed, 41 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8c9d459d/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
----------------------------------------------------------------------
diff --git a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
index 94df1e6..b98e478 100644
--- a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
+++ b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
@@ -130,8 +130,6 @@ public class ConnectorMojo extends AbstractJarMojo {
getLog().debug(header);
rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true);
- // we do not offer editing component properties (yet) so clear the rows
- rows.clear();
String componentOptions = buildComponentOptionsSchema(rows, dto);
getLog().debug(componentOptions);
@@ -208,24 +206,56 @@ public class ConnectorMojo extends AbstractJarMojo {
}
private String buildComponentOptionsSchema(List<Map<String, String>> rows, Map dto) throws JsonProcessingException {
+ // find the endpoint options
+ List options = (List) dto.get("componentOptions");
+ Map values = (Map) dto.get("componentValues");
+ Map overrides = (Map) dto.get("componentOverrides");
+
ObjectMapper mapper = new ObjectMapper();
StringBuilder sb = new StringBuilder();
sb.append(" \"componentProperties\": {\n");
+ boolean first = true;
for (int i = 0; i < rows.size(); i++) {
Map<String, String> row = rows.get(i);
String key = row.get("name");
row.remove("name");
+
+ if (options == null || !options.contains(key)) {
+ continue;
+ }
+
+ // do we have a new default value for this row?
+ if (values != null && values.containsKey(key)) {
+ String newDefaultValue = (String) values.get(key);
+ if (newDefaultValue != null) {
+ row.put("defaultValue", newDefaultValue);
+ }
+ }
+
+ // is there any overrides for this row?
+ if (overrides != null && overrides.containsKey(key)) {
+ Map over = (Map) overrides.get(key);
+ if (over != null) {
+ row.putAll(over);
+ }
+ }
+
+ // we should build the json as one-line which is how Camel does it today
+ // which makes its internal json parser support loading our generated schema file
String line = mapper.writeValueAsString(row);
- sb.append(" \"" + key + "\": ");
- sb.append(line);
- if (i < rows.size() - 1) {
+ if (!first) {
sb.append(",\n");
- } else {
- sb.append("\n");
}
+ sb.append(" \"" + key + "\": ");
+ sb.append(line);
+
+ first = false;
+ }
+ if (!first) {
+ sb.append("\n");
}
sb.append(" },\n");
http://git-wip-us.apache.org/repos/asf/camel/blob/8c9d459d/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json
----------------------------------------------------------------------
diff --git a/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json b/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json
index a2228a0..0cd1639 100644
--- a/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json
+++ b/connectors/examples/twitter-mention-connector/src/main/resources/camel-connector-schema.json
@@ -16,6 +16,10 @@
"version": "2.19.0-SNAPSHOT"
},
"componentProperties": {
+ "accessToken": {"kind":"property","group":"security","label":"security","required":"false","type":"string","javaType":"java.lang.String","deprecated":"false","secret":"true","description":"The access token"},
+ "accessTokenSecret": {"kind":"property","group":"security","label":"security","required":"false","type":"string","javaType":"java.lang.String","deprecated":"false","secret":"true","description":"The access token secret"},
+ "consumerKey": {"kind":"property","group":"security","label":"security","required":"false","type":"string","javaType":"java.lang.String","deprecated":"false","secret":"true","description":"The consumer key"},
+ "consumerSecret": {"kind":"property","group":"security","label":"security","required":"false","type":"string","javaType":"java.lang.String","deprecated":"false","secret":"true","description":"The consumer secret"}
},
"properties": {
}