From: David ‘Bombe’ Roden Date: Wed, 13 Oct 2010 19:27:50 +0000 (+0200) Subject: Add method to insert a directory into Freenet. X-Git-Tag: 0.1-RC1~452 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=80b69bbf2b53e5587088a1e8b8764aeb92e1c1ae;p=Sone.git Add method to insert a directory into Freenet. --- diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index 1098069..aa46f93 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.core; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -25,6 +26,7 @@ import net.pterodactylus.util.service.AbstractService; import freenet.client.FetchException; import freenet.client.FetchResult; import freenet.client.HighLevelSimpleClient; +import freenet.client.InsertException; import freenet.keys.FreenetURI; import freenet.node.Node; @@ -92,4 +94,25 @@ public class FreenetInterface extends AbstractService { return new String[] { keyPair[1].toString(), keyPair[0].toString() }; } + /** + * Inserts a directory into Freenet. + * + * @param insertUri + * The insert URI + * @param manifestEntries + * The directory entries + * @param defaultFile + * The name of the default file + * @return The generated URI + * @throws SoneException + * if an insert error occurs + */ + public FreenetURI insertDirectory(FreenetURI insertUri, HashMap manifestEntries, String defaultFile) throws SoneException { + try { + return client.insertManifest(insertUri, manifestEntries, defaultFile); + } catch (InsertException ie1) { + throw new SoneException(null, ie1); + } + } + }