001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.web.wiki.macros;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.kernel.KernelConstants;
038: import org.libresource.kernel.interfaces.KernelService;
039:
040: import org.libresource.membership.MembershipConstants;
041: import org.libresource.membership.interfaces.MembershipService;
042:
043: import org.libresource.web.taglibs.JspFunctions;
044:
045: import org.radeox.macro.BaseMacro;
046: import org.radeox.macro.parameter.MacroParameter;
047:
048: import java.io.IOException;
049: import java.io.Writer;
050:
051: import java.net.URI;
052:
053: public class BookmarksMacro extends BaseMacro {
054: KernelService kernelService = null;
055: MembershipService membershipService = null;
056:
057: public BookmarksMacro() throws Exception {
058: kernelService = (KernelService) Libresource
059: .getService(KernelConstants.SERVICE);
060: membershipService = (MembershipService) Libresource
061: .getService(MembershipConstants.SERVICE);
062: }
063:
064: public String getName() {
065: return "bookmarks";
066: }
067:
068: public void execute(Writer writer, MacroParameter params)
069: throws IllegalArgumentException, IOException {
070: try {
071: URI userUri = kernelService.getConnectedResource();
072: String bookmarksContent = (String) membershipService
073: .getProfile().getInfos().get(
074: "libresource-web.bookmarks");
075:
076: if (bookmarksContent != null) {
077: writer.write("<div class=\"bookmarks\"><h3><a href=\""
078: + userUri.getPath()
079: + "?action=bookmarks\">My bookmarks :</h3>");
080: writer.write(JspFunctions.render(userUri,
081: bookmarksContent));
082: writer.write("</div>");
083: }
084: } catch (IOException e) {
085: throw e;
086: } catch (IllegalArgumentException e) {
087: throw e;
088: } catch (Exception e) {
089: throw new IllegalArgumentException(e.getMessage());
090: }
091: }
092:
093: public String getDescription() {
094: return "Display the user bookmarks.";
095: }
096:
097: public String[] getParamDescription() {
098: return new String[0];
099: }
100: }
|