This is an automated email from the ASF dual-hosted git repository.
acosentino 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 42d2e6ec [CAMEL-13173] [IPFS] Remove transitive dependency on bitcoin
and cipher
42d2e6ec is described below
commit 42d2e6ec7d69bd1f994a1d6e4c133382cad29d12
Author: Thomas Diesler <[email protected]>
AuthorDate: Thu Feb 14 14:01:49 2019 +0100
[CAMEL-13173] [IPFS] Remove transitive dependency on bitcoin and cipher
---
components/camel-ipfs/pom.xml | 2 +-
.../apache/camel/component/ipfs/IPFSComponent.java | 9 ++++---
.../apache/camel/component/ipfs/IPFSEndpoint.java | 30 ++++++++++++++++------
.../camel/component/ipfs/SimpleIPFSTest.java | 21 +++++++++++++--
parent/pom.xml | 4 +--
5 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/components/camel-ipfs/pom.xml b/components/camel-ipfs/pom.xml
index d47f120..1dc09b9 100644
--- a/components/camel-ipfs/pom.xml
+++ b/components/camel-ipfs/pom.xml
@@ -55,7 +55,7 @@
</dependency>
<dependency>
<groupId>io.nessus</groupId>
- <artifactId>nessus-ipfs</artifactId>
+ <artifactId>nessus-ipfs-client</artifactId>
</dependency>
<!-- Test -->
diff --git
a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java
b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java
index 889ba6e..982ee6c 100644
---
a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java
+++
b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSComponent.java
@@ -19,13 +19,13 @@ package org.apache.camel.component.ipfs;
import java.net.URI;
import java.util.Map;
-import io.nessus.ipfs.IPFSClient;
-import io.nessus.ipfs.impl.DefaultIPFSClient;
-
import org.apache.camel.Endpoint;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import io.nessus.ipfs.client.DefaultIPFSClient;
+import io.nessus.ipfs.client.IPFSClient;
+
@Component("ipfs")
public class IPFSComponent extends DefaultComponent {
@@ -65,6 +65,7 @@ public class IPFSComponent extends DefaultComponent {
}
private synchronized IPFSClient createClient(IPFSConfiguration config) {
- return new DefaultIPFSClient(config.getIpfsHost(),
config.getIpfsPort());
+ IPFSClient ipfsClient = new DefaultIPFSClient(config.getIpfsHost(),
config.getIpfsPort());
+ return ipfsClient.connect();
}
}
diff --git
a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java
b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java
index 4a6c64c..753c79b 100644
---
a/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java
+++
b/components/camel-ipfs/src/main/java/org/apache/camel/component/ipfs/IPFSEndpoint.java
@@ -22,8 +22,9 @@ import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-
-import io.nessus.ipfs.IPFSClient;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
@@ -34,6 +35,9 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.support.DefaultEndpoint;
+import io.ipfs.multihash.Multihash;
+import io.nessus.ipfs.client.IPFSClient;
+
/**
* The camel-ipfs component provides access to the Interplanetary File System
* (IPFS).
@@ -41,6 +45,8 @@ import org.apache.camel.support.DefaultEndpoint;
@UriEndpoint(firstVersion = "2.23.0", scheme = "ipfs", title = "IPFS", syntax
= "ipfs:host:port/cmd", producerOnly = true, label = "file,ipfs")
public class IPFSEndpoint extends DefaultEndpoint {
+ static long DEFAULT_TIMEOUT = 10000L;
+
@UriParam
private final IPFSConfiguration configuration;
@@ -87,17 +93,25 @@ public class IPFSEndpoint extends DefaultEndpoint {
}
List<String> ipfsAdd(Path path) throws IOException {
- return ipfs().add(path);
+ List<Multihash> cids = ipfs().add(path);
+ return cids.stream().map(mh ->
mh.toBase58()).collect(Collectors.toList());
}
- InputStream ipfsCat(String cid) throws IOException {
- return ipfs().cat(cid);
+ InputStream ipfsCat(String cid) throws IOException, TimeoutException {
+ Multihash mhash = Multihash.fromBase58(cid);
+ Future<InputStream> future = ipfs().cat(mhash);
+ try {
+ return future.get(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new IOException("Cannot obtain: " + cid, ex);
+ }
}
- Path ipfsGet(String cid, Path outdir) throws IOException {
- Future<Path> future = ipfs().get(cid, outdir);
+ Path ipfsGet(String cid, Path outdir) throws IOException, TimeoutException
{
+ Multihash mhash = Multihash.fromBase58(cid);
+ Future<Path> future = ipfs().get(mhash, outdir);
try {
- return future.get();
+ return future.get(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException ex) {
throw new IOException("Cannot obtain: " + cid, ex);
}
diff --git
a/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java
b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java
index 07aec74..584d9f5 100644
---
a/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java
+++
b/components/camel-ipfs/src/test/java/org/apache/camel/component/ipfs/SimpleIPFSTest.java
@@ -25,18 +25,35 @@ import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
-import io.nessus.utils.StreamUtils;
-
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.junit.Assert;
import org.junit.Assume;
+import org.junit.Before;
import org.junit.Test;
+import io.nessus.ipfs.client.DefaultIPFSClient;
+import io.nessus.ipfs.client.IPFSClient;
+import io.nessus.ipfs.client.IPFSException;
+import io.nessus.utils.StreamUtils;
+
public class SimpleIPFSTest {
+ IPFSClient ipfs;
+
+ @Before
+ public void before() {
+ ipfs = new DefaultIPFSClient("127.0.0.1", 5001);
+ try {
+ ipfs.connect();
+ } catch (IPFSException ex) {
+ // ignore
+ }
+ Assume.assumeTrue(ipfs.hasConnection());
+ }
+
@Test
public void ipfsVersion() throws Exception {
diff --git a/parent/pom.xml b/parent/pom.xml
index aae0660..78337a8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -506,7 +506,7 @@
<mvel-version>2.4.2.Final</mvel-version>
<mybatis-version>3.5.0</mybatis-version>
<narayana-version>5.9.2.Final</narayana-version>
- <nessus-version>1.0.0.Beta1</nessus-version>
+ <nessus-version>1.0.0.Beta4</nessus-version>
<nsq-client-version>1.0.0.RC4</nsq-client-version>
<neethi-bundle-version>3.0.1</neethi-bundle-version>
<nekohtml-version>1.9.22</nekohtml-version>
@@ -4866,7 +4866,7 @@
<dependency>
<groupId>io.nessus</groupId>
- <artifactId>nessus-ipfs</artifactId>
+ <artifactId>nessus-ipfs-client</artifactId>
<version>${nessus-version}</version>
</dependency>
</dependencies>