You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/09/20 09:01:14 UTC
[camel] 01/03: CAMEL-13990: Add schema name checks in
EndpointAnnotationProcessor
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 38efc986773aa9544d29c14ed4c255784d6dc438
Author: Omar Al-Safi <om...@gmail.com>
AuthorDate: Wed Sep 18 13:38:02 2019 +0200
CAMEL-13990: Add schema name checks in EndpointAnnotationProcessor
Signed-off-by: Omar Al-Safi <om...@gmail.com>
---
.../org/apache/camel/tools/apt/EndpointAnnotationProcessor.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
index 2de4bbb..353267c 100644
--- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java
@@ -38,6 +38,7 @@ import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic.Kind;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
@@ -94,6 +95,7 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
String extendsScheme = uriEndpoint.extendsScheme();
String title = uriEndpoint.title();
final String label = uriEndpoint.label();
+ validateSchemaName(scheme, classElement);
if (!isNullOrEmpty(scheme)) {
// support multiple schemes separated by comma, which maps to the exact same component
// for example camel-mail has a bunch of component schema names that does that
@@ -122,6 +124,13 @@ public class EndpointAnnotationProcessor extends AbstractCamelAnnotationProcesso
}
}
+ private void validateSchemaName(final String schemaName, final TypeElement classElement) {
+ // our schema name has to be in lowercase
+ if (!schemaName.equals(schemaName.toLowerCase())) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, String.format("Schema name '%s' in '%s' must be lowercase!", schemaName, classElement.getQualifiedName()));
+ }
+ }
+
protected void writeJSonSchemeAndPropertyConfigurer(PrintWriter writer, RoundEnvironment roundEnv, TypeElement classElement, UriEndpoint uriEndpoint,
String title, String scheme, String extendsScheme, String label, String[] schemes) {
// gather component information