omarsmak commented on a change in pull request #4697:
URL: https://github.com/apache/camel/pull/4697#discussion_r532446710



##########
File path: 
components/camel-azure-storage-datalake/src/main/java/org/apache/camel/component/azure/storage/datalake/DataLakeComponent.java
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.azure.storage.datalake;
+
+import java.util.Map;
+import java.util.Set;
+
+import com.azure.identity.ClientSecretCredential;
+import com.azure.storage.common.StorageSharedKeyCredential;
+import com.azure.storage.file.datalake.DataLakeServiceClient;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component("azure-storage-datalake")
+public class DataLakeComponent extends DefaultComponent {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(DataLakeComponent.class);
+
+    @Metadata(description = "configuration object for datalake")
+    private DataLakeConfiguration configuration = new DataLakeConfiguration();
+
+    public DataLakeComponent() {
+    }
+
+    public DataLakeComponent(final CamelContext camelContext) {
+        super(camelContext);
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+
+        if (remaining == null || remaining.trim().isEmpty()) {
+            throw new IllegalArgumentException("At least the account name must 
be specified");
+        }
+
+        final DataLakeConfiguration configuration;
+        if (this.configuration != null) {
+            configuration = this.configuration.copy();
+        } else {
+            configuration = new DataLakeConfiguration();
+        }
+
+        final String[] details = remaining.split("/");
+
+        configuration.setAccountName(details[0]);
+
+        if (details.length > 1) {
+            configuration.setFileSystemName(details[1]);
+        }
+
+        final DataLakeEndpoint endpoint = new DataLakeEndpoint(uri, this, 
configuration);
+        setProperties(endpoint, parameters);
+        setClientFromRegistry(configuration);
+
+        setCredentialsFromRegistry(configuration);
+        validateConfiguration(configuration);
+
+        return endpoint;
+    }
+
+    public DataLakeConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(DataLakeConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    private void setCredentialsFromRegistry(final DataLakeConfiguration 
configuration) {
+        final DataLakeServiceClient client = configuration.getServiceClient();
+
+        if (client == null) {
+            Set<StorageSharedKeyCredential> storageSharedKeyCredentials
+                    = 
getCamelContext().getRegistry().findByType(StorageSharedKeyCredential.class);
+            Set<ClientSecretCredential> clientSecretCredentials
+                    = 
getCamelContext().getRegistry().findByType(ClientSecretCredential.class);
+
+            if (storageSharedKeyCredentials.size() == 1) {
+                
configuration.setSharedKeyCredential(storageSharedKeyCredentials.stream().findFirst().get());
+            }
+
+            if (clientSecretCredentials.size() == 1) {
+                
configuration.setClientSecretCredential(clientSecretCredentials.stream().findFirst().get());
+            }
+
+        }
+    }
+
+    private void setClientFromRegistry(final DataLakeConfiguration 
configuration) {

Review comment:
       Actually we no longer need this, we can now autowire the client by 
adding `@Metadata(autowired = true)` to the serviceClient configuration and 
remove this. An example 
[here](https://github.com/apache/camel/commit/bc8fa176a66bfab4b5385305c626fddc01d29c2b#diff-fa0be9a42d8b24af5d483c6e806968d302c829087bcf363ce5fc2e67559ca863)

##########
File path: 
components/camel-azure-storage-datalake/src/main/java/org/apache/camel/component/azure/storage/datalake/DataLakeEndpoint.java
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.azure.storage.datalake;
+
+import com.azure.storage.file.datalake.DataLakeServiceClient;
+import org.apache.camel.Category;
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import 
org.apache.camel.component.azure.storage.datalake.client.DataLakeClientFactory;
+import 
org.apache.camel.component.azure.storage.datalake.operations.DataLakeOperationResponse;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@UriEndpoint(firstVersion = "3.5.0", scheme = "azure-storage-datalake", title 
= "Azure storage datalake service",

Review comment:
       the first version should be 3.7.0

##########
File path: 
components/camel-azure-storage-datalake/src/main/java/org/apache/camel/component/azure/storage/datalake/DataLakeComponent.java
##########
@@ -0,0 +1,126 @@
+/*
+ * 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.azure.storage.datalake;
+
+import java.util.Map;
+import java.util.Set;
+
+import com.azure.identity.ClientSecretCredential;
+import com.azure.storage.common.StorageSharedKeyCredential;
+import com.azure.storage.file.datalake.DataLakeServiceClient;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component("azure-storage-datalake")
+public class DataLakeComponent extends DefaultComponent {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(DataLakeComponent.class);
+
+    @Metadata(description = "configuration object for datalake")
+    private DataLakeConfiguration configuration = new DataLakeConfiguration();
+
+    public DataLakeComponent() {
+    }
+
+    public DataLakeComponent(final CamelContext camelContext) {
+        super(camelContext);
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, 
Map<String, Object> parameters) throws Exception {
+
+        if (remaining == null || remaining.trim().isEmpty()) {
+            throw new IllegalArgumentException("At least the account name must 
be specified");
+        }
+
+        final DataLakeConfiguration configuration;
+        if (this.configuration != null) {
+            configuration = this.configuration.copy();
+        } else {
+            configuration = new DataLakeConfiguration();
+        }
+
+        final String[] details = remaining.split("/");
+
+        configuration.setAccountName(details[0]);
+
+        if (details.length > 1) {
+            configuration.setFileSystemName(details[1]);
+        }
+
+        final DataLakeEndpoint endpoint = new DataLakeEndpoint(uri, this, 
configuration);
+        setProperties(endpoint, parameters);
+        setClientFromRegistry(configuration);
+
+        setCredentialsFromRegistry(configuration);
+        validateConfiguration(configuration);
+
+        return endpoint;
+    }
+
+    public DataLakeConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(DataLakeConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    private void setCredentialsFromRegistry(final DataLakeConfiguration 
configuration) {
+        final DataLakeServiceClient client = configuration.getServiceClient();
+
+        if (client == null) {
+            Set<StorageSharedKeyCredential> storageSharedKeyCredentials
+                    = 
getCamelContext().getRegistry().findByType(StorageSharedKeyCredential.class);
+            Set<ClientSecretCredential> clientSecretCredentials
+                    = 
getCamelContext().getRegistry().findByType(ClientSecretCredential.class);
+
+            if (storageSharedKeyCredentials.size() == 1) {
+                
configuration.setSharedKeyCredential(storageSharedKeyCredentials.stream().findFirst().get());
+            }
+
+            if (clientSecretCredentials.size() == 1) {
+                
configuration.setClientSecretCredential(clientSecretCredentials.stream().findFirst().get());
+            }
+
+        }
+    }
+
+    private void setClientFromRegistry(final DataLakeConfiguration 
configuration) {
+        if (ObjectHelper.isEmpty(configuration.getServiceClient())) {
+            final Set<DataLakeServiceClient> clients = 
getCamelContext().getRegistry().findByType(DataLakeServiceClient.class);
+
+            if (clients.size() == 1) {
+                
configuration.setServiceClient(clients.stream().findFirst().get());
+            }
+
+        }
+    }
+
+    private void validateConfiguration(final DataLakeConfiguration config) {
+        if (config.getServiceClient() == null && 
config.getClientSecretCredential() == null) {
+            throw new IllegalArgumentException("cliet or credentials must be 
specified");

Review comment:
       typo here

##########
File path: 
components/camel-azure-storage-datalake/src/main/java/org/apache/camel/component/azure/storage/datalake/operations/DataLakeDirectoryOperations.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.azure.storage.datalake.operations;
+
+import org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration;
+import 
org.apache.camel.component.azure.storage.datalake.DataLakeConfigurationOptionsProxy;
+import 
org.apache.camel.component.azure.storage.datalake.client.DataLakeDirectoryClientWrapper;
+import org.apache.camel.util.ObjectHelper;
+
+public class DataLakeDirectoryOperations {

Review comment:
       Is there any good use for this class?




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to