diff --git a/src/kademlia/dht/DHT.java b/src/kademlia/dht/DHT.java index c6883d0..500c59e 100644 --- a/src/kademlia/dht/DHT.java +++ b/src/kademlia/dht/DHT.java @@ -96,6 +96,7 @@ public class DHT /* We have this content, but not the latest version, lets delete it so the new version will be added below */ try { + System.out.println("Removing older content to update it"); this.remove(content.getContentMetadata()); } catch (ContentNotFoundException ex) diff --git a/src/kademlia/dht/StorageEntry.java b/src/kademlia/dht/StorageEntry.java index eb69b1c..93d1a13 100644 --- a/src/kademlia/dht/StorageEntry.java +++ b/src/kademlia/dht/StorageEntry.java @@ -9,7 +9,7 @@ package kademlia.dht; public class StorageEntry { - private final byte[] content; + private final String content; private final StorageEntryMetadata metadata; public StorageEntry(KadContent content) @@ -19,11 +19,11 @@ public class StorageEntry public StorageEntry(KadContent content, StorageEntryMetadata metadata) { - this.content = content.toBytes(); + this.content = new String(content.toBytes()); this.metadata = metadata; } - public byte[] getContent() + public String getContent() { return this.content; } diff --git a/src/kademlia/tests/ContentSendingTest.java b/src/kademlia/tests/ContentSendingTest.java index aa0684e..2bd17c2 100644 --- a/src/kademlia/tests/ContentSendingTest.java +++ b/src/kademlia/tests/ContentSendingTest.java @@ -43,7 +43,7 @@ public class ContentSendingTest List conte = kad2.get(gp, 4); for (StorageEntry cc : conte) { - System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent())); + System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes())); System.out.println("Content Metadata: " + cc.getContentMetadata()); } diff --git a/src/kademlia/tests/ContentUpdatingTest.java b/src/kademlia/tests/ContentUpdatingTest.java index 580b867..3e813c9 100644 --- a/src/kademlia/tests/ContentUpdatingTest.java +++ b/src/kademlia/tests/ContentUpdatingTest.java @@ -38,7 +38,7 @@ public class ContentUpdatingTest List conte = kad2.get(gp, 4); for (StorageEntry cc : conte) { - System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent())); + System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes())); System.out.println("Content Metadata: " + cc.getContentMetadata()); } @@ -51,7 +51,7 @@ public class ContentUpdatingTest conte = kad2.get(gp, 4); for (StorageEntry cc : conte) { - System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent())); + System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes())); System.out.println("Content Metadata: " + cc.getContentMetadata()); } diff --git a/src/kademlia/tests/SaveStateTest2.java b/src/kademlia/tests/SaveStateTest2.java index 43baaae..db77155 100644 --- a/src/kademlia/tests/SaveStateTest2.java +++ b/src/kademlia/tests/SaveStateTest2.java @@ -57,7 +57,7 @@ public class SaveStateTest2 if (!content.isEmpty()) { - DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent()); + DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent().getBytes()); System.out.println("Content received: " + cc); } else