[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui ...

Christian Bauer christian at hibernate.org
Tue Dec 18 23:29:22 EST 2007


  User: cbauer  
  Date: 07/12/18 23:29:22

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/ui       
                        Converters.java FileServlet.java FeedServlet.java
                        WikiFormattedTextHandler.java
                        UIWikiFormattedText.java
  Added:       examples/wiki/src/main/org/jboss/seam/wiki/core/ui       
                        HttpSessionChecker.java
  Removed:     examples/wiki/src/main/org/jboss/seam/wiki/core/ui       
                        FileMetaMap.java
  Log:
  Major rewrite of the most of the application
  
  Revision  Changes    Path
  1.13      +4 -4      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/Converters.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Converters.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/Converters.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- Converters.java	24 Sep 2007 08:23:20 -0000	1.12
  +++ Converters.java	19 Dec 2007 04:29:22 -0000	1.13
  @@ -10,12 +10,12 @@
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
  -import org.jboss.seam.annotations.Transactional;
  +import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.wiki.core.model.Role;
   import org.jboss.seam.wiki.core.search.metamodel.SearchRegistry;
   import org.jboss.seam.wiki.core.search.metamodel.SearchableEntity;
  -import org.jboss.seam.wiki.core.importers.metamodel.Importer;
  -import org.jboss.seam.wiki.core.importers.metamodel.ImporterRegistry;
  +import org.jboss.seam.wiki.core.upload.importers.metamodel.Importer;
  +import org.jboss.seam.wiki.core.upload.importers.metamodel.ImporterRegistry;
   
   import javax.faces.component.UIComponent;
   import javax.faces.context.FacesContext;
  @@ -105,7 +105,7 @@
       @Name("treeNodeAdapter")
       public static class TreeNodeAdapter {
   
  -        /* TODO: Fixme
  +        /* TODO: Fixme or deleteme
           @Factory(value = "writableDirectoryTree", scope = ScopeType.CONVERSATION, autoCreate = true)
           public TreeNode loadWritableDirectoryTree() {
               Directory wikiroot = (Directory) Component.getInstance("restrictedWikiRoot");
  
  
  
  1.12      +29 -35    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FileServlet.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- FileServlet.java	25 Sep 2007 14:30:44 -0000	1.11
  +++ FileServlet.java	19 Dec 2007 04:29:22 -0000	1.12
  @@ -1,6 +1,8 @@
   package org.jboss.seam.wiki.core.ui;
   
  -import org.jboss.seam.wiki.core.model.File;
  +import org.jboss.seam.wiki.core.model.WikiUpload;
  +import org.jboss.seam.wiki.core.model.WikiUploadImage;
  +import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
   
   import javax.persistence.EntityManager;
   import javax.persistence.NoResultException;
  @@ -46,8 +48,9 @@
           if (DOWNLOAD_PATH.equals(request.getPathInfo())) {
   
               String id = request.getParameter("fileId");
  -            File file = null;
  +            WikiUpload file = null;
   
  +            if (!"".equals(id)) {
               // TODO: Seam should use its transaction interceptor for java beans: http://jira.jboss.com/jira/browse/JBSEAM-957
               UserTransaction userTx = null;
               boolean startedTx = false;
  @@ -59,27 +62,20 @@
                       userTx.begin();
                   }
   
  -                EntityManager em = ((EntityManager)org.jboss.seam.Component.getInstance("restrictedEntityManager"));
  -
  -                if (!"".equals(id)) {
  -                    try {
  -                        file = (File)em.createQuery("select f from File f where f.id = :fid")
  -                                .setParameter("fid", Long.parseLong(id))
  -                                .getSingleResult();
  -                    } catch (NoResultException ex) {
  -                        // ignore... we want null
  -                    }
  -                }
  +                    WikiNodeDAO wikiNodeDAO = (WikiNodeDAO)org.jboss.seam.Component.getInstance("wikiNodeDAO");
  +                    file = wikiNodeDAO.findWikiUpload(Long.parseLong(id));
   
                   if (startedTx) userTx.commit();
               } catch (Exception ex) {
                   try {
  -                    if (startedTx) userTx.rollback();
  +                        if (startedTx && userTx.getStatus() != javax.transaction.Status.STATUS_MARKED_ROLLBACK)
  +                            userTx.rollback();
                   } catch (Exception rbEx) {
                       rbEx.printStackTrace();
                   }
                   throw new RuntimeException(ex);
               }
  +            }
   
               String contentType = null;
               byte[] data = null;
  @@ -89,17 +85,15 @@
               if (file != null
                   && thumbnail != null
                   && Boolean.valueOf(thumbnail)
  -                && file.getImageMetaInfo() != null
  -                && file.getImageMetaInfo().getThumbnailData() != null
  -                && file.getImageMetaInfo().getThumbnailData().length >0) {
  +                && file.isInstance(WikiUploadImage.class)
  +                && ((WikiUploadImage)file).getThumbnailData() != null
  +                && ((WikiUploadImage)file).getThumbnailData().length >0) {
   
                   // Render thumbnail picture
                   contentType = file.getContentType();
  -                data = file.getImageMetaInfo().getThumbnailData();
  +                data = ((WikiUploadImage)file).getThumbnailData();
   
  -            } else if (file != null
  -                       && file.getData() != null
  -                       && file.getData().length > 0) {
  +            } else if (file != null && file.getData() != null && file.getData().length > 0) {
   
                   // Render file regularly
                   contentType = file.getContentType();
  @@ -119,7 +113,7 @@
                   // the file instead of displaying it
                   // TODO: What about PDFs? Lot's of people want to show PDFs inline...
                   if ( file != null &&
  -                    ( file.getImageMetaInfo() == null || (file.getImageMetaInfo() != null && file.getImageMetaInfo().getThumbnail() == 'A') )
  +                    ( !file.isInstance(WikiUploadImage.class) || ( ((WikiUploadImage)file).getThumbnail() == 'A') )
                      ) {
                       response.setHeader("Content-Disposition", "attachement; filename=\"" + file.getFilename() + "\"" );
                   }
  
  
  
  1.12      +81 -46    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FeedServlet.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- FeedServlet.java	16 Nov 2007 05:47:25 -0000	1.11
  +++ FeedServlet.java	19 Dec 2007 04:29:22 -0000	1.12
  @@ -9,12 +9,11 @@
   import com.sun.syndication.feed.synd.*;
   import com.sun.syndication.io.SyndFeedOutput;
   import org.jboss.seam.Component;
  -import org.jboss.seam.wiki.core.dao.FeedDAO;
  -import org.jboss.seam.wiki.core.dao.UserRoleAccessFactory;
  +import org.jboss.seam.wiki.core.feeds.FeedDAO;
   import org.jboss.seam.wiki.core.model.Feed;
   import org.jboss.seam.wiki.core.model.FeedEntry;
  -import org.jboss.seam.wiki.core.model.User;
   import org.jboss.seam.wiki.core.action.Authenticator;
  +import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
   import org.jboss.seam.wiki.util.WikiUtil;
   
   import javax.servlet.ServletException;
  @@ -25,13 +24,41 @@
   import java.io.IOException;
   import java.util.*;
   
  +/**
  + * Serves syndicated feeds, one feed for each directory that has a feed.
  + * <p>
  + * This servlet uses either the currently logged in user (session) or
  + * basic HTTP authorization if there is no user logged in or if the feed
  + * requires a higher access level than currently available. The access level
  + * of the feed is the read-access level of the directory the feed belongs to.
  + * Feed entries are also read-access filtered, depending on the document they
  + * belong to.
  + *
  + * @author Christian Bauer
  + */
   public class FeedServlet extends HttpServlet {
   
  -    private Map<String,String> feedTypes = new HashMap<String,String>() {{
  -        put("/atom.seam", "atom_1.0");
  -        // TODO: Support more of these... also need to consider setContentType() ... put("/rss.seam", "rss_2.0");
  +    // Possible feed types
  +    public enum SyndFeedType {
  +        ATOM("/atom.seam", "atom_1.0", "application/atom+xml"),
  +        RSS2("/rss.seam", "rss_2.0", "application/rss+xml");
  +
  +        SyndFeedType(String pathInfo, String feedType, String contentType) {
  +            this.pathInfo = pathInfo;
  +            this.feedType = feedType;
  +            this.contentType = contentType;
  +        }
  +        String pathInfo;
  +        String feedType;
  +        String contentType;
  +    }
  +
  +    // Supported feed types
  +    private Map<String, SyndFeedType> feedTypes = new HashMap<String,SyndFeedType>() {{
  +        put(SyndFeedType.ATOM.pathInfo, SyndFeedType.ATOM);
       }};
   
  +    // Allow unit testing
       public FeedServlet() {}
   
       @Override
  @@ -42,7 +69,7 @@
           String feedId = request.getParameter("feedId");
   
           if (!feedTypes.containsKey(pathInfo)) return;
  -        String feedType = feedTypes.get(pathInfo);
  +        SyndFeedType syndFeedType = feedTypes.get(pathInfo);
           if (feedId == null) return;
   
           // TODO: Seam should use its transaction interceptor for java beans: http://jira.jboss.com/jira/browse/JBSEAM-957
  @@ -76,12 +103,37 @@
                   }
               }
   
  +            SyndFeed syndFeed = createSyndFeed(request.getRequestURL().toString(), syndFeedType,  feed, currentAccessLevel);
  +
  +            // Write feed to output
  +            response.setContentType(syndFeedType.contentType);
  +            response.setCharacterEncoding("UTF-8");
  +            SyndFeedOutput output = new SyndFeedOutput();
  +            output.output(syndFeed, response.getWriter());
  +            response.getWriter().flush();
  +
  +            if (startedTx) userTx.commit();
  +        } catch (Exception ex) {
  +            try {
  +                if (startedTx && userTx.getStatus() != javax.transaction.Status.STATUS_MARKED_ROLLBACK)
  +                    userTx.rollback();
  +            } catch (Exception rbEx) {
  +                rbEx.printStackTrace();
  +            }
  +            throw new RuntimeException(ex);
  +        }
  +    }
  +
  +    public SyndFeed createSyndFeed(String baseURI, SyndFeedType syndFeedType, Feed feed, Integer currentAccessLevel) {
  +
  +        WikiPreferences prefs = (WikiPreferences)Component.getInstance("wikiPreferences");
  +
               // Create feed
               SyndFeed syndFeed = new SyndFeedImpl();
  -            syndFeed.setUri(request.getRequestURL().toString() + "?feedId=" + feedId);
  -            syndFeed.setFeedType(feedType);
  -            syndFeed.setTitle(feed.getTitle());
  -            syndFeed.setLink(request.getRequestURL().toString() + "?feedId=" + feedId);
  +        syndFeed.setUri(baseURI + "?feedId=" + feed.getId());
  +        syndFeed.setFeedType(syndFeedType.feedType);
  +        syndFeed.setTitle(prefs.getFeedTitlePrefix() + feed.getTitle());
  +        syndFeed.setLink(WikiUtil.renderURL(feed.getDirectory()));
               syndFeed.setAuthor(feed.getAuthor());
               if (feed.getDescription() != null && feed.getDescription().length() >0)
                   syndFeed.setDescription(feed.getDescription());
  @@ -91,8 +143,8 @@
               List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
               SortedSet<FeedEntry> entries = feed.getFeedEntries();
               for (FeedEntry entry : entries) {
  +            if (entry.getReadAccessLevel() <= currentAccessLevel) {
                   SyndEntry syndEntry;
  -                SyndContent description;
                   syndEntry = new SyndEntryImpl();
                   syndEntry.setTitle(entry.getTitle());
                   syndEntry.setLink(entry.getLink());
  @@ -100,36 +152,19 @@
                   syndEntry.setAuthor(entry.getAuthor());
                   syndEntry.setPublishedDate(entry.getPublishedDate());
                   syndEntry.setUpdatedDate(entry.getUpdatedDate());
  +
  +                SyndContent description;
                   description = new SyndContentImpl();
                   description.setType(entry.getDescriptionType());
                   description.setValue(WikiUtil.removeMacros(entry.getDescriptionValue()));
                   syndEntry.setDescription(description);
  -                if (entry.getDocument() != null && entry.getDocument().getReadAccessLevel() <= currentAccessLevel) {
  -                    // Only add entry if the associated document has the right access level
  -                    syndEntries.add(syndEntry);
  -                } else if (entry.getDocument() == null) {
  -                    // or if there is no document associated with it, then everyone can read it who can read the feed
  +
                       syndEntries.add(syndEntry);
                   }
               }
               syndFeed.setEntries(syndEntries);
   
  -            // Write feed to output
  -            response.setContentType("application/atom+xml"); // TODO: Make this more flexible
  -            response.setCharacterEncoding("UTF-8");
  -            SyndFeedOutput output = new SyndFeedOutput();
  -            output.output(syndFeed, response.getWriter());
  -            response.getWriter().flush();
  -
  -            if (startedTx) userTx.commit();
  -        } catch (Exception ex) {
  -            try {
  -                if (startedTx) userTx.rollback();
  -            } catch (Exception rbEx) {
  -                rbEx.printStackTrace();
  -            }
  -            throw new RuntimeException(ex);
  -        }
  +        return syndFeed;
       }
   
   }
  
  
  
  1.16      +4 -6      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiFormattedTextHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/WikiFormattedTextHandler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- WikiFormattedTextHandler.java	14 Nov 2007 10:19:42 -0000	1.15
  +++ WikiFormattedTextHandler.java	19 Dec 2007 04:29:22 -0000	1.16
  @@ -94,12 +94,11 @@
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_BROKEN_LINK_STYLE_CLASS);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_ATTACHMENT_LINK_STYLE_CLASS);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_THUMBNAIL_LINK_STYLE_CLASS);
  -        setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_UPDATE_RESOLVED_LINKS);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_PLAIN_VIEW);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_INTERNAL_TARGET_FRAME);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_EXTERNAL_TARGET_FRAME);
  -        setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_RENDER_BASE_DOCUMENT);
  -        setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_RENDER_BASE_DIRECTORY);
  +        setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_LINK_BASE_FILE);
  +        setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_CURRENT_AREA_NUMBER);
           setAttribute(ctx, cmp, UIWikiFormattedText.ATTR_ENABLE_PLUGINS);
       }
   
  @@ -139,7 +138,7 @@
           String unparsed = valueAttribute.getValue(ctx);
   
           if (getAttribute(UIWikiFormattedText.ATTR_ENABLE_PLUGINS) == null ||
  -            !getAttribute(UIWikiFormattedText.ATTR_ENABLE_PLUGINS).getValue().equals("true")) {
  +            !getAttribute(UIWikiFormattedText.ATTR_ENABLE_PLUGINS).getBoolean(ctx)) {
               wikiFormattedText.setValue(unparsed);
               return;
           }
  @@ -167,8 +166,7 @@
                   } else {
                       // Best guess based plugin renderer
                       placeHolder = wikiFormattedText.addPlugin(
  -                        (parent.getChildren().get(parent.getChildCount() - 1)
  -                            .getClientId( ctx.getFacesContext() )
  +                        (parent.getChildren().get(parent.getChildCount() - 1).getClientId( ctx.getFacesContext() )
                           )
                       );
                   }
  
  
  
  1.32      +66 -46    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIWikiFormattedText.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/UIWikiFormattedText.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -b -r1.31 -r1.32
  --- UIWikiFormattedText.java	12 Nov 2007 11:14:29 -0000	1.31
  +++ UIWikiFormattedText.java	19 Dec 2007 04:29:22 -0000	1.32
  @@ -6,30 +6,34 @@
    */
   package org.jboss.seam.wiki.core.ui;
   
  -import java.io.IOException;
  -import java.io.StringWriter;
  -import java.util.ArrayList;
  -import java.util.List;
  -
  -import javax.faces.component.UIComponent;
  -import javax.faces.component.UIOutput;
  -import javax.faces.context.FacesContext;
  -import javax.faces.context.ResponseWriter;
  -
  +import antlr.ANTLRException;
  +import antlr.RecognitionException;
   import org.jboss.seam.Component;
  +import org.jboss.seam.core.Conversation;
  +import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.log.Log;
   import org.jboss.seam.log.Logging;
   import org.jboss.seam.ui.util.JSF;
   import org.jboss.seam.ui.validator.FormattedTextValidator;
  -import org.jboss.seam.contexts.Contexts;
  -import org.jboss.seam.core.Conversation;
  -import org.jboss.seam.wiki.core.engine.*;
  -import org.jboss.seam.wiki.core.model.File;
  -import org.jboss.seam.wiki.core.model.Document;
  -import org.jboss.seam.wiki.core.model.Node;
  +import org.jboss.seam.wiki.core.engine.DefaultWikiTextRenderer;
  +import org.jboss.seam.wiki.core.engine.WikiLink;
  +import org.jboss.seam.wiki.core.engine.WikiLinkResolver;
  +import org.jboss.seam.wiki.core.engine.WikiTextParser;
  +import org.jboss.seam.wiki.core.model.WikiFile;
  +import org.jboss.seam.wiki.core.model.WikiUpload;
  +import org.jboss.seam.wiki.core.model.WikiUploadImage;
   import org.jboss.seam.wiki.util.WikiUtil;
  -import antlr.RecognitionException;
  -import antlr.ANTLRException;
  +
  +import javax.faces.component.UIComponent;
  +import javax.faces.component.UIOutput;
  +import javax.faces.context.FacesContext;
  +import javax.faces.context.ResponseWriter;
  +import java.io.IOException;
  +import java.io.StringWriter;
  +import java.util.ArrayList;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.HashMap;
   
   /**
    * Uses WikiTextParser and WikiLinkResolver to render Seam Text markup with wiki links.
  @@ -47,12 +51,11 @@
       public static final String ATTR_BROKEN_LINK_STYLE_CLASS         = "brokenLinkStyleClass";
       public static final String ATTR_ATTACHMENT_LINK_STYLE_CLASS     = "attachmentLinkStyleClass";
       public static final String ATTR_THUMBNAIL_LINK_STYLE_CLASS      = "thumbnailLinkStyleClass";
  -    public static final String ATTR_UPDATE_RESOLVED_LINKS           = "updateResolvedLinks";
       public static final String ATTR_PLAIN_VIEW                      = "plainView";
       public static final String ATTR_INTERNAL_TARGET_FRAME           = "internalTargetFrame";
       public static final String ATTR_EXTERNAL_TARGET_FRAME           = "externalTargetFrame";
  -    public static final String ATTR_RENDER_BASE_DOCUMENT            = "renderBaseDocument";
  -    public static final String ATTR_RENDER_BASE_DIRECTORY           = "renderBaseDirectory";
  +    public static final String ATTR_LINK_BASE_FILE                  = "linkBaseFile";
  +    public static final String ATTR_CURRENT_AREA_NUMBER             = "currentAreaNumber";
       public static final String ATTR_ENABLE_PLUGINS                  = "enablePlugins";
   
       private List<String> plugins;
  @@ -89,10 +92,9 @@
           WikiTextParser parser = new WikiTextParser((String) getValue(), false, true);
   
           // Resolve the base document and directory we are resolving against
  -        final Document baseDocument = (Document)getAttributes().get(ATTR_RENDER_BASE_DOCUMENT);
  -        final Node baseDirectory = (Node)getAttributes().get(ATTR_RENDER_BASE_DIRECTORY);
  -        parser.setCurrentDocument(baseDocument);
  -        parser.setCurrentDirectory(baseDirectory);
  +        final WikiFile baseFile = (WikiFile)getAttributes().get(ATTR_LINK_BASE_FILE);
  +        final Long currentAreaNumber = (Long)getAttributes().get(ATTR_CURRENT_AREA_NUMBER);
  +        parser.setCurrentAreaNumber(currentAreaNumber);
   
           parser.setResolver((WikiLinkResolver)Component.getInstance("wikiLinkResolver"));
   
  @@ -105,8 +107,8 @@
                               inlineLink.isBroken()
                                   ? inlineLink.getUrl()
                                   : "true".equals(getAttributes().get(ATTR_PLAIN_VIEW))
  -                                  ? WikiUtil.renderPlainURL(inlineLink.getNode())
  -                                  : WikiUtil.renderURL(inlineLink.getNode())
  +                                  ? WikiUtil.renderPlainURL(inlineLink.getFile())
  +                                  : WikiUtil.renderURL(inlineLink.getFile())
                              )
                           + "\" target=\""
                           + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
  @@ -130,8 +132,8 @@
               public String renderFileAttachmentLink(int attachmentNumber, WikiLink attachmentLink) {
                   return "<a href=\""
                           + ("true".equals(getAttributes().get(ATTR_PLAIN_VIEW))
  -                          ? WikiUtil.renderPlainURL(baseDocument)
  -                          : WikiUtil.renderURL(baseDocument))
  +                          ? WikiUtil.renderPlainURL(baseFile)
  +                          : WikiUtil.renderURL(baseFile))
                           + "#attachment" + attachmentNumber
                           + "\" target=\""
                           + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
  @@ -141,31 +143,34 @@
               }
   
               public String renderThumbnailImageInlineLink(WikiLink inlineLink) {
  -                File file = (File) inlineLink.getNode();
   
  -                if (file.getImageMetaInfo().getThumbnail() == 'F') {
  +                // TODO: This is not typesafe and clean, need different rendering strategy for WikiUpload subclasses
  +                WikiUploadImage image = (WikiUploadImage)inlineLink.getFile();
  +                if (image.getThumbnail() == 'F') {
                       // Full size display, no thumbnail
  -
  -                    String imageUrl = WikiUtil.renderURL(inlineLink.getNode()) + "&amp;cid=" + Conversation.instance().getId();
  +                    //TODO: Make sure we really don't need this - but it messes up the comment form conversation:
  +                    //String imageUrl = WikiUtil.renderURL(image) + "&amp;cid=" + Conversation.instance().getId();
  +                    String imageUrl = WikiUtil.renderURL(image);
                       return "<img src='"+ imageUrl + "'" +
  -                            " width='"+ file.getImageMetaInfo().getSizeX()+"'" +
  -                            " height='"+ file.getImageMetaInfo().getSizeY() +"'/>";
  +                            " width='"+ image.getSizeX()+"'" +
  +                            " height='"+ image.getSizeY() +"'/>";
                   } else {
                       // Thumbnail with link display
   
                       // I have no idea why this needs HTML entities for the & symbol -
                       // Firefox complains about invalid XML if an & is in an attribute
                       // value!
  -                    String thumbnailUrl = WikiUtil.renderURL(inlineLink.getNode()) + "&amp;thumbnail=true&amp;cid=" + Conversation.instance().getId();
  +                    //TODO: Make sure we really don't need this - but it messes up the comment form conversation:
  +                    // String thumbnailUrl = WikiUtil.renderURL(image) + "&amp;thumbnail=true&amp;cid=" + Conversation.instance().getId();
  +                    String thumbnailUrl = WikiUtil.renderURL(image) + "&amp;thumbnail=true";
   
                       return "<a href=\""
  -                            + (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(inlineLink.getNode()))
  +                            + (inlineLink.isBroken() ? inlineLink.getUrl() : WikiUtil.renderURL(image))
                               + "\" target=\""
                               + (getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) != null ? getAttributes().get(ATTR_INTERNAL_TARGET_FRAME) : "")
                               + "\" class=\""
                               + getAttributes().get(ATTR_THUMBNAIL_LINK_STYLE_CLASS) + "\"><img src=\""
                               + thumbnailUrl + "\"/></a>";
  -
                   }
               }
   
  @@ -199,24 +204,39 @@
   
               public void setAttachmentLinks(List<WikiLink> attachmentLinks) {
                   // Put attachments (wiki links...) into the event context for later rendering
  -                Contexts.getEventContext().set("wikiTextAttachments", attachmentLinks);
  +                setLinks("wikiTextAttachments", attachmentLinks);
               }
   
               public void setExternalLinks(List<WikiLink> externalLinks) {
                   // Put external links (to targets not on this wiki) into the event context for later rendering
  -                Contexts.getEventContext().set("wikiTextExternalLinks", externalLinks);
  +                setLinks("wikiTextExternalLinks", externalLinks);
  +            }
  +
  +            private void setLinks(String contextVariable, List<WikiLink> links) {
  +                // TODO: Need some tricks here with link identifiers and attachment numbers, right now we just skip this if it's already set
  +                /// ... hoping that the first caller was the document renderer and not the comment renderer - that means comment attachments are broken
  +                List<WikiLink> contextLinks = (List<WikiLink>)Contexts.getEventContext().get(contextVariable);
  +                if (contextLinks == null || contextLinks.size()==0) {
  +                    Contexts.getEventContext().set(contextVariable, links);
  +                }
  +                        /*
  +                Map<Integer, WikiLink> contextLinks =
  +                    (Map<Integer,WikiLink>)Contexts.getEventContext().get(contextVariable);
  +                if (contextLinks == null) {
  +                    contextLinks = new HashMap<Integer, WikiLink>();
  +                }
  +                for (WikiLink link : links) {
  +                    contextLinks.put(link.getIdentifier(), link);
  +                }
  +                Contexts.getEventContext().set(contextVariable, contextLinks);
  +                */
               }
           }
   
           parser.setRenderer(new WikiFormattedTextRenderer());
   
  -        // Run the parser (default to true for updating resolved links)
  -        Boolean updateResolvedLinks =
  -                getAttributes().get(ATTR_UPDATE_RESOLVED_LINKS) == null
  -                || Boolean.valueOf((String) getAttributes().get(ATTR_UPDATE_RESOLVED_LINKS));
           try {
  -
  -            parser.parse(updateResolvedLinks);
  +            parser.parse();
   
           } catch (RecognitionException rex) {
               // Log a nice message for any lexer/parser errors, users can disable this if they want to
  
  
  
  1.1      date: 2007/12/19 04:29:22;  author: cbauer;  state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/HttpSessionChecker.java
  
  Index: HttpSessionChecker.java
  ===================================================================
  package org.jboss.seam.wiki.core.ui;
  
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.annotations.remoting.WebRemote;
  import org.jboss.seam.web.ServletContexts;
  
  
  @Name("httpSessionChecker")
  @Scope(ScopeType.APPLICATION)
  public class HttpSessionChecker {
  
      @WebRemote
      public boolean isNewSession() {
          return ServletContexts.instance().getRequest().getSession().isNew();
      }
  }
  
  
  



More information about the jboss-cvs-commits mailing list