You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/06/25 16:12:13 UTC
[GitHub] [camel] hokutor opened a new pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
hokutor opened a new pull request #5753:
URL: https://github.com/apache/camel/pull/5753
JIRA - https://issues.apache.org/jira/browse/CAMEL-16758
Huawei Cloud's Object Storage Service (OBS) provides stable, secure, efficient, and easy-to-use cloud storage service that lets you store virtually any volume of unstructured data in any format and access it from anywhere. Refer to https://www.huaweicloud.com/intl/en-us/product/obs.html for more information.
This PR contains the first 3 operations for integrating with Huawei Cloud's OBS.
- listBuckets
- createBucket
- deleteBucket
Other bucket operations and object operations will be added soon, including support for consumer operations.
<!-- Uncomment and fill this section if your PR is not trivial
- [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
-->
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660840532
##########
File path: components/camel-huawei/camel-huaweicloud-obs/pom.xml
##########
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
Review comment:
Added missing license header in pom file
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660842130
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/ClientConfigurations.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.obs.models;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to combine parameters which can be passed through exchange properties and endpoint parameters to avoid checking
+ * both each time they are used
+ */
+public class ClientConfigurations {
+ private static final Logger LOG = LoggerFactory.getLogger(ClientConfigurations.class.getName());
Review comment:
Removed unused logger in ClientConfigurations 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.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660088871
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
Review comment:
Remove this as you have WARN logging for every requrest
##########
File path: components/camel-huawei/camel-huaweicloud-obs/pom.xml
##########
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
Review comment:
Add missing LICENSE header
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/OBSRegion.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.obs.models;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Class containing Huawei Cloud OBS regions and endpoints
+ */
+public final class OBSRegion {
Review comment:
Is an ENUM not a better class for this? Then you can also use Camel's enum support with automatic type conversion and avoid any mixed case problems, eg CN-NORTH-1 vs cn-north-1
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/ClientConfigurations.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.obs.models;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to combine parameters which can be passed through exchange properties and endpoint parameters to avoid checking
+ * both each time they are used
+ */
+public class ClientConfigurations {
+ private static final Logger LOG = LoggerFactory.getLogger(ClientConfigurations.class.getName());
Review comment:
Remove not used logger
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("No bucket location given, defaulting to '" + OBSConstants.DEFAULT_LOCATION + "'");
+ }
+ clientConfigurations.setBucketLocation(OBSConstants.DEFAULT_LOCATION);
+ }
+ // verify valid bucket location
+ OBSRegion.checkValidRegion(clientConfigurations.getBucketLocation());
+
+ request = new CreateBucketRequest(clientConfigurations.getBucketName(), clientConfigurations.getBucketLocation());
+ }
+
+ // invoke create bucket method and map response object to exchange body
+ ObsBucket response = obsClient.createBucket(request);
+ exchange.getMessage().setBody(gson.toJson(response));
+ }
+
+ /**
+ * Perform delete bucket operation
+ *
+ * @param exchange
+ */
+ private void deleteBucket(Exchange exchange) throws ObsException {
+ // check for bucket name, which is mandatory to delete a bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: parent/pom.xml
##########
@@ -239,6 +239,7 @@
<httpcore4-version>4.4.14</httpcore4-version>
<httpclient4-version>4.5.13</httpclient4-version>
<httpasyncclient-version>4.1.4</httpasyncclient-version>
+ <huaweicloud-obs-version>3.21.4.1</huaweicloud-obs-version>
Review comment:
Use same indent as the other lines
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("No bucket location given, defaulting to '" + OBSConstants.DEFAULT_LOCATION + "'");
+ }
+ clientConfigurations.setBucketLocation(OBSConstants.DEFAULT_LOCATION);
+ }
+ // verify valid bucket location
+ OBSRegion.checkValidRegion(clientConfigurations.getBucketLocation());
+
+ request = new CreateBucketRequest(clientConfigurations.getBucketName(), clientConfigurations.getBucketLocation());
+ }
+
+ // invoke create bucket method and map response object to exchange body
+ ObsBucket response = obsClient.createBucket(request);
+ exchange.getMessage().setBody(gson.toJson(response));
+ }
+
+ /**
+ * Perform delete bucket operation
+ *
+ * @param exchange
+ */
+ private void deleteBucket(Exchange exchange) throws ObsException {
+ // check for bucket name, which is mandatory to delete a bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to delete bucket");
+ }
+
+ // invoke delete bucket method and map response object to exchange body
+ HeaderResponse response = obsClient.deleteBucket(clientConfigurations.getBucketName());
+ exchange.getMessage().setBody(gson.toJson(response.getResponseHeaders()));
+ }
+
+ /**
+ * Update dynamic client configurations. Some endpoint parameters (operation, and bucket name and location) 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
+ */
+ private void updateClientConfigs(Exchange exchange) {
+ resetDynamicConfigs();
+
+ // checking for required operation (exchange overrides endpoint operation if both are provided)
+ if (ObjectHelper.isEmpty(exchange.getProperty(OBSProperties.OPERATION))
+ && ObjectHelper.isEmpty(endpoint.getOperation())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Do not LOG and re-throw. Remove this!
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/test/resources/log4j2.properties
##########
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.out.type = Console
Review comment:
For logging we log by default to a test log file. See the other components and their log4j properties file
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-869828105
I am trying to upgrade the OBS component to 3.12.0-SNAPSHOT, but many of the dependencies cannot be resolved when I try to build it. I pulled the latest changes from the main branch, so I tried to build an existing component (huaweicloud-functiongraph) to see if the dependencies would be resolved there, but I'm getting the following error:
```
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.736 s
[INFO] Finished at: 2021-06-28T12:14:13-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.camel:camel-bundle-plugin:3.12.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.apache.camel:camel-bundle-plugin:jar:3.12.0-SNAPSHOT in central-plugin
```
I noticed that the camel-bundle-plugin is not yet updated to the latest release of 3.11.0

--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-870003413
You need to rebuild the entire source tree to update to 3.12.0-SNAPSHOT.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] omarsmak commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
omarsmak commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r659537020
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
Review comment:
I guess this will be targeting 3.12 since 3.11 has been released?
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
Review comment:
same here
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
+ syntax = "hwcloud-obs:operation",
+ category = { Category.CLOUD })
+public class OBSEndpoint extends DefaultEndpoint {
+
+ @UriPath(description = "Operation to be performed", displayName = "Operation", label = "producer", secret = false)
Review comment:
no need to add `secret=false`, it is by default `false`
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ this.clientConfigurations = new ClientConfigurations();
Review comment:
I think initializing new objects could be moved to `doInit`
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660051558
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ this.clientConfigurations = new ClientConfigurations();
Review comment:
Done. Initializing objects now done in doInit instead of doStart
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor edited a comment on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor edited a comment on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-869828105
@omarsmak -
I am trying to upgrade the OBS component to 3.12.0-SNAPSHOT, but many of the dependencies cannot be resolved when I try to build it. I pulled the latest changes from the main branch, so I tried to build an existing component (huaweicloud-functiongraph) to see if the dependencies would be resolved there, but I'm getting the following error:
```
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.736 s
[INFO] Finished at: 2021-06-28T12:14:13-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.camel:camel-bundle-plugin:3.12.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.apache.camel:camel-bundle-plugin:jar:3.12.0-SNAPSHOT in central-plugin
```
I noticed that the camel-bundle-plugin is not yet updated to the latest release of 3.11.0

Will this be updated?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660050937
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
Review comment:
Done. Changed firstVersion to 3.12.0 and pom version to 3.12.0-SNAPSHOT
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
+ syntax = "hwcloud-obs:operation",
+ category = { Category.CLOUD })
+public class OBSEndpoint extends DefaultEndpoint {
+
+ @UriPath(description = "Operation to be performed", displayName = "Operation", label = "producer", secret = false)
Review comment:
Done. Removed secret = false from all parameters with it
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ this.clientConfigurations = new ClientConfigurations();
Review comment:
Done. Initializing objects now done in doInit instead of doStart
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
davsclaus commented on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-870003413
You need to rebuild the entire source tree to update to 3.12.0-SNAPSHOT.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660051226
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
+ syntax = "hwcloud-obs:operation",
+ category = { Category.CLOUD })
+public class OBSEndpoint extends DefaultEndpoint {
+
+ @UriPath(description = "Operation to be performed", displayName = "Operation", label = "producer", secret = false)
Review comment:
Done. Removed secret = false from all parameters with it
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor edited a comment on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor edited a comment on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-869828105
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660842654
##########
File path: parent/pom.xml
##########
@@ -239,6 +239,7 @@
<httpcore4-version>4.4.14</httpcore4-version>
<httpclient4-version>4.5.13</httpclient4-version>
<httpasyncclient-version>4.1.4</httpasyncclient-version>
+ <huaweicloud-obs-version>3.21.4.1</huaweicloud-obs-version>
Review comment:
Removed extra indentation
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660841148
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Done. Try-catch block removed
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660841796
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Done. Removed LOG error/warn checks
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660842536
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/test/resources/log4j2.properties
##########
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.out.type = Console
Review comment:
Done. Updated log4j properties file to log to a default test file.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660912549
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/OBSRegion.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.obs.models;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Class containing Huawei Cloud OBS regions and endpoints
+ */
+public final class OBSRegion {
Review comment:
Thanks @davsclaus for the suggestion. For OBS alone, we use [a different cloud SDK](https://github.com/huaweicloud/huaweicloud-sdk-java-obs) whereas for other huawei cloud components, we have used [huaweicloud-sdk-java-v3](https://github.com/huaweicloud/huaweicloud-sdk-java-v3) . To be consistent with the [v3 sdk style of maintaining endpoints](https://github.com/huaweicloud/huaweicloud-sdk-java-v3/blob/master/services/functiongraph/src/main/java/com/huaweicloud/sdk/functiongraph/v2/region/FunctionGraphRegion.java), we decided to keep the similar pattern until v3 team comes up with support for OBS.
Considering the potential mixed case problem, I have made it case insensitive to shield against different user behaviors in [this commit](https://github.com/apache/camel/pull/5753/commits/238b61819f1e86978b8abf5851b54b20a24b2883) and https://github.com/apache/camel/pull/5753/commits/6c471100cc2fc3a4827e3b6a24425f21e9926fa8
Let me know what you feel about this change.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660912549
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/OBSRegion.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.obs.models;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Class containing Huawei Cloud OBS regions and endpoints
+ */
+public final class OBSRegion {
Review comment:
Thanks @davsclaus for the suggestion. For OBS alone, we use [a different cloud SDK](https://github.com/huaweicloud/huaweicloud-sdk-java-obs) whereas for other huawei cloud components, we have used [huaweicloud-sdk-java-v3](https://github.com/huaweicloud/huaweicloud-sdk-java-v3) . To be consistent with the [v3 sdk style of maintaining endpoints](https://github.com/huaweicloud/huaweicloud-sdk-java-v3/blob/master/services/functiongraph/src/main/java/com/huaweicloud/sdk/functiongraph/v2/region/FunctionGraphRegion.java), we decided to keep the similar pattern untill v3 team comes up with support for OBS.
Considering the potential mixed case problem, I have made it case insensitive to shield against different user behaviors in [this commit](https://github.com/apache/camel/pull/5753/commits/238b61819f1e86978b8abf5851b54b20a24b2883)
Let me know what you feel about this change.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor edited a comment on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor edited a comment on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-869828105
I am trying to upgrade the OBS component to 3.12.0-SNAPSHOT, but many of the dependencies cannot be resolved when I try to build it. I pulled the latest changes from the main branch, so I tried to build an existing component (huaweicloud-functiongraph) to see if the dependencies would be resolved there, but I'm getting the following error:
```
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.736 s
[INFO] Finished at: 2021-06-28T12:14:13-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.camel:camel-bundle-plugin:3.12.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.apache.camel:camel-bundle-plugin:jar:3.12.0-SNAPSHOT in central-plugin
```
I noticed that the camel-bundle-plugin is not yet updated to the latest release of 3.11.0

Will this be updated?
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660912549
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/OBSRegion.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.obs.models;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Class containing Huawei Cloud OBS regions and endpoints
+ */
+public final class OBSRegion {
Review comment:
Thanks @davsclaus for the suggestion. For OBS alone, we use [a different cloud SDK](https://github.com/huaweicloud/huaweicloud-sdk-java-obs) whereas for other huawei cloud components, we have used [huaweicloud-sdk-java-v3](https://github.com/huaweicloud/huaweicloud-sdk-java-v3) . To be consistent with the [v3 sdk style of maintaining endpoints](https://github.com/huaweicloud/huaweicloud-sdk-java-v3/blob/master/services/functiongraph/src/main/java/com/huaweicloud/sdk/functiongraph/v2/region/FunctionGraphRegion.java), we decided to keep the similar pattern until v3 team comes up with support for OBS.
Considering the potential mixed case problem, I have made it case insensitive to shield against different user behaviors in [this commit](https://github.com/apache/camel/pull/5753/commits/238b61819f1e86978b8abf5851b54b20a24b2883)
Let me know what you feel about this change.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660088871
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
Review comment:
Remove this as you have WARN logging for every requrest
##########
File path: components/camel-huawei/camel-huaweicloud-obs/pom.xml
##########
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
Review comment:
Add missing LICENSE header
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/OBSRegion.java
##########
@@ -0,0 +1,88 @@
+/*
+ * 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.obs.models;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Class containing Huawei Cloud OBS regions and endpoints
+ */
+public final class OBSRegion {
Review comment:
Is an ENUM not a better class for this? Then you can also use Camel's enum support with automatic type conversion and avoid any mixed case problems, eg CN-NORTH-1 vs cn-north-1
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/models/ClientConfigurations.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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.obs.models;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to combine parameters which can be passed through exchange properties and endpoint parameters to avoid checking
+ * both each time they are used
+ */
+public class ClientConfigurations {
+ private static final Logger LOG = LoggerFactory.getLogger(ClientConfigurations.class.getName());
Review comment:
Remove not used logger
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("No bucket location given, defaulting to '" + OBSConstants.DEFAULT_LOCATION + "'");
+ }
+ clientConfigurations.setBucketLocation(OBSConstants.DEFAULT_LOCATION);
+ }
+ // verify valid bucket location
+ OBSRegion.checkValidRegion(clientConfigurations.getBucketLocation());
+
+ request = new CreateBucketRequest(clientConfigurations.getBucketName(), clientConfigurations.getBucketLocation());
+ }
+
+ // invoke create bucket method and map response object to exchange body
+ ObsBucket response = obsClient.createBucket(request);
+ exchange.getMessage().setBody(gson.toJson(response));
+ }
+
+ /**
+ * Perform delete bucket operation
+ *
+ * @param exchange
+ */
+ private void deleteBucket(Exchange exchange) throws ObsException {
+ // check for bucket name, which is mandatory to delete a bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: parent/pom.xml
##########
@@ -239,6 +239,7 @@
<httpcore4-version>4.4.14</httpcore4-version>
<httpclient4-version>4.5.13</httpclient4-version>
<httpasyncclient-version>4.1.4</httpasyncclient-version>
+ <huaweicloud-obs-version>3.21.4.1</huaweicloud-obs-version>
Review comment:
Use same indent as the other lines
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("Failed to perform operation");
+ LOG.error("HTTP Code: " + e.getResponseCode());
+ LOG.error("Error Code: " + e.getErrorCode());
+ LOG.error("Error Message: " + e.getErrorMessage());
+ LOG.error("Request ID: " + e.getErrorRequestId());
+ LOG.error("Host ID: " + e.getErrorHostId());
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Perform list buckets operation
+ *
+ * @param exchange
+ */
+ private void listBuckets(Exchange exchange) throws ObsException {
+ // invoke list buckets method and map response object to exchange body
+ ListBucketsRequest request = new ListBucketsRequest();
+ ListBucketsResult response = obsClient.listBucketsV2(request);
+ exchange.getMessage().setBody(gson.toJson(response.getBuckets()));
+ }
+
+ /**
+ * Perform create bucket operation
+ *
+ * @param exchange
+ */
+ private void createBucket(Exchange exchange) throws ObsException {
+ CreateBucketRequest request = null;
+
+ // checking if user inputted exchange body containing bucket information. Body must be a CreateBucketRequest or a valid JSON string (Advanced users)
+ Object exchangeBody = exchange.getMessage().getBody();
+ if (exchangeBody instanceof CreateBucketRequest) {
+ request = (CreateBucketRequest) exchangeBody;
+ } else if (exchangeBody instanceof String) {
+ String strBody = (String) exchangeBody;
+ try {
+ request = new ObjectMapper().readValue(strBody, CreateBucketRequest.class);
+ } catch (JsonProcessingException e) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn(
+ "String request body must be a valid JSON representation of a CreateBucketRequest. Attempting to create a bucket from endpoint parameters");
+ }
+ }
+ }
+
+ // if no CreateBucketRequest was found in the exchange body, then create one from endpoint parameters (Basic users)
+ if (request == null) {
+ // check for bucket name, which is mandatory to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to create bucket");
+ }
+
+ // check for bucket location, which is optional to create a new bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketLocation())) {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("No bucket location given, defaulting to '" + OBSConstants.DEFAULT_LOCATION + "'");
+ }
+ clientConfigurations.setBucketLocation(OBSConstants.DEFAULT_LOCATION);
+ }
+ // verify valid bucket location
+ OBSRegion.checkValidRegion(clientConfigurations.getBucketLocation());
+
+ request = new CreateBucketRequest(clientConfigurations.getBucketName(), clientConfigurations.getBucketLocation());
+ }
+
+ // invoke create bucket method and map response object to exchange body
+ ObsBucket response = obsClient.createBucket(request);
+ exchange.getMessage().setBody(gson.toJson(response));
+ }
+
+ /**
+ * Perform delete bucket operation
+ *
+ * @param exchange
+ */
+ private void deleteBucket(Exchange exchange) throws ObsException {
+ // check for bucket name, which is mandatory to delete a bucket
+ if (ObjectHelper.isEmpty(clientConfigurations.getBucketName())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No bucket name given");
+ }
+ throw new IllegalArgumentException("Bucket name is mandatory to delete bucket");
+ }
+
+ // invoke delete bucket method and map response object to exchange body
+ HeaderResponse response = obsClient.deleteBucket(clientConfigurations.getBucketName());
+ exchange.getMessage().setBody(gson.toJson(response.getResponseHeaders()));
+ }
+
+ /**
+ * Update dynamic client configurations. Some endpoint parameters (operation, and bucket name and location) 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
+ */
+ private void updateClientConfigs(Exchange exchange) {
+ resetDynamicConfigs();
+
+ // checking for required operation (exchange overrides endpoint operation if both are provided)
+ if (ObjectHelper.isEmpty(exchange.getProperty(OBSProperties.OPERATION))
+ && ObjectHelper.isEmpty(endpoint.getOperation())) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Remove this
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSProducer.java
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.obs;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.CreateBucketRequest;
+import com.obs.services.model.HeaderResponse;
+import com.obs.services.model.ListBucketsRequest;
+import com.obs.services.model.ListBucketsResult;
+import com.obs.services.model.ObsBucket;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSConstants;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSOperations;
+import org.apache.camel.component.huaweicloud.obs.constants.OBSProperties;
+import org.apache.camel.component.huaweicloud.obs.models.ClientConfigurations;
+import org.apache.camel.component.huaweicloud.obs.models.OBSRegion;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OBSProducer extends DefaultProducer {
+ private static final Logger LOG = LoggerFactory.getLogger(OBSProducer.class);
+ private OBSEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private ObsClient obsClient;
+ private Gson gson;
+
+ public OBSProducer(OBSEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ this.clientConfigurations = new ClientConfigurations();
+ this.obsClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ try {
+ switch (clientConfigurations.getOperation()) {
+ case OBSOperations.LIST_BUCKETS:
+ listBuckets(exchange);
+ break;
+ case OBSOperations.CREATE_BUCKET:
+ createBucket(exchange);
+ break;
+ case OBSOperations.DELETE_BUCKET:
+ deleteBucket(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation", clientConfigurations.getOperation()));
+ }
+ } catch (ObsException e) {
+ if (LOG.isErrorEnabled()) {
Review comment:
Do not LOG and re-throw. Remove this!
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/test/resources/log4j2.properties
##########
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.out.type = Console
Review comment:
For logging we log by default to a test log file. See the other components and their log4j properties file
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on a change in pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on a change in pull request #5753:
URL: https://github.com/apache/camel/pull/5753#discussion_r660050937
##########
File path: components/camel-huawei/camel-huaweicloud-obs/src/main/java/org/apache/camel/component/huaweicloud/obs/OBSEndpoint.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.obs;
+
+import com.obs.services.HttpProxyConfiguration;
+import com.obs.services.ObsClient;
+import com.obs.services.ObsConfiguration;
+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.obs.models.OBSRegion;
+import org.apache.camel.component.huaweicloud.obs.models.ServiceKeys;
+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;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To provide stable, secure, efficient, and easy-to-use cloud storage service on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-obs", title = "Huawei Cloud Object Storage Service (OBS)",
Review comment:
Done. Changed firstVersion to 3.12.0 and pom version to 3.12.0-SNAPSHOT
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus merged pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
davsclaus merged pull request #5753:
URL: https://github.com/apache/camel/pull/5753
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] hokutor commented on pull request #5753: CAMEL-16758: Base commit for Huawei Cloud OBS Component
Posted by GitBox <gi...@apache.org>.
hokutor commented on pull request #5753:
URL: https://github.com/apache/camel/pull/5753#issuecomment-869828105
I am trying to upgrade the OBS component to 3.12.0-SNAPSHOT, but many of the dependencies cannot be resolved when I try to build it. I pulled the latest changes from the main branch, so I tried to build an existing component (huaweicloud-functiongraph) to see if the dependencies would be resolved there, but I'm getting the following error:
```
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.736 s
[INFO] Finished at: 2021-06-28T12:14:13-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.camel:camel-bundle-plugin:3.12.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.apache.camel:camel-bundle-plugin:jar:3.12.0-SNAPSHOT in central-plugin
```
I noticed that the camel-bundle-plugin is not yet updated to the latest release of 3.11.0

--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org