+ /**
+ * Container for information that are required to insert a Sone. This
+ * container merely exists to copy all relevant data without holding a lock
+ * on the {@link Sone} object for too long.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private class InsertInformation {
+
+ /** The request URI of the Sone. */
+ private final FreenetURI requestUri;
+
+ /** The insert URI of the Sone. */
+ private final FreenetURI insertUri;
+
+ /**
+ * Creates a new insert information container.
+ *
+ * @param requestUri
+ * The request URI of the Sone
+ * @param insertUri
+ * The insert URI of the Sone
+ */
+ public InsertInformation(FreenetURI requestUri, FreenetURI insertUri) {
+ this.requestUri = requestUri;
+ this.insertUri = insertUri;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the request URI of the Sone.
+ *
+ * @return The request URI of the Sone
+ */
+ @SuppressWarnings("unused")
+ public FreenetURI getRequestUri() {
+ return requestUri;
+ }
+
+ /**
+ * Returns the insert URI of the Sone.
+ *
+ * @return The insert URI of the Sone
+ */
+ public FreenetURI getInsertUri() {
+ return insertUri;
+ }
+
+ //
+ // ACTIONS
+ //
+
+ /**
+ * Generates all manifest entries required to insert this Sone.
+ *
+ * @return The manifest entries for the Sone insert
+ */
+ @SuppressWarnings("synthetic-access")
+ public HashMap<String, Object> generateManifestEntries() {
+ HashMap<String, Object> manifestEntries = new HashMap<String, Object>();
+
+ Charset utf8Charset = Charset.forName("UTF-8");
+
+ /* first, create an index.html. */
+ Template indexTemplate = templateFactory.createTemplate(new InputStreamReader(getClass().getResourceAsStream("/templates/insert/index.html"), utf8Charset));
+ indexTemplate.set("currentSone", sone);
+ StringWriter indexWriter = new StringWriter();
+ indexTemplate.render(indexWriter);
+ StringBucket indexBucket = new StringBucket(indexWriter.toString(), utf8Charset);
+ ManifestElement indexManifestElement = new ManifestElement("index.html", indexBucket, "text/html; charset=utf-8", indexBucket.size());
+ manifestEntries.put("index.html", indexManifestElement);
+
+ return manifestEntries;
+ }
+
+ //
+ // PRIVATE METHODS
+ //
+
+ }
+