[camel] branch master updated: CAMEL-13052: Remove deprecated connector stuff

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-13052: Remove deprecated connector stuff

davsclaus-2
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 137f601  CAMEL-13052: Remove deprecated connector stuff
137f601 is described below

commit 137f60163f16ba5ea87a6463df440f79e749cd3c
Author: Claus Ibsen <[hidden email]>
AuthorDate: Sat Jan 12 10:31:46 2019 +0100

    CAMEL-13052: Remove deprecated connector stuff
---
 .../catalog/maven/ConnectorArtifactHelper.java     | 49 ----------------------
 .../maven/DefaultMavenArtifactProvider.java        | 45 +-------------------
 .../camel/catalog/maven/MavenArtifactProvider.java |  6 +--
 .../catalog/maven/MavenArtifactProviderTest.java   | 30 +------------
 4 files changed, 4 insertions(+), 126 deletions(-)

diff --git a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/ConnectorArtifactHelper.java b/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/ConnectorArtifactHelper.java
deleted file mode 100644
index d32d77d..0000000
--- a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/ConnectorArtifactHelper.java
+++ /dev/null
@@ -1,49 +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.catalog.maven;
-
-import java.io.InputStream;
-
-import static org.apache.camel.catalog.CatalogHelper.loadText;
-
-public final class ConnectorArtifactHelper {
-
-    private ConnectorArtifactHelper() {
-    }
-
-    public static String[] loadJSonSchemas(boolean log, ClassLoader classLoader) {
-        String[] answer = new String[3];
-        answer[0] = loadJsonSchema(log, classLoader, "camel-connector.json");
-        answer[1] = loadJsonSchema(log, classLoader, "camel-connector-schema.json");
-        answer[2] = loadJsonSchema(log, classLoader, "camel-component-schema.json");
-        return answer;
-    }
-
-    private static String loadJsonSchema(boolean log, ClassLoader classLoader, String jsonSchemaPath) {
-        try (InputStream is = classLoader.getResourceAsStream(jsonSchemaPath)) {
-            if (is != null) {
-                return loadText(is);
-            }
-        } catch (Throwable e) {
-            if (log) {
-                System.out.println("WARN: Error loading " + jsonSchemaPath + " file due " + e.getMessage());
-            }
-        }
-        return null;
-    }
-
-}
diff --git a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/DefaultMavenArtifactProvider.java b/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/DefaultMavenArtifactProvider.java
index 8d68a82..dddeb52 100644
--- a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/DefaultMavenArtifactProvider.java
+++ b/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/DefaultMavenArtifactProvider.java
@@ -21,20 +21,14 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import groovy.grape.Grape;
 import groovy.lang.GroovyClassLoader;
 import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.connector.CamelConnectorCatalog;
 
 import static org.apache.camel.catalog.maven.ComponentArtifactHelper.extractComponentJavaType;
 import static org.apache.camel.catalog.maven.ComponentArtifactHelper.loadComponentJSonSchema;
 import static org.apache.camel.catalog.maven.ComponentArtifactHelper.loadComponentProperties;
-import static org.apache.camel.catalog.maven.ConnectorArtifactHelper.loadJSonSchemas;
 
 /**
  * Default {@link MavenArtifactProvider} which uses Groovy Grape to download the artifact.
@@ -66,7 +60,7 @@ public class DefaultMavenArtifactProvider implements MavenArtifactProvider {
     }
 
     @Override
-    public Set<String> addArtifactToCatalog(CamelCatalog camelCatalog, CamelConnectorCatalog camelConnectorCatalog,
+    public Set<String> addArtifactToCatalog(CamelCatalog camelCatalog,
                                             String groupId, String artifactId, String version) {
         final Set<String> names = new LinkedHashSet<>();
 
@@ -100,9 +94,6 @@ public class DefaultMavenArtifactProvider implements MavenArtifactProvider {
                 if (camelCatalog != null) {
                     scanCamelComponents(camelCatalog, classLoader, names);
                 }
-                if (camelConnectorCatalog != null) {
-                    scanCamelConnectors(camelConnectorCatalog, classLoader, groupId, artifactId, version, names);
-                }
             }
 
         } catch (Exception e) {
@@ -141,39 +132,5 @@ public class DefaultMavenArtifactProvider implements MavenArtifactProvider {
         }
     }
 
-    protected void scanCamelConnectors(CamelConnectorCatalog camelConnectorCatalog, ClassLoader classLoader,
-                                       String groupId, String artifactId, String version,
-                                       Set<String> names) {
-        String[] json = loadJSonSchemas(log, classLoader);
-        if (json != null) {
-            if (!camelConnectorCatalog.hasConnector(groupId, artifactId, version)) {
-                try {
-                    ObjectMapper mapper = new ObjectMapper();
-                    JsonNode tree = mapper.readTree(json[0]);
-                    String name = tree.get("name").textValue();
-                    String scheme = tree.get("scheme").textValue();
-                    String javaType = tree.get("javaType").textValue();
-                    String description = tree.get("description").textValue();
-
-                    String csb = StreamSupport.stream(tree.withArray("labels").spliterator(), false)
-                            .map(JsonNode::textValue)
-                            .collect(Collectors.joining(","));
-
-                    if (log) {
-                        System.out.println("Adding connector: " + name + " with scheme: " + scheme);
-                    }
-                    camelConnectorCatalog.addConnector(groupId, artifactId, version,
-                        name, scheme, javaType, description, csb, json[0], json[1], json[2]);
-
-                    names.add(name);
-                } catch (Throwable e) {
-                    if (log) {
-                        System.out.println("WARN: Error parsing Connector JSon due " + e.getMessage());
-                    }
-                }
-            }
-        }
-    }
-
 }
 
diff --git a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/MavenArtifactProvider.java b/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/MavenArtifactProvider.java
index 8a96808..ad39aa5 100644
--- a/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/MavenArtifactProvider.java
+++ b/platforms/camel-catalog-maven/src/main/java/org/apache/camel/catalog/maven/MavenArtifactProvider.java
@@ -19,7 +19,6 @@ package org.apache.camel.catalog.maven;
 import java.util.Set;
 
 import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.connector.CamelConnectorCatalog;
 
 /**
  * Provider which allows downloading artifact using Maven and add content to the {@link CamelCatalog}.
@@ -45,16 +44,15 @@ public interface MavenArtifactProvider {
 
     /**
      * Downloads the artifact using the Maven coordinates and scans the JAR for Camel components
-     * which will be added to the CamelCatalog or CamelConnectorCatalog.
+     * which will be added to the CamelCatalog.
      *
      * @param camelCatalog          The Camel Catalog
-     * @param camelConnectorCatalog The Camel Connector Catalog
      * @param groupId               Maven group id
      * @param artifactId            Maven artifact id
      * @param version               Maven version
      * @return the names of the components that was added, or an empty set if none found or they already exists in the catalog
      */
-    Set<String> addArtifactToCatalog(CamelCatalog camelCatalog, CamelConnectorCatalog camelConnectorCatalog,
+    Set<String> addArtifactToCatalog(CamelCatalog camelCatalog,
                                      String groupId, String artifactId, String version);
 
 }
\ No newline at end of file
diff --git a/platforms/camel-catalog-maven/src/test/java/org/apache/camel/catalog/maven/MavenArtifactProviderTest.java b/platforms/camel-catalog-maven/src/test/java/org/apache/camel/catalog/maven/MavenArtifactProviderTest.java
index 3a94c21..8463609 100644
--- a/platforms/camel-catalog-maven/src/test/java/org/apache/camel/catalog/maven/MavenArtifactProviderTest.java
+++ b/platforms/camel-catalog-maven/src/test/java/org/apache/camel/catalog/maven/MavenArtifactProviderTest.java
@@ -16,14 +16,10 @@
  */
 package org.apache.camel.catalog.maven;
 
-import java.util.List;
 import java.util.Set;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.DefaultCamelCatalog;
-import org.apache.camel.catalog.connector.CamelConnectorCatalog;
-import org.apache.camel.catalog.connector.ConnectorDto;
-import org.apache.camel.catalog.connector.DefaultCamelConnectorCatalog;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -39,7 +35,7 @@ public class MavenArtifactProviderTest extends Assert {
 
         int before = camelCatalog.findComponentNames().size();
 
-        Set<String> names = provider.addArtifactToCatalog(camelCatalog, null, "org.apache.camel", "dummy-component", camelCatalog.getCatalogVersion());
+        Set<String> names = provider.addArtifactToCatalog(camelCatalog, "org.apache.camel", "dummy-component", camelCatalog.getCatalogVersion());
         assertTrue(names.contains("dummy"));
 
         int after = camelCatalog.findComponentNames().size();
@@ -47,28 +43,4 @@ public class MavenArtifactProviderTest extends Assert {
         assertTrue("Should find 1 new component", after - before == 1);
     }
 
-    @Test
-    public void testAddConnector() {
-        CamelCatalog camelCatalog = new DefaultCamelCatalog();
-        CamelConnectorCatalog camelConnectorCatalog = new DefaultCamelConnectorCatalog();
-        MavenArtifactProvider provider = new DefaultMavenArtifactProvider();
-        provider.setCacheDirectory("target/cache");
-
-        int before = camelCatalog.findComponentNames().size();
-        List<ConnectorDto> list = camelConnectorCatalog.findConnector("foo", false);
-        assertEquals(0, list.size());
-
-        Set<String> names = provider.addArtifactToCatalog(camelCatalog, camelConnectorCatalog, "org.apache.camel", "myfoo-connector", camelCatalog.getCatalogVersion());
-        assertTrue(names.contains("MyFoo"));
-
-        int after = camelCatalog.findComponentNames().size();
-
-        assertTrue("Should find 1 new component", after - before == 1);
-
-        list = camelConnectorCatalog.findConnector("foo", false);
-        assertEquals(1, list.size());
-        assertEquals("MyFoo", list.get(0).getName());
-        assertTrue(camelCatalog.findComponentNames().contains("my-foo"));
-    }
-
 }