davsclaus commented on a change in pull request #6107:
URL: https://github.com/apache/camel/pull/6107#discussion_r711522383



##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionEndpoint.java
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.huaweicloud.common.models.ServiceKeys;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * component to connect to image recognition service
+ */
+@UriEndpoint(firstVersion = "3.12.0-SNAPSHOT", scheme = "hwcloud-image", title 
= "Huawei Cloud Image Recognition",
+             syntax = "hwcloud-image:operation",
+             category = { Category.CLOUD, Category.MESSAGING }, producerOnly = 
true)
+public class ImageRecognitionEndpoint extends DefaultEndpoint {
+    @UriPath(
+             description = "Name of Image Recognition operation to perform, 
including celebrityRecognition and tagRecognition",
+             displayName = "Operation name", label = "producer")
+    @Metadata(required = true)
+    private String operation;
+
+    @UriParam(description = "Configuration object for cloud service 
authentication",
+              displayName = "Service Configuration", secret = true)
+    @Metadata(required = false)
+    private ServiceKeys serviceKeys;
+
+    @UriParam(description = "Access key for the cloud user", displayName = 
"Account access key (AK)", secret = true)
+    @Metadata(required = true)
+    private String accessKey;
+
+    @UriParam(description = "Secret key for the cloud user", displayName = 
"Account secret key (SK)", secret = true)
+    @Metadata(required = true)
+    private String secretKey;
+
+    @UriParam(description = "Cloud project ID", displayName = "Project ID", 
secret = false)
+    @Metadata(required = true)
+    private String projectId;
+
+    @UriParam(description = "Proxy server ip/hostname", displayName = "Proxy 
server host", secret = false)
+    @Metadata(required = false)
+    private String proxyHost;
+
+    @UriParam(description = "Proxy server port", displayName = "Proxy server 
port", secret = false)
+    @Metadata(required = false)
+    private int proxyPort;
+
+    @UriParam(description = "Proxy authentication user", displayName = "Proxy 
user", secret = true)
+    @Metadata(required = false)
+    private String proxyUser;
+
+    @UriParam(description = "Proxy authentication password", displayName = 
"Proxy password", secret = true)
+    @Metadata(required = false)
+    private String proxyPassword;
+
+    @UriParam(description = "Ignore SSL verification", displayName = "SSL 
Verification Ignored", secret = false,
+              defaultValue = "false", label = "security")
+    @Metadata(required = false)
+    private boolean ignoreSslVerification;
+
+    @UriParam(
+              description = "Image Recognition service region. Currently only 
cn-north-1 and cn-north-4 are supported. This is lower precedence than endpoint 
based configuration.",
+              displayName = "Service region", secret = false)
+    @Metadata(required = true)
+    private String region;
+
+    @UriParam(
+              description = "Fully qualified Image Recognition service url. 
Carries higher precedence than region based configuration.",
+              displayName = "Service endpoint", secret = false)
+    @Metadata(required = false)
+    private String endpoint;
+
+    @UriParam(
+              description = "Indicates the Base64 character string converted 
from the image. The size cannot exceed 10 MB. The image resolution of the 
narrow sides must be greater than 15 pixels, and that of the wide sides cannot 
exceed 4096 pixels."
+                            + "The supported image formats include JPG, PNG, 
and BMP. \n"
+                            + "Configure either this parameter or imageUrl, 
and this one carries higher precedence than imageUrl.",
+              displayName = "imageContent", secret = false)
+    @Metadata(required = false)

Review comment:
       Remove all metadata with required false as that is the default

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");

Review comment:
       Remove LOG error as you throw an exception

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");
+            throw new IllegalStateException("operation name cannot be empty");
+        }
+        switch (operation) {
+            case ImageRecognitionConstants.OPERATION_CELEBRITY_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing celebrity recognition");
+                }
+                performCelebrityRecognitionOperation(exchange);
+                break;
+            case ImageRecognitionConstants.OPERATION_TAG_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing tag recognition");
+                }
+                performTagRecognitionOperation(exchange);
+                break;
+            default:
+                LOG.error("Unsupported operation: {}", operation);
+                throw new UnsupportedOperationException(
+                        "operation can only be either tagRecognition or 
celebrityRecognition");
+        }
+    }
+
+    /**
+     * perform celebrity recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performCelebrityRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        CelebrityRecognitionReq reqBody = new 
CelebrityRecognitionReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold());
+
+        RunCelebrityRecognitionResponse response
+                = this.imageClient.runCelebrityRecognition(new 
RunCelebrityRecognitionRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * perform tag recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performTagRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        ImageTaggingReq reqBody = new 
ImageTaggingReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold())
+                .withLanguage(this.clientConfigurations.getTagLanguage())
+                .withLimit(this.clientConfigurations.getTagLimit());
+
+        RunImageTaggingResponse response = 
this.imageClient.runImageTagging(new 
RunImageTaggingRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * Update dynamic client configurations. Some endpoint parameters 
(imageContent, imageUrl, tagLanguage, tagLimit and
+     * threshold) can also be passed via exchange properties, so they can be 
updated between each transaction. Since
+     * they can change, we must clear the previous transaction and update 
these parameters with their new values
+     *
+     * @param exchange camel exchange
+     */
+    private void updateClientConfigurations(Exchange exchange) {
+        resetDynamicConfigurations();
+
+        boolean isImageContentSet = true;
+        boolean isImageUrlSet = true;
+
+        String imageContent = 
exchange.getProperty(ImageRecognitionProperties.IMAGE_CONTENT, String.class);
+        if (!StringUtils.isEmpty(imageContent)) {
+            clientConfigurations.setImageContent(imageContent);
+        } else if (!StringUtils.isEmpty(this.endpoint.getImageContent())) {
+            
clientConfigurations.setImageContent(this.endpoint.getImageContent());
+        } else {
+            isImageContentSet = false;
+        }
+
+        String imageUrl = 
exchange.getProperty(ImageRecognitionProperties.IMAGE_URL, String.class);
+        if (!StringUtils.isEmpty(imageUrl)) {
+            clientConfigurations.setImageUrl(imageUrl);
+        } else if (!StringUtils.isEmpty(this.endpoint.getImageUrl())) {
+            clientConfigurations.setImageUrl(this.endpoint.getImageUrl());
+        } else {
+            isImageUrlSet = false;
+        }
+        if (!isImageContentSet && !isImageUrlSet) {
+            LOG.error("Image content and url are not set");
+            throw new IllegalArgumentException("either image content or image 
url should be set");
+        }
+
+        String tagLanguageProperty = 
exchange.getProperty(ImageRecognitionProperties.TAG_LANGUAGE, String.class);
+        clientConfigurations.setTagLanguage(
+                StringUtils.isEmpty(tagLanguageProperty) ? 
this.endpoint.getTagLanguage() : tagLanguageProperty);
+        if 
(!ImageRecognitionConstants.TAG_LANGUAGE_ZH.equals(clientConfigurations.getTagLanguage())
+                && 
!ImageRecognitionConstants.TAG_LANGUAGE_EN.equals(clientConfigurations.getTagLanguage()))
 {
+            LOG.error("Tag language is invalid: {}", 
clientConfigurations.getTagLanguage());
+            throw new IllegalArgumentException("tag language can only be 'zh' 
or 'en'");
+        }
+
+        Integer tagLimitProperty = 
exchange.getProperty(ImageRecognitionProperties.TAG_LIMIT, Integer.class);
+        clientConfigurations.setTagLimit(tagLimitProperty == null ? 
endpoint.getTagLimit() : tagLimitProperty);
+
+        Float thresholdProperty = 
exchange.getProperty(ImageRecognitionProperties.THRESHOLD, Float.class);
+        clientConfigurations.setThreshold(thresholdProperty == null ? 
endpoint.getThreshold() : thresholdProperty);
+
+        if (clientConfigurations.getThreshold() == -1) {
+            clientConfigurations
+                    
.setThreshold(ImageRecognitionConstants.OPERATION_TAG_RECOGNITION.equals(endpoint.getOperation())
+                            ? 
ImageRecognitionConstants.DEFAULT_TAG_RECOGNITION_THRESHOLD
+                            : 
ImageRecognitionConstants.DEFAULT_CELEBRITY_RECOGNITION_THRESHOLD);
+        }
+        validateThresholdValue(clientConfigurations.getThreshold(), 
endpoint.getOperation());
+    }
+
+    /**
+     * validate threshold value. for tagRecognition, threshold should be at 
0~100. for celebrityRecognition, threshold
+     * should be at 0~1.
+     *
+     * @param threshold threshold value
+     * @param operation operation
+     */
+    private void validateThresholdValue(float threshold, String operation) {
+        if 
(ImageRecognitionConstants.OPERATION_TAG_RECOGNITION.equals(operation)) {
+            if (threshold < 0 || threshold > 
ImageRecognitionConstants.TAG_RECOGNITION_THRESHOLD_MAX) {
+                LOG.error("Tag threshold is invalid: {}", threshold);

Review comment:
       Same thing dont log and throw exception

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionEndpoint.java
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.huaweicloud.common.models.ServiceKeys;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * component to connect to image recognition service
+ */
+@UriEndpoint(firstVersion = "3.12.0-SNAPSHOT", scheme = "hwcloud-image", title 
= "Huawei Cloud Image Recognition",

Review comment:
       Do not use SNAPSHOT here

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");
+            throw new IllegalStateException("operation name cannot be empty");
+        }
+        switch (operation) {
+            case ImageRecognitionConstants.OPERATION_CELEBRITY_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing celebrity recognition");
+                }
+                performCelebrityRecognitionOperation(exchange);
+                break;
+            case ImageRecognitionConstants.OPERATION_TAG_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing tag recognition");
+                }
+                performTagRecognitionOperation(exchange);
+                break;
+            default:
+                LOG.error("Unsupported operation: {}", operation);

Review comment:
       Same here

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(

Review comment:
       Why is the is WARN? An end user may think something is not good. 

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");
+            throw new IllegalStateException("operation name cannot be empty");
+        }
+        switch (operation) {
+            case ImageRecognitionConstants.OPERATION_CELEBRITY_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing celebrity recognition");
+                }
+                performCelebrityRecognitionOperation(exchange);
+                break;
+            case ImageRecognitionConstants.OPERATION_TAG_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing tag recognition");
+                }
+                performTagRecognitionOperation(exchange);
+                break;
+            default:
+                LOG.error("Unsupported operation: {}", operation);
+                throw new UnsupportedOperationException(
+                        "operation can only be either tagRecognition or 
celebrityRecognition");

Review comment:
       Use upper case O in Operation

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");

Review comment:
       Do not log and throw exception

##########
File path: components/camel-huawei/camel-huaweicloud-imagerecognition/pom.xml
##########
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://maven.apache.org/POM/4.0.0";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-huawei-parent</artifactId>
+        <version>3.12.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-huaweicloud-imagerecognition</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Huawei Cloud :: ImageRecognition Component</name>
+    <description>A Camel Huawei Image Recognition component</description>
+
+    <properties>
+        <firstVersion>3.12.0</firstVersion>
+    </properties>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-huaweicloud-common</artifactId>
+            <version>3.12.0-SNAPSHOT</version>

Review comment:
       Remove version or use ${project.version}

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/test/resources/log4j2.properties
##########
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-huaweicloud-iam-test.log

Review comment:
       Wrong file name

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");
+            throw new IllegalStateException("operation name cannot be empty");
+        }
+        switch (operation) {
+            case ImageRecognitionConstants.OPERATION_CELEBRITY_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing celebrity recognition");
+                }
+                performCelebrityRecognitionOperation(exchange);
+                break;
+            case ImageRecognitionConstants.OPERATION_TAG_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing tag recognition");
+                }
+                performTagRecognitionOperation(exchange);
+                break;
+            default:
+                LOG.error("Unsupported operation: {}", operation);
+                throw new UnsupportedOperationException(
+                        "operation can only be either tagRecognition or 
celebrityRecognition");
+        }
+    }
+
+    /**
+     * perform celebrity recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performCelebrityRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        CelebrityRecognitionReq reqBody = new 
CelebrityRecognitionReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold());
+
+        RunCelebrityRecognitionResponse response
+                = this.imageClient.runCelebrityRecognition(new 
RunCelebrityRecognitionRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * perform tag recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performTagRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        ImageTaggingReq reqBody = new 
ImageTaggingReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold())
+                .withLanguage(this.clientConfigurations.getTagLanguage())
+                .withLimit(this.clientConfigurations.getTagLimit());
+
+        RunImageTaggingResponse response = 
this.imageClient.runImageTagging(new 
RunImageTaggingRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * Update dynamic client configurations. Some endpoint parameters 
(imageContent, imageUrl, tagLanguage, tagLimit and
+     * threshold) can also be passed via exchange properties, so they can be 
updated between each transaction. Since
+     * they can change, we must clear the previous transaction and update 
these parameters with their new values
+     *
+     * @param exchange camel exchange
+     */
+    private void updateClientConfigurations(Exchange exchange) {
+        resetDynamicConfigurations();

Review comment:
       This is not thread safe! you can have concurrent exchanges with 
different configurations that then both alter this shared configuration

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionEndpoint.java
##########
@@ -0,0 +1,292 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.huaweicloud.common.models.ServiceKeys;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * component to connect to image recognition service
+ */
+@UriEndpoint(firstVersion = "3.12.0-SNAPSHOT", scheme = "hwcloud-image", title 
= "Huawei Cloud Image Recognition",
+             syntax = "hwcloud-image:operation",
+             category = { Category.CLOUD, Category.MESSAGING }, producerOnly = 
true)
+public class ImageRecognitionEndpoint extends DefaultEndpoint {
+    @UriPath(
+             description = "Name of Image Recognition operation to perform, 
including celebrityRecognition and tagRecognition",
+             displayName = "Operation name", label = "producer")
+    @Metadata(required = true)
+    private String operation;
+
+    @UriParam(description = "Configuration object for cloud service 
authentication",
+              displayName = "Service Configuration", secret = true)
+    @Metadata(required = false)
+    private ServiceKeys serviceKeys;
+
+    @UriParam(description = "Access key for the cloud user", displayName = 
"Account access key (AK)", secret = true)
+    @Metadata(required = true)
+    private String accessKey;
+
+    @UriParam(description = "Secret key for the cloud user", displayName = 
"Account secret key (SK)", secret = true)
+    @Metadata(required = true)
+    private String secretKey;
+
+    @UriParam(description = "Cloud project ID", displayName = "Project ID", 
secret = false)

Review comment:
       Remove all the secret = false as that is the default and just clutter up 
the code

##########
File path: 
components/camel-huawei/camel-huaweicloud-imagerecognition/src/main/java/org/apache/camel/component/huaweicloud/image/ImageRecognitionProducer.java
##########
@@ -0,0 +1,327 @@
+/*
+ * 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.component.huaweicloud.image;
+
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.core.utils.StringUtils;
+import com.huaweicloud.sdk.image.v2.ImageClient;
+import com.huaweicloud.sdk.image.v2.model.CelebrityRecognitionReq;
+import com.huaweicloud.sdk.image.v2.model.ImageTaggingReq;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionRequest;
+import com.huaweicloud.sdk.image.v2.model.RunCelebrityRecognitionResponse;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingRequest;
+import com.huaweicloud.sdk.image.v2.model.RunImageTaggingResponse;
+import com.huaweicloud.sdk.image.v2.region.ImageRegion;
+import org.apache.camel.Exchange;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionConstants;
+import 
org.apache.camel.component.huaweicloud.image.constants.ImageRecognitionProperties;
+import 
org.apache.camel.component.huaweicloud.image.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ImageRecognitionProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(ImageRecognitionProducer.class);
+
+    private ImageClient imageClient;
+
+    private ClientConfigurations clientConfigurations;
+
+    private ImageRecognitionEndpoint endpoint;
+
+    public ImageRecognitionProducer(ImageRecognitionEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = initializeConfigurations(this.endpoint);
+        this.imageClient = initializeClient(this.endpoint);
+    }
+
+    /**
+     * initialize ClientConfigurations
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ClientConfigurations
+     */
+    private ClientConfigurations 
initializeConfigurations(ImageRecognitionEndpoint endpoint) {
+        ClientConfigurations clientConfigurations = new ClientConfigurations();
+
+        clientConfigurations.setAccessKey(getAccessKey(endpoint));
+        clientConfigurations.setSecretKey(getSecretKey(endpoint));
+        clientConfigurations.setProjectId(getProjectId(endpoint));
+        clientConfigurations.setEndpoint(getEndpoint(endpoint));
+
+        if (StringUtils.isEmpty(endpoint.getImageContent()) && 
StringUtils.isEmpty(endpoint.getImageUrl())) {
+            if (StringUtils.isEmpty(endpoint.getRegion())) {
+                LOG.error("image and url not found");
+                throw new IllegalArgumentException("either image or url should 
be set");
+            }
+        }
+        
clientConfigurations.setIgnoreSslVerification(endpoint.isIgnoreSslVerification());
+        if (clientConfigurations.isIgnoreSslVerification()) {
+            LOG.warn("SSL verification is ignored. This is unsafe in 
production environment");
+        }
+        if (!StringUtils.isEmpty(endpoint.getProxyHost())) {
+            clientConfigurations.setProxyHost(endpoint.getProxyHost());
+            clientConfigurations.setProxyPort(endpoint.getProxyPort());
+            clientConfigurations.setProxyUser(endpoint.getProxyUser());
+            clientConfigurations.setProxyPassword(endpoint.getProxyPassword());
+        }
+        return clientConfigurations;
+    }
+
+    /**
+     * initialize image client. this is lazily initialized on the first message
+     *
+     * @param  endpoint ImageRecognitionEndpoint
+     * @return          ImageClient
+     */
+    private ImageClient initializeClient(ImageRecognitionEndpoint endpoint) {
+        if (endpoint.getImageClient() != null) {
+            LOG.warn(
+                    "Instance of ImageClient was set on the endpoint. Skipping 
creation of ImageClient from endpoint parameters");
+            return endpoint.getImageClient();
+        }
+        HttpConfig httpConfig = null;
+        if (clientConfigurations.getProxyHost() != null) {
+            httpConfig = HttpConfig.getDefaultHttpConfig()
+                    .withProxyHost(clientConfigurations.getProxyHost())
+                    .withProxyPort(clientConfigurations.getProxyPort())
+                    
.withIgnoreSSLVerification(clientConfigurations.isIgnoreSslVerification());
+
+            if (clientConfigurations.getProxyUser() != null) {
+                
httpConfig.setProxyUsername(clientConfigurations.getProxyUser());
+                
httpConfig.setProxyPassword(clientConfigurations.getProxyPassword());
+            }
+        }
+
+        BasicCredentials credentials = new 
BasicCredentials().withAk(clientConfigurations.getAccessKey())
+                .withSk(clientConfigurations.getSecretKey())
+                .withProjectId(clientConfigurations.getProjectId());
+
+        ImageClient client = ImageClient.newBuilder()
+                .withCredential(credentials)
+                .withHttpConfig(httpConfig)
+                .withEndpoint(clientConfigurations.getEndpoint())
+                .build();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Successfully initialized Image client");
+        }
+        return client;
+    }
+
+    public void process(Exchange exchange) {
+        String operation = ((ImageRecognitionEndpoint) 
super.getEndpoint()).getOperation();
+        if (StringUtils.isEmpty(operation)) {
+            LOG.error("Operation is empty");
+            throw new IllegalStateException("operation name cannot be empty");
+        }
+        switch (operation) {
+            case ImageRecognitionConstants.OPERATION_CELEBRITY_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing celebrity recognition");
+                }
+                performCelebrityRecognitionOperation(exchange);
+                break;
+            case ImageRecognitionConstants.OPERATION_TAG_RECOGNITION:
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Performing tag recognition");
+                }
+                performTagRecognitionOperation(exchange);
+                break;
+            default:
+                LOG.error("Unsupported operation: {}", operation);
+                throw new UnsupportedOperationException(
+                        "operation can only be either tagRecognition or 
celebrityRecognition");
+        }
+    }
+
+    /**
+     * perform celebrity recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performCelebrityRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        CelebrityRecognitionReq reqBody = new 
CelebrityRecognitionReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold());
+
+        RunCelebrityRecognitionResponse response
+                = this.imageClient.runCelebrityRecognition(new 
RunCelebrityRecognitionRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * perform tag recognition
+     *
+     * @param exchange camel exchange
+     */
+    private void performTagRecognitionOperation(Exchange exchange) {
+        updateClientConfigurations(exchange);
+
+        ImageTaggingReq reqBody = new 
ImageTaggingReq().withImage(this.clientConfigurations.getImageContent())
+                .withUrl(this.clientConfigurations.getImageUrl())
+                .withThreshold(this.clientConfigurations.getThreshold())
+                .withLanguage(this.clientConfigurations.getTagLanguage())
+                .withLimit(this.clientConfigurations.getTagLimit());
+
+        RunImageTaggingResponse response = 
this.imageClient.runImageTagging(new 
RunImageTaggingRequest().withBody(reqBody));
+
+        exchange.getMessage().setBody(response.getResult());
+    }
+
+    /**
+     * Update dynamic client configurations. Some endpoint parameters 
(imageContent, imageUrl, tagLanguage, tagLimit and
+     * threshold) can also be passed via exchange properties, so they can be 
updated between each transaction. Since
+     * they can change, we must clear the previous transaction and update 
these parameters with their new values
+     *
+     * @param exchange camel exchange
+     */
+    private void updateClientConfigurations(Exchange exchange) {
+        resetDynamicConfigurations();
+
+        boolean isImageContentSet = true;
+        boolean isImageUrlSet = true;
+
+        String imageContent = 
exchange.getProperty(ImageRecognitionProperties.IMAGE_CONTENT, String.class);
+        if (!StringUtils.isEmpty(imageContent)) {
+            clientConfigurations.setImageContent(imageContent);
+        } else if (!StringUtils.isEmpty(this.endpoint.getImageContent())) {
+            
clientConfigurations.setImageContent(this.endpoint.getImageContent());
+        } else {
+            isImageContentSet = false;
+        }
+
+        String imageUrl = 
exchange.getProperty(ImageRecognitionProperties.IMAGE_URL, String.class);
+        if (!StringUtils.isEmpty(imageUrl)) {
+            clientConfigurations.setImageUrl(imageUrl);
+        } else if (!StringUtils.isEmpty(this.endpoint.getImageUrl())) {
+            clientConfigurations.setImageUrl(this.endpoint.getImageUrl());
+        } else {
+            isImageUrlSet = false;
+        }
+        if (!isImageContentSet && !isImageUrlSet) {
+            LOG.error("Image content and url are not set");
+            throw new IllegalArgumentException("either image content or image 
url should be set");
+        }
+
+        String tagLanguageProperty = 
exchange.getProperty(ImageRecognitionProperties.TAG_LANGUAGE, String.class);
+        clientConfigurations.setTagLanguage(
+                StringUtils.isEmpty(tagLanguageProperty) ? 
this.endpoint.getTagLanguage() : tagLanguageProperty);
+        if 
(!ImageRecognitionConstants.TAG_LANGUAGE_ZH.equals(clientConfigurations.getTagLanguage())
+                && 
!ImageRecognitionConstants.TAG_LANGUAGE_EN.equals(clientConfigurations.getTagLanguage()))
 {
+            LOG.error("Tag language is invalid: {}", 
clientConfigurations.getTagLanguage());
+            throw new IllegalArgumentException("tag language can only be 'zh' 
or 'en'");
+        }
+
+        Integer tagLimitProperty = 
exchange.getProperty(ImageRecognitionProperties.TAG_LIMIT, Integer.class);
+        clientConfigurations.setTagLimit(tagLimitProperty == null ? 
endpoint.getTagLimit() : tagLimitProperty);
+
+        Float thresholdProperty = 
exchange.getProperty(ImageRecognitionProperties.THRESHOLD, Float.class);
+        clientConfigurations.setThreshold(thresholdProperty == null ? 
endpoint.getThreshold() : thresholdProperty);
+
+        if (clientConfigurations.getThreshold() == -1) {
+            clientConfigurations
+                    
.setThreshold(ImageRecognitionConstants.OPERATION_TAG_RECOGNITION.equals(endpoint.getOperation())
+                            ? 
ImageRecognitionConstants.DEFAULT_TAG_RECOGNITION_THRESHOLD
+                            : 
ImageRecognitionConstants.DEFAULT_CELEBRITY_RECOGNITION_THRESHOLD);
+        }
+        validateThresholdValue(clientConfigurations.getThreshold(), 
endpoint.getOperation());
+    }
+
+    /**
+     * validate threshold value. for tagRecognition, threshold should be at 
0~100. for celebrityRecognition, threshold
+     * should be at 0~1.
+     *
+     * @param threshold threshold value
+     * @param operation operation
+     */
+    private void validateThresholdValue(float threshold, String operation) {
+        if 
(ImageRecognitionConstants.OPERATION_TAG_RECOGNITION.equals(operation)) {
+            if (threshold < 0 || threshold > 
ImageRecognitionConstants.TAG_RECOGNITION_THRESHOLD_MAX) {
+                LOG.error("Tag threshold is invalid: {}", threshold);
+                throw new IllegalArgumentException("tag recognition threshold 
should be at 0~100");
+            }
+        } else {
+            if (threshold < 0 || threshold > 
ImageRecognitionConstants.CELEBRITY_RECOGNITION_THRESHOLD_MAX) {
+                LOG.error("Celebrity recognition threshold is invalid: {}", 
threshold);

Review comment:
       Same thing dont log and throw exception




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to