This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new 0d8852de Expression as non string value in YAML
0d8852de is described below
commit 0d8852deedd7dd6f9c989954bbf068312755241c
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Fri Dec 6 11:28:26 2024 -0500
Expression as non string value in YAML
---
.../src/main/webui/src/designer/utils/CamelUi.tsx | 2 +-
karavan-core/src/core/api/CamelUtil.ts | 8 +--
karavan-designer/public/example/demo.camel.yaml | 57 +++++++++-------------
karavan-designer/src/designer/utils/CamelUi.tsx | 2 +-
karavan-space/src/designer/utils/CamelUi.tsx | 2 +-
5 files changed, 29 insertions(+), 42 deletions(-)
diff --git a/karavan-app/src/main/webui/src/designer/utils/CamelUi.tsx
b/karavan-app/src/main/webui/src/designer/utils/CamelUi.tsx
index a12e19d6..523e03db 100644
--- a/karavan-app/src/main/webui/src/designer/utils/CamelUi.tsx
+++ b/karavan-app/src/main/webui/src/designer/utils/CamelUi.tsx
@@ -403,7 +403,7 @@ export class CamelUi {
static isShowExpressionTooltip = (element: CamelElement): boolean => {
if (element.hasOwnProperty("expression")) {
const exp = CamelDefinitionApiExt.getExpressionValue((element as
any).expression);
- return (exp !== undefined && (exp as
any)?.expression?.trim().length > 0);
+ return (exp !== undefined && (exp as
any)?.expression?.toString().trim().length > 0);
}
return false;
}
diff --git a/karavan-core/src/core/api/CamelUtil.ts
b/karavan-core/src/core/api/CamelUtil.ts
index f9def80c..ff148a5b 100644
--- a/karavan-core/src/core/api/CamelUtil.ts
+++ b/karavan-core/src/core/api/CamelUtil.ts
@@ -216,7 +216,7 @@ export class CamelUtil {
if (elementMeta) {
for (const property of elementMeta.properties.filter(p =>
p.required)) {
const value = (element as any)[property.name];
- if (property.type === 'string' && !property.isArray && (value
=== undefined || !value.trim())) {
+ if (property.type === 'string' && !property.isArray && (value
=== undefined || !value.toString().trim())) {
result[0] = false;
result[1].push(`${property.displayName} is required`);
} else if (['ExpressionSubElementDefinition',
'ExpressionDefinition'].includes(property.type)) {
@@ -242,7 +242,7 @@ export class CamelUtil {
const requiredProperties =
CamelUtil.getComponentProperties(element).filter(p => p.required);
for (const property of requiredProperties) {
const value =
CamelDefinitionApiExt.getParametersValue(element, property.name, property.kind
=== 'path');
- if (value === undefined || (property.type === 'string' &&
value.trim().length === 0)) {
+ if (value === undefined || (property.type === 'string' &&
value.toString().trim().length === 0)) {
result[0] = false;
result[1].push(`${property.displayName} is required`);
}
@@ -251,7 +251,7 @@ export class CamelUtil {
for (const property of secretProperties) {
const value =
CamelDefinitionApiExt.getParametersValue(element, property.name, property.kind
=== 'path');
if (value !== undefined && property.type === 'string'
- && (!value?.trim()?.startsWith("{{") ||
!value?.trim()?.endsWith('}}'))) {
+ && (!value?.toString().trim()?.startsWith("{{") ||
!value?.toString().trim()?.endsWith('}}'))) {
result[0] = false;
result[1].push(`${property.displayName} is set in
plain text`);
}
@@ -270,7 +270,7 @@ export class CamelUtil {
const sensitiveParameters = filledParameters.filter(p =>
CamelUtil.checkIfKameletParameterSensitive(p, kamelet));
sensitiveParameters.forEach(p => {
const value = elementAsAny?.parameters[p];
- if (value !== undefined &&
(!value?.trim()?.startsWith("{{") || !value?.trim()?.endsWith('}}'))) {
+ if (value !== undefined &&
(!value?.toString()?.trim()?.startsWith("{{") ||
!value?.toString()?.trim()?.endsWith('}}'))) {
result[0] = false;
result[1].push(`${p} is set in plain text`);
}
diff --git a/karavan-designer/public/example/demo.camel.yaml
b/karavan-designer/public/example/demo.camel.yaml
index 6c655d36..f8e0248f 100644
--- a/karavan-designer/public/example/demo.camel.yaml
+++ b/karavan-designer/public/example/demo.camel.yaml
@@ -1,35 +1,22 @@
-- routeTemplate:
- id: routeFileReaderTemplate2
- description: File reader template
- route:
- id: routeFileReader 2
- description: File reader route
- from:
- id: from-4101
- uri: sftp
- steps:
- - to:
- id: to-1234
- uri: sql
- parameters:
- query: "{{folderName}}"
- - loadBalance:
- id: loadBalance-8172
- - log:
- id: log-7fa8
- message: ${body}
- - loop:
- id: loop-6068
- expression:
- groovy:
- id: groovy-4e44
- steps:
- - marshal:
- id: marshal-930d
- json:
- id: json-135e
- parameters:
- - description: Folder with files
- name: folderName
- - description: Server Hostname
- name: serverName
+- beans:
+ - name: userService
+ type: "org.apache.camel.example.rest.UserService"
+- route:
+ from:
+ uri: direct
+ parameters:
+ name: getUser
+ steps:
+ - to:
+ uri: bean
+ parameters:
+ beanName: userService
+ method: "getUser(${header.id})"
+ - filter:
+ simple:
+ expression: "${body} == null"
+ steps:
+ - setHeader:
+ name: Exchange.HTTP_RESPONSE_CODE
+ constant:
+ expression: 404
\ No newline at end of file
diff --git a/karavan-designer/src/designer/utils/CamelUi.tsx
b/karavan-designer/src/designer/utils/CamelUi.tsx
index a12e19d6..523e03db 100644
--- a/karavan-designer/src/designer/utils/CamelUi.tsx
+++ b/karavan-designer/src/designer/utils/CamelUi.tsx
@@ -403,7 +403,7 @@ export class CamelUi {
static isShowExpressionTooltip = (element: CamelElement): boolean => {
if (element.hasOwnProperty("expression")) {
const exp = CamelDefinitionApiExt.getExpressionValue((element as
any).expression);
- return (exp !== undefined && (exp as
any)?.expression?.trim().length > 0);
+ return (exp !== undefined && (exp as
any)?.expression?.toString().trim().length > 0);
}
return false;
}
diff --git a/karavan-space/src/designer/utils/CamelUi.tsx
b/karavan-space/src/designer/utils/CamelUi.tsx
index a12e19d6..523e03db 100644
--- a/karavan-space/src/designer/utils/CamelUi.tsx
+++ b/karavan-space/src/designer/utils/CamelUi.tsx
@@ -403,7 +403,7 @@ export class CamelUi {
static isShowExpressionTooltip = (element: CamelElement): boolean => {
if (element.hasOwnProperty("expression")) {
const exp = CamelDefinitionApiExt.getExpressionValue((element as
any).expression);
- return (exp !== undefined && (exp as
any)?.expression?.trim().length > 0);
+ return (exp !== undefined && (exp as
any)?.expression?.toString().trim().length > 0);
}
return false;
}