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

Christian Bauer christian at hibernate.org
Fri Aug 17 09:00:29 EDT 2007


  User: cbauer  
  Date: 07/08/17 09:00:29

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/action            
                        WikiIdentity.java DirectoryHome.java
                        PluginPreferenceEditor.java Menu.java UserHome.java
                        NodeHome.java Authenticator.java NodeHistory.java
                        NodePermissions.java NodeBrowser.java
                        DocumentHome.java CommentHome.java
  Log:
  Major refactoring of core data schema and some new features
  
  Revision  Changes    Path
  1.9       +8 -4      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiIdentity.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- WikiIdentity.java	21 Jun 2007 11:05:49 -0000	1.8
  +++ WikiIdentity.java	17 Aug 2007 13:00:28 -0000	1.9
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import static org.jboss.seam.ScopeType.SESSION;
  @@ -7,7 +13,6 @@
   import org.jboss.seam.annotations.*;
   import org.jboss.seam.annotations.intercept.BypassInterceptors;
   import org.jboss.seam.wiki.core.model.User;
  -import org.jboss.seam.wiki.core.model.Directory;
   import org.jboss.seam.wiki.core.model.Node;
   import org.jboss.seam.wiki.core.dao.UserRoleAccessFactory;
   import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
  @@ -40,7 +45,7 @@
           }
   
           if ("Node".equals(name) && "create".equals(action)) {
  -            return checkCreateAccess( (Directory)args[0]);
  +            return checkCreateAccess( (Node)args[0]);
           } else
           if ("Node".equals(name) && "edit".equals(action)) {
               return checkEditAccess((Node)args[0]);
  @@ -78,7 +83,7 @@
           User either needs to have the access level of the parent directory
           or the user is the creator of the parent directory
       */
  -    private boolean checkCreateAccess(Directory directory) {
  +    private boolean checkCreateAccess(Node directory) {
           if (directory.getId().equals(wikiPrefs.getMemberAreaId())) return false; // Member home dir is immutable
           if (directory.getWriteAccessLevel() == UserRoleAccessFactory.GUESTROLE_ACCESSLEVEL) return true;
           int dirWriteAccessLevel = directory.getWriteAccessLevel();
  @@ -114,7 +119,6 @@
           User either needs to have the access level of the edited node or has to be the creator
       */
       private boolean checkEditAccess(Node node) {
  -        if (node.getId() != null && node.getId().equals(wikiPrefs.getMemberAreaId())) return false; // Member home dir is immutable
           if (node.getWriteAccessLevel() == UserRoleAccessFactory.GUESTROLE_ACCESSLEVEL) return true;
           int nodeWriteAccessLevel = node.getWriteAccessLevel();
           User nodeCreator = node.getCreatedBy();
  
  
  
  1.13      +19 -18    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DirectoryHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DirectoryHome.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- DirectoryHome.java	9 Jul 2007 16:37:40 -0000	1.12
  +++ DirectoryHome.java	17 Aug 2007 13:00:28 -0000	1.13
  @@ -1,20 +1,22 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
   import org.jboss.seam.annotations.security.Restrict;
  -import org.jboss.seam.annotations.datamodel.DataModel;
  -import org.jboss.seam.annotations.datamodel.DataModelSelection;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.wiki.core.model.Directory;
   import org.jboss.seam.wiki.core.model.Node;
   import org.jboss.seam.wiki.core.model.Document;
   import org.jboss.seam.wiki.core.model.Feed;
   import org.jboss.seam.wiki.util.WikiUtil;
  -import org.ajax4jsf.dnd.event.DropEvent;
   
   import javax.faces.application.FacesMessage;
   import java.util.List;
  -import java.util.Collections;
   import java.util.ArrayList;
   import java.util.Date;
   
  @@ -24,11 +26,6 @@
   
       /* -------------------------- Context Wiring ------------------------------ */
   
  -    @DataModel
  -    List<Node> childNodes;
  -
  -    @DataModelSelection
  -    Node selectedChildNode;
   
       /* -------------------------- Internal State ------------------------------ */
   
  @@ -84,6 +81,8 @@
           return super.beforeUpdate();
       }
   
  +    
  +
       protected boolean prepareRemove() {
           if (getInstance().getParent() == null) return false; // Veto wiki root delete
           return true;
  @@ -92,8 +91,8 @@
       /* -------------------------- Internal Methods ------------------------------ */
   
       private void refreshChildNodes() {
  -        childNodes = getInstance().getChildren();
  -        for (Node childNode : childNodes) {
  +        childDocuments.clear();
  +        for (Node childNode : getInstance().getChildren()) {
               if (childNode instanceof Document) childDocuments.add((Document)childNode);
           }
       }
  @@ -155,18 +154,20 @@
       }
   
       @Restrict("#{s:hasPermission('Node', 'editMenu', directoryHome.instance)}")
  -    public void dropMenuItem(DropEvent event) {
  -
  -        Node draggedObject = (Node)event.getDragValue();
  -        int currentPosition = getInstance().getChildren().indexOf(draggedObject);
  -        int newPosition = (Integer)event.getDropValue();
  +    public void moveNode(int currentPosition, int newPosition) {
   
           if (currentPosition != newPosition) {
  +
  +            // Shift and refresh displayed list
               WikiUtil.shiftListElement(getInstance().getChildren(), currentPosition, newPosition);
  -            refreshChildNodes();
  -        }
   
  +            // Required update, this is only refreshed on database load
  +            for (Node node : getInstance().getChildren()) {
  +                node.setDisplayPosition( getInstance().getChildren().indexOf(node) );
       }
   
  +            refreshChildNodes();
  +        }
  +    }
   
   }
  
  
  
  1.4       +28 -0     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/PluginPreferenceEditor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PluginPreferenceEditor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/PluginPreferenceEditor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- PluginPreferenceEditor.java	20 Jun 2007 01:30:36 -0000	1.3
  +++ PluginPreferenceEditor.java	17 Aug 2007 13:00:28 -0000	1.4
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.wiki.preferences.*;
  @@ -15,6 +21,20 @@
   import java.util.*;
   import java.io.Serializable;
   
  +/**
  + * Inline editor for preference values, e.g. during document edit.
  + * <p>
  + * Fires the event <tt>PreferenceEditor.refresh.seamNameOfThePreferenceComponent</tt> after the values
  + * of a preference components are changed, used inside a conversation to re-read the state from the
  + * edited prefrence value holders into the preference component instances.
  + * </p>
  + * <p>
  + * Fires the event <tt>PreferenceComponent.refresh.seamNameOfThePreferenceComponent</tt> after the
  + * preference component instances are refreshed. This allows clients of theses components to reload
  + * their state, e.g. re-render themselves with new settings.
  + * </p>
  + * @author Christian Bauer
  + */
   public class PluginPreferenceEditor implements Serializable {
   
       private String pluginPreferenceName;
  @@ -40,6 +60,10 @@
   
       }
   
  +    public PreferenceComponent getPreferenceComponent() {
  +        return preferenceComponent;
  +    }
  +
       public List<PreferenceValue> getPreferenceValues() {
           return preferenceValues;
       }
  @@ -67,7 +91,11 @@
                   PreferenceProvider provider = (PreferenceProvider)Component.getInstance("preferenceProvider");
                   preferenceValues = new ArrayList<PreferenceValue>(provider.store(preferenceComponent, new HashSet<PreferenceValue>(preferenceValues), user, instance));
   
  +                // Reload the preference values from the edited value holders into the preference component instance
                   Events.instance().raiseEvent("PreferenceEditor.refresh." + preferenceComponent.getName());
  +
  +                // Notify users of the preference component
  +                Events.instance().raiseEvent("PreferenceComponent.refresh." + preferenceComponent.getName());
               }
           }
   
  
  
  
  1.9       +36 -80    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Menu.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Menu.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Menu.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- Menu.java	9 Jul 2007 16:37:40 -0000	1.8
  +++ Menu.java	17 Aug 2007 13:00:28 -0000	1.9
  @@ -1,102 +1,58 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
  -import org.jboss.seam.annotations.*;
   import org.jboss.seam.ScopeType;
  -import org.jboss.seam.Component;
  -import org.jboss.seam.security.Identity;
  -import org.jboss.seam.wiki.core.model.Node;
  +import org.jboss.seam.annotations.In;
  +import org.jboss.seam.annotations.Name;
  +import org.jboss.seam.annotations.Observer;
  +import org.jboss.seam.annotations.Scope;
  +import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
  +import org.jboss.seam.wiki.core.dao.NodeDAO;
   import org.jboss.seam.wiki.core.model.Directory;
  -import org.jboss.seam.wiki.util.WikiUtil;
  +import org.jboss.seam.wiki.core.model.Node;
  +import org.jboss.seam.wiki.core.nestedset.NestedSetNodeWrapper;
   
  -import java.util.List;
  -import java.util.ArrayList;
   import java.io.Serializable;
   
   /**
    * Holds the nodes that are displayed in the site menu
  - * <p>
  - * For performance reasons we cache this in the session context and refresh it through observing of
  - * modification events. This might be PAGE scoped once we have a nested set model for the node tree.
  - * </p>
  - * Looks up the <tt>menuBase</tt> contextual variable; if present, this is the root <tt>Directory</tt>
  - * of the rendered menu. Otherwise, the wiki root is the base. Note that the menu is only rendered two
  - * levels deep visually but that it includes all subtree nodes that are menu items. Everything deeper
  - * than the second level is rendered on the second level.
    *
    * @author Christian Bauer
    */
   @Name("menu")
  - at Scope(ScopeType.SESSION)
  + at Scope(ScopeType.PAGE)
   public class Menu implements Serializable {
   
  -    @In(required = false)
  -    Directory menuBase;
  -    Directory lastMenuBase;
  -
  -    private List<MenuItem> items;
  -    public List<MenuItem> getItems() {
  -        if (items == null) refreshMenuItems();
  -        return items;
  -    }
  +    @In
  +    Directory wikiRoot;
   
  -    /** 
  -     * This is very inefficient. There really is no better way if we want recursively have
  -     * all documents and directories with isMenuItem() in the menu. Not even a direct
  -     * SQL query would help (multicolumn ordering would require by PK, not good). If this
  -     * can't be made performant with caching, we need to replace it with a simple one
  -     * or two level menu item search. Currently optimizing with batch fetching, future
  -     * implementation might use a nested set approach.
  -     */
  -    @Observer("Nodes.menuStructureModified")
  -    public void refreshMenuItems() {
  -        System.out.println("################################ REFRESHING MENU ########################### ");
  -        items = new ArrayList<MenuItem>();
  -        if (menuBase != null && lastMenuBase != menuBase) {
  -            lastMenuBase = menuBase;
  -        } else {
  -            menuBase = (Directory)Component.getInstance("restrictedWikiRoot");
  -        }
  -        for(Node child: menuBase.getChildren())
  -            addNodesToMenuTree(items, 0, child);
  -    }
  +    @In
  +    NodeDAO nodeDAO;
   
  -    // Recursive
  -    private void addNodesToMenuTree(List<MenuItem> menuItems, int i, Node node) {
  -        MenuItem menuItem = new MenuItem(node, WikiUtil.renderURL(node));
  -        menuItem.setLevel(i);
  -        if (node.isMenuItem() && Identity.instance().hasPermission("Node", "read", node))
  -            menuItems.add(menuItem); // Check flag in-memory
  -        if (node.getChildren() != null && node.getChildren().size() > 0) {
  -            i++;
  -            for (Node child : node.getChildren()) {
  -                if (i > 1)
  -                    // Flatten the menu tree into two levels (simple display)
  -                    addNodesToMenuTree(menuItems, i, child);
  -                else
  -                    addNodesToMenuTree(menuItem.getSubItems(), i, child);
  -            }
  -        }
  -    }
  -
  -    public class MenuItem implements Serializable {
  -        private Node node;
  -        private int level;
  -        private List<MenuItem> subItems = new ArrayList<MenuItem>();
  -        private String url;
  -
  -        public MenuItem(Node node, String url) { this.node = node; this.url = url; }
  -
  -        public Node getNode() { return node; }
  -        public void setNode(Node node) { this.node = node; }
  +    @In
  +    WikiPreferences wikiPreferences;
   
  -        public int getLevel() { return level; }
  -        public void setLevel(int level) { this.level = level; }
  +    NestedSetNodeWrapper<Node> root;
   
  -        public List<MenuItem> getSubItems() { return subItems; }
  -        public void setSubItems(List<MenuItem> subItems) { this.subItems = subItems; }
  -
  -        public String getUrl() { return url; }
  -        public void setUrl(String url) { this.url = url; }
  +    public NestedSetNodeWrapper<Node> getRoot() {
  +        if (root == null) {
  +            refreshRoot();
  +        }
  +        return root;
       }
       
  +    @Observer("Nodes.menuStructureModified")
  +    public void refreshRoot() {
  +        root = nodeDAO.findMenuItems(
  +                wikiRoot,
  +                wikiPreferences.getMainMenuDepth(), 
  +                wikiPreferences.getMainMenuLevels(),
  +                wikiPreferences.isMainMenuShowAdminOnly()
  +        );
  +    }
   }
  
  
  
  1.14      +41 -1     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UserHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- UserHome.java	6 Jul 2007 14:38:36 -0000	1.13
  +++ UserHome.java	17 Aug 2007 13:00:28 -0000	1.14
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.Component;
  @@ -17,13 +23,16 @@
   import org.jboss.seam.wiki.core.dao.UserDAO;
   import org.jboss.seam.wiki.core.model.Role;
   import org.jboss.seam.wiki.core.model.User;
  +import org.jboss.seam.wiki.core.ui.FileMetaMap;
   import org.jboss.seam.wiki.preferences.PreferenceComponent;
   import org.jboss.seam.wiki.preferences.PreferenceVisibility;
   import org.jboss.seam.wiki.util.Hash;
  +import org.jboss.seam.wiki.util.WikiUtil;
   
   import javax.faces.application.FacesMessage;
   import java.util.List;
   import java.util.ArrayList;
  +import java.util.Map;
   import java.util.regex.Matcher;
   import java.util.regex.Pattern;
   
  @@ -49,9 +58,12 @@
       @In
       private Hash hashUtil;
   
  -    @In
  +    @In(create = true)
       private Renderer renderer;
   
  +    @In
  +    Map<String, FileMetaMap.FileMetaInfo> fileMetaMap;
  +
       @DataModel
       private List<PreferenceComponent> userPreferenceComponents;
       PreferenceEditor preferenceEditor;
  @@ -61,6 +73,9 @@
       private String passwordControl;
       private List<Role> roles;
       private org.jboss.seam.wiki.core.model.Role defaultRole;
  +    private String portraitContentType;
  +    // TODO: This should really use an InputStream and directly stream into the BLOB without consuming server memory
  +    private byte[] portraitImageData;
   
       @Override
       public Object getId() {
  @@ -200,6 +215,25 @@
           // User changed his username
           if (!getInstance().getUsername().equals(oldUsername)) loginCredentialsModified = true;
   
  +        // Profile image upload
  +        if (portraitImageData != null && portraitImageData.length > 0) {
  +
  +            if (fileMetaMap.get(portraitContentType) != null &&
  +                fileMetaMap.get(portraitContentType).image) {
  +                getLog().debug("updating portrait file data/type");
  +                getInstance().getProfile().setImageContentType(portraitContentType);
  +                getInstance().getProfile().setImage(
  +                        WikiUtil.resizeImage(portraitImageData, portraitContentType, 120)
  +                );
  +            } else {
  +                facesMessages.addFromResourceBundleOrDefault(
  +                    FacesMessage.SEVERITY_ERROR,
  +                    getMessageKeyPrefix() + "wrongPortraitImageType",
  +                    "The file type '" + portraitContentType + "' is not supported, the portrait hasn't been updated."
  +                );
  +            }
  +        }
  +
           String outcome = super.update();
           if (outcome != null) {
   
  @@ -263,6 +297,12 @@
       public String getPasswordControl() { return passwordControl; }
       public void setPasswordControl(String passwordControl) { this.passwordControl = passwordControl; }
   
  +    public String getPortraitContentType() { return portraitContentType; }
  +    public void setPortraitContentType(String portraitContentType) { this.portraitContentType = portraitContentType; }
  +
  +    public byte[] getPortraitImageData() { return portraitImageData; }
  +    public void setPortraitImageData(byte[] portraitImageData) { this.portraitImageData = portraitImageData; }
  +
       public List<Role> getRoles() { return roles; }
       @Restrict("#{s:hasPermission('User', 'editRoles', currentUser)}")
       public void setRoles(List<Role> roles) { this.roles = roles; }
  
  
  
  1.21      +28 -13    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHome.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -b -r1.20 -r1.21
  --- NodeHome.java	9 Jul 2007 16:37:40 -0000	1.20
  +++ NodeHome.java	17 Aug 2007 13:00:28 -0000	1.21
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import static javax.faces.application.FacesMessage.SEVERITY_ERROR;
  @@ -113,6 +119,7 @@
           // Load the parent directory (needs to be called first)
           // The parentDirectory (and parentDirId) parameter can actually be null but this only happens
           // when the wiki root is edited... it can only be update()ed anyway, all the other code is null-safe.
  +        log.trace("loading parent directory: " + parentDirId);
           parentDirectory = nodeDAO.findDirectory(parentDirId);
   
           if (parentDirectory == null)
  @@ -145,9 +152,11 @@
           setWikiName();
   
           // Link the node with its parent directory
  +        log.trace("linking new node with its parent directory");
           getParentDirectory().addChild(getInstance());
   
           // Set created by user
  +        log.trace("setting created by user: " + getCurrentUser());
           getInstance().setCreatedBy(getCurrentUser());
   
           // Set its area number (if subclass didn't already set it)
  @@ -158,11 +167,14 @@
           if (!isValidModel()) return null;
   
           if (!beforePersist()) return null;
  +        log.trace("persisting new node");
           String outcome = super.persist();
   
           // Notify any plugin preferences editors to also flush
  +        log.trace("notifying preference editors to also flush");
           Events.instance().raiseEvent("PreferenceEditor.flushAll");
   
  +        log.trace("completed persistsing of new node");
           return outcome;
       }
   
  @@ -185,12 +197,11 @@
           if (!beforeUpdate()) return null;
           String outcome = super.update();
   
  -        // Refresh UI
  -        refreshMenuItems();
  -
           // Notify any plugin preferences editors to also flush
           Events.instance().raiseEvent("PreferenceEditor.flushAll");
   
  +        Events.instance().raiseEvent("Nodes.menuStructureModified");
  +
           return outcome;
       }
   
  @@ -199,10 +210,7 @@
           if (!prepareRemove()) return null;
   
           // Unlink the node from its directory
  -        getInstance().getParent().removeChild(getInstance());
  -
  -        // Refresh UI
  -        refreshMenuItems();
  +        getParentDirectory().removeChild(getInstance());
   
           if (!beforeRemove()) return null;
   
  @@ -210,10 +218,15 @@
           PreferenceProvider provider = (PreferenceProvider) Component.getInstance("preferenceProvider");
           provider.deleteInstancePreferences(getInstance());
   
  -        return super.remove();
  +        String outcome = super.remove();
  +
  +        Events.instance().raiseEvent("Nodes.menuStructureModified");
  +
  +        return outcome;
       }
   
       protected boolean isValidModel() {
  +        log.trace("validating model");
           if (getParentDirectory() == null) return true; // Special case, editing the wiki root
   
           // Unique wiki name
  @@ -234,29 +247,31 @@
       /* -------------------------- Internal Methods ------------------------------ */
   
       protected void setWikiName() {
  +        log.trace("setting wiki name of new node");
           getInstance().setWikiname(WikiUtil.convertToWikiName(getInstance().getName()));
       }
   
       protected void setLastModifiedMetadata() {
  +        log.trace("setting last modified metadata");
           getInstance().setLastModifiedBy(currentUser);
           getInstance().setLastModifiedOn(new Date());
       }
   
       protected void checkNodeAccessLevelChangePermission() {
  +        /*
  +        log.trace("checking access level change permission");
           if (!Identity.instance().hasPermission("Node", "changeAccessLevel", getInstance()))
               throw new AuthorizationException("You don't have permission for this operation");
  +            */
       }
   
       protected void removeAsDefaultDocument(Directory directory) {
  +        log.trace("removing node as the default document from directory: " + directory);
           if (directory.getDefaultDocument() != null &&
               directory.getDefaultDocument().getId().equals(getInstance().getId())
              ) directory.setDefaultDocument(null);
       }
   
  -    protected void refreshMenuItems() {
  -        Events.instance().raiseEvent("Nodes.menuStructureModified");
  -    }
  -
       /* -------------------------- Subclass Callbacks ------------------------------ */
   
       /**
  @@ -320,7 +335,7 @@
               removeAsDefaultDocument(oldParentDirectory);
   
               // Attach to new parent
  -            parentDirectory.addChild(getInstance()); // Disconnects from old parent
  +            getInstance().setParent(parentDirectory); // TODO: Disconnects from old parent?
               getInstance().setAreaNumber(parentDirectory.getAreaNumber());
   
               afterNodeMoved(oldParentDirectory, parentDirectory);
  
  
  
  1.7       +13 -2     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Authenticator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- Authenticator.java	26 Jun 2007 22:47:52 -0000	1.6
  +++ Authenticator.java	17 Aug 2007 13:00:28 -0000	1.7
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
  @@ -89,6 +95,7 @@
           homeDirectory.setCreatedBy(user);
           homeDirectory.setWriteAccessLevel(UserRoleAccessFactory.ADMINROLE_ACCESSLEVEL);
           homeDirectory.setReadAccessLevel(UserRoleAccessFactory.GUESTROLE_ACCESSLEVEL);
  +        homeDirectory.setMenuItem(true);
           memberArea.addChild(homeDirectory);
           user.setMemberHome(homeDirectory);
   
  @@ -106,12 +113,16 @@
           homePage.setWikiname(WikiUtil.convertToWikiName(homePage.getName()));
           homePage.setCreatedBy(user);
           homePage.setAreaNumber(homeDirectory.getAreaNumber());
  -        homePage.setContent("This is the homepage of " + user.getFullname() + ".");
  +        homePage.setContent(
  +            ((UserManagementPreferences)Component.getInstance("userManagementPreferences")).getHomepageDefaultContent()
  +        );
           homePage.setWriteAccessLevel(UserRoleAccessFactory.ADMINROLE_ACCESSLEVEL);
           homePage.setReadAccessLevel(UserRoleAccessFactory.GUESTROLE_ACCESSLEVEL);
  +        homePage.setMenuItem(true);
           homeDirectory.addChild(homePage);
           homeDirectory.setDefaultDocument(homePage);
  -        nodeDAO.makePersistent(homeDirectory);
  +
  +        nodeDAO.makePersistent(homePage);
       }
   
       public String logout() {
  
  
  
  1.7       +10 -5     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHistory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeHistory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeHistory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- NodeHistory.java	6 Jul 2007 14:38:36 -0000	1.6
  +++ NodeHistory.java	17 Aug 2007 13:00:28 -0000	1.7
  @@ -1,6 +1,7 @@
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
  +import org.jboss.seam.annotations.web.RequestParameter;
   import org.jboss.seam.annotations.security.Restrict;
   import org.jboss.seam.annotations.datamodel.DataModel;
   import org.jboss.seam.annotations.datamodel.DataModelSelection;
  @@ -37,12 +38,15 @@
       @DataModel
       private List<Node> historicalNodeList;
   
  +    @RequestParameter
  +    Long nodeId;
  +
       @DataModelSelection
       @Out(required = false, scope = ScopeType.CONVERSATION)
  -    private Node selectedHistoricalNode;
  +    private Document selectedHistoricalNode;
   
  -    @In @Out(scope = ScopeType.CONVERSATION)
  -    private Node currentNode;
  +    @In(required = false) @Out(scope = ScopeType.CONVERSATION)
  +    private Document currentNode;
   
       private String diffResult;
   
  @@ -54,6 +58,7 @@
   
       @Create
       public void create() {
  +        currentNode = nodeDAO.findDocument(nodeId);
           if (!Identity.instance().hasPermission("Node", "read", currentNode) ) {
               throw new AuthorizationException("You don't have permission for this operation");
           }
  @@ -73,8 +78,8 @@
       public void diff() {
   
           // Wiki text parser needs these nodes but we don't really care because links are not rendered and resolved
  -        String revision = renderWikiText( (Document)currentNode, (Directory)currentNode.getParent(), ((Document)currentNode).getContent() );
  -        String original = renderWikiText( (Document)selectedHistoricalNode, (Directory)currentNode.getParent(), ((Document)selectedHistoricalNode).getContent() );
  +        String revision = renderWikiText( currentNode, currentNode.getParent(), currentNode.getContent() );
  +        String original = renderWikiText( selectedHistoricalNode, currentNode.getParent(), selectedHistoricalNode.getContent() );
   
           // Create diff by comparing rendered HTML
           Diff diff = new Diff() {
  
  
  
  1.4       +9 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodePermissions.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodePermissions.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodePermissions.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- NodePermissions.java	2 Apr 2007 18:25:06 -0000	1.3
  +++ NodePermissions.java	17 Aug 2007 13:00:28 -0000	1.4
  @@ -1,9 +1,16 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.In;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Create;
  +import org.jboss.seam.annotations.security.Restrict;
   import org.jboss.seam.wiki.core.model.Node;
   import org.jboss.seam.wiki.core.model.Role;
   import org.jboss.seam.wiki.core.dao.UserRoleAccessFactory;
  @@ -46,6 +53,7 @@
           return writeAccessLevel;
       }
   
  +    @Restrict("#{s:hasPermission('Node', 'changeAccessLevel', currentNode)}")
       public void setWriteAccessLevel(Role.AccessLevel writeAccessLevel) {
           this.writeAccessLevel = writeAccessLevel;
           currentNode.setWriteAccessLevel(
  @@ -57,6 +65,7 @@
           return readAccessLevel;
       }
   
  +    @Restrict("#{s:hasPermission('Node', 'changeAccessLevel', currentNode)}")
       public void setReadAccessLevel(Role.AccessLevel readAccessLevel) {
           this.readAccessLevel = readAccessLevel;
           currentNode.setReadAccessLevel(
  
  
  
  1.19      +13 -3     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeBrowser.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeBrowser.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeBrowser.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -b -r1.18 -r1.19
  --- NodeBrowser.java	6 Jul 2007 14:38:36 -0000	1.18
  +++ NodeBrowser.java	17 Aug 2007 13:00:28 -0000	1.19
  @@ -1,6 +1,13 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
  +import org.jboss.seam.annotations.Observer;
   import org.jboss.seam.annotations.web.RequestParameter;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.Component;
  @@ -181,11 +188,14 @@
       public void captureConversationEntryPoint() {
           if (lastConversationId != null) {
               ConversationEntries allConversations = ConversationEntries.instance();
  +            if (allConversations.getConversationEntry(lastConversationId) != null) {
               Contexts.getConversationContext()
                       .set("conversationEntryPoint", allConversations.getConversationEntry(lastConversationId));
           }
       }
  +    }
   
  +    @Observer("NodeBrowser.prepare")
       @Transactional
       public String prepare() {
   
  @@ -208,7 +218,7 @@
   
               } else {
                   // Document found, take its directory
  -                currentDirectory = currentDocument.getParent();
  +                currentDirectory = (Directory)currentDocument.getParent();
               }
   
           // Have we been called with an areaName and nodeName request parameter
  
  
  
  1.18      +11 -10    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- DocumentHome.java	6 Jul 2007 14:38:36 -0000	1.17
  +++ DocumentHome.java	17 Aug 2007 13:00:28 -0000	1.18
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
  @@ -10,9 +16,6 @@
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.contexts.Contexts;
   
  -import java.util.List;
  -import java.util.ArrayList;
  -
   @Name("documentHome")
   @Scope(ScopeType.CONVERSATION)
   public class DocumentHome extends NodeHome<Document> {
  @@ -104,6 +107,11 @@
           return true;
       }
   
  +    protected boolean beforeRemove() {
  +        removeAsDefaultDocument(getParentDirectory());
  +        return super.beforeRemove();
  +    }
  +
       protected void afterNodeMoved(Directory oldParent, Directory newParent) {
           // Update view
           syncFormToInstance(oldParent); // Resolve existing links in old directory
  @@ -168,11 +176,4 @@
           return showPluginPrefs != null ? showPluginPrefs : false;
       }
   
  -    public List<String> autoCompleteLink(Object incompleteLink) {
  -        System.out.printf("################# COMPLETE THIS: " + incompleteLink);
  -        return new ArrayList<String>() {{
  -            add("Foo");
  -            add("Bar");
  -        }};
  -    }
   }
  
  
  
  1.7       +11 -6     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CommentHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- CommentHome.java	21 Jun 2007 11:05:49 -0000	1.6
  +++ CommentHome.java	17 Aug 2007 13:00:28 -0000	1.7
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.core.action;
   
   import org.jboss.seam.annotations.*;
  @@ -6,10 +12,7 @@
   import org.jboss.seam.security.Identity;
   import org.jboss.seam.security.AuthorizationException;
   import org.jboss.seam.faces.FacesMessages;
  -import org.jboss.seam.wiki.core.model.Document;
  -import org.jboss.seam.wiki.core.model.User;
  -import org.jboss.seam.wiki.core.model.Directory;
  -import org.jboss.seam.wiki.core.model.Comment;
  +import org.jboss.seam.wiki.core.model.*;
   import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
   import org.jboss.seam.wiki.util.WikiUtil;
   
  @@ -33,7 +36,7 @@
       Document currentDocument;
   
       @In
  -    Directory currentDirectory;
  +    Node currentDirectory;
   
       @In
       User currentUser;
  @@ -85,7 +88,9 @@
       public void persist() {
   
           entityManager.joinTransaction();
  -        comment.setDocument(entityManager.merge(currentDocument));
  +        currentDocument = entityManager.merge(currentDocument);
  +        comment.setDocument(currentDocument);
  +        currentDocument.getComments().add(comment);
   
           // Null out the property so that the @Email validator doesn't fall over it...
           // I hate JSF and its "let's set an empty string" behavior
  
  
  



More information about the jboss-cvs-commits mailing list