Author: nextgens
Date: 2007-11-20 19:25:07 +0000 (Tue, 20 Nov 2007)
New Revision: 15884
Modified:
trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
trunk/freenet/src/freenet/clients/http/bookmark/Bookmark.java
trunk/freenet/src/freenet/clients/http/bookmark/BookmarkCategory.java
trunk/freenet/src/freenet/clients/http/bookmark/BookmarkItem.java
trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
Log:
indent
Modified: trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
2007-11-20 19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
2007-11-20 19:25:07 UTC (rev 15884)
@@ -24,322 +24,328 @@
public class BookmarkEditorToadlet extends Toadlet {
- private static final int MAX_ACTION_LENGTH = 20;
- private static final int MAX_KEY_LENGTH = QueueToadlet.MAX_KEY_LENGTH;
- private static final int MAX_NAME_LENGTH = 500;
- private static final int MAX_BOOKMARK_PATH_LENGTH = 10 *
MAX_NAME_LENGTH;
+ private static final int MAX_ACTION_LENGTH = 20;
+ private static final int MAX_KEY_LENGTH = QueueToadlet.MAX_KEY_LENGTH;
+ private static final int MAX_NAME_LENGTH = 500;
+ private static final int MAX_BOOKMARK_PATH_LENGTH = 10 * MAX_NAME_LENGTH;
+ private final NodeClientCore core;
+ private final BookmarkManager bookmarkManager;
+ private String cutedPath;
- private final NodeClientCore core;
- private final BookmarkManager bookmarkManager;
- private String cutedPath;
+ BookmarkEditorToadlet(HighLevelSimpleClient client, NodeClientCore core) {
+ super(client);
+ this.core = core;
+ this.bookmarkManager = core.bookmarkManager;
+ this.cutedPath = null;
+ }
+ private void addCategoryToList(BookmarkCategory cat, String path, HTMLNode
list) {
+ BookmarkItems items = cat.getItems();
- BookmarkEditorToadlet(HighLevelSimpleClient client, NodeClientCore core)
- {
- super(client);
- this.core = core;
- this.bookmarkManager = core.bookmarkManager;
- this.cutedPath = null;
- }
+ final String edit = L10n.getString("BookmarkEditorToadlet.edit");
+ final String delete = L10n.getString("BookmarkEditorToadlet.delete");
+ final String cut = L10n.getString("BookmarkEditorToadlet.cut");
+ final String moveUp = L10n.getString("BookmarkEditorToadlet.moveUp");
+ final String moveDown =
L10n.getString("BookmarkEditorToadlet.moveDown");
+ final String paste = L10n.getString("BookmarkEditorToadlet.paste");
+ final String addBookmark =
L10n.getString("BookmarkEditorToadlet.addBookmark");
+ final String addCategory =
L10n.getString("BookmarkEditorToadlet.addCategory");
- private void addCategoryToList(BookmarkCategory cat, String path,
HTMLNode list)
- {
- BookmarkItems items = cat.getItems();
+ for (int i = 0; i < items.size(); i++) {
- final String edit =
L10n.getString("BookmarkEditorToadlet.edit");
- final String delete =
L10n.getString("BookmarkEditorToadlet.delete");
- final String cut = L10n.getString("BookmarkEditorToadlet.cut");
- final String moveUp =
L10n.getString("BookmarkEditorToadlet.moveUp");
- final String moveDown =
L10n.getString("BookmarkEditorToadlet.moveDown");
- final String paste =
L10n.getString("BookmarkEditorToadlet.paste");
- final String addBookmark =
L10n.getString("BookmarkEditorToadlet.addBookmark");
- final String addCategory =
L10n.getString("BookmarkEditorToadlet.addCategory");
+ String itemPath = URLEncoder.encode(path + items.get(i).getName(),
false);
+ HTMLNode li = new HTMLNode("li", "class", "item",
items.get(i).getName());
- for(int i = 0; i < items.size(); i++) {
+ HTMLNode actions = new HTMLNode("span", "class", "actions");
+ actions.addChild("a", "href", "?action=edit&bookmark=" +
itemPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/edit.png", edit, edit});
- String itemPath = URLEncoder.encode(path +
items.get(i).getName(), false);
- HTMLNode li = new HTMLNode("li", "class", "item" ,
items.get(i).getName());
+ actions.addChild("a", "href", "?action=del&bookmark=" +
itemPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/delete.png", delete, delete});
- HTMLNode actions = new HTMLNode("span", "class",
"actions");
- actions.addChild("a", "href", "?action=edit&bookmark="
+ itemPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/edit.png", edit, edit});
+ if (cutedPath == null) {
+ actions.addChild("a", "href", "?action=cut&bookmark=" +
itemPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/cut.png", cut, cut});
+ }
- actions.addChild("a", "href", "?action=del&bookmark=" +
itemPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/delete.png", delete, delete});
+ if (i != 0) {
+ actions.addChild("a", "href", "?action=up&bookmark=" +
itemPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/go-up.png", moveUp, moveUp});
+ }
- if(cutedPath == null)
- actions.addChild("a", "href",
"?action=cut&bookmark=" + itemPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/cut.png", cut, cut});
+ if (i != items.size() - 1) {
+ actions.addChild("a", "href", "?action=down&bookmark=" +
itemPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/go-down.png", moveDown, moveDown});
+ }
- if(i != 0)
- actions.addChild("a", "href",
"?action=up&bookmark=" + itemPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-up.png", moveUp, moveUp});
+ li.addChild(actions);
+ list.addChild(li);
+ }
- if(i != items.size()-1)
- actions.addChild("a", "href",
"?action=down&bookmark=" + itemPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/go-down.png", moveDown, moveDown});
+ BookmarkCategories cats = cat.getSubCategories();
+ for (int i = 0; i < cats.size(); i++) {
- li.addChild(actions);
- list.addChild(li);
- }
+ String catPath = URLEncoder.encode(path + cats.get(i).getName() +
"/", false);
- BookmarkCategories cats = cat.getSubCategories();
- for(int i = 0; i < cats.size(); i++) {
+ HTMLNode subCat = list.addChild("li", "class", "cat",
cats.get(i).getName());
- String catPath = URLEncoder.encode(path +
cats.get(i).getName() + "/", false);
+ HTMLNode actions = new HTMLNode("span", "class", "actions");
- HTMLNode subCat = list.addChild("li", "class", "cat",
cats.get(i).getName());
+ actions.addChild("a", "href", "?action=edit&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/edit.png", edit, edit});
- HTMLNode actions = new HTMLNode("span", "class",
"actions");
+ actions.addChild("a", "href", "?action=del&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/delete.png", delete, delete});
- actions.addChild("a", "href", "?action=edit&bookmark="
+ catPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/edit.png", edit, edit});
+ actions.addChild("a", "href", "?action=addItem&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/bookmark-new.png", addBookmark, addBookmark});
- actions.addChild("a", "href", "?action=del&bookmark=" +
catPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/delete.png", delete, delete});
+ actions.addChild("a", "href", "?action=addCat&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/folder-new.png", addCategory, addCategory});
- actions.addChild("a", "href",
"?action=addItem&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/bookmark-new.png", addBookmark,
addBookmark});
+ if (cutedPath == null) {
+ actions.addChild("a", "href", "?action=cut&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/cut.png", cut, cut});
+ }
- actions.addChild("a", "href",
"?action=addCat&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/folder-new.png", addCategory,
addCategory});
+ if (i != 0) {
+ actions.addChild("a", "href", "?action=up&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/go-up.png", moveUp, moveUp});
+ }
- if(cutedPath == null)
- actions.addChild("a", "href",
"?action=cut&bookmark=" + catPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/cut.png", cut, cut});
+ if (i != cats.size() - 1) {
+ actions.addChild("a", "href", "?action=down&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/go-down.png", moveDown, moveDown});
+ }
- if(i != 0)
- actions.addChild("a", "href",
"?action=up&bookmark=" + catPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-up.png", moveUp, moveUp});
+ if (cutedPath != null && !catPath.startsWith(cutedPath) &&
!catPath.equals(bookmarkManager.parentPath(cutedPath))) {
+ actions.addChild("a", "href", "?action=paste&bookmark=" +
catPath).addChild("img", new String[]{"src", "alt", "title"}, new
String[]{"/static/icon/paste.png", paste, paste});
+ }
- if(i != cats.size() -1)
- actions.addChild("a", "href",
"?action=down&bookmark=" + catPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-down.png", moveDown, moveDown});
+ subCat.addChild(actions);
+ if (cats.get(i).size() != 0) {
+ addCategoryToList(cats.get(i), catPath,
list.addChild("li").addChild("ul"));
+ }
+ }
+ }
- if(cutedPath != null && ! catPath.startsWith(cutedPath)
&& ! catPath.equals(bookmarkManager.parentPath(cutedPath)))
- actions.addChild("a", "href",
"?action=paste&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/paste.png", paste, paste});
+ public HTMLNode getBookmarksList() {
+ HTMLNode bookmarks = new HTMLNode("ul", "id", "bookmarks");
- subCat.addChild(actions);
- if(cats.get(i).size() != 0)
- addCategoryToList(cats.get(i), catPath,
list.addChild("li").addChild("ul"));
- }
- }
+ HTMLNode root = bookmarks.addChild("li", "class", "cat root", "/");
+ HTMLNode actions = new HTMLNode("span", "class", "actions");
+ String addBookmark =
L10n.getString("BookmarkEditorToadlet.addBookmark");
+ String addCategory =
L10n.getString("BookmarkEditorToadlet.addCategory");
+ String paste = L10n.getString("BookmarkEditorToadlet.paste");
+ actions.addChild("a", "href",
"?action=addItem&bookmark=/").addChild("img", new String[]{"src", "alt",
"title"}, new String[]{"/static/icon/bookmark-new.png", addBookmark,
addBookmark});
+ actions.addChild("a", "href",
"?action=addCat&bookmark=/").addChild("img", new String[]{"src", "alt",
"title"}, new String[]{"/static/icon/folder-new.png", addCategory,
addCategory});
- public HTMLNode getBookmarksList()
- {
- HTMLNode bookmarks = new HTMLNode("ul", "id", "bookmarks");
+ if (cutedPath != null &&
!"/".equals(bookmarkManager.parentPath(cutedPath))) {
+ actions.addChild("a", "href",
"?action=paste&bookmark=/").addChild("img", new String[]{"src", "alt",
"title"}, new String[]{"/static/icon/paste.png", paste, paste});
+ }
- HTMLNode root = bookmarks.addChild("li", "class", "cat root",
"/");
- HTMLNode actions = new HTMLNode("span", "class", "actions");
- String addBookmark =
L10n.getString("BookmarkEditorToadlet.addBookmark");
- String addCategory =
L10n.getString("BookmarkEditorToadlet.addCategory");
- String paste = L10n.getString("BookmarkEditorToadlet.paste");
- actions.addChild("a", "href",
"?action=addItem&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/bookmark-new.png", addBookmark,
addBookmark});
- actions.addChild("a", "href",
"?action=addCat&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/folder-new.png", addCategory,
addCategory});
+ root.addChild(actions);
+ addCategoryToList(BookmarkManager.MAIN_CATEGORY, "/",
root.addChild("ul"));
- if(cutedPath != null && !
"/".equals(bookmarkManager.parentPath(cutedPath)))
- actions.addChild("a", "href",
"?action=paste&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/paste.png", paste, paste});
+ return bookmarks;
+ }
- root.addChild(actions);
- addCategoryToList(BookmarkManager.MAIN_CATEGORY, "/",
root.addChild("ul"));
+ public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx)
+ throws ToadletContextClosedException, IOException {
+ PageMaker pageMaker = ctx.getPageMaker();
+ String editorTitle = L10n.getString("BookmarkEditorToadlet.title");
+ String error = L10n.getString("BookmarkEditorToadlet.error");
+ HTMLNode pageNode = pageMaker.getPageNode(editorTitle, ctx);
+ HTMLNode content = pageMaker.getContentNode(pageNode);
- return bookmarks;
- }
+ if (req.getParam("action").length() > 0 &&
req.getParam("bookmark").length() > 0) {
+ String action = req.getParam("action");
+ String bookmarkPath;
+ try {
+ bookmarkPath = URLDecoder.decode(req.getParam("bookmark"),
false);
+ } catch (URLEncodedFormatException e) {
+ HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error", error));
+ pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.urlDecodeError"));
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ }
+ Bookmark bookmark;
- public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx)
- throws ToadletContextClosedException, IOException
- {
- PageMaker pageMaker = ctx.getPageMaker();
- String editorTitle =
L10n.getString("BookmarkEditorToadlet.title");
- String error = L10n.getString("BookmarkEditorToadlet.error");
- HTMLNode pageNode = pageMaker.getPageNode(editorTitle, ctx);
- HTMLNode content = pageMaker.getContentNode(pageNode);
+ if (bookmarkPath.endsWith("/")) {
+ bookmark = bookmarkManager.getCategoryByPath(bookmarkPath);
+ } else {
+ bookmark = bookmarkManager.getItemByPath(bookmarkPath);
+ }
- if (req.getParam("action").length() > 0 &&
req.getParam("bookmark").length() > 0) {
- String action = req.getParam("action");
- String bookmarkPath;
- try {
- bookmarkPath =
URLDecoder.decode(req.getParam("bookmark"), false);
- } catch (URLEncodedFormatException e) {
- HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error", error));
-
pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.urlDecodeError"));
- writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- }
- Bookmark bookmark;
+ if (bookmark == null) {
+ HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error", error));
+ pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new
String[]{"bookmark"}, new String[]{bookmarkPath}));
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ } else {
- if (bookmarkPath.endsWith("/"))
- bookmark =
bookmarkManager.getCategoryByPath(bookmarkPath);
- else
- bookmark =
bookmarkManager.getItemByPath(bookmarkPath);
+ if ("del".equals(action)) {
- if(bookmark == null) {
- HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error", error));
-
pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new String[] {
"bookmark" }, new String[] { bookmarkPath }));
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- } else {
+ String[] bm = new String[]{"bookmark"};
+ String[] path = new String[]{bookmarkPath};
+ String queryTitle =
L10n.getString("BookmarkEditorToadlet." + ((bookmark instanceof BookmarkItem) ?
"deleteBookmark" : "deleteCategory"));
+ HTMLNode infoBox =
content.addChild(pageMaker.getInfobox("infobox-query", queryTitle));
+ HTMLNode infoBoxContent =
pageMaker.getContentNode(infoBox);
- if("del".equals(action)){
+ String query = L10n.getString("BookmarkEditorToadlet." +
((bookmark instanceof BookmarkItem) ? "deleteBookmarkConfirm" :
"deleteCategoryConfirm"), bm, path);
+ infoBoxContent.addChild("p").addChild("#", query);
- String[] bm = new String[] { "bookmark"
};
- String[] path = new String[] {
bookmarkPath };
- String queryTitle =
L10n.getString("BookmarkEditorToadlet." + ((bookmark instanceof BookmarkItem) ?
"deleteBookmark" : "deleteCategory"));
- HTMLNode infoBox =
content.addChild(pageMaker.getInfobox("infobox-query", queryTitle));
- HTMLNode infoBoxContent =
pageMaker.getContentNode(infoBox);
+ HTMLNode confirmForm = ctx.addFormChild(infoBoxContent,
"", "confirmDeleteForm");
+ confirmForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "bookmark", bookmarkPath});
+ confirmForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancel", L10n.getString("Toadlet.cancel")});
+ confirmForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "confirmdelete",
L10n.getString("BookmarkEditorToadlet.confirmDelete")});
- String query =
L10n.getString("BookmarkEditorToadlet." + ((bookmark instanceof BookmarkItem) ?
"deleteBookmarkConfirm" : "deleteCategoryConfirm"), bm, path);
-
infoBoxContent.addChild("p").addChild("#", query);
+ } else if ("cut".equals(action)) {
- HTMLNode confirmForm =
ctx.addFormChild(infoBoxContent, "", "confirmDeleteForm");
- confirmForm.addChild("input", new
String[] { "type", "name", "value" }, new String[] { "hidden", "bookmark",
bookmarkPath});
- confirmForm.addChild("input", new
String[] { "type", "name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel") });
- confirmForm.addChild("input", new
String[] { "type", "name", "value" }, new String[] { "submit", "confirmdelete",
L10n.getString("BookmarkEditorToadlet.confirmDelete") });
+ cutedPath = bookmarkPath;
- } else if ("cut".equals(action)) {
+ } else if ("paste".equals(action) && cutedPath != null) {
- cutedPath = bookmarkPath;
+ bookmarkManager.moveBookmark(cutedPath, bookmarkPath,
true);
+ cutedPath = null;
- } else if ("paste".equals(action) && cutedPath
!= null) {
+ } else if ("edit".equals(action) || "addItem".equals(action)
|| "addCat".equals(action)) {
- bookmarkManager.moveBookmark(cutedPath,
bookmarkPath, true);
- cutedPath = null;
+ String header;
+ if ("edit".equals(action)) {
+ header = L10n.getString("BookmarkEditorToadlet.edit" +
((bookmark instanceof BookmarkItem) ? "Bookmark" : "Category") + "Title");
+ } else if ("addItem".equals(action)) {
+ header =
L10n.getString("BookmarkEditorToadlet.addNewBookmark");
+ } else {
+ header =
L10n.getString("BookmarkEditorToadlet.addNewCategory");
+ }
- } else if ("edit".equals(action) ||
"addItem".equals(action) || "addCat".equals(action)) {
+ HTMLNode actionBox =
content.addChild(pageMaker.getInfobox("infobox-query", header));
- String header;
- if("edit".equals(action)) {
- header =
L10n.getString("BookmarkEditorToadlet.edit" + ((bookmark instanceof
BookmarkItem) ? "Bookmark" : "Category") + "Title");
- } else if("addItem".equals(action)) {
- header =
L10n.getString("BookmarkEditorToadlet.addNewBookmark");
- } else {
- header =
L10n.getString("BookmarkEditorToadlet.addNewCategory");
- }
+ HTMLNode form =
ctx.addFormChild(pageMaker.getContentNode(actionBox), "", "editBookmarkForm");
- HTMLNode actionBox =
content.addChild(pageMaker.getInfobox("infobox-query", header));
+ form.addChild("label", "for", "name",
(L10n.getString("BookmarkEditorToadlet.nameLabel") + ' '));
+ form.addChild("input", new String[]{"type", "id", "name",
"size", "value"}, new String[]{"text", "name", "name", "20",
"edit".equals(action) ? bookmark.getName() : ""});
- HTMLNode form =
ctx.addFormChild(pageMaker.getContentNode(actionBox), "", "editBookmarkForm");
+ form.addChild("br");
+ boolean isNew = false;
+ if (("edit".equals(action) && bookmark instanceof
BookmarkItem) || (isNew = "addItem".equals(action))) {
+ BookmarkItem item = isNew ? null : (BookmarkItem)
bookmark;
+ String key = (action.equals("edit") ? item.getKey() :
"");
+ form.addChild("label", "for", "key",
(L10n.getString("BookmarkEditorToadlet.keyLabel") + ' '));
+ form.addChild("input", new String[]{"type", "id",
"name", "size", "value"}, new String[]{"text", "key", "key", "50", key});
+ form.addChild("br");
+ form.addChild("label", "for", "hasAnActivelink",
(L10n.getString("BookmarkEditorToadlet.hasAnActivelinkLabel") + ' '));
+ if (item != null && item.hasAnActivelink()) {
+ form.addChild("input", new String[]{"type", "id",
"name", "checked"}, new String[]{"checkbox", "hasAnActivelink",
"hasAnActivelink", String.valueOf(item.hasAnActivelink())});
+ } else {
+ form.addChild("input", new String[]{"type", "id",
"name"}, new String[]{"checkbox", "hasAnActivelink", "hasAnActivelink"});
+ }
+ }
- form.addChild("label", "for", "name",
(L10n.getString("BookmarkEditorToadlet.nameLabel") + ' '));
- form.addChild("input", new
String[]{"type", "id", "name", "size", "value"}, new String []{"text", "name",
"name", "20", "edit".equals(action)?bookmark.getName():""});
+ form.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "bookmark", bookmarkPath});
- form.addChild("br");
- boolean isNew = false;
- if (("edit".equals(action) && bookmark
instanceof BookmarkItem) || (isNew = "addItem".equals(action))) {
- BookmarkItem item = isNew ?
null : (BookmarkItem) bookmark;
- String key =
(action.equals("edit") ? item.getKey() : "");
- form.addChild("label", "for",
"key", (L10n.getString("BookmarkEditorToadlet.keyLabel") + ' '));
- form.addChild("input", new
String[]{"type", "id", "name", "size", "value"}, new String []{"text", "key",
"key", "50", key});
- form.addChild("br");
- form.addChild("label", "for",
"hasAnActivelink",
(L10n.getString("BookmarkEditorToadlet.hasAnActivelinkLabel") + ' '));
- if(item != null &&
item.hasAnActivelink())
- form.addChild("input",
new String[]{"type", "id", "name", "checked" }, new String[]{"checkbox",
"hasAnActivelink", "hasAnActivelink", String.valueOf(item.hasAnActivelink()) });
- else
- form.addChild("input",
new String[]{"type", "id", "name"}, new String[]{"checkbox", "hasAnActivelink",
"hasAnActivelink" });
- }
+ form.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "action", req.getParam("action")});
- form.addChild("input", new String[]
{"type", "name", "value"}, new String[] {"hidden", "bookmark",bookmarkPath});
+ form.addChild("br");
+ form.addChild("input", new String[]{"type", "value"}, new
String[]{"submit", L10n.getString("BookmarkEditorToadlet.save")});
+ } else if ("up".equals(action)) {
+ bookmarkManager.moveBookmarkUp(bookmarkPath, true);
+ } else if ("down".equals(action)) {
+ bookmarkManager.moveBookmarkDown(bookmarkPath, true);
+ }
+ }
- form.addChild("input", new String[]
{"type", "name", "value"}, new String[] {"hidden",
"action",req.getParam("action")});
+ }
- form.addChild("br");
- form.addChild("input", new
String[]{"type", "value"}, new String[]{"submit",
L10n.getString("BookmarkEditorToadlet.save")});
- } else if ("up".equals(action)) {
-
bookmarkManager.moveBookmarkUp(bookmarkPath, true);
- } else if("down".equals(action)) {
-
bookmarkManager.moveBookmarkDown(bookmarkPath, true);
- }
- }
+ if (cutedPath != null) {
+ HTMLNode infoBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.pasteTitle")));
+ HTMLNode infoBoxContent = pageMaker.getContentNode(infoBox);
+ infoBoxContent.addChild("#",
L10n.getString("BookmarkEditorToadlet.pasteOrCancel"));
+ HTMLNode cancelForm = ctx.addFormChild(infoBoxContent, "",
"cancelCutForm");
+ cancelForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancelCut",
L10n.getString("BookmarkEditorToadlet.cancelCut")});
+ }
- }
+ HTMLNode bookmarksBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle")));
+ pageMaker.getContentNode(bookmarksBox).addChild(getBookmarksList());
- if(cutedPath != null) {
- HTMLNode infoBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.pasteTitle")));
- HTMLNode infoBoxContent =
pageMaker.getContentNode(infoBox);
-
infoBoxContent.addChild("#",L10n.getString("BookmarkEditorToadlet.pasteOrCancel"));
- HTMLNode cancelForm = ctx.addFormChild(infoBoxContent,
"", "cancelCutForm");
- cancelForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "cancelCut",
L10n.getString("BookmarkEditorToadlet.cancelCut") });
- }
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ }
- HTMLNode bookmarksBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle")));
-
pageMaker.getContentNode(bookmarksBox).addChild(getBookmarksList());
+ public void handlePost(URI uri, HTTPRequest req, ToadletContext ctx)
+ throws ToadletContextClosedException, IOException {
+ PageMaker pageMaker = ctx.getPageMaker();
+ HTMLNode pageNode =
pageMaker.getPageNode(L10n.getString("BookmarkEditorToadlet.title"), ctx);
+ HTMLNode content = pageMaker.getContentNode(pageNode);
- this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- }
+ String passwd = req.getPartAsString("formPassword", 32);
+ boolean noPassword = (passwd == null) ||
!passwd.equals(core.formPassword);
+ if (noPassword) {
+ writePermanentRedirect(ctx, "Invalid", "");
+ return;
+ }
- public void handlePost(URI uri, HTTPRequest req, ToadletContext ctx)
- throws ToadletContextClosedException, IOException
- {
- PageMaker pageMaker = ctx.getPageMaker();
- HTMLNode pageNode =
pageMaker.getPageNode(L10n.getString("BookmarkEditorToadlet.title"), ctx);
- HTMLNode content = pageMaker.getContentNode(pageNode);
+ String bookmarkPath = req.getPartAsString("bookmark",
MAX_BOOKMARK_PATH_LENGTH);
+ try {
- String passwd = req.getPartAsString("formPassword", 32);
- boolean noPassword = (passwd == null) ||
!passwd.equals(core.formPassword);
- if(noPassword) {
- writePermanentRedirect(ctx, "Invalid", "");
- return;
- }
+ Bookmark bookmark;
+ if (bookmarkPath.endsWith("/")) {
+ bookmark = bookmarkManager.getCategoryByPath(bookmarkPath);
+ } else {
+ bookmark = bookmarkManager.getItemByPath(bookmarkPath);
+ }
+ if (bookmark == null) {
+ HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error",
L10n.getString("BookmarkEditorToadlet.error")));
+ pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new
String[]{"bookmark"}, new String[]{bookmarkPath}));
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ }
- String bookmarkPath = req.getPartAsString("bookmark",
MAX_BOOKMARK_PATH_LENGTH);
- try {
+ String action = req.getPartAsString("action", MAX_ACTION_LENGTH);
- Bookmark bookmark;
- if(bookmarkPath.endsWith("/"))
- bookmark =
bookmarkManager.getCategoryByPath(bookmarkPath);
- else
- bookmark =
bookmarkManager.getItemByPath(bookmarkPath);
- if(bookmark == null) {
- HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error",
L10n.getString("BookmarkEditorToadlet.error")));
-
pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.bookmarkDoesNotExist", new String[] {
"bookmark" } , new String[] { bookmarkPath }));
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- }
+ if (req.isPartSet("confirmdelete")) {
+ bookmarkManager.removeBookmark(bookmarkPath, true);
+ HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.deleteSucceededTitle")));
+ pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.deleteSucceeded"));
+ } else if (req.isPartSet("cancelCut")) {
+ cutedPath = null;
- String action = req.getPartAsString("action",
MAX_ACTION_LENGTH);
+ } else if ("edit".equals(action) || "addItem".equals(action) ||
"addCat".equals(action)) {
- if (req.isPartSet("confirmdelete")) {
- bookmarkManager.removeBookmark(bookmarkPath,
true);
- HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.deleteSucceededTitle")));
-
pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.deleteSucceeded"));
+ String name = "unnamed";
+ if (req.getPartAsString("name", MAX_NAME_LENGTH).length() > 0)
{
+ name = req.getPartAsString("name", MAX_NAME_LENGTH);
+ }
- } else if (req.isPartSet("cancelCut")) {
- cutedPath = null;
+ if ("edit".equals(action)) {
+ bookmarkManager.renameBookmark(bookmarkPath, name);
+ boolean hasAnActivelink = req.isPartSet("hasAnActivelink");
+ if (bookmark instanceof BookmarkItem) {
+ ((BookmarkItem) bookmark).setKey(new
FreenetURI(req.getPartAsString("key", MAX_KEY_LENGTH)), hasAnActivelink);
+ }
- } else if ("edit".equals(action) ||
"addItem".equals(action) || "addCat".equals(action)) {
+ HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.changesSavedTitle")));
+ pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.changesSaved"));
- String name = "unnamed";
- if (req.getPartAsString("name",
MAX_NAME_LENGTH).length() > 0)
- name = req.getPartAsString("name",
MAX_NAME_LENGTH);
+ } else if ("addItem".equals(action) ||
"addCat".equals(action)) {
- if("edit".equals(action)) {
-
bookmarkManager.renameBookmark(bookmarkPath, name);
- boolean hasAnActivelink =
req.isPartSet("hasAnActivelink");
- if(bookmark instanceof BookmarkItem)
- ((BookmarkItem)
bookmark).setKey(new FreenetURI(req.getPartAsString("key", MAX_KEY_LENGTH)),
hasAnActivelink);
+ Bookmark newBookmark;
+ if ("addItem".equals(action)) {
+ FreenetURI key = new
FreenetURI(req.getPartAsString("key", MAX_KEY_LENGTH));
+ boolean hasAnActivelink =
req.isPartSet("hasAnActivelink");
+ newBookmark = new BookmarkItem(key, name,
hasAnActivelink, core.alerts);
+ } else {
+ newBookmark = new BookmarkCategory(name);
+ }
- HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.changesSavedTitle")));
-
pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.changesSaved"));
+ bookmarkManager.addBookmark(bookmarkPath, newBookmark,
true);
- } else if ("addItem".equals(action) ||
"addCat".equals(action)) {
+ HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.addedNewBookmarkTitle")));
+ pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.addedNewBookmark"));
+ }
+ }
+ } catch (MalformedURLException mue) {
+ HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error",
L10n.getString("BookmarkEditorToadlet.invalidKeyTitle")));
+ pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.invalidKey"));
+ }
+ HTMLNode bookmarksBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle")));
+ pageMaker.getContentNode(bookmarksBox).addChild(getBookmarksList());
- Bookmark newBookmark;
- if("addItem".equals(action)) {
- FreenetURI key = new
FreenetURI(req.getPartAsString("key", MAX_KEY_LENGTH));
- boolean hasAnActivelink =
req.isPartSet("hasAnActivelink");
- newBookmark = new
BookmarkItem(key, name, hasAnActivelink, core.alerts);
- } else
- newBookmark = new
BookmarkCategory(name);
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ }
-
bookmarkManager.addBookmark(bookmarkPath, newBookmark, true);
-
- HTMLNode successBox =
content.addChild(pageMaker.getInfobox("infobox-success",
L10n.getString("BookmarkEditorToadlet.addedNewBookmarkTitle")));
-
pageMaker.getContentNode(successBox).addChild("p",
L10n.getString("BookmarkEditorToadlet.addedNewBookmark"));
- }
- }
- } catch (MalformedURLException mue) {
- HTMLNode errorBox =
content.addChild(pageMaker.getInfobox("infobox-error",
L10n.getString("BookmarkEditorToadlet.invalidKeyTitle")));
- pageMaker.getContentNode(errorBox).addChild("#",
L10n.getString("BookmarkEditorToadlet.invalidKey"));
- }
- HTMLNode bookmarksBox =
content.addChild(pageMaker.getInfobox("infobox-normal",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle")));
-
pageMaker.getContentNode(bookmarksBox).addChild(getBookmarksList());
-
- this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- }
-
- public String supportedMethods()
- {
- return "GET, POST";
- }
+ public String supportedMethods() {
+ return "GET, POST";
+ }
}
Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2007-11-20
19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2007-11-20
19:25:07 UTC (rev 15884)
@@ -38,170 +38,168 @@
import freenet.frost.message.*;
+public class WelcomeToadlet extends Toadlet {
+ private static final int MAX_URL_LENGTH = 1024 * 1024;
+ final NodeClientCore core;
+ final Node node;
+ final BookmarkManager bookmarkManager;
+ WelcomeToadlet(HighLevelSimpleClient client, NodeClientCore core, Node
node) {
+ super(client);
+ this.node = node;
+ this.core = core;
+ this.bookmarkManager = core.bookmarkManager;
+ try {
+ manageBookmarksURI = new URI("/welcome/?managebookmarks");
+ } catch (URISyntaxException e) {
+ throw new Error(e);
+ }
+ }
-public class WelcomeToadlet extends Toadlet {
- private static final int MAX_URL_LENGTH = 1024 * 1024;
- final NodeClientCore core;
- final Node node;
- final BookmarkManager bookmarkManager;
-
- WelcomeToadlet(HighLevelSimpleClient client, NodeClientCore core, Node
node) {
- super(client);
- this.node = node;
- this.core = core;
- this.bookmarkManager = core.bookmarkManager;
- try {
- manageBookmarksURI = new
URI("/welcome/?managebookmarks");
- } catch (URISyntaxException e) {
- throw new Error(e);
- }
- }
+ void redirectToRoot(ToadletContext ctx) throws
ToadletContextClosedException, IOException {
+ MultiValueTable headers = new MultiValueTable();
+ headers.put("Location", "/");
+ ctx.sendReplyHeaders(302, "Found", headers, null, 0);
+ return;
+ }
+ URI manageBookmarksURI;
- void redirectToRoot(ToadletContext ctx) throws
ToadletContextClosedException, IOException {
- MultiValueTable headers = new MultiValueTable();
- headers.put("Location", "/");
- ctx.sendReplyHeaders(302, "Found", headers, null, 0);
- return;
- }
+ private void addCategoryToList(BookmarkCategory cat, HTMLNode list) {
+ BookmarkItems items = cat.getItems();
+ if (items.size() > 0) {
+ // FIXME CSS noborder ...
+ HTMLNode table = list.addChild("li").addChild("table", new
String[]{"border", "style"}, new String[]{"0", "border: none"});
+ for (int i = 0; i < items.size(); i++) {
+ BookmarkItem item = items.get(i);
+ HTMLNode row = table.addChild("tr");
+ HTMLNode cell = row.addChild("td", "style", "border: none");
+ if (item.hasAnActivelink()) {
+ cell.addChild("a", "href", '/' +
item.getKey()).addChild("img", new String[]{"src", "height", "width", "alt"},
+ new String[]{'/' + item.getKey() +
"/activelink.png", "36px", "108px", "activelink"});
+ } else {
+ cell.addChild("#", " ");
+ }
+ cell = row.addChild("td", "style", "border: none");
+ cell.addChild("a", "href", '/' + item.getKey(),
item.getName());
+ }
+ }
- URI manageBookmarksURI;
-
-
- private void addCategoryToList(BookmarkCategory cat, HTMLNode list)
- {
- BookmarkItems items = cat.getItems();
- if(items.size() > 0) {
- // FIXME CSS noborder ...
- HTMLNode table = list.addChild("li").addChild("table", new
String[] { "border", "style" }, new String[] { "0", "border: none" });
- for(int i = 0; i < items.size(); i++) {
- BookmarkItem item = items.get(i);
- HTMLNode row = table.addChild("tr");
- HTMLNode cell = row.addChild("td", "style", "border:
none");
- if(item.hasAnActivelink()) {
- cell.addChild("a", "href", '/' + item.getKey())
- .addChild("img", new String[] { "src", "height",
"width", "alt"},
- new String[] { '/' + item.getKey() +
"/activelink.png", "36px", "108px", "activelink"});
- } else
- cell.addChild("#", " ");
- cell = row.addChild("td", "style", "border: none");
- cell.addChild("a", "href", '/' + item.getKey(),
item.getName());
- }
- }
+ BookmarkCategories cats = cat.getSubCategories();
+ for (int i = 0; i < cats.size(); i++) {
+ list.addChild("li", "class", "cat", cats.get(i).getName());
+ addCategoryToList(cats.get(i), list.addChild("li").addChild("ul"));
+ }
+ }
- BookmarkCategories cats = cat.getSubCategories();
- for (int i = 0; i < cats.size(); i++) {
- list.addChild("li", "class", "cat",
cats.get(i).getName());
- addCategoryToList(cats.get(i),
list.addChild("li").addChild("ul"));
- }
- }
-
- public void handlePost(URI uri, HTTPRequest request, ToadletContext
ctx) throws ToadletContextClosedException, IOException {
-
- if(!ctx.isAllowedFullAccess()) {
- super.sendErrorPage(ctx, 403, "Unauthorized",
L10n.getString("Toadlet.unauthorized"));
- return;
- }
-
- String passwd = request.getPartAsString("formPassword", 32);
- boolean noPassword = (passwd == null) ||
!passwd.equals(core.formPassword);
- if(noPassword) {
- if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "No password ("+passwd+" should be "+core.formPassword+ ')');
- }
-
- if(request.getPartAsString("updateconfirm", 32).length() > 0){
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- // false for no navigation bars, because that would be
very silly
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("updatingTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("updatingTitle")));
- HTMLNode content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("p").addChild("#", l10n("updating"));
- content.addChild("p").addChild("#", l10n("thanks"));
- writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- Logger.normal(this, "Node is updating/restarting");
- node.getNodeUpdater().arm();
- }else if
(request.getPartAsString(GenericReadFilterCallback.magicHTTPEscapeString,
MAX_URL_LENGTH).length()>0){
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- MultiValueTable headers = new MultiValueTable();
- String url = null;
- if((request.getPartAsString("Go", 32).length() > 0))
- url =
request.getPartAsString(GenericReadFilterCallback.magicHTTPEscapeString,
MAX_URL_LENGTH);
- headers.put("Location", url==null ? "/" : url);
- ctx.sendReplyHeaders(302, "Found", headers, null, 0);
- }else if (request.getPartAsString("update", 32).length() > 0) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("nodeUpdateConfirmTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("nodeUpdateConfirmTitle")));
- HTMLNode content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("p").addChild("#",
l10n("nodeUpdateConfirm"));
- HTMLNode updateForm = ctx.addFormChild(content, "/",
"updateConfirmForm");
- updateForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel")});
- updateForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "updateconfirm", l10n("update") });
- writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- }else if(request.isPartSet("getThreadDump")) {
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("threadDumpTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- if(node.isUsingWrapper()){
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("threadDumpSubTitle")));
-
ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("threadDumpWithFilename", "filename",
WrapperManager.getProperties().getProperty("wrapper.logfile")));
- System.out.println("Thread Dump:");
- WrapperManager.requestThreadDump();
- }else{
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error",l10n("threadDumpSubTitle")));
-
ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("threadDumpNotUsingWrapper"));
- }
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- }else if(request.isPartSet("getJEStatsDump")) {
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("databaseStatsTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("databaseStatsSubTitle")));
+ public void handlePost(URI uri, HTTPRequest request, ToadletContext ctx)
throws ToadletContextClosedException, IOException {
- System.out.println(">>>>>>>>>>>>>>>>>>>>>>> START
DATABASE STATS <<<<<<<<<<<<<<<<<<<<<<<");
- node.JEStatsDump();
- System.out.println(">>>>>>>>>>>>>>>>>>>>>>> END
DATABASE STATS <<<<<<<<<<<<<<<<<<<<<<<");
+ if (!ctx.isAllowedFullAccess()) {
+ super.sendErrorPage(ctx, 403, "Unauthorized",
L10n.getString("Toadlet.unauthorized"));
+ return;
+ }
-
ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("writtenDatabaseStats"));
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- }else if(request.isPartSet("disable")){
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- UserAlert[] alerts=core.alerts.getAlerts();
- for(int i=0;i<alerts.length;i++){
-
if(request.getIntPart("disable",-1)==alerts[i].hashCode()){
- UserAlert alert = alerts[i];
- // Won't be dismissed if it's not
allowed anyway
- if(alert.userCanDismiss() &&
alert.shouldUnregisterOnDismiss()) {
- alert.onDismiss();
-
Logger.normal(this,"Unregistering the userAlert "+alert.hashCode());
- core.alerts.unregister(alert);
- } else {
- Logger.normal(this,"Disabling
the userAlert "+alert.hashCode());
- alert.isValid(false);
- }
- }
- }
- writePermanentRedirect(ctx, l10n("disabledAlert"), "/");
- return;
- } else
if(request.isPartSet("boardname")&&(request.isPartSet("filename")||request.isPartSet("message")))
{
- // Inserting into a frost board FIN
+ String passwd = request.getPartAsString("formPassword", 32);
+ boolean noPassword = (passwd == null) ||
!passwd.equals(core.formPassword);
+ if (noPassword) {
+ if (Logger.shouldLog(Logger.MINOR, this)) {
+ Logger.minor(this, "No password (" + passwd + " should be " +
core.formPassword + ')');
+ }
+ }
+
+ if (request.getPartAsString("updateconfirm", 32).length() > 0) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ // false for no navigation bars, because that would be very silly
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("updatingTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("updatingTitle")));
+ HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("p").addChild("#", l10n("updating"));
+ content.addChild("p").addChild("#", l10n("thanks"));
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ Logger.normal(this, "Node is updating/restarting");
+ node.getNodeUpdater().arm();
+ } else if
(request.getPartAsString(GenericReadFilterCallback.magicHTTPEscapeString,
MAX_URL_LENGTH).length() > 0) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ MultiValueTable headers = new MultiValueTable();
+ String url = null;
+ if ((request.getPartAsString("Go", 32).length() > 0)) {
+ url =
request.getPartAsString(GenericReadFilterCallback.magicHTTPEscapeString,
MAX_URL_LENGTH);
+ }
+ headers.put("Location", url == null ? "/" : url);
+ ctx.sendReplyHeaders(302, "Found", headers, null, 0);
+ } else if (request.getPartAsString("update", 32).length() > 0) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("nodeUpdateConfirmTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("nodeUpdateConfirmTitle")));
+ HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("p").addChild("#", l10n("nodeUpdateConfirm"));
+ HTMLNode updateForm = ctx.addFormChild(content, "/",
"updateConfirmForm");
+ updateForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancel", L10n.getString("Toadlet.cancel")});
+ updateForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "updateconfirm", l10n("update")});
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ } else if (request.isPartSet("getThreadDump")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("threadDumpTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ if (node.isUsingWrapper()) {
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("threadDumpSubTitle")));
+ ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("threadDumpWithFilename", "filename",
WrapperManager.getProperties().getProperty("wrapper.logfile")));
+ System.out.println("Thread Dump:");
+ WrapperManager.requestThreadDump();
+ } else {
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error",
l10n("threadDumpSubTitle")));
+ ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("threadDumpNotUsingWrapper"));
+ }
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ } else if (request.isPartSet("getJEStatsDump")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("databaseStatsTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("databaseStatsSubTitle")));
+
+ System.out.println(">>>>>>>>>>>>>>>>>>>>>>> START DATABASE STATS
<<<<<<<<<<<<<<<<<<<<<<<");
+ node.JEStatsDump();
+ System.out.println(">>>>>>>>>>>>>>>>>>>>>>> END DATABASE STATS
<<<<<<<<<<<<<<<<<<<<<<<");
+
+ ctx.getPageMaker().getContentNode(infobox).addChild("#",
l10n("writtenDatabaseStats"));
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ } else if (request.isPartSet("disable")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ UserAlert[] alerts = core.alerts.getAlerts();
+ for (int i = 0; i < alerts.length; i++) {
+ if (request.getIntPart("disable", -1) == alerts[i].hashCode())
{
+ UserAlert alert = alerts[i];
+ // Won't be dismissed if it's not allowed anyway
+ if (alert.userCanDismiss() &&
alert.shouldUnregisterOnDismiss()) {
+ alert.onDismiss();
+ Logger.normal(this, "Unregistering the userAlert " +
alert.hashCode());
+ core.alerts.unregister(alert);
+ } else {
+ Logger.normal(this, "Disabling the userAlert " +
alert.hashCode());
+ alert.isValid(false);
+ }
+ }
+ }
+ writePermanentRedirect(ctx, l10n("disabledAlert"), "/");
+ return;
+ } else if (request.isPartSet("boardname") &&
(request.isPartSet("filename") || request.isPartSet("message"))) {
+ // Inserting into a frost board FIN
// boardname
// filename
// boardprivatekey (not needed)
@@ -209,400 +207,408 @@
// innitialindex
// sender
// subject
- String boardName =
request.getPartAsString("boardname",FrostBoard.MAX_NAME_LENGTH);
- String boardPrivateKey =
request.getPartAsString("boardprivatekey",78);
- String boardPublicKey =
request.getPartAsString("boardpublickey",78);
- String sender = request.getPartAsString("sender",64);
- String subject = request.getPartAsString("subject",128);
- String message =
request.getPartAsString("message",1024);
- if(message.length() == 0) // back compatibility; should
use message
- message = request.getPartAsString("filename",
1024);
-
- int initialIndex = 0;
- if(request.isPartSet("initialindex")) {
- try {
- initialIndex =
Integer.parseInt(request.getPartAsString("initialindex",10));
- } catch(NumberFormatException e) {
- initialIndex = 0;
- }
- } else if(request.isPartSet("innitialindex")) {
- try {
- initialIndex =
Integer.parseInt(request.getPartAsString("innitialindex",10));
- } catch(NumberFormatException e) {
- initialIndex = 0;
- }
- }
-
- if(noPassword) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("finTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("finTitle")));
- HTMLNode content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("p").addChild("#",
l10n("confirmFIN"));
- HTMLNode postForm =
ctx.addFormChild(content.addChild("p"), "/", "finConfirmForm");
- HTMLNode table = postForm.addChild("table",
"align", "center");
-
- finInputRow(table, "boardname",
l10n("targetBoardHeader"), boardName);
- finInputRow(table, "boardprivatekey",
l10n("privateKeyHeader"), boardPrivateKey);
- finInputRow(table, "boardpublickey",
l10n("publicKeyHeader"), boardPublicKey);
- finInputRow(table, "initialindex",
l10n("startIndexHeader"), Integer.toString(initialIndex));
- finInputRow(table, "sender",
l10n("fromHeader"), sender);
- finInputRow(table, "subject",
l10n("subjectHeader"), subject);
- finInputBoxRow(table, "message",
l10n("messageHeader"), message);
-
- postForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel") });
- postForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "finconfirm", l10n("post")
});
- writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- }
-
- if(!request.isPartSet("finconfirm")) {
- redirectToRoot(ctx);
- return;
- }
-
- FrostBoard board = null;
- if(boardPrivateKey.length()>0 &&
boardPublicKey.length()>0) { // keyed board
- board = new FrostBoard(boardName,
boardPrivateKey, boardPublicKey);
- } else { // unkeyed or public board
- board = new FrostBoard(boardName);
- }
- FrostMessage fin = new FrostMessage("news", board,
sender, subject, message);
-
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("finInsertedTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode content;
- try {
- FreenetURI finalKey =
fin.insertMessage(this.getClientImpl(), initialIndex);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-success",
l10n("insertSucceededTitle")));
- content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("#",
l10n("finInsertSuccessWithKey", "key", finalKey.toString()));
- } catch (InsertException e) {
- HTMLNode infobox =
ctx.getPageMaker().getInfobox("infobox-error", l10n("insertFailedTitle"));
- content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("#",
l10n("insertFailedWithMessage", "message", e.getMessage()));
- content.addChild("br");
- if (e.uri != null) {
- content.addChild("#",
l10n("uriWouldHaveBeen", "uri", e.uri.toString()));
- }
- int mode = e.getMode();
- if((mode ==
InsertException.FATAL_ERRORS_IN_BLOCKS) || (mode ==
InsertException.TOO_MANY_RETRIES_IN_BLOCKS)) {
- content.addChild("br"); /* TODO */
- content.addChild("#",
l10n("splitfileErrorLabel"));
- content.addChild("pre",
e.errorCodes.toVerboseString());
- }
- }
- content.addChild("br");
- addHomepageLink(content);
-
- writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- request.freeParts();
- }else
if(request.isPartSet("key")&&request.isPartSet("filename")){
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
+ String boardName = request.getPartAsString("boardname",
FrostBoard.MAX_NAME_LENGTH);
+ String boardPrivateKey =
request.getPartAsString("boardprivatekey", 78);
+ String boardPublicKey = request.getPartAsString("boardpublickey",
78);
+ String sender = request.getPartAsString("sender", 64);
+ String subject = request.getPartAsString("subject", 128);
+ String message = request.getPartAsString("message", 1024);
+ if (message.length() == 0) // back compatibility; should use
message
+ {
+ message = request.getPartAsString("filename", 1024);
+ }
- FreenetURI key = new
FreenetURI(request.getPartAsString("key",128));
- String type =
request.getPartAsString("content-type",128);
- if(type==null) type = "text/plain";
- ClientMetadata contentType = new ClientMetadata(type);
-
- Bucket bucket = request.getPart("filename");
-
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("insertedTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode content;
- String filenameHint = null;
- if(key.getKeyType().equals("CHK")) {
- String[] metas = key.getAllMetaStrings();
- if(metas != null && metas.length > 1) {
- filenameHint = metas[0];
- }
- }
- InsertBlock block = new InsertBlock(bucket,
contentType, key);
- try {
- key = this.insert(block, filenameHint, false);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-success",
l10n("insertSucceededTitle")));
- content =
ctx.getPageMaker().getContentNode(infobox);
- String u = key.toString();
- L10n.addL10nSubstitution(content,
"WelcomeToadlet.keyInsertedSuccessfullyWithKeyAndName",
- new String[] { "link", "/link",
"name" },
- new String[] { "<a
href=\"/"+u+"\">", "</a>", u });
- } catch (InsertException e) {
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error",
l10n("insertFailedTitle")));
- content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("#",
l10n("insertFailedWithMessage", "message", e.getMessage()));
- content.addChild("br");
- if (e.uri != null) {
- content.addChild("#",
l10n("uriWouldHaveBeen", "uri", e.uri.toString()));
- }
- int mode = e.getMode();
- if((mode ==
InsertException.FATAL_ERRORS_IN_BLOCKS) || (mode ==
InsertException.TOO_MANY_RETRIES_IN_BLOCKS)) {
- content.addChild("br"); /* TODO */
- content.addChild("#",
l10n("splitfileErrorLabel"));
- content.addChild("pre",
e.errorCodes.toVerboseString());
- }
- }
-
- content.addChild("br");
- addHomepageLink(content);
-
- writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- request.freeParts();
- bucket.free();
- }else if (request.isPartSet("shutdownconfirm")) {
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
- MultiValueTable headers = new MultiValueTable();
- headers.put("Location", "/?terminated&formPassword=" +
core.formPassword);
- ctx.sendReplyHeaders(302, "Found", headers, null, 0);
- node.ps.queueTimedJob(new Runnable(){
- public void run() {
- node.exit("Shutdown from fproxy");
- }
- }, 1);
- return;
- }else if(request.isPartSet("restartconfirm")){
- if(noPassword) {
- redirectToRoot(ctx);
- return;
- }
+ int initialIndex = 0;
+ if (request.isPartSet("initialindex")) {
+ try {
+ initialIndex =
Integer.parseInt(request.getPartAsString("initialindex", 10));
+ } catch (NumberFormatException e) {
+ initialIndex = 0;
+ }
+ } else if (request.isPartSet("innitialindex")) {
+ try {
+ initialIndex =
Integer.parseInt(request.getPartAsString("innitialindex", 10));
+ } catch (NumberFormatException e) {
+ initialIndex = 0;
+ }
+ }
- MultiValueTable headers = new MultiValueTable();
- headers.put("Location", "/?restarted&formPassword=" +
core.formPassword);
- ctx.sendReplyHeaders(302, "Found", headers, null, 0);
- node.ps.queueTimedJob(new Runnable(){
- public void run() {
- node.getNodeStarter().restart();
- }
- }, 1);
- return;
- }else {
- redirectToRoot(ctx);
- }
- }
-
- private void finInputBoxRow(HTMLNode table, String name, String label,
String message) {
- HTMLNode row = table.addChild("tr");
- HTMLNode cell = row.addChild("td");
- // FIXME this should be in the CSS, not the generated code
- HTMLNode right = cell.addChild("div", "align", "right");
- HTMLNode bold = right.addChild("b");
- HTMLNode font = bold.addChild("font", "size", "-1");
- font.addChild("#", label);
- cell = row.addChild("td");
- cell.addChild("textarea", new String[] { "name", "rows", "cols"
},
- new String[] { name, "12", "80"
}).addChild("#", message);
- }
+ if (noPassword) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("finTitle"), ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("finTitle")));
+ HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("p").addChild("#", l10n("confirmFIN"));
+ HTMLNode postForm = ctx.addFormChild(content.addChild("p"),
"/", "finConfirmForm");
+ HTMLNode table = postForm.addChild("table", "align", "center");
- private void finInputRow(HTMLNode table, String name, String label,
String message) {
- HTMLNode row = table.addChild("tr");
- HTMLNode cell = row.addChild("td");
- // FIXME this should be in the CSS, not the generated code
- HTMLNode right = cell.addChild("div", "align", "right");
- HTMLNode bold = right.addChild("b");
- HTMLNode font = bold.addChild("font", "size", "-1");
- font.addChild("#", label);
- cell = row.addChild("td");
- cell.addChild("input", new String[] { "type", "name", "size",
"value" },
- new String[] { "text", name, "30", message });
- }
+ finInputRow(table, "boardname", l10n("targetBoardHeader"),
boardName);
+ finInputRow(table, "boardprivatekey",
l10n("privateKeyHeader"), boardPrivateKey);
+ finInputRow(table, "boardpublickey", l10n("publicKeyHeader"),
boardPublicKey);
+ finInputRow(table, "initialindex", l10n("startIndexHeader"),
Integer.toString(initialIndex));
+ finInputRow(table, "sender", l10n("fromHeader"), sender);
+ finInputRow(table, "subject", l10n("subjectHeader"), subject);
+ finInputBoxRow(table, "message", l10n("messageHeader"),
message);
- public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx)
throws ToadletContextClosedException, IOException {
- boolean advancedModeOutputEnabled =
core.getToadletContainer().isAdvancedModeEnabled();
-
- if(ctx.isAllowedFullAccess()) {
+ postForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancel", L10n.getString("Toadlet.cancel")});
+ postForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "finconfirm", l10n("post")});
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ }
- if(request.isParameterSet("latestlog")) {
- final File logs = new
File(node.config.get("logger").getString("dirname") + File.separator +
"freenet-latest.log");
-
- this.writeHTMLReply(ctx, 200, "OK",
FileUtil.readUTF(logs));
- return;
- } else if (request.isParameterSet("terminated")) {
- if((!request.isParameterSet("formPassword")) ||
!request.getParam("formPassword").equals(core.formPassword)) {
- redirectToRoot(ctx);
- return;
- }
- // Tell the user that the node is shutting down
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode("Node Shutdown", false, ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("shutdownDone")));
- HTMLNode infoboxContent =
ctx.getPageMaker().getContentNode(infobox);
- infoboxContent.addChild("#", l10n("thanks"));
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- } else if (request.isParameterSet("restarted")) {
- if((!request.isParameterSet("formPassword")) ||
!request.getParam("formPassword").equals(core.formPassword)) {
- redirectToRoot(ctx);
- return;
- }
- // Tell the user that the node is restarting
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode("Node Restart", false, ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("restartingTitle")));
- HTMLNode infoboxContent =
ctx.getPageMaker().getContentNode(infobox);
- infoboxContent.addChild("#",
l10n("restarting"));
- writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- Logger.normal(this, "Node is restarting");
- return;
- } else if (request.getParam("newbookmark").length() >
0) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("confirmAddBookmarkTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("confirmAddBookmarkSubTitle")));
- HTMLNode addForm =
ctx.addFormChild(ctx.getPageMaker().getContentNode(infobox),
"/bookmarkEditor/", "editBookmarkForm");
- addForm.addChild("#",
l10n("confirmAddBookmarkWithKey", "key", request.getParam("newbookmark")));
- addForm.addChild("br");
- String key = request.getParam("newbookmark");
- if(key.startsWith("freenet:"))
- key = key.substring(8);
- addForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "hidden", "key", key});
- addForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "text", "name",
request.getParam("desc") });
- addForm.addChild("input", new String[] {"type",
"name", "value"}, new String[] {"hidden", "bookmark", "/"});
- addForm.addChild("input", new String[] {"type",
"name", "value"}, new String[] {"hidden", "action", "addItem"});
- addForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "addbookmark",
L10n.getString("BookmarkEditorToadlet.addBookmark") });
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- } else if
(request.getParam(GenericReadFilterCallback.magicHTTPEscapeString).length() >
0) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode( l10n("confirmExternalLinkTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode warnbox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-warning",
l10n("confirmExternalLinkSubTitle")));
- HTMLNode externalLinkForm =
ctx.addFormChild(ctx.getPageMaker().getContentNode(warnbox), "/",
"confirmExternalLinkForm");
+ if (!request.isPartSet("finconfirm")) {
+ redirectToRoot(ctx);
+ return;
+ }
- final String target =
request.getParam(GenericReadFilterCallback.magicHTTPEscapeString);
- externalLinkForm.addChild("#",
l10n("confirmExternalLinkWithURL", "url", target));
- externalLinkForm.addChild("br");
- externalLinkForm.addChild("input", new String[]
{ "type", "name", "value" }, new String[] { "hidden",
GenericReadFilterCallback.magicHTTPEscapeString, target });
- externalLinkForm.addChild("input", new String[]
{ "type", "name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel") });
- externalLinkForm.addChild("input", new String[]
{ "type", "name", "value" }, new String[] { "submit", "Go",
l10n("goToExternalLink") });
- this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- } else if (request.isParameterSet("exit")) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("shutdownConfirmTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("shutdownConfirmTitle")));
- HTMLNode content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("p").addChild("#",
l10n("shutdownConfirm"));
- HTMLNode shutdownForm =
ctx.addFormChild(content.addChild("p"), "/", "confirmShutdownForm");
- shutdownForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel") });
- shutdownForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "shutdownconfirm",
l10n("shutdown") });
- writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- }else if (request.isParameterSet("restart")) {
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("restartConfirmTitle"), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
- HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("restartConfirmTitle")));
- HTMLNode content =
ctx.getPageMaker().getContentNode(infobox);
- content.addChild("p").addChild("#",
l10n("restartConfirm"));
- HTMLNode restartForm =
ctx.addFormChild(content.addChild("p"), "/", "confirmRestartForm");
- restartForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "cancel",
L10n.getString("Toadlet.cancel") });
- restartForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "restartconfirm",
l10n("restart") });
- writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
- return;
- }
- }
+ FrostBoard board = null;
+ if (boardPrivateKey.length() > 0 && boardPublicKey.length() > 0) {
// keyed board
+ board = new FrostBoard(boardName, boardPrivateKey,
boardPublicKey);
+ } else { // unkeyed or public board
+ board = new FrostBoard(boardName);
+ }
+ FrostMessage fin = new FrostMessage("news", board, sender,
subject, message);
- HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("homepageFullTitleWithName", "name",
node.getMyName()), ctx);
- HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("finInsertedTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode content;
+ try {
+ FreenetURI finalKey = fin.insertMessage(this.getClientImpl(),
initialIndex);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-success",
l10n("insertSucceededTitle")));
+ content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("#", l10n("finInsertSuccessWithKey", "key",
finalKey.toString()));
+ } catch (InsertException e) {
+ HTMLNode infobox =
ctx.getPageMaker().getInfobox("infobox-error", l10n("insertFailedTitle"));
+ content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("#", l10n("insertFailedWithMessage",
"message", e.getMessage()));
+ content.addChild("br");
+ if (e.uri != null) {
+ content.addChild("#", l10n("uriWouldHaveBeen", "uri",
e.uri.toString()));
+ }
+ int mode = e.getMode();
+ if ((mode == InsertException.FATAL_ERRORS_IN_BLOCKS) || (mode
== InsertException.TOO_MANY_RETRIES_IN_BLOCKS)) {
+ content.addChild("br"); /* TODO */
+ content.addChild("#", l10n("splitfileErrorLabel"));
+ content.addChild("pre", e.errorCodes.toVerboseString());
+ }
+ }
+ content.addChild("br");
+ addHomepageLink(content);
- if(node.isTestnetEnabled()) {
- HTMLNode testnetBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-alert",
l10n("testnetWarningTitle")));
- HTMLNode testnetContent =
ctx.getPageMaker().getContentNode(testnetBox);
- testnetContent.addChild("#", l10n("testnetWarning"));
- }
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ request.freeParts();
+ } else if (request.isPartSet("key") && request.isPartSet("filename")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
- String useragent = (String)ctx.getHeaders().get("user-agent");
+ FreenetURI key = new FreenetURI(request.getPartAsString("key",
128));
+ String type = request.getPartAsString("content-type", 128);
+ if (type == null) {
+ type = "text/plain";
+ }
+ ClientMetadata contentType = new ClientMetadata(type);
- if (useragent != null) {
- useragent = useragent.toLowerCase();
- if ((useragent.indexOf("msie") > -1) &&
(useragent.indexOf("opera") == -1)) {
- HTMLNode browserWarningBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-alert",
l10n("ieWarningTitle")));
- HTMLNode browserWarningContent =
ctx.getPageMaker().getContentNode(browserWarningBox);
- browserWarningContent.addChild("#",
l10n("ieWarning"));
- }
- }
+ Bucket bucket = request.getPart("filename");
- // Alerts
- if(ctx.isAllowedFullAccess())
- contentNode.addChild(core.alerts.createAlerts());
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("insertedTitle"), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode content;
+ String filenameHint = null;
+ if (key.getKeyType().equals("CHK")) {
+ String[] metas = key.getAllMetaStrings();
+ if (metas != null && metas.length > 1) {
+ filenameHint = metas[0];
+ }
+ }
+ InsertBlock block = new InsertBlock(bucket, contentType, key);
+ try {
+ key = this.insert(block, filenameHint, false);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-success",
l10n("insertSucceededTitle")));
+ content = ctx.getPageMaker().getContentNode(infobox);
+ String u = key.toString();
+ L10n.addL10nSubstitution(content,
"WelcomeToadlet.keyInsertedSuccessfullyWithKeyAndName",
+ new String[]{"link", "/link", "name"},
+ new String[]{"<a href=\"/" + u + "\">", "</a>", u});
+ } catch (InsertException e) {
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-error",
l10n("insertFailedTitle")));
+ content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("#", l10n("insertFailedWithMessage",
"message", e.getMessage()));
+ content.addChild("br");
+ if (e.uri != null) {
+ content.addChild("#", l10n("uriWouldHaveBeen", "uri",
e.uri.toString()));
+ }
+ int mode = e.getMode();
+ if ((mode == InsertException.FATAL_ERRORS_IN_BLOCKS) || (mode
== InsertException.TOO_MANY_RETRIES_IN_BLOCKS)) {
+ content.addChild("br"); /* TODO */
+ content.addChild("#", l10n("splitfileErrorLabel"));
+ content.addChild("pre", e.errorCodes.toVerboseString());
+ }
+ }
- // Bookmarks
- HTMLNode bookmarkBox = contentNode.addChild("div", "class",
"infobox infobox-normal");
- HTMLNode bookmarkBoxHeader = bookmarkBox.addChild("div",
"class", "infobox-header");
- bookmarkBoxHeader.addChild("#",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle"));
- if(ctx.isAllowedFullAccess()){
- bookmarkBoxHeader.addChild("#", " [");
- bookmarkBoxHeader.addChild("span", "id",
"bookmarkedit").addChild("a", new String[] { "href", "class" }, new String[] {
"/bookmarkEditor/", "interfacelink" },
L10n.getString("BookmarkEditorToadlet.edit"));
- bookmarkBoxHeader.addChild("#", "]");
- }
+ content.addChild("br");
+ addHomepageLink(content);
- HTMLNode bookmarkBoxContent = bookmarkBox.addChild("div",
"class", "infobox-content");
- HTMLNode bookmarksList = bookmarkBoxContent.addChild("ul",
"id", "bookmarks");
- addCategoryToList(BookmarkManager.PROTECTED_CATEGORY,
bookmarksList);
- addCategoryToList(BookmarkManager.MAIN_CATEGORY,
bookmarksList);
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ request.freeParts();
+ bucket.free();
+ } else if (request.isPartSet("shutdownconfirm")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
+ MultiValueTable headers = new MultiValueTable();
+ headers.put("Location", "/?terminated&formPassword=" +
core.formPassword);
+ ctx.sendReplyHeaders(302, "Found", headers, null, 0);
+ node.ps.queueTimedJob(new Runnable() {
- // Fetch-a-key box
- HTMLNode fetchKeyBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-normal",
l10n("fetchKeyLabel")));
- HTMLNode fetchKeyContent =
ctx.getPageMaker().getContentNode(fetchKeyBox);
- fetchKeyContent.addAttribute("id", "keyfetchbox");
- HTMLNode fetchKeyForm = fetchKeyContent.addChild("form", new
String[] { "action", "method" }, new String[] { "/", "get" }).addChild("div");
- fetchKeyForm.addChild("#", l10n("keyRequestLabel")+' ');
- fetchKeyForm.addChild("input", new String[] { "type", "size",
"name" }, new String[] { "text", "80", "key" });
- fetchKeyForm.addChild("input", new String[] { "type", "value"
}, new String[] { "submit", l10n("fetch") });
+ public void run() {
+ node.exit("Shutdown from fproxy");
+ }
+ }, 1);
+ return;
+ } else if (request.isPartSet("restartconfirm")) {
+ if (noPassword) {
+ redirectToRoot(ctx);
+ return;
+ }
- // Version info and Quit Form
- HTMLNode versionBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("versionHeader")));
- HTMLNode versionContent =
ctx.getPageMaker().getContentNode(versionBox);
- versionContent.addChild("#",
- L10n.getString("WelcomeToadlet.version", new
String[] { "fullVersion", "build", "rev" },
- new String[] {
Version.nodeVersion, Integer.toString(Version.buildNumber()),
Version.cvsRevision }));
- versionContent.addChild("br");
- if(NodeStarter.extBuildNumber <
NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER) {
- versionContent.addChild("#",
-
L10n.getString("WelcomeToadlet.extVersionWithRecommended", new String[] {
"build", "recbuild", "rev" },
- new String[] {
Integer.toString(NodeStarter.extBuildNumber),
Integer.toString(NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER),
NodeStarter.extRevisionNumber }));
- } else {
- versionContent.addChild("#",
-
L10n.getString("WelcomeToadlet.extVersion", new String[] { "build", "rev" },
- new String[] {
Integer.toString(NodeStarter.extBuildNumber), NodeStarter.extRevisionNumber }));
- }
- versionContent.addChild("br");
- if(ctx.isAllowedFullAccess()){
- HTMLNode shutdownForm = versionContent.addChild("form",
new String[] { "action", "method" }, new String[] { ".", "get"
}).addChild("div");
- shutdownForm.addChild("input", new String[] { "type",
"name" }, new String[] { "hidden", "exit" });
- shutdownForm.addChild("input", new String[] { "type",
"value" }, new String[] { "submit", l10n("shutdownNode") });
- if(node.isUsingWrapper()){
- HTMLNode restartForm =
versionContent.addChild("form", new String[] { "action", "method" }, new
String[] { ".", "get" }).addChild("div");
- restartForm.addChild("input", new String[] {
"type", "name" }, new String[] { "hidden", "restart" });
- restartForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "restart2",
l10n("restartNode") });
- }
- }
+ MultiValueTable headers = new MultiValueTable();
+ headers.put("Location", "/?restarted&formPassword=" +
core.formPassword);
+ ctx.sendReplyHeaders(302, "Found", headers, null, 0);
+ node.ps.queueTimedJob(new Runnable() {
- // Activity
- HTMLNode activityBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("activityTitle")));
- HTMLNode activityContent =
ctx.getPageMaker().getContentNode(activityBox);
- HTMLNode activityList = activityContent.addChild("ul", "id",
"activity");
- activityList.addChild("li", l10n("insertCount", "total",
Integer.toString(node.getNumInsertSenders())));
- activityList.addChild("li", l10n("requestCount", "total",
Integer.toString(node.getNumRequestSenders())));
- activityList.addChild("li", l10n("transferringRequestCount",
"total", Integer.toString(node.getNumTransferringRequestSenders())));
- if (advancedModeOutputEnabled) {
- activityList.addChild("li", l10n("arkFetchCount",
"total", Integer.toString(node.getNumARKFetchers())));
- }
+ public void run() {
+ node.getNodeStarter().restart();
+ }
+ }, 1);
+ return;
+ } else {
+ redirectToRoot(ctx);
+ }
+ }
- this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
- }
-
- public String supportedMethods() {
- return "GET, POST";
- }
-
- private String l10n(String key) {
- return L10n.getString("WelcomeToadlet."+key);
- }
-
- private String l10n(String key, String pattern, String value) {
- return L10n.getString("WelcomeToadlet."+key, new String[] {
pattern }, new String[] { value });
- }
+ private void finInputBoxRow(HTMLNode table, String name, String label,
String message) {
+ HTMLNode row = table.addChild("tr");
+ HTMLNode cell = row.addChild("td");
+ // FIXME this should be in the CSS, not the generated code
+ HTMLNode right = cell.addChild("div", "align", "right");
+ HTMLNode bold = right.addChild("b");
+ HTMLNode font = bold.addChild("font", "size", "-1");
+ font.addChild("#", label);
+ cell = row.addChild("td");
+ cell.addChild("textarea", new String[]{"name", "rows", "cols"},
+ new String[]{name, "12", "80"}).addChild("#", message);
+ }
+
+ private void finInputRow(HTMLNode table, String name, String label, String
message) {
+ HTMLNode row = table.addChild("tr");
+ HTMLNode cell = row.addChild("td");
+ // FIXME this should be in the CSS, not the generated code
+ HTMLNode right = cell.addChild("div", "align", "right");
+ HTMLNode bold = right.addChild("b");
+ HTMLNode font = bold.addChild("font", "size", "-1");
+ font.addChild("#", label);
+ cell = row.addChild("td");
+ cell.addChild("input", new String[]{"type", "name", "size", "value"},
+ new String[]{"text", name, "30", message});
+ }
+
+ public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx)
throws ToadletContextClosedException, IOException {
+ boolean advancedModeOutputEnabled =
core.getToadletContainer().isAdvancedModeEnabled();
+
+ if (ctx.isAllowedFullAccess()) {
+
+ if (request.isParameterSet("latestlog")) {
+ final File logs = new
File(node.config.get("logger").getString("dirname") + File.separator +
"freenet-latest.log");
+
+ this.writeHTMLReply(ctx, 200, "OK", FileUtil.readUTF(logs));
+ return;
+ } else if (request.isParameterSet("terminated")) {
+ if ((!request.isParameterSet("formPassword")) ||
!request.getParam("formPassword").equals(core.formPassword)) {
+ redirectToRoot(ctx);
+ return;
+ }
+ // Tell the user that the node is shutting down
+ HTMLNode pageNode = ctx.getPageMaker().getPageNode("Node
Shutdown", false, ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("shutdownDone")));
+ HTMLNode infoboxContent =
ctx.getPageMaker().getContentNode(infobox);
+ infoboxContent.addChild("#", l10n("thanks"));
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ } else if (request.isParameterSet("restarted")) {
+ if ((!request.isParameterSet("formPassword")) ||
!request.getParam("formPassword").equals(core.formPassword)) {
+ redirectToRoot(ctx);
+ return;
+ }
+ // Tell the user that the node is restarting
+ HTMLNode pageNode = ctx.getPageMaker().getPageNode("Node
Restart", false, ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("restartingTitle")));
+ HTMLNode infoboxContent =
ctx.getPageMaker().getContentNode(infobox);
+ infoboxContent.addChild("#", l10n("restarting"));
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ Logger.normal(this, "Node is restarting");
+ return;
+ } else if (request.getParam("newbookmark").length() > 0) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("confirmAddBookmarkTitle"), ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox(l10n("confirmAddBookmarkSubTitle")));
+ HTMLNode addForm =
ctx.addFormChild(ctx.getPageMaker().getContentNode(infobox),
"/bookmarkEditor/", "editBookmarkForm");
+ addForm.addChild("#", l10n("confirmAddBookmarkWithKey", "key",
request.getParam("newbookmark")));
+ addForm.addChild("br");
+ String key = request.getParam("newbookmark");
+ if (key.startsWith("freenet:")) {
+ key = key.substring(8);
+ }
+ addForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "key", key});
+ addForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"text", "name", request.getParam("desc")});
+ addForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "bookmark", "/"});
+ addForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"hidden", "action", "addItem"});
+ addForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "addbookmark",
L10n.getString("BookmarkEditorToadlet.addBookmark")});
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ } else if
(request.getParam(GenericReadFilterCallback.magicHTTPEscapeString).length() >
0) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("confirmExternalLinkTitle"), ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode warnbox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-warning",
l10n("confirmExternalLinkSubTitle")));
+ HTMLNode externalLinkForm =
ctx.addFormChild(ctx.getPageMaker().getContentNode(warnbox), "/",
"confirmExternalLinkForm");
+
+ final String target =
request.getParam(GenericReadFilterCallback.magicHTTPEscapeString);
+ externalLinkForm.addChild("#",
l10n("confirmExternalLinkWithURL", "url", target));
+ externalLinkForm.addChild("br");
+ externalLinkForm.addChild("input", new String[]{"type",
"name", "value"}, new String[]{"hidden",
GenericReadFilterCallback.magicHTTPEscapeString, target});
+ externalLinkForm.addChild("input", new String[]{"type",
"name", "value"}, new String[]{"submit", "cancel",
L10n.getString("Toadlet.cancel")});
+ externalLinkForm.addChild("input", new String[]{"type",
"name", "value"}, new String[]{"submit", "Go", l10n("goToExternalLink")});
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ } else if (request.isParameterSet("exit")) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("shutdownConfirmTitle"), ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("shutdownConfirmTitle")));
+ HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("p").addChild("#", l10n("shutdownConfirm"));
+ HTMLNode shutdownForm =
ctx.addFormChild(content.addChild("p"), "/", "confirmShutdownForm");
+ shutdownForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancel", L10n.getString("Toadlet.cancel")});
+ shutdownForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "shutdownconfirm", l10n("shutdown")});
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ } else if (request.isParameterSet("restart")) {
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("restartConfirmTitle"), ctx);
+ HTMLNode contentNode =
ctx.getPageMaker().getContentNode(pageNode);
+ HTMLNode infobox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-query",
l10n("restartConfirmTitle")));
+ HTMLNode content = ctx.getPageMaker().getContentNode(infobox);
+ content.addChild("p").addChild("#", l10n("restartConfirm"));
+ HTMLNode restartForm = ctx.addFormChild(content.addChild("p"),
"/", "confirmRestartForm");
+ restartForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "cancel", L10n.getString("Toadlet.cancel")});
+ restartForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "restartconfirm", l10n("restart")});
+ writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ return;
+ }
+ }
+
+ HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("homepageFullTitleWithName", "name",
node.getMyName()), ctx);
+ HTMLNode contentNode = ctx.getPageMaker().getContentNode(pageNode);
+
+ if (node.isTestnetEnabled()) {
+ HTMLNode testnetBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-alert",
l10n("testnetWarningTitle")));
+ HTMLNode testnetContent =
ctx.getPageMaker().getContentNode(testnetBox);
+ testnetContent.addChild("#", l10n("testnetWarning"));
+ }
+
+ String useragent = (String) ctx.getHeaders().get("user-agent");
+
+ if (useragent != null) {
+ useragent = useragent.toLowerCase();
+ if ((useragent.indexOf("msie") > -1) &&
(useragent.indexOf("opera") == -1)) {
+ HTMLNode browserWarningBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-alert",
l10n("ieWarningTitle")));
+ HTMLNode browserWarningContent =
ctx.getPageMaker().getContentNode(browserWarningBox);
+ browserWarningContent.addChild("#", l10n("ieWarning"));
+ }
+ }
+
+ // Alerts
+ if (ctx.isAllowedFullAccess()) {
+ contentNode.addChild(core.alerts.createAlerts());
+ }
+
+ // Bookmarks
+ HTMLNode bookmarkBox = contentNode.addChild("div", "class", "infobox
infobox-normal");
+ HTMLNode bookmarkBoxHeader = bookmarkBox.addChild("div", "class",
"infobox-header");
+ bookmarkBoxHeader.addChild("#",
L10n.getString("BookmarkEditorToadlet.myBookmarksTitle"));
+ if (ctx.isAllowedFullAccess()) {
+ bookmarkBoxHeader.addChild("#", " [");
+ bookmarkBoxHeader.addChild("span", "id",
"bookmarkedit").addChild("a", new String[]{"href", "class"}, new
String[]{"/bookmarkEditor/", "interfacelink"},
L10n.getString("BookmarkEditorToadlet.edit"));
+ bookmarkBoxHeader.addChild("#", "]");
+ }
+
+ HTMLNode bookmarkBoxContent = bookmarkBox.addChild("div", "class",
"infobox-content");
+ HTMLNode bookmarksList = bookmarkBoxContent.addChild("ul", "id",
"bookmarks");
+ addCategoryToList(BookmarkManager.PROTECTED_CATEGORY, bookmarksList);
+ addCategoryToList(BookmarkManager.MAIN_CATEGORY, bookmarksList);
+
+ // Fetch-a-key box
+ HTMLNode fetchKeyBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-normal",
l10n("fetchKeyLabel")));
+ HTMLNode fetchKeyContent =
ctx.getPageMaker().getContentNode(fetchKeyBox);
+ fetchKeyContent.addAttribute("id", "keyfetchbox");
+ HTMLNode fetchKeyForm = fetchKeyContent.addChild("form", new
String[]{"action", "method"}, new String[]{"/", "get"}).addChild("div");
+ fetchKeyForm.addChild("#", l10n("keyRequestLabel") + ' ');
+ fetchKeyForm.addChild("input", new String[]{"type", "size", "name"},
new String[]{"text", "80", "key"});
+ fetchKeyForm.addChild("input", new String[]{"type", "value"}, new
String[]{"submit", l10n("fetch")});
+
+ // Version info and Quit Form
+ HTMLNode versionBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("versionHeader")));
+ HTMLNode versionContent =
ctx.getPageMaker().getContentNode(versionBox);
+ versionContent.addChild("#",
+ L10n.getString("WelcomeToadlet.version", new
String[]{"fullVersion", "build", "rev"},
+ new String[]{Version.nodeVersion,
Integer.toString(Version.buildNumber()), Version.cvsRevision}));
+ versionContent.addChild("br");
+ if (NodeStarter.extBuildNumber <
NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER) {
+ versionContent.addChild("#",
+ L10n.getString("WelcomeToadlet.extVersionWithRecommended",
new String[]{"build", "recbuild", "rev"},
+ new String[]{Integer.toString(NodeStarter.extBuildNumber),
Integer.toString(NodeStarter.RECOMMENDED_EXT_BUILD_NUMBER),
NodeStarter.extRevisionNumber}));
+ } else {
+ versionContent.addChild("#",
+ L10n.getString("WelcomeToadlet.extVersion", new
String[]{"build", "rev"},
+ new String[]{Integer.toString(NodeStarter.extBuildNumber),
NodeStarter.extRevisionNumber}));
+ }
+ versionContent.addChild("br");
+ if (ctx.isAllowedFullAccess()) {
+ HTMLNode shutdownForm = versionContent.addChild("form", new
String[]{"action", "method"}, new String[]{".", "get"}).addChild("div");
+ shutdownForm.addChild("input", new String[]{"type", "name"}, new
String[]{"hidden", "exit"});
+ shutdownForm.addChild("input", new String[]{"type", "value"}, new
String[]{"submit", l10n("shutdownNode")});
+ if (node.isUsingWrapper()) {
+ HTMLNode restartForm = versionContent.addChild("form", new
String[]{"action", "method"}, new String[]{".", "get"}).addChild("div");
+ restartForm.addChild("input", new String[]{"type", "name"},
new String[]{"hidden", "restart"});
+ restartForm.addChild("input", new String[]{"type", "name",
"value"}, new String[]{"submit", "restart2", l10n("restartNode")});
+ }
+ }
+
+ // Activity
+ HTMLNode activityBox =
contentNode.addChild(ctx.getPageMaker().getInfobox("infobox-information",
l10n("activityTitle")));
+ HTMLNode activityContent =
ctx.getPageMaker().getContentNode(activityBox);
+ HTMLNode activityList = activityContent.addChild("ul", "id",
"activity");
+ activityList.addChild("li", l10n("insertCount", "total",
Integer.toString(node.getNumInsertSenders())));
+ activityList.addChild("li", l10n("requestCount", "total",
Integer.toString(node.getNumRequestSenders())));
+ activityList.addChild("li", l10n("transferringRequestCount", "total",
Integer.toString(node.getNumTransferringRequestSenders())));
+ if (advancedModeOutputEnabled) {
+ activityList.addChild("li", l10n("arkFetchCount", "total",
Integer.toString(node.getNumARKFetchers())));
+ }
+
+ this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
+ }
+
+ public String supportedMethods() {
+ return "GET, POST";
+ }
+
+ private String l10n(String key) {
+ return L10n.getString("WelcomeToadlet." + key);
+ }
+
+ private String l10n(String key, String pattern, String value) {
+ return L10n.getString("WelcomeToadlet." + key, new String[]{pattern},
new String[]{value});
+ }
}
Modified: trunk/freenet/src/freenet/clients/http/bookmark/Bookmark.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/Bookmark.java
2007-11-20 19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/bookmark/Bookmark.java
2007-11-20 19:25:07 UTC (rev 15884)
@@ -1,22 +1,29 @@
package freenet.clients.http.bookmark;
public abstract class Bookmark {
- protected String name;
- public String getName() {
- return name;
- }
+ protected String name;
- protected void setName(String s) {
- name = s;
- }
-
- public boolean equals(Object o) {
- if(o == this) return true;
- if(o instanceof Bookmark) {
- Bookmark b = (Bookmark) o;
- if(!b.name.equals(name)) return false;
- return true;
- } else return false;
- }
+ public String getName() {
+ return name;
+ }
+
+ protected void setName(String s) {
+ name = s;
+ }
+
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof Bookmark) {
+ Bookmark b = (Bookmark) o;
+ if (!b.name.equals(name)) {
+ return false;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
}
Modified: trunk/freenet/src/freenet/clients/http/bookmark/BookmarkCategory.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/BookmarkCategory.java
2007-11-20 19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/bookmark/BookmarkCategory.java
2007-11-20 19:25:07 UTC (rev 15884)
@@ -7,132 +7,146 @@
public class BookmarkCategory extends Bookmark {
- private final Vector bookmarks = new Vector();
+ private final Vector bookmarks = new Vector();
- public BookmarkCategory(String name) {
- setName(name);
- }
+ public BookmarkCategory(String name) {
+ setName(name);
+ }
- protected synchronized Bookmark addBookmark(Bookmark b) {
- if(b == null) return null;
- int x = bookmarks.indexOf(b);
- if(x >= 0) return (Bookmark) bookmarks.get(x);
- bookmarks.add(b);
- return b;
- }
+ protected synchronized Bookmark addBookmark(Bookmark b) {
+ if (b == null) {
+ return null;
+ }
+ int x = bookmarks.indexOf(b);
+ if (x >= 0) {
+ return (Bookmark) bookmarks.get(x);
+ }
+ bookmarks.add(b);
+ return b;
+ }
- protected synchronized void removeBookmark(Bookmark b) {
- bookmarks.remove(b);
- }
+ protected synchronized void removeBookmark(Bookmark b) {
+ bookmarks.remove(b);
+ }
- public Bookmark get(int i) {
- return (Bookmark) bookmarks.get(i);
- }
+ public Bookmark get(int i) {
+ return (Bookmark) bookmarks.get(i);
+ }
- protected void moveBookmarkUp(Bookmark b) {
- int index = bookmarks.indexOf(b);
- if (index == -1)
- return;
+ protected void moveBookmarkUp(Bookmark b) {
+ int index = bookmarks.indexOf(b);
+ if (index == -1) {
+ return;
+ }
- Bookmark bk = get(index);
- bookmarks.remove(index);
- bookmarks.add((--index < 0) ? 0 : index, bk);
- }
+ Bookmark bk = get(index);
+ bookmarks.remove(index);
+ bookmarks.add((--index < 0) ? 0 : index, bk);
+ }
- protected void moveBookmarkDown(Bookmark b) {
- int index = bookmarks.indexOf(b);
- if (index == -1)
- return;
+ protected void moveBookmarkDown(Bookmark b) {
+ int index = bookmarks.indexOf(b);
+ if (index == -1) {
+ return;
+ }
- Bookmark bk = get(index);
- bookmarks.remove(index);
- bookmarks.add((++index > size()) ? size() : index, bk);
- }
+ Bookmark bk = get(index);
+ bookmarks.remove(index);
+ bookmarks.add((++index > size()) ? size() : index, bk);
+ }
- public int size() {
- return bookmarks.size();
- }
+ public int size() {
+ return bookmarks.size();
+ }
- public BookmarkItems getItems() {
- BookmarkItems items = new BookmarkItems();
- for (int i = 0; i < size(); i++) {
- if (get(i) instanceof BookmarkItem)
- items.add((BookmarkItem) get(i));
- }
+ public BookmarkItems getItems() {
+ BookmarkItems items = new BookmarkItems();
+ for (int i = 0; i < size(); i++) {
+ if (get(i) instanceof BookmarkItem) {
+ items.add((BookmarkItem) get(i));
+ }
+ }
- return items;
- }
+ return items;
+ }
- public BookmarkItems getAllItems() {
- BookmarkItems items = getItems();
- BookmarkCategories subCategories = getSubCategories();
+ public BookmarkItems getAllItems() {
+ BookmarkItems items = getItems();
+ BookmarkCategories subCategories = getSubCategories();
- for (int i = 0; i < subCategories.size(); i++) {
- items.extend(subCategories.get(i).getAllItems());
- }
- return items;
- }
+ for (int i = 0; i < subCategories.size(); i++) {
+ items.extend(subCategories.get(i).getAllItems());
+ }
+ return items;
+ }
- public BookmarkCategories getSubCategories() {
- BookmarkCategories categories = new BookmarkCategories();
- for (int i = 0; i < size(); i++) {
- if (get(i) instanceof BookmarkCategory)
- categories.add((BookmarkCategory) get(i));
- }
+ public BookmarkCategories getSubCategories() {
+ BookmarkCategories categories = new BookmarkCategories();
+ for (int i = 0; i < size(); i++) {
+ if (get(i) instanceof BookmarkCategory) {
+ categories.add((BookmarkCategory) get(i));
+ }
+ }
- return categories;
- }
+ return categories;
+ }
- public BookmarkCategories getAllSubCategories() {
- BookmarkCategories categories = getSubCategories();
- BookmarkCategories subCategories = getSubCategories();
+ public BookmarkCategories getAllSubCategories() {
+ BookmarkCategories categories = getSubCategories();
+ BookmarkCategories subCategories = getSubCategories();
- for (int i = 0; i < subCategories.size(); i++) {
-
categories.extend(subCategories.get(i).getAllSubCategories());
- }
+ for (int i = 0; i < subCategories.size(); i++) {
+ categories.extend(subCategories.get(i).getAllSubCategories());
+ }
- return categories;
- }
+ return categories;
+ }
- public String[] toStrings() {
- return StringArray.toArray(toStrings("").toArray());
- }
+ public String[] toStrings() {
+ return StringArray.toArray(toStrings("").toArray());
+ }
- // Iternal use only
- private Vector toStrings(String prefix) {
- Vector strings = new Vector();
- BookmarkItems items = getItems();
- BookmarkCategories subCategories = getSubCategories();
- prefix += this.name + "/";
+ // Iternal use only
- for (int i = 0; i < items.size(); i++)
- strings.add(prefix + items.get(i).toString());
+ private Vector toStrings(String prefix) {
+ Vector strings = new Vector();
+ BookmarkItems items = getItems();
+ BookmarkCategories subCategories = getSubCategories();
+ prefix += this.name + "/";
- for (int i = 0; i < subCategories.size(); i++)
- strings.addAll(subCategories.get(i).toStrings(prefix));
+ for (int i = 0; i < items.size(); i++) {
+ strings.add(prefix + items.get(i).toString());
+ }
- return strings;
+ for (int i = 0; i < subCategories.size(); i++) {
+ strings.addAll(subCategories.get(i).toStrings(prefix));
+ }
- }
+ return strings;
- public SimpleFieldSet toSimpleFieldSet() {
- SimpleFieldSet sfs = new SimpleFieldSet(true);
+ }
- BookmarkItems items = getItems();
- for (int i = 0; i < items.size(); i++) {
- BookmarkItem item = items.get(i);
- sfs.putSingle(String.valueOf(i), item.toString());
- }
+ public SimpleFieldSet toSimpleFieldSet() {
+ SimpleFieldSet sfs = new SimpleFieldSet(true);
- BookmarkCategories subCategories = getSubCategories();
- for (int i = 0; i < subCategories.size(); i++) {
- BookmarkCategory category = subCategories.get(i);
- SimpleFieldSet toPut = category.toSimpleFieldSet();
- if("".equals(category.name) || toPut.isEmpty()) continue;
- sfs.put(category.name, toPut);
+ BookmarkItems items = getItems();
+ for (int i = 0; i < items.size(); i++) {
+ BookmarkItem item = items.get(i);
+ sfs.putSingle(String.valueOf(i), item.toString());
+ }
+
+ BookmarkCategories subCategories = getSubCategories();
+ for (int i = 0; i < subCategories.size(); i++) {
+ BookmarkCategory category = subCategories.get(i);
+ SimpleFieldSet toPut = category.toSimpleFieldSet();
+ if ("".equals(category.name) || toPut.isEmpty()) {
+ continue;
}
+ sfs.put(category.name, toPut);
+ }
- return sfs;
- }
- // Don't override equals(), two categories are equal if they have the
same name and description.
+ return sfs;
+ }
+ // Don't override equals(), two categories are equal if they have the same
name and description.
+
}
Modified: trunk/freenet/src/freenet/clients/http/bookmark/BookmarkItem.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/BookmarkItem.java
2007-11-20 19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/bookmark/BookmarkItem.java
2007-11-20 19:25:07 UTC (rev 15884)
@@ -18,165 +18,180 @@
public class BookmarkItem extends Bookmark {
- private FreenetURI key;
- private boolean updated;
- private boolean hasAnActivelink = false;
- private final BookmarkUpdatedUserAlert alert;
- private final UserAlertManager alerts;
- protected String desc;
+ private FreenetURI key;
+ private boolean updated;
+ private boolean hasAnActivelink = false;
+ private final BookmarkUpdatedUserAlert alert;
+ private final UserAlertManager alerts;
+ protected String desc;
- public BookmarkItem(FreenetURI k, String n, boolean hasAnActivelink,
UserAlertManager uam)
- throws MalformedURLException {
- this.key = k;
- this.name = n;
- this.hasAnActivelink = hasAnActivelink;
- this.alerts = uam;
- alert = new BookmarkUpdatedUserAlert();
- }
+ public BookmarkItem(FreenetURI k, String n, boolean hasAnActivelink,
UserAlertManager uam)
+ throws MalformedURLException {
+ this.key = k;
+ this.name = n;
+ this.hasAnActivelink = hasAnActivelink;
+ this.alerts = uam;
+ alert = new BookmarkUpdatedUserAlert();
+ }
- public BookmarkItem(FreenetURI k, String n, String d, boolean
hasAnActivelink, UserAlertManager uam)
- throws MalformedURLException {
+ public BookmarkItem(FreenetURI k, String n, String d, boolean
hasAnActivelink, UserAlertManager uam)
+ throws MalformedURLException {
- this.key = k;
- this.name = n;
- this.desc = d;
- this.hasAnActivelink = hasAnActivelink;
- this.alerts = uam;
- alert = new BookmarkUpdatedUserAlert();
- }
-
- public BookmarkItem(String line, UserAlertManager uam) throws
MalformedURLException {
- String[] result = line.split("###");
- this.name = result[0];
- this.desc = result[1];
- this.hasAnActivelink = Fields.stringToBool(result[2], false);
- this.key = new FreenetURI(result[3]);
- this.alerts = uam;
- this.alert = new BookmarkUpdatedUserAlert();
+ this.key = k;
+ this.name = n;
+ this.desc = d;
+ this.hasAnActivelink = hasAnActivelink;
+ this.alerts = uam;
+ alert = new BookmarkUpdatedUserAlert();
+ }
+
+ public BookmarkItem(String line, UserAlertManager uam) throws
MalformedURLException {
+ String[] result = line.split("###");
+ this.name = result[0];
+ this.desc = result[1];
+ this.hasAnActivelink = Fields.stringToBool(result[2], false);
+ this.key = new FreenetURI(result[3]);
+ this.alerts = uam;
+ this.alert = new BookmarkUpdatedUserAlert();
+ }
+
+ private class BookmarkUpdatedUserAlert extends AbstractUserAlert {
+
+ public BookmarkUpdatedUserAlert() {
+ super(true, null, null, null, UserAlert.MINOR, false, null, true,
null);
}
- private class BookmarkUpdatedUserAlert extends AbstractUserAlert {
+ public String getTitle() {
+ return l10n("bookmarkUpdatedTitle", "name", name);
+ }
- public BookmarkUpdatedUserAlert() {
- super(true, null, null, null, UserAlert.MINOR, false,
null, true, null);
- }
-
- public String getTitle() {
- return l10n("bookmarkUpdatedTitle", "name", name);
- }
+ public String getText() {
+ return l10n("bookmarkUpdated", new String[]{"name", "edition"},
+ new String[]{name,
Long.toString(key.getSuggestedEdition())});
+ }
- public String getText() {
- return l10n("bookmarkUpdated", new String[] { "name",
"edition" },
- new String[] { name,
Long.toString(key.getSuggestedEdition()) });
- }
+ public HTMLNode getHTMLText() {
+ HTMLNode n = new HTMLNode("div");
+ L10n.addL10nSubstitution(n,
"BookmarkItem.bookmarkUpdatedWithLink", new String[]{"link", "/link", "name",
"edition"},
+ new String[]{"<a href=\"" + key.toString() + "\">",
"</a>", HTMLEncoder.encode(name), Long.toString(key.getSuggestedEdition())});
+ return n;
+ }
- public HTMLNode getHTMLText() {
- HTMLNode n = new HTMLNode("div");
- L10n.addL10nSubstitution(n,
"BookmarkItem.bookmarkUpdatedWithLink", new String[] { "link", "/link", "name",
"edition" },
- new String[] { "<a
href=\""+key.toString()+"\">", "</a>", HTMLEncoder.encode(name),
Long.toString(key.getSuggestedEdition()) });
- return n;
- }
+ public boolean isValid() {
+ synchronized (BookmarkItem.this) {
+ return updated;
+ }
+ }
- public boolean isValid() {
- synchronized (BookmarkItem.this) {
- return updated;
- }
- }
+ public void isValid(boolean validity) {
+ if (validity) {
+ return;
+ }
+ disableBookmark();
+ }
- public void isValid(boolean validity) {
- if (validity)
- return;
- disableBookmark();
- }
+ public String dismissButtonText() {
+ return l10n("deleteBookmarkUpdateNotification");
+ }
- public String dismissButtonText() {
- return l10n("deleteBookmarkUpdateNotification");
- }
+ public void onDismiss() {
+ disableBookmark();
+ }
+ }
- public void onDismiss() {
- disableBookmark();
- }
+ private synchronized void disableBookmark() {
+ updated = false;
+ alerts.unregister(alert);
+ }
- }
+ private String l10n(String key) {
+ return L10n.getString("BookmarkItem." + key);
+ }
- private synchronized void disableBookmark() {
- updated = false;
- alerts.unregister(alert);
- }
+ private String l10n(String key, String pattern, String value) {
+ return L10n.getString("BookmarkItem." + key, new String[]{pattern},
new String[]{value});
+ }
- private String l10n(String key) {
- return L10n.getString("BookmarkItem."+key);
- }
+ private String l10n(String key, String[] patterns, String[] values) {
+ return L10n.getString("BookmarkItem." + key, patterns, values);
+ }
- private String l10n(String key, String pattern, String value) {
- return L10n.getString("BookmarkItem."+key, new String[] {
pattern }, new String[] { value });
- }
+ private synchronized void enableBookmark() {
+ if (updated) {
+ return;
+ }
+ updated = true;
+ alerts.register(alert);
+ }
- private String l10n(String key, String[] patterns, String[] values) {
- return L10n.getString("BookmarkItem."+key, patterns, values);
- }
+ public String getKey() {
+ return key.toString();
+ }
- private synchronized void enableBookmark() {
- if (updated)
- return;
- updated = true;
- alerts.register(alert);
- }
+ public synchronized FreenetURI getURI() {
+ return key;
+ }
- public String getKey() {
- return key.toString();
- }
+ public synchronized void setKey(FreenetURI uri, boolean hasAnActivelink) {
+ key = uri;
+ this.hasAnActivelink = hasAnActivelink;
+ }
- public synchronized FreenetURI getURI() {
- return key;
- }
+ public synchronized String getKeyType() {
+ return key.getKeyType();
+ }
- public synchronized void setKey(FreenetURI uri, boolean
hasAnActivelink) {
- key = uri;
- this.hasAnActivelink = hasAnActivelink;
- }
+ public String getName() {
+ return ("".equals(name) ? l10n("unnamedBookmark") : name);
+ }
- public synchronized String getKeyType() {
- return key.getKeyType();
- }
+ public String toString() {
+ return this.name + "###" + this.desc + "###" + this.hasAnActivelink +
"###" + this.key.toString();
+ }
- public String getName() {
- return ("".equals(name) ? l10n("unnamedBookmark") : name);
- }
+ public synchronized void setEdition(long ed, NodeClientCore node) {
+ if (key.getSuggestedEdition() >= ed) {
+ return;
+ }
+ key = key.setSuggestedEdition(ed);
+ enableBookmark();
+ }
- public String toString() {
- return this.name + "###" + this.desc + "###" +
this.hasAnActivelink + "###" + this.key.toString();
- }
+ public USK getUSK() throws MalformedURLException {
+ return USK.create(key);
+ }
- public synchronized void setEdition(long ed, NodeClientCore node) {
- if (key.getSuggestedEdition() >= ed)
- return;
- key = key.setSuggestedEdition(ed);
- enableBookmark();
- }
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof BookmarkItem) {
+ BookmarkItem b = (BookmarkItem) o;
+ if (!super.equals(o)) {
+ return false;
+ }
+ if (!b.key.equals(key)) {
+ if (b.key.getKeyType().equals("USK")) {
+ if
(!b.key.setSuggestedEdition(key.getSuggestedEdition()).equals(key)) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ if (b.alerts != alerts) {
+ return false;
+ } // Belongs to a different node???
+ if (b.hasAnActivelink != hasAnActivelink) {
+ return false;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
- public USK getUSK() throws MalformedURLException {
- return USK.create(key);
- }
-
- public boolean equals(Object o) {
- if(o == this) return true;
- if(o instanceof BookmarkItem) {
- BookmarkItem b = (BookmarkItem) o;
- if(!super.equals(o)) return false;
- if(!b.key.equals(key)) {
- if(b.key.getKeyType().equals("USK")) {
-
if(!b.key.setSuggestedEdition(key.getSuggestedEdition()).equals(key))
- return false;
- } else return false;
- }
- if(b.alerts != alerts) return false; // Belongs to a
different node???
- if(b.hasAnActivelink != hasAnActivelink) return false;
- return true;
- } else return false;
- }
-
- public boolean hasAnActivelink() {
- return hasAnActivelink;
+ public boolean hasAnActivelink() {
+ return hasAnActivelink;
+ }
}
-}
Modified: trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
2007-11-20 19:23:51 UTC (rev 15883)
+++ trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
2007-11-20 19:25:07 UTC (rev 15884)
@@ -101,7 +101,8 @@
addBookmark(matcher.group(1), new BookmarkItem(key,
title, hasAnActiveLink, node.alerts), false);
}
- } catch (MalformedURLException e) {}
+ } catch (MalformedURLException e) {
+ }
}
}
@@ -148,8 +149,9 @@
}
public BookmarkCategory getCategoryByPath(String path) {
- if (getBookmarkByPath(path.trim()) instanceof BookmarkCategory)
+ if (getBookmarkByPath(path.trim()) instanceof BookmarkCategory) {
return (BookmarkCategory) getBookmarkByPath(path);
+ }
return null;
}
@@ -174,7 +176,7 @@
storeBookmarks();
}
}
-
+
public void addBookmark(String parentPath, Bookmark bookmark, boolean
store) {
BookmarkCategory parent = getCategoryByPath(parentPath);
parent.addBookmark(bookmark);
@@ -337,9 +339,9 @@
return;
}
isSavingBookmarks = true;
-
+
SimpleFieldSet toSave = MAIN_CATEGORY.toSimpleFieldSet();
- if(toSave.isEmpty()) {
+ if (toSave.isEmpty()) {
isSavingBookmarks = false;
return;
}
@@ -389,7 +391,7 @@
category.addBookmark(item);
addBookmark(category, item, false);
} catch (MalformedURLException e) {
- Logger.error(this, "Error while adding one of the
bookmarks :"+e.getMessage(), e);
+ Logger.error(this, "Error while adding one of the
bookmarks :" + e.getMessage(), e);
}
}
}