From 80b69bbf2b53e5587088a1e8b8764aeb92e1c1ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Oct 2010 21:27:50 +0200 Subject: [PATCH] Add method to insert a directory into Freenet. --- .../pterodactylus/sone/core/FreenetInterface.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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); + } + } + } -- 2.7.4