This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit e3804c8082f982060ebdef4b2312f06daf6457d9 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu May 8 14:23:17 2025 +0200 CAMEL-22013 - camel-api - Remove all usage of component.extension and the component.extension package content itself - Dropbox Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../camel/component/dropbox/DropboxComponent.java | 1 - .../dropbox/DropboxComponentVerifierExtension.java | 81 ---------------------- .../DropboxComponentVerifierExtensionTest.java | 78 --------------------- 3 files changed, 160 deletions(-) diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java index 12535c53d96..7aa6f55a2a1 100644 --- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java +++ b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponent.java @@ -35,7 +35,6 @@ public class DropboxComponent extends DefaultComponent { public DropboxComponent(CamelContext context) { super(context); - registerExtension(new DropboxComponentVerifierExtension()); } /** diff --git a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java b/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java deleted file mode 100644 index 1b7423f83c2..00000000000 --- a/components/camel-dropbox/src/main/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtension.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.dropbox; - -import java.util.Locale; -import java.util.Map; - -import com.dropbox.core.DbxRequestConfig; -import com.dropbox.core.v2.DbxClientV2; -import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension; -import org.apache.camel.component.extension.verifier.ResultBuilder; -import org.apache.camel.component.extension.verifier.ResultErrorBuilder; -import org.apache.camel.component.extension.verifier.ResultErrorHelper; - -public class DropboxComponentVerifierExtension extends DefaultComponentVerifierExtension { - - public DropboxComponentVerifierExtension() { - this("dropbox"); - } - - protected DropboxComponentVerifierExtension(String scheme) { - super(scheme); - } - - // ********************************* - // Parameters validation - // - @Override - protected Result verifyParameters(Map<String, Object> parameters) { - ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.PARAMETERS) - .error(ResultErrorHelper.requiresOption(parameters, "accessToken")) - .error(ResultErrorHelper.requiresOption(parameters, "clientIdentifier")); - - return builder.build(); - } - - // ********************************* - // Connectivity validation - // ********************************* - @Override - protected Result verifyConnectivity(Map<String, Object> parameters) { - return ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY) - .error(parameters, this::verifyCredentials).build(); - } - - private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) { - - String token = (String) parameters.get("accessToken"); - String clientId = (String) parameters.get("clientIdentifier"); - - try { - // Create Dropbox client - DbxRequestConfig config = DbxRequestConfig.newBuilder(clientId) - .withUserLocaleFrom(Locale.getDefault()) - .build(); - DbxClientV2 client = new DbxClientV2(config, token); - client.users().getCurrentAccount(); - } catch (Exception e) { - builder.error(ResultErrorBuilder - .withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, - "Invalid client identifier and/or access token") - .parameterKey("accessToken").parameterKey("clientIdentifier").build()); - } - - } - -} diff --git a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtensionTest.java b/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtensionTest.java deleted file mode 100644 index e0c3b345563..00000000000 --- a/components/camel-dropbox/src/test/java/org/apache/camel/component/dropbox/DropboxComponentVerifierExtensionTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.dropbox; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.Component; -import org.apache.camel.component.extension.ComponentVerifierExtension; -import org.apache.camel.test.junit5.CamelTestSupport; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class DropboxComponentVerifierExtensionTest extends CamelTestSupport { - - // ************************************************* - // Tests (parameters) - // ************************************************* - @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Test - public void testParameters() { - Component component = context().getComponent("dropbox"); - - ComponentVerifierExtension verifier - = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("accessToken", "l"); - parameters.put("expireIn", "1000"); - parameters.put("refreshToken", "l"); - parameters.put("apiKey", "a"); - parameters.put("apiSecret", "s"); - parameters.put("clientIdentifier", "k"); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - - assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); - } - - @Test - public void testConnectivity() { - Component component = context().getComponent("dropbox"); - ComponentVerifierExtension verifier - = component.getExtension(ComponentVerifierExtension.class).orElseThrow(IllegalStateException::new); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("accessToken", "l"); - parameters.put("expireIn", "1000"); - parameters.put("refreshToken", "l"); - parameters.put("apiKey", "a"); - parameters.put("apiSecret", "s"); - parameters.put("clientIdentifier", "k"); - - ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - - assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - } - -}