camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/4] camel git commit: CAMEL-10828: camel-catalog-nexus - more work
Date Mon, 20 Feb 2017 13:24:17 GMT
CAMEL-10828: camel-catalog-nexus - more work


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d492153a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d492153a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d492153a

Branch: refs/heads/master
Commit: d492153a9392dbf2c7cf6f54e306dcb5d320254e
Parents: 5aae583
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Feb 20 13:49:50 2017 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Feb 20 13:54:14 2017 +0100

----------------------------------------------------------------------
 platforms/catalog-nexus/readme.md               |   2 +-
 .../nexus/ComponentCatalogNexusRepository.java  | 152 +++++++++++++++++++
 .../catalog/nexus/ComponentNexusRepository.java | 152 -------------------
 .../camel/catalog/nexus/ConnectorDataStore.java |  37 +++++
 .../ConnectorDataStoreNexusRepository.java      | 140 +++++++++++++++++
 .../camel/catalog/nexus/ConnectorDto.java       |  85 +++++++++++
 .../catalog/nexus/MemoryConnectorDataStore.java |  40 +++++
 .../camel/catalog/nexus/NexusRepository.java    |  35 -----
 ...ocalFileComponentCatalogNexusRepository.java |  57 +++++++
 .../catalog/nexus/LocalFileNexusRepository.java |  57 -------
 ...ocalNexusComponentCatalogRepositoryTest.java |  54 +++++++
 .../catalog/nexus/LocalNexusRepositoryTest.java |  54 -------
 .../org/apache/camel/catalog/CatalogHelper.java |  51 ++++++-
 13 files changed, 616 insertions(+), 300 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/readme.md
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/readme.md b/platforms/catalog-nexus/readme.md
index 8e51fa1..283fb08cbf 100644
--- a/platforms/catalog-nexus/readme.md
+++ b/platforms/catalog-nexus/readme.md
@@ -13,7 +13,7 @@ The Camel Catalog can then be used by tooling to present the list of components
 
 The Nexus repository must provide a REST API which allows this module to query it.
 
-The url is configured on `ComponentNexusRepository` in the `nexusUrl` setter.
+The url is configured on `ComponentCatalogNexusRepository` in the `nexusUrl` setter.
 
 For example if you have a nexus repository at: `http://company-nexus` then the url can be
set as
 

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentCatalogNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentCatalogNexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentCatalogNexusRepository.java
new file mode 100644
index 0000000..2e606f9
--- /dev/null
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentCatalogNexusRepository.java
@@ -0,0 +1,152 @@
+/**
+ * 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.nexus;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.camel.catalog.CamelCatalog;
+
+import static org.apache.camel.catalog.CatalogHelper.loadText;
+
+/**
+ * Nexus repository that can scan for custom Camel components and add to the {@link org.apache.camel.catalog.CamelCatalog}.
+ */
+public class ComponentCatalogNexusRepository extends BaseNexusRepository {
+
+    public ComponentCatalogNexusRepository() {
+        super("component");
+    }
+
+    @Override
+    public void onNewArtifacts(Set<NexusArtifactDto> newArtifacts) {
+        // now download the new artifact JARs and look inside to find more details
+        for (NexusArtifactDto dto : newArtifacts) {
+            try {
+                log.debug("Processing new artifact: {}:{}:{}", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
+                String url = createArtifactURL(dto);
+                URL jarUrl = new URL(url);
+                addCustomCamelComponentsFromArtifact(dto, jarUrl);
+            } catch (Throwable e) {
+                log.warn("Error downloading component JAR " + dto.getArtifactLink() + ".
This exception is ignored. " + e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Adds the component to the {@link CamelCatalog}
+     *
+     * @param dto           the artifact
+     * @param camelCatalog  the Camel Catalog
+     * @param scheme        component name
+     * @param javaType      component java class
+     * @param json          component json schema
+     */
+    protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme,
String javaType, String json) {
+        log.info("Added component: {}:{}:{} to Camel Catalog", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
+        camelCatalog.addComponent(scheme, javaType, json);
+    }
+
+    /**
+     * Adds any discovered third party Camel components from the artifact.
+     */
+    private void addCustomCamelComponentsFromArtifact(NexusArtifactDto dto, URL jarUrl )
{
+        try (URLClassLoader classLoader = new URLClassLoader(new URL[]{jarUrl});) {
+            // is there any custom Camel components in this library?
+            Properties properties = loadComponentProperties(classLoader);
+            if (properties != null) {
+                String components = (String) properties.get("components");
+                if (components != null) {
+                    String[] part = components.split("\\s");
+                    for (String scheme : part) {
+                        if (!getCamelCatalog().findComponentNames().contains(scheme)) {
+                            // find the class name
+                            String javaType = extractComponentJavaType(classLoader, scheme);
+                            if (javaType != null) {
+                                String json = loadComponentJSonSchema(classLoader, scheme);
+                                if (json != null) {
+                                    addComponent(dto, getCamelCatalog(), scheme, javaType,
json);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (IOException e) {
+            log.warn("Error scanning JAR for custom Camel components", e);
+        }
+    }
+
+    private Properties loadComponentProperties(URLClassLoader classLoader) {
+        Properties answer = new Properties();
+        try {
+            // load the component files using the recommended way by a component.properties
file
+            InputStream is = classLoader.getResourceAsStream("META-INF/services/org/apache/camel/component.properties");
+            if (is != null) {
+                answer.load(is);
+            }
+        } catch (Throwable e) {
+            log.warn("Error loading META-INF/services/org/apache/camel/component.properties
file", e);
+        }
+        return answer;
+    }
+
+    private String extractComponentJavaType(URLClassLoader classLoader, String scheme) {
+        try {
+            InputStream is = classLoader.getResourceAsStream("META-INF/services/org/apache/camel/component/"
+ scheme);
+            if (is != null) {
+                Properties props = new Properties();
+                props.load(is);
+                return (String) props.get("class");
+            }
+        } catch (Throwable e) {
+            log.warn("Error loading META-INF/services/org/apache/camel/component/" + scheme
+ " file", e);
+        }
+
+        return null;
+    }
+
+    private String loadComponentJSonSchema(URLClassLoader classLoader, String scheme) {
+        String answer = null;
+
+        String path = null;
+        String javaType = extractComponentJavaType(classLoader, scheme);
+        if (javaType != null) {
+            int pos = javaType.lastIndexOf(".");
+            path = javaType.substring(0, pos);
+            path = path.replace('.', '/');
+            path = path + "/" + scheme + ".json";
+        }
+
+        if (path != null) {
+            try {
+                InputStream is = classLoader.getResourceAsStream(path);
+                if (is != null) {
+                    answer = loadText(is);
+                }
+            } catch (Throwable e) {
+                log.warn("Error loading " + path + " file", e);
+            }
+        }
+
+        return answer;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
deleted file mode 100644
index 2fb15c3..0000000
--- a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
+++ /dev/null
@@ -1,152 +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.nexus;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.camel.catalog.CamelCatalog;
-
-import static org.apache.camel.catalog.CatalogHelper.loadText;
-
-/**
- * Nexus repository that can scan for custom Camel components and add to the {@link org.apache.camel.catalog.CamelCatalog}.
- */
-public class ComponentNexusRepository extends BaseNexusRepository {
-
-    public ComponentNexusRepository() {
-        super("component");
-    }
-
-    @Override
-    public void onNewArtifacts(Set<NexusArtifactDto> newArtifacts) {
-        // now download the new artifact JARs and look inside to find more details
-        for (NexusArtifactDto dto : newArtifacts) {
-            try {
-                log.debug("Processing new artifact: {}:{}:{}", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
-                String url = createArtifactURL(dto);
-                URL jarUrl = new URL(url);
-                addCustomCamelComponentsFromArtifact(dto, jarUrl);
-            } catch (Throwable e) {
-                log.warn("Error downloading component JAR " + dto.getArtifactLink() + ".
This exception is ignored. " + e.getMessage());
-            }
-        }
-    }
-
-    /**
-     * Adds the component to the {@link CamelCatalog}
-     *
-     * @param dto           the artifact
-     * @param camelCatalog  the Camel Catalog
-     * @param scheme        component name
-     * @param javaType      component java class
-     * @param json          component json schema
-     */
-    protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme,
String javaType, String json) {
-        log.info("Added component: {}:{}:{} to Camel Catalog", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
-        camelCatalog.addComponent(scheme, javaType, json);
-    }
-
-    /**
-     * Adds any discovered third party Camel components from the artifact.
-     */
-    private void addCustomCamelComponentsFromArtifact(NexusArtifactDto dto, URL jarUrl )
{
-        try (URLClassLoader classLoader = new URLClassLoader(new URL[]{jarUrl});) {
-            // is there any custom Camel components in this library?
-            Properties properties = loadComponentProperties(classLoader);
-            if (properties != null) {
-                String components = (String) properties.get("components");
-                if (components != null) {
-                    String[] part = components.split("\\s");
-                    for (String scheme : part) {
-                        if (!getCamelCatalog().findComponentNames().contains(scheme)) {
-                            // find the class name
-                            String javaType = extractComponentJavaType(classLoader, scheme);
-                            if (javaType != null) {
-                                String json = loadComponentJSonSchema(classLoader, scheme);
-                                if (json != null) {
-                                    addComponent(dto, getCamelCatalog(), scheme, javaType,
json);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } catch (IOException e) {
-            log.warn("Error scanning JAR for custom Camel components", e);
-        }
-    }
-
-    private Properties loadComponentProperties(URLClassLoader classLoader) {
-        Properties answer = new Properties();
-        try {
-            // load the component files using the recommended way by a component.properties
file
-            InputStream is = classLoader.getResourceAsStream("META-INF/services/org/apache/camel/component.properties");
-            if (is != null) {
-                answer.load(is);
-            }
-        } catch (Throwable e) {
-            log.warn("Error loading META-INF/services/org/apache/camel/component.properties
file", e);
-        }
-        return answer;
-    }
-
-    private String extractComponentJavaType(URLClassLoader classLoader, String scheme) {
-        try {
-            InputStream is = classLoader.getResourceAsStream("META-INF/services/org/apache/camel/component/"
+ scheme);
-            if (is != null) {
-                Properties props = new Properties();
-                props.load(is);
-                return (String) props.get("class");
-            }
-        } catch (Throwable e) {
-            log.warn("Error loading META-INF/services/org/apache/camel/component/" + scheme
+ " file", e);
-        }
-
-        return null;
-    }
-
-    private String loadComponentJSonSchema(URLClassLoader classLoader, String scheme) {
-        String answer = null;
-
-        String path = null;
-        String javaType = extractComponentJavaType(classLoader, scheme);
-        if (javaType != null) {
-            int pos = javaType.lastIndexOf(".");
-            path = javaType.substring(0, pos);
-            path = path.replace('.', '/');
-            path = path + "/" + scheme + ".json";
-        }
-
-        if (path != null) {
-            try {
-                InputStream is = classLoader.getResourceAsStream(path);
-                if (is != null) {
-                    answer = loadText(is);
-                }
-            } catch (Throwable e) {
-                log.warn("Error loading " + path + " file", e);
-            }
-        }
-
-        return answer;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStore.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStore.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStore.java
new file mode 100644
index 0000000..68c9858
--- /dev/null
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStore.java
@@ -0,0 +1,37 @@
+/**
+ * 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.nexus;
+
+import java.util.List;
+
+public interface ConnectorDataStore {
+
+    /**
+     * Adds a connector to the data store.
+     */
+    void addConnector(ConnectorDto connector);
+
+    /**
+     * Search for connectors in the data store.
+     *
+     * @param filter            the filter connectors based on their names, description or
labels.
+     * @param latestVersionOnly to only include the latest version of a given Maven <tt>groupId:artifactId</tt>
+     * @return the found connectors, or an empty list if none found
+     */
+    List<ConnectorDto> searchArtifacts(String filter, boolean latestVersionOnly);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStoreNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStoreNexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStoreNexusRepository.java
new file mode 100644
index 0000000..50e0190
--- /dev/null
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDataStoreNexusRepository.java
@@ -0,0 +1,140 @@
+/**
+ * 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.nexus;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Set;
+
+import org.apache.camel.catalog.CatalogHelper;
+
+import static org.apache.camel.catalog.CatalogHelper.loadText;
+
+/**
+ * Nexus repository that can scan for custom Camel connectors and add to the {@link ConnectorDataStore}.
+ */
+public class ConnectorDataStoreNexusRepository extends BaseNexusRepository {
+
+    private ConnectorDataStore connectorDataStore;
+
+    public ConnectorDataStoreNexusRepository() {
+        super("connector");
+    }
+
+    public ConnectorDataStore getConnectorDataStore() {
+        return connectorDataStore;
+    }
+
+    public void setConnectorDataStore(ConnectorDataStore connectorDataStore) {
+        this.connectorDataStore = connectorDataStore;
+    }
+
+    @Override
+    public void onNewArtifacts(Set<NexusArtifactDto> newArtifacts) {
+        // now download the new artifact JARs and look inside to find more details
+        for (NexusArtifactDto dto : newArtifacts) {
+            try {
+                log.debug("Processing new artifact: {}:{}:{}", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
+                String url = createArtifactURL(dto);
+                URL jarUrl = new URL(url);
+                addCustomCamelConnectorFromArtifact(dto, jarUrl);
+            } catch (Throwable e) {
+                log.warn("Error downloading connector JAR " + dto.getArtifactLink() + ".
This exception is ignored. " + e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Adds the connector to the data store
+     *
+     * @param dto                 the artifact
+     * @param name                name of connector
+     * @param connectorJson       camel-connector JSon
+     * @param connectorSchemaJson camel-connector-schema JSon
+     */
+    protected void addConnector(NexusArtifactDto dto, String name, String connectorJson,
String connectorSchemaJson) {
+        if (connectorDataStore != null) {
+            ConnectorDto connector = new ConnectorDto(dto, name, connectorJson, connectorSchemaJson);
+            log.info("Added connector: {}:{}:{}", dto.getGroupId(), dto.getArtifactId(),
dto.getVersion());
+            connectorDataStore.addConnector(connector);
+        }
+    }
+
+    /**
+     * Adds any discovered third party Camel connectors from the artifact.
+     */
+    private void addCustomCamelConnectorFromArtifact(NexusArtifactDto dto, URL jarUrl) {
+        try (URLClassLoader classLoader = new URLClassLoader(new URL[] {jarUrl});) {
+            String[] json = loadConnectorJSonSchema(classLoader);
+            if (json != null) {
+                addConnector(dto, json[0], json[1], json[2]);
+            }
+        } catch (IOException e) {
+            log.warn("Error scanning JAR for custom Camel components", e);
+        }
+    }
+
+    private String[] loadConnectorJSonSchema(URLClassLoader classLoader) {
+        String[] answer = new String[3];
+
+        String path = "camel-connector.json";
+        try {
+            InputStream is = classLoader.getResourceAsStream(path);
+            if (is != null) {
+                answer[1] = loadText(is);
+            }
+        } catch (Throwable e) {
+            log.warn("Error loading " + path + " file", e);
+        }
+
+        path = "camel-connector-schema.json";
+        try {
+            InputStream is = classLoader.getResourceAsStream(path);
+            if (is != null) {
+                answer[2] = loadText(is);
+            }
+        } catch (Throwable e) {
+            log.warn("Error loading " + path + " file", e);
+        }
+
+        String name = extractConnectorName(answer[1]);
+        answer[0] = name;
+
+        return answer;
+    }
+
+    /**
+     * Extracts the name of the connector from the json blob
+     */
+    private static String extractConnectorName(String json) {
+        String[] lines = json.split("\n");
+        for (String line : lines) {
+            line = line.trim();
+            if (line.startsWith("\"name\":")) {
+                String name = CatalogHelper.after(line, ":");
+                if (name != null) {
+                    name = name.trim();
+                    return CatalogHelper.removeLeadingAndEndingQuotes(name);
+                }
+            }
+        }
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDto.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDto.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDto.java
new file mode 100644
index 0000000..1aa2b98
--- /dev/null
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ConnectorDto.java
@@ -0,0 +1,85 @@
+/**
+ * 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.nexus;
+
+import java.io.Serializable;
+
+public class ConnectorDto implements Serializable {
+
+    private NexusArtifactDto nexusArtifactDto;
+    private String name;
+    private String connectorJson;
+    private String connectorSchemaJson;
+
+    public ConnectorDto(NexusArtifactDto nexusArtifactDto, String name, String connectorJson,
String connectorSchemaJson) {
+        this.nexusArtifactDto = nexusArtifactDto;
+        this.name = name;
+        this.connectorJson = connectorJson;
+        this.connectorSchemaJson = connectorSchemaJson;
+    }
+
+    public NexusArtifactDto getNexusArtifactDto() {
+        return nexusArtifactDto;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getConnectorJson() {
+        return connectorJson;
+    }
+
+    public String getConnectorSchemaJson() {
+        return connectorSchemaJson;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        ConnectorDto that = (ConnectorDto) o;
+
+        if (!nexusArtifactDto.equals(that.nexusArtifactDto)) {
+            return false;
+        }
+        return name.equals(that.name);
+    }
+
+    @Override
+    public int hashCode() {
+        int result = nexusArtifactDto.hashCode();
+        result = 31 * result + name.hashCode();
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        return "ConnectorDto[" +
+            "groupId='" + nexusArtifactDto.getGroupId() + '\'' +
+            ", artifactId='" + nexusArtifactDto.getArtifactId() + '\'' +
+            ", version='" + nexusArtifactDto.getVersion() + '\'' +
+            ", name='" + name + '\'' +
+            ']';
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/MemoryConnectorDataStore.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/MemoryConnectorDataStore.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/MemoryConnectorDataStore.java
new file mode 100644
index 0000000..b78e96a
--- /dev/null
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/MemoryConnectorDataStore.java
@@ -0,0 +1,40 @@
+/**
+ * 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.nexus;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A in-memory based {@link ConnectorDataStore}.
+ */
+public class MemoryConnectorDataStore implements ConnectorDataStore {
+
+    private final Set<ConnectorDto> connectors = new LinkedHashSet<>();
+
+    @Override
+    public void addConnector(ConnectorDto connector) {
+        connectors.add(connector);
+    }
+
+    @Override
+    public List<ConnectorDto> searchArtifacts(String filter, boolean latestVersionOnly)
{
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/NexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/NexusRepository.java
b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/NexusRepository.java
deleted file mode 100644
index 153df3a..0000000
--- a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/NexusRepository.java
+++ /dev/null
@@ -1,35 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.nexus;
-
-import java.util.List;
-
-/**
- * Nexus repository
- */
-public interface NexusRepository {
-
-    /**
-     * Search for new artifacts in the Nexus repository.
-     *
-     * @param filter the filter artifacts
-     * @param latestVersionOnly to only include the latest version of a given Maven <tt>groupId:artifactId</tt>
-     * @return the found artifacts
-     */
-    List<NexusArtifactDto> searchArtifacts(String filter, boolean latestVersionOnly);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileComponentCatalogNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileComponentCatalogNexusRepository.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileComponentCatalogNexusRepository.java
new file mode 100644
index 0000000..6d18289
--- /dev/null
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileComponentCatalogNexusRepository.java
@@ -0,0 +1,57 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.nexus;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.camel.catalog.CamelCatalog;
+
+public class LocalFileComponentCatalogNexusRepository extends ComponentCatalogNexusRepository
{
+
+    private Runnable onAddComponent;
+
+    public Runnable getOnAddComponent() {
+        return onAddComponent;
+    }
+
+    public void setOnAddComponent(Runnable onAddComponent) {
+        this.onAddComponent = onAddComponent;
+    }
+
+    @Override
+    protected URL createNexusUrl() throws MalformedURLException {
+        File file = new File("target/test-classes/nexus-sample-result.xml");
+        return new URL("file:" + file.getAbsolutePath());
+    }
+
+    @Override
+    protected String createArtifactURL(NexusArtifactDto dto) {
+        // load from local file instead
+        return "file:target/localrepo/" + dto.getArtifactId() + "-" + dto.getVersion() +
".jar";
+    }
+
+    @Override
+    protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme,
String javaType, String json) {
+        super.addComponent(dto, camelCatalog, scheme, javaType, json);
+
+        if (onAddComponent != null) {
+            onAddComponent.run();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
deleted file mode 100644
index 3a05b5f..0000000
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
+++ /dev/null
@@ -1,57 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.nexus;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.camel.catalog.CamelCatalog;
-
-public class LocalFileNexusRepository extends ComponentNexusRepository {
-
-    private Runnable onAddComponent;
-
-    public Runnable getOnAddComponent() {
-        return onAddComponent;
-    }
-
-    public void setOnAddComponent(Runnable onAddComponent) {
-        this.onAddComponent = onAddComponent;
-    }
-
-    @Override
-    protected URL createNexusUrl() throws MalformedURLException {
-        File file = new File("target/test-classes/nexus-sample-result.xml");
-        return new URL("file:" + file.getAbsolutePath());
-    }
-
-    @Override
-    protected String createArtifactURL(NexusArtifactDto dto) {
-        // load from local file instead
-        return "file:target/localrepo/" + dto.getArtifactId() + "-" + dto.getVersion() +
".jar";
-    }
-
-    @Override
-    protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme,
String javaType, String json) {
-        super.addComponent(dto, camelCatalog, scheme, javaType, json);
-
-        if (onAddComponent != null) {
-            onAddComponent.run();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusComponentCatalogRepositoryTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusComponentCatalogRepositoryTest.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusComponentCatalogRepositoryTest.java
new file mode 100644
index 0000000..454bfdf
--- /dev/null
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusComponentCatalogRepositoryTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.nexus;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import junit.framework.TestCase;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.junit.Test;
+
+public class LocalNexusComponentCatalogRepositoryTest extends TestCase {
+
+    private final CamelCatalog catalog = new DefaultCamelCatalog();
+
+    @Test
+    public void testLocalNexus() throws Exception {
+        int before = catalog.findComponentNames().size();
+
+        LocalFileComponentCatalogNexusRepository repo = new LocalFileComponentCatalogNexusRepository();
+        repo.setCamelCatalog(catalog);
+        repo.setInitialDelay(2);
+        repo.setDelay(3);
+        repo.setNexusUrl("dummy");
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        repo.setOnAddComponent(latch::countDown);
+
+        repo.start();
+
+        assertTrue("Should have found component", latch.await(10, TimeUnit.SECONDS));
+
+        repo.stop();
+
+        int after = catalog.findComponentNames().size();
+
+        assertTrue("There should be 1 component found", after - before == 1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
deleted file mode 100644
index 4c8a8c0..0000000
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
+++ /dev/null
@@ -1,54 +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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.nexus;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.DefaultCamelCatalog;
-import org.junit.Test;
-
-public class LocalNexusRepositoryTest extends TestCase {
-
-    private final CamelCatalog catalog = new DefaultCamelCatalog();
-
-    @Test
-    public void testLocalNexus() throws Exception {
-        int before = catalog.findComponentNames().size();
-
-        LocalFileNexusRepository repo = new LocalFileNexusRepository();
-        repo.setCamelCatalog(catalog);
-        repo.setInitialDelay(2);
-        repo.setDelay(3);
-        repo.setNexusUrl("dummy");
-
-        final CountDownLatch latch = new CountDownLatch(1);
-        repo.setOnAddComponent(latch::countDown);
-
-        repo.start();
-
-        assertTrue("Should have found component", latch.await(10, TimeUnit.SECONDS));
-
-        repo.stop();
-
-        int after = catalog.findComponentNames().size();
-
-        assertTrue("There should be 1 component found", after - before == 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/d492153a/platforms/catalog/src/main/java/org/apache/camel/catalog/CatalogHelper.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/CatalogHelper.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/CatalogHelper.java
index 2ce8089..f7c0072 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/CatalogHelper.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/CatalogHelper.java
@@ -28,7 +28,6 @@ public final class CatalogHelper {
     private CatalogHelper() {
     }
 
-
     /**
      * Loads the entire stream into memory as a String and returns it.
      * <p/>
@@ -143,4 +142,54 @@ public final class CatalogHelper {
         return before(text, before);
     }
 
+    /**
+     * Tests whether the value is <tt>null</tt> or an empty string.
+     *
+     * @param value  the value, if its a String it will be tested for text length as well
+     * @return true if empty
+     */
+    public static boolean isEmpty(Object value) {
+        return !isNotEmpty(value);
+    }
+
+    /**
+     * Tests whether the value is <b>not</b> <tt>null</tt> or an
empty string.
+     *
+     * @param value  the value, if its a String it will be tested for text length as well
+     * @return true if <b>not</b> empty
+     */
+    public static boolean isNotEmpty(Object value) {
+        if (value == null) {
+            return false;
+        } else if (value instanceof String) {
+            String text = (String) value;
+            return text.trim().length() > 0;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * Removes all leading and ending quotes (single and double) from the string
+     *
+     * @param s  the string
+     * @return the string without leading and ending quotes (single and double)
+     */
+    public static String removeLeadingAndEndingQuotes(String s) {
+        if (isEmpty(s)) {
+            return s;
+        }
+
+        String copy = s.trim();
+        if (copy.startsWith("'") && copy.endsWith("'")) {
+            return copy.substring(1, copy.length() - 1);
+        }
+        if (copy.startsWith("\"") && copy.endsWith("\"")) {
+            return copy.substring(1, copy.length() - 1);
+        }
+
+        // no quotes, so return as-is
+        return s;
+    }
+
 }


Mime
View raw message