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

Christian Bauer christian at hibernate.org
Sun Apr 22 15:19:29 EDT 2007


  User: cbauer  
  Date: 07/04/22 15:19:29

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/core/action   
                        NodeBrowser.java UserSearch.java UserHome.java
  Log:
  Added feature: Manual account creation (for admins)
  
  Revision  Changes    Path
  1.11      +23 -9     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.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- NodeBrowser.java	4 Apr 2007 10:38:13 -0000	1.10
  +++ NodeBrowser.java	22 Apr 2007 19:19:29 -0000	1.11
  @@ -3,17 +3,16 @@
   import org.jboss.seam.annotations.*;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.Component;
  +import org.jboss.seam.log.Log;
   import org.jboss.seam.contexts.Contexts;
  -import org.jboss.seam.core.Conversation;
  -import org.jboss.seam.core.Manager;
  -import org.jboss.seam.core.ConversationEntries;
  -import org.jboss.seam.core.ConversationEntry;
  +import org.jboss.seam.core.*;
   import org.jboss.seam.security.Identity;
   import org.jboss.seam.wiki.core.dao.NodeDAO;
   import org.jboss.seam.wiki.core.model.*;
   import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
   import org.jboss.seam.wiki.util.WikiUtil;
   
  +import javax.faces.application.FacesMessage;
   import java.util.*;
   import java.io.Serializable;
   
  @@ -43,6 +42,8 @@
   @AutoCreate
   public class NodeBrowser implements Serializable {
   
  +    @Logger static Log log;
  +
       @RequestParameter
       protected String areaName;
   
  @@ -122,30 +123,43 @@
           Conversation currentConversation = Conversation.instance();
           if (currentConversation.isNested()) {
               // End this nested conversation and return to last rendered view-id of parent
  +            log.debug("ending current conversation and redirecting to last view of the parent conversation");
               currentConversation.endAndRedirect(endBeforeRedirect);
           } else {
               // Always end this conversation
  +            log.debug("ending conversation");
               currentConversation.end();
   
               ConversationEntry entryPoint =
                       (ConversationEntry)Contexts.getConversationContext().get("conversationEntryPoint");
               if (entryPoint != null) {
  -                // We came here from another conversation
  +                log.debug("entry-point of this conversation has been another conversation");
                   if (entryPoint.isDisplayable()) {
  +
  +                    // Get messages for propagation
  +                    FacesMessages messages = (FacesMessages)Component.getInstance("facesMessages");
  +
  +                    log.debug("switching to entry-point conversation");
                       entryPoint.switchConversation();
  +
  +                    log.debug("propagating faces messages from the ended conversation into the destination conversation");
  +                    Contexts.getConversationContext().set("org.jboss.seam.core.facesMessages", messages);
                   } else {
  -                    // The entry point is gone... What now? Go to start page...
  +                    log.debug("the entry-point of this conversation is gone, redirecting to wiki start page");
                       Manager.instance().redirect("/display.xhtml", new HashMap<String,Object>(), true);
                   }
               } else {
  -                // We came here from a non-conversational page
  -                if (endBeforeRedirect)
  +                log.debug("entry-point of this conversation has been a non-conversational page we remembered");
  +                if (endBeforeRedirect) {
  +                    log.debug("redirecting to last browsed page without propagating the ended conversation");
                       redirectToLastBrowsedPage();
  -                else
  +                } else {
  +                    log.debug("redirecting to last browsed page and propagating the ended conversation across redirect");
                       redirectToLastBrowsedPageWithConversation();
               }
           }
       }
  +    }
   
       // Just a convenience method for recursive calling
       protected void addDirectoryToPath(List<Node> path, Node directory) {
  
  
  
  1.5       +0 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserSearch.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  
  
  
  1.7       +49 -35    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.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- UserHome.java	19 Apr 2007 18:36:12 -0000	1.6
  +++ UserHome.java	22 Apr 2007 19:19:29 -0000	1.7
  @@ -8,6 +8,8 @@
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.core.FacesMessages;
   import org.jboss.seam.core.Renderer;
  +import org.jboss.seam.core.Conversation;
  +import org.jboss.seam.core.Events;
   import org.jboss.seam.framework.EntityHome;
   import org.jboss.seam.security.AuthorizationException;
   import org.jboss.seam.security.Identity;
  @@ -111,6 +113,10 @@
           // Set password hash
           getInstance().setPasswordHash(hashUtil.hash(getPassword()));
   
  +        if (Identity.instance().hasPermission("User", "isAdmin", Component.getInstance("currentUser"))) {
  +            // Current user is admin and creating a new account, the new account is active automatically
  +            return super.persist();
  +        } else {
           // Set activation code (unique user in time)
           String seed = getInstance().getUsername() + System.currentTimeMillis() + userManagementPreferences.getActivationCodeSalt();
           getInstance().setActivationCode( ((Hash)Component.getInstance("hashUtil")).hash(seed) );
  @@ -146,9 +152,9 @@
                   return "error";
               }
           }
  -
           return outcome;
       }
  +    }
   
       @Restrict("#{s:hasPermission('User', 'edit', userHome.instance)}")
       public String update() {
  @@ -220,7 +226,11 @@
           // All nodes created by this user are reset to be created by the admin user
           userDAO.resetNodeCreatorToAdmin(getInstance());
           
  -        return super.remove();
  +        String outcome = super.remove();
  +        if (outcome != null) {
  +            browser.exitConversation(false);
  +        }
  +        return outcome;
       }
   
       protected String getCreatedMessageKey() {
  @@ -228,7 +238,7 @@
       }
   
       public String getCreatedMessage() {
  -        return "Your account '" + getInstance().getUsername() + "' has been created.";
  +        return "The account '" + getInstance().getUsername() + "' has been created.";
       }
   
       protected String getUpdatedMessageKey() {
  @@ -239,6 +249,10 @@
           return "The user '" + getInstance().getUsername() + "' has been updated.";
       }
   
  +    public String getDeletedMessage() {
  +        return "The user '" + getInstance().getUsername() + "' has been deleted.";
  +    }
  +
       public String getPassword() { return password; }
       public void setPassword(String password) { this.password = password; }
   
  
  
  



More information about the jboss-cvs-commits mailing list