davsclaus commented on code in PR #25433:
URL: https://github.com/apache/camel/pull/25433#discussion_r3755606046


##########
components/camel-alibaba/camel-alibaba-common/pom.xml:
##########
@@ -0,0 +1,61 @@
+<?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="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-alibaba-parent</artifactId>
+        <version>4.22.0-SNAPSHOT</version>
+    </parent>
+
+    <properties>
+        <firstVersion>4.22.0</firstVersion>
+    </properties>
+
+    <artifactId>camel-alibaba-common</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Alibaba Cloud :: Common</name>
+    <description>Common utilities for Camel Alibaba Cloud 
components</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-support</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.aliyun</groupId>

Review Comment:
   The `alibabacloud-oss-v2` SDK dependency is OSS-specific but lives in the 
common module. This means `camel-alibaba-mns` (which depends on common) 
transitively pulls in the entire OSS SDK.
   
   Consider moving `AlibabaClientBuilderUtil` (the only class that uses this 
SDK) into `camel-alibaba-oss` and removing this dependency from common. The 
common module should only contain `ServiceKeys`, `AlibabaClientRegistry`, and 
other truly shared code.



##########
parent/pom.xml:
##########
@@ -80,7 +80,13 @@
         <avro-ipc-jetty-version>1.12.1</avro-ipc-jetty-version>
         <avro-ipc-netty-version>1.12.1</avro-ipc-netty-version>
         <awaitility-version>4.3.0</awaitility-version>
+<<<<<<< HEAD

Review Comment:
   **Blocker:** Unresolved merge conflict markers. The branch needs to be 
rebased on current `main`.
   
   ```
   <<<<<<< HEAD
           <aws-java-sdk2-version>2.50.3</aws-java-sdk2-version>
   =======
   ...
   >>>>>>> 23fa869e949
   ```
   
   After rebasing, the resolved version should keep the new 
`alibabacloud-oss-version` and `aliyun-sdk-mns-version` properties and use the 
latest `aws-java-sdk2-version` from `main`.



##########
components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSComponent.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.alibaba.oss;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.HealthCheckComponent;
+
+@Component("alibaba-oss")
+public class OSSComponent extends HealthCheckComponent {
+
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {

Review Comment:
   Missing `@Override` annotation (the MNS component has it).
   
   ```suggestion
       @Override
       protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
   ```



##########
components/camel-alibaba/camel-alibaba-oss/src/main/java/org/apache/camel/component/alibaba/oss/OSSEndpoint.java:
##########
@@ -0,0 +1,240 @@
+/*
+ * 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.alibaba.oss;
+
+import com.aliyun.sdk.service.oss2.OSSClient;
+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.alibaba.common.AlibabaClientBuilderUtil;
+import org.apache.camel.component.alibaba.common.models.ServiceKeys;
+import org.apache.camel.component.alibaba.oss.constants.OSSHeaders;
+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.ScheduledPollEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Alibaba Cloud Object Storage Service (OSS) component
+ */
+@UriEndpoint(firstVersion = "4.22.0", scheme = "alibaba-oss", title = "Alibaba 
Object Storage Service (OSS)",
+             syntax = "alibaba-oss:operation",
+             category = { Category.CLOUD }, headersClass = OSSHeaders.class)
+public class OSSEndpoint extends ScheduledPollEndpoint {
+
+    @UriPath(description = "Operation to be performed", displayName = 
"Operation", label = "producer")
+    @Metadata(required = true)
+    private String operation;
+
+    @UriParam(description = "OSS service region", displayName = "Service 
region")
+    @Metadata(required = true)
+    private String region;
+
+    @UriParam(description = "OSS endpoint URL. Carries higher precedence than 
region based client initialization",
+              displayName = "Endpoint url")
+    private String endpoint;
+
+    @UriParam(description = "Configuration object for cloud service 
authentication", displayName = "Service Configuration",
+              security = "secret", label = "security")
+    private ServiceKeys serviceKeys;
+
+    @UriParam(description = "Access key for the cloud user", displayName = 
"API access key (AK)",
+              security = "secret", label = "security")
+    @Metadata(required = true)
+    private String accessKey;
+
+    @UriParam(description = "Secret key for the cloud user", displayName = 
"API secret key (SK)",
+              security = "secret", label = "security")
+    @Metadata(required = true)
+    private String secretKey;
+
+    @UriParam(description = "Name of bucket to perform operation on", 
displayName = "Bucket Name", endpointIdentity = true)
+    private String bucketName;
+
+    @UriParam(description = "Name of object to perform operation with", 
displayName = "Object Name")
+    private String objectName;
+
+    @UriParam(description = "The object name prefix used for filtering objects 
to be listed", displayName = "Prefix",
+              label = "consumer")
+    private String prefix;
+
+    @UriParam(description = "The maximum number of keys returned when listing 
objects", displayName = "Max Keys",
+              label = "consumer,producer")
+    private Integer maxKeys;
+
+    @UriParam(description = "Determines if objects should be deleted after 
they have been retrieved",
+              displayName = "Delete after read", defaultValue = "false", label 
= "consumer")
+    private boolean deleteAfterRead;
+
+    @UriParam(description = "The maximum number of messages to poll at each 
polling", displayName = "Maximum messages per poll",
+              defaultValue = "10", label = "consumer")
+    private int maxMessagesPerPoll = 10;
+
+    @UriParam(description = "An autowired OSS client", displayName = "OSS 
Client", label = "advanced")
+    @Metadata(autowired = true)
+    private OSSClient ossClient;
+
+    public OSSEndpoint() {
+    }
+
+    public OSSEndpoint(String uri, String operation, OSSComponent component) {
+        super(uri, component);
+        this.operation = operation;
+    }
+
+    public Producer createProducer() throws Exception {
+        return new OSSProducer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        OSSConsumer consumer = new OSSConsumer(this, processor);
+        configureConsumer(consumer);
+        consumer.setMaxMessagesPerPoll(maxMessagesPerPoll);
+        return consumer;
+    }
+
+    /**
+     * Initialize and return an OSS client
+     */
+    public OSSClient initClient() {
+        if (ossClient != null) {
+            return ossClient;
+        }
+
+        if (ObjectHelper.isEmpty(getServiceKeys()) && 
ObjectHelper.isEmpty(getAccessKey())) {
+            throw new IllegalArgumentException("Authentication parameter 
'access key (AK)' not found");
+        }
+        if (ObjectHelper.isEmpty(getServiceKeys()) && 
ObjectHelper.isEmpty(getSecretKey())) {
+            throw new IllegalArgumentException("Authentication parameter 
'secret key (SK)' not found");
+        }
+        if (ObjectHelper.isEmpty(getRegion()) && 
ObjectHelper.isEmpty(getEndpoint())) {
+            throw new IllegalArgumentException("Region/endpoint not found");
+        }
+
+        String auth = getServiceKeys() != null ? 
getServiceKeys().getAccessKey() : getAccessKey();
+        String secret = getServiceKeys() != null ? 
getServiceKeys().getSecretKey() : getSecretKey();
+

Review Comment:
   The created client is returned but never assigned to `this.ossClient`, so 
`getOssClient()` always returns null after initialization and a new client is 
created on every call.
   
   ```suggestion
           this.ossClient = AlibabaClientBuilderUtil.createOssClient(auth, 
secret, region, endpoint);
           return ossClient;
   ```



-- 
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