roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r225230 [1/2] - in /incubator/roller/branches/roller_2.0: metadata/database/ src/org/roller/business/ src/org/roller/model/ src/org/roller/pojos/ src/org/roller/presentation/ src/org/roller/presentation/util/ src/org/roller/presentation/web...
Date Tue, 26 Jul 2005 04:35:38 GMT
Author: snoopdave
Date: Mon Jul 25 21:35:24 2005
New Revision: 225230

URL: http://svn.apache.org/viewcvs?rev=225230&view=rev
Log:
First cut of group blogging actions and JSP.

Added:
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/SslUtil.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/StrutsUtil.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/NewWebsiteForm.java
Modified:
    incubator/roller/branches/roller_2.0/metadata/database/130-to-200-migration-raw.sql
    incubator/roller/branches/roller_2.0/metadata/database/createdb-raw.sql
    incubator/roller/branches/roller_2.0/src/org/roller/business/UserManagerImpl.java
    incubator/roller/branches/roller_2.0/src/org/roller/model/UserManager.java
    incubator/roller/branches/roller_2.0/src/org/roller/pojos/UserData.java
    incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteData.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/BasePageModel.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/InviteMemberAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/MemberPermissionsAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/NewWebsiteAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserBaseAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserNewAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourProfileAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourWebsitesAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/UserFormEx.java
    incubator/roller/branches/roller_2.0/src/org/roller/util/DateUtil.java
    incubator/roller/branches/roller_2.0/src/org/roller/util/Utilities.java
    incubator/roller/branches/roller_2.0/tests/org/roller/RollerTestBase.java
    incubator/roller/branches/roller_2.0/tests/org/roller/business/FileManagerTest.java
    incubator/roller/branches/roller_2.0/tests/org/roller/business/UserManagerTest.java
    incubator/roller/branches/roller_2.0/web/index.jsp
    incubator/roller/branches/roller_2.0/web/website/NewWebsite.jsp
    incubator/roller/branches/roller_2.0/web/website/UserNew.jsp
    incubator/roller/branches/roller_2.0/web/website/YourProfile.jsp

Modified: incubator/roller/branches/roller_2.0/metadata/database/130-to-200-migration-raw.sql
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/metadata/database/130-to-200-migration-raw.sql?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/metadata/database/130-to-200-migration-raw.sql (original)
+++ incubator/roller/branches/roller_2.0/metadata/database/130-to-200-migration-raw.sql Mon Jul 25 21:35:24 2005
@@ -19,6 +19,7 @@
 
 -- Add new handle field to uniquely identify websites in URLs
 alter table website add column handle varchar(255) @ALTER_TABLE_NOT_NULL@;
+alter table website add column datecreated  timestamp @ALTER_TABLE_NOT_NULL@;
 create index website_handle_index on userrole(handle);
 alter table website add constraint website_handle_uq unique (handle@INDEXSIZE@);
 

Modified: incubator/roller/branches/roller_2.0/metadata/database/createdb-raw.sql
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/metadata/database/createdb-raw.sql?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/metadata/database/createdb-raw.sql (original)
+++ incubator/roller/branches/roller_2.0/metadata/database/createdb-raw.sql Mon Jul 25 21:35:24 2005
@@ -98,7 +98,8 @@
     timezone          varchar(50) null,  
     defaultplugins    varchar(255) null,
     pinnedtomain      @BOOLEAN_SQL_TYPE_FALSE@ not null,
-    isenabled         @BOOLEAN_SQL_TYPE_TRUE@ not null
+    isenabled         @BOOLEAN_SQL_TYPE_TRUE@ not null,
+    datecreated     timestamp not null
 );
 create index website_id_index        on website(id);
 create index website_userid_index    on website(userid);

Modified: incubator/roller/branches/roller_2.0/src/org/roller/business/UserManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/business/UserManagerImpl.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/business/UserManagerImpl.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/business/UserManagerImpl.java Mon Jul 25 21:35:24 2005
@@ -222,6 +222,9 @@
     public WebsiteData createWebsite(
             UserData ud, 
             Map pages, 
+            String handle,
+            String name, 
+            String description,
             String theme, 
             String locale, 
             String timezone) throws RollerException
@@ -229,24 +232,25 @@
         Roller mRoller = RollerFactory.getRoller();
         UserManager umgr = mRoller.getUserManager();
         WeblogManager wmgr = mRoller.getWeblogManager();
-
-        WebsiteData website = new WebsiteData(null,
-            ud.getFullName()+"'s Weblog", // name
-            ud.getUserName(),             // handle
-            ud.getFullName()+"'s Weblog", // description
-            ud,                 // userId
-            "dummy",            // defaultPageId
-            "dummy",            // weblogDayPageId
-            Boolean.TRUE,       // enableBloggerApi
-            null,               // bloggerCategory
-            null,               // defaultCategory
-            "editor-text.jsp",  // editorPage
-            "",                 // ignoreWords
-            Boolean.TRUE,       // allowComments  
-            Boolean.FALSE,      // emailComments
-            "",                 // emailFromAddress
-            Boolean.TRUE,       // isEnabled
-            "dummy@example.com");  // emailAddress
+        WebsiteData website = new WebsiteData(
+            null,                // id
+            name,                // name
+            handle,              // handle
+            description,         // description
+            ud,                  // userId
+            "dummy",             // defaultPageId
+            "dummy",             // weblogDayPageId
+            Boolean.TRUE,        // enableBloggerApi
+            null,                // bloggerCategory
+            null,                // defaultCategory
+            "editor-text.jsp",   // editorPage
+            "",                  // ignoreWords
+            Boolean.TRUE,        // allowComments  
+            Boolean.FALSE,       // emailComments
+            "",                  // emailFromAddress
+            Boolean.TRUE,        // isEnabled
+            "dummy@example.com", // emailAddress
+            new Date());
         website.setEditorTheme(theme);
         website.setLocale(locale);
         website.setTimezone(timezone);

Modified: incubator/roller/branches/roller_2.0/src/org/roller/model/UserManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/model/UserManager.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/model/UserManager.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/model/UserManager.java Mon Jul 25 21:35:24 2005
@@ -117,19 +117,24 @@
     public void addUser(UserData user) throws RollerException;
 
     /**
-     * @param ud
-     * @param pages
-     * @param theme
-     * @param locale
-     * @param timezone
-     * @param mRoller
-     * @param wmgr
-     * @return
+     * Create a fresh new website.
+     * @param ud          User creating website
+     * @param pages       Pages to be used in theme (TODO: elim. this redundancy)
+     * @param handle      Handle of new website
+     * @param name        Name of new website
+     * @param description Description of new website
+     * @param theme       Name of theme to be used
+     * @param locale      Locale code of new website
+     * @param timezone    ID of timezone of new website
+     * @return            New website object (has been saved and committed)
      * @throws RollerException
      */
     public WebsiteData createWebsite(
             UserData ud, 
             Map pages, 
+            String handle,
+            String name, 
+            String description,
             String theme, 
             String locale, 
             String timezone) throws RollerException;

Modified: incubator/roller/branches/roller_2.0/src/org/roller/pojos/UserData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/pojos/UserData.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/pojos/UserData.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/pojos/UserData.java Mon Jul 25 21:35:24 2005
@@ -39,15 +39,15 @@
    
    static final long serialVersionUID = -6354583200913127874L;
 
-   protected java.lang.String id;
-   protected java.lang.String userName;
-   protected java.lang.String password;
-   protected java.lang.String fullName;
-   protected java.lang.String emailAddress;
-   protected java.util.Date dateCreated;
+   protected String id;
+   protected String userName;
+   protected String password;
+   protected String fullName;
+   protected String emailAddress;
+   protected Date dateCreated;
    protected String  locale;
-   protected String  timezone;
-   protected Boolean isEnabled;
+   protected String  timeZone;
+   protected Boolean isEnabled = Boolean.TRUE;
    
    private Set roles = new TreeSet();
    private List permissions = new ArrayList();
@@ -56,11 +56,11 @@
    {
    }
 
-	public UserData( java.lang.String id, java.lang.String userName,
-                     java.lang.String password, java.lang.String fullName,
-                     java.lang.String emailAddress, 
+	public UserData( String id, String userName,
+                     String password, String fullName,
+                     String emailAddress, 
                      String locale, String timezone,
-                     java.util.Date dateCreated,
+                     Date dateCreated,
                      Boolean isEnabled)
 	{
          this.id = id;
@@ -70,7 +70,7 @@
          this.emailAddress = emailAddress;
          this.dateCreated = (Date)dateCreated.clone();
          this.locale = locale;
-         this.timezone = timezone;
+         this.timeZone = timezone;
          this.isEnabled = isEnabled;
 	}
 
@@ -123,12 +123,12 @@
      * @hibernate.id column="id" type="string"
      *  generator-class="uuid.hex" unsaved-value="null"
      */
-   public java.lang.String getId()
+   public String getId()
    {
       return this.id;
    }
    /** @ejb:persistent-field */ 
-   public void setId( java.lang.String id )
+   public void setId( String id )
    {
       this.id = id;
    }
@@ -137,12 +137,12 @@
      * @ejb:persistent-field 
      * @hibernate.property column="username" non-null="true" unique="true"
      */
-   public java.lang.String getUserName()
+   public String getUserName()
    {
       return this.userName;
    }
    /** @ejb:persistent-field */ 
-   public void setUserName( java.lang.String userName )
+   public void setUserName( String userName )
    {
       this.userName = userName;
    }
@@ -153,7 +153,7 @@
     * @ejb:persistent-field 
     * @hibernate.property column="passphrase" non-null="true"
     */
-   public java.lang.String getPassword()
+   public String getPassword()
    {
       return this.password;
    }
@@ -162,7 +162,7 @@
     * If password encryption is turned on, then pass in an encrypted password. 
     * @ejb:persistent-field 
     */ 
-   public void setPassword( java.lang.String password )
+   public void setPassword( String password )
    {
       this.password = password;
    }
@@ -171,12 +171,12 @@
      * @ejb:persistent-field 
      * @hibernate.property column="fullname" non-null="true" unique="true"
      */
-   public java.lang.String getFullName()
+   public String getFullName()
    {
       return this.fullName;
    }
    /** @ejb:persistent-field */ 
-   public void setFullName( java.lang.String fullName )
+   public void setFullName( String fullName )
    {
       this.fullName = fullName;
    }
@@ -185,12 +185,12 @@
      * @ejb:persistent-field 
      * @hibernate.property column="emailaddress" non-null="true" unique="true"
      */
-   public java.lang.String getEmailAddress()
+   public String getEmailAddress()
    {
       return this.emailAddress;
    }
    /** @ejb:persistent-field */ 
-   public void setEmailAddress( java.lang.String emailAddress )
+   public void setEmailAddress( String emailAddress )
    {
       this.emailAddress = emailAddress;
    }
@@ -199,7 +199,7 @@
 	* @ejb:persistent-field 
 	* @hibernate.property column="datecreated" non-null="true" unique="false"
 	*/
-   public java.util.Date getDateCreated()
+   public Date getDateCreated()
    {
        if (dateCreated == null) 
        {
@@ -211,7 +211,7 @@
        }
    }
    /** @ejb:persistent-field */ 
-   public void setDateCreated(final java.util.Date date)
+   public void setDateCreated(final Date date)
    {
 	   if (date != null) 
 	   {
@@ -244,15 +244,15 @@
     * @ejb:persistent-field
     * @hibernate.property column="timezone" non-null="true" unique="false"
     */
-   public String getTimezone()
+   public String getTimeZone()
    {
-       return this.timezone;
+       return this.timeZone;
    }
 
    /** @ejb:persistent-field */
-   public void setTimezone(String timezone)
+   public void setTimeZone(String timeZone)
    {
-       this.timezone = timezone;
+       this.timeZone = timeZone;
    }
 
    //------------------------------------------------------------------- citizenship
@@ -371,7 +371,7 @@
       this.fullName = ((UserData)otherData).fullName;
       this.emailAddress = ((UserData)otherData).emailAddress;
       this.locale = ((UserData)otherData).locale;
-      this.timezone = ((UserData)otherData).timezone;
+      this.timeZone = ((UserData)otherData).timeZone;
       this.dateCreated = ((UserData)otherData).dateCreated;
    }
 

Modified: incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteData.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteData.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteData.java Mon Jul 25 21:35:24 2005
@@ -1,6 +1,9 @@
 package org.roller.pojos;
 
+
+
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -49,6 +52,7 @@
     protected String  timezone;
     protected String  mDefaultPlugins;
     protected Boolean isEnabled;
+    protected Date dateCreated;
     
     // Associated objects
     protected UserData mUser = null; // TODO: decide if website.user is needed
@@ -77,7 +81,8 @@
                        final Boolean  emailComments,
                        final String   emailFromAddress,
                        final Boolean  isEnabled,
-                       final String   emailAddress)
+                       final String   emailAddress,
+                       final Date     dateCreated)
     {
         this.id = id;
         this.name = name;
@@ -96,6 +101,7 @@
         this.emailFromAddress = emailFromAddress;
         this.isEnabled = isEnabled;
         this.emailAddress = emailAddress;
+        this.dateCreated = dateCreated;
     }
 
     public WebsiteData(WebsiteData otherData)
@@ -431,6 +437,34 @@
         this.timezone = timezone;
     }
 
+    /** 
+    * @ejb:persistent-field 
+    * @hibernate.property column="datecreated" non-null="true" unique="false"
+    */
+   public Date getDateCreated()
+   {
+       if (dateCreated == null) 
+       {
+           return null;
+       }
+       else 
+       {
+           return (Date)dateCreated.clone();
+       }
+   }
+   /** @ejb:persistent-field */ 
+   public void setDateCreated(final Date date)
+   {
+       if (date != null) 
+       {
+           dateCreated = (Date)date.clone();
+       }
+       else
+       {
+           dateCreated = null;
+       }
+   }
+
     /**
      * Comma-delimited list of user's default Plugins.
      * @ejb:persistent-field
@@ -595,6 +629,7 @@
         this.timezone = other.timezone;
         this.mDefaultPlugins = other.mDefaultPlugins;
         this.isEnabled = other.isEnabled;
+        this.dateCreated = dateCreated;
     }
     
     /**

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/BasePageModel.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/BasePageModel.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/BasePageModel.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/BasePageModel.java Mon Jul 25 21:35:24 2005
@@ -5,12 +5,14 @@
 
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.struts.action.ActionMapping;
 import org.roller.RollerException;
+import org.roller.presentation.util.StrutsUtil;
 
 /**
  * Re-usable base for page models.
@@ -30,6 +32,8 @@
         this.request = request;
         this.response = response;
         this.mapping = mapping;
+        request.setAttribute("locales", StrutsUtil.getLocaleBeans());        
+        request.setAttribute("timezones", StrutsUtil.getTimeZoneBeans());        
     }
 
     public String getBaseURL()
@@ -86,5 +90,15 @@
     public boolean getIsAdmin() throws RollerException
     {
         return RollerSession.getRollerSession(request).isAdminUser(); 
+    }
+
+    public List getLocales()
+    {
+        return StrutsUtil.getLocaleBeans();
+    }
+
+    public List getTimeZones()
+    {
+        return StrutsUtil.getTimeZoneBeans();
     }
 }

Added: incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/SslUtil.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/SslUtil.java?rev=225230&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/SslUtil.java (added)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/SslUtil.java Mon Jul 25 21:35:24 2005
@@ -0,0 +1,131 @@
+package org.roller.presentation.util;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.roller.config.RollerConfig;
+
+/**
+ * SslUtil utility class Good ol' copy-n-paste from  <a
+ * href="http://www.javaworld.com/javaworld/jw-02-2002/ssl/utilityclass.txt">
+ * http://www.javaworld.com/javaworld/jw-02-2002/ssl/utilityclass.txt</a>
+ * which is referenced in the following article: <a
+ * href="http://www.javaworld.com/javaworld/jw-02-2002/jw-0215-ssl.html">
+ * http://www.javaworld.com/javaworld/jw-02-2002/jw-0215-ssl.html</a>
+ */
+public class SslUtil {
+    //~ Static fields/initializers =============================================
+
+    public static final String HTTP = "http";
+    public static final String HTTPS = "https";
+    public static final String HTTP_PORT_PARAM = "listenPort_http";
+    public static final String HTTPS_PORT_PARAM = "listenPort_https";
+    private static String HTTP_PORT = null;
+    private static String HTTPS_PORT = null;
+    public static final String STD_HTTP_PORT = "80";
+    public static final String STD_HTTPS_PORT = "443";
+
+    //~ Methods ================================================================
+
+    public static String getRedirectString(HttpServletRequest request,
+                                           ServletContext ctx, boolean isSecure) {
+        // get the port numbers from the application context
+        HTTP_PORT = RollerConfig.getProperty("securelogin.http.port");
+        HTTPS_PORT = RollerConfig.getProperty("securelogin.https.port");
+
+        // get the scheme we want to use for this page and
+        // get the scheme used in this request
+        String desiredScheme = isSecure ? HTTPS : HTTP;
+        String usingScheme = request.getScheme();
+
+        // Determine the port number we want to use
+        // and the port number we used in this request
+        String desiredPort = isSecure ? HTTPS_PORT : HTTP_PORT;
+        String usingPort = String.valueOf(request.getServerPort());
+
+        String urlString = null;
+
+        // Must also check ports, because of IE multiple redirect problem
+        if (!desiredScheme.equals(usingScheme) ||
+                !desiredPort.equals(usingPort)) {
+            urlString =
+                buildNewUrlString(request, desiredScheme, usingScheme,
+                                  desiredPort, usingPort);
+
+            // Temporarily store attributes in session
+            RequestUtil.stowRequestAttributes(request);
+        } else {
+            // Retrieve attributes from session
+            RequestUtil.reclaimRequestAttributes(request);
+        }
+
+        return urlString;
+    }
+
+    /**
+     * Builds the URL that we will redirect to
+     *
+     * @param request DOCUMENT ME!
+     * @param desiredScheme DOCUMENT ME!
+     * @param usingScheme DOCUMENT ME!
+     * @param desiredPort DOCUMENT ME!
+     * @param usingPort DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    private static String buildNewUrlString(HttpServletRequest request,
+                                            String desiredScheme,
+                                            String usingScheme,
+                                            String desiredPort, String usingPort) {
+        StringBuffer url = request.getRequestURL();
+
+        url.replace(0, usingScheme.length(), desiredScheme);
+
+        // Find the port used within the URL string
+        int startIndex = url.toString().indexOf(usingPort);
+
+        if (startIndex == -1) { // Port not found in URL
+
+            if ((!(STD_HTTPS_PORT.equals(desiredPort) &&
+                    HTTPS.equals(desiredScheme))) &&
+                    (!(STD_HTTP_PORT.equals(desiredPort) &&
+                    HTTP.equals(desiredScheme)))) {
+                startIndex =
+                    url.toString().indexOf("/",
+                                           url.toString().indexOf("/",
+                                                                  url.toString()
+                                                                     .indexOf("/") +
+                                                                  1) + 1);
+                url.insert(startIndex, ":" + desiredPort);
+            }
+        } else { // Port found in URL
+
+            if ((STD_HTTPS_PORT.equals(desiredPort) &&
+                    HTTPS.equals(desiredScheme)) ||
+                    (STD_HTTP_PORT.equals(desiredPort) &&
+                    HTTP.equals(desiredScheme))) {
+                url.delete(startIndex - 1, startIndex + usingPort.length());
+            } else { // desired port is not a default port
+
+                // Replace requested port with desired port number in URL string
+                url.replace(startIndex, startIndex + usingPort.length(),
+                            desiredPort);
+            }
+        }
+
+        // add query string, if any
+        String queryString = request.getQueryString();
+
+        if ((queryString != null) && (queryString.length() != 0)) {
+            url.append("?" + queryString);
+        } else {
+            queryString = RequestUtil.getRequestParameters(request);
+
+            if ((queryString != null) && (queryString.length() != 0)) {
+                url.append("?" + queryString);
+            }
+        }
+
+        return url.toString();
+    }
+}

Added: incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/StrutsUtil.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/StrutsUtil.java?rev=225230&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/StrutsUtil.java (added)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/util/StrutsUtil.java Mon Jul 25 21:35:24 2005
@@ -0,0 +1,88 @@
+package org.roller.presentation.util;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.TreeSet;
+
+import org.apache.struts.util.LabelValueBean;
+import org.roller.util.LocaleComparator;
+import org.roller.util.TimeZoneComparator;
+
+public class StrutsUtil
+{
+    public static ArrayList locales;
+    public static ArrayList timezones;
+    
+    //-----------------------------------------------------------------------
+    /**
+     * LabelValueBeans are Comparable but violate the
+     * equals() part of the TreeSet requirements.
+     * And the html:options tag won't recognize
+     * toString as a property.  So we have to put the
+     * Locales into a TreeSet to sort them, then convert
+     * them to LabelValueBeans to display them.
+     * Glad we only have to do this once.
+     * 
+     * @return List of LabelValueBeans, one for each locale available from the JVM
+     */
+    public static List getLocaleBeans() 
+    {
+        if (locales == null)
+        {
+            locales = new ArrayList();
+            TreeSet locTree = new TreeSet(new LocaleComparator());
+            Locale[] localeArray = Locale.getAvailableLocales();
+            for (int i=0; i<localeArray.length; i++)
+            {
+                locTree.add(localeArray[i]);
+            }
+            java.util.Iterator it = locTree.iterator();
+            while (it.hasNext())
+            {
+                Locale loc = (Locale)it.next();
+                locales.add(new LabelValueBean(
+                   loc.getDisplayName(),
+                   loc.toString()));
+            }
+
+        }
+        return locales;
+    }
+
+    //-----------------------------------------------------------------------
+    /**
+     * html:options tag recognizes "ID" as a property
+     * so we don't have to go through all the rigamarole (sp?)
+     * that we did for Locales.
+     */
+    public static List getTimeZoneBeans() 
+    {
+        if (timezones == null)
+        {
+            Date today = new Date();
+            timezones = new ArrayList();
+            TreeSet zoneTree = new TreeSet(new TimeZoneComparator());
+            String[] zoneArray = TimeZone.getAvailableIDs();
+            for (int i=0; i<zoneArray.length; i++)
+            {
+                zoneTree.add((TimeZone)TimeZone.getTimeZone(zoneArray[i]));
+            }
+            java.util.Iterator it = zoneTree.iterator();
+            while (it.hasNext())
+            {
+                StringBuffer sb = new StringBuffer();
+                TimeZone zone = (TimeZone)it.next();
+                sb.append(zone.getDisplayName(zone.inDaylightTime(today), TimeZone.SHORT));
+                sb.append(" - ");
+                sb.append(zone.getID());
+                timezones.add(new LabelValueBean(
+                   sb.toString(),
+                   zone.getID()));
+            }
+        }
+        return timezones;
+    }
+}

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/InviteMemberAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/InviteMemberAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/InviteMemberAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/InviteMemberAction.java Mon Jul 25 21:35:24 2005
@@ -32,6 +32,6 @@
         throws IOException, ServletException
     {
         ActionForward forward = mapping.findForward("inviteMembers.page");
-        return forward;
+        return forward; 
     }
 }

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/MemberPermissionsAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/MemberPermissionsAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/MemberPermissionsAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/MemberPermissionsAction.java Mon Jul 25 21:35:24 2005
@@ -16,7 +16,7 @@
 /**
  * Allows website admin to change website member permissions.
  * 
- * @struts.action path="/editor/memberPermissions" parameter="method"
+ * @struts.action path="/editor/memberPermissions" parameter="method" 
  * @struts.action-forward name="memberPermissions.page" path="/website/MemberPermissions.jsp"
  */
 public class MemberPermissionsAction extends DispatchAction

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/NewWebsiteAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/NewWebsiteAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/NewWebsiteAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/NewWebsiteAction.java Mon Jul 25 21:35:24 2005
@@ -1,37 +1,192 @@
 package org.roller.presentation.website.actions;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
 
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessages;
 import org.apache.struts.actions.DispatchAction;
+import org.roller.RollerException;
+import org.roller.model.RollerFactory;
+import org.roller.model.UserManager;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WebsiteData;
+import org.roller.presentation.BasePageModel;
+import org.roller.presentation.RollerContext;
+import org.roller.presentation.RollerRequest;
+import org.roller.presentation.RollerSession;
+import org.roller.presentation.website.formbeans.NewWebsiteForm;
 
 /**
  * Allows user to create a new website.
  * 
- * @struts.action path="/editor/newWebsite" parameter="method"
+ * @struts.action path="/editor/newWebsite" parameter="method" name="newWebsiteForm"
  * @struts.action-forward name="newWebsite.page" path="/website/NewWebsite.jsp"
+ * @struts.action-forward name="newWebsiteDone.page" path="/website/NewWebsiteDone.jsp"
  */
 public class NewWebsiteAction extends DispatchAction
 {
     private static Log mLogger =
         LogFactory.getFactory().getInstance(NewWebsiteAction.class);
     
-    public ActionForward edit(
-        ActionMapping       mapping,
-        ActionForm          actionForm,
-        HttpServletRequest  request,
-        HttpServletResponse response)
-        throws IOException, ServletException
+    /** If method param is not specified, use HTTP verb to pick method to call */
+    public ActionForward unspecified(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
     {
+        if (request.getMethod().equals("GET"))
+        {
+            return create(mapping, actionForm, request, response);
+        }
+        return save(mapping, actionForm, request, response);
+    }
+    
+    /** Present new website form to user */
+    public ActionForward create(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException
+    {
+        NewWebsiteForm form = (NewWebsiteForm)actionForm;
+        form.setLocale( Locale.getDefault().toString() );
+        form.setTimeZone( TimeZone.getDefault().getID() );      
+
+        request.setAttribute("model", 
+            new NewWebsitePageModel(request, response, mapping, null));
+        
         ActionForward forward = mapping.findForward("newWebsite.page");
         return forward;
+    }
+    
+    /** Save new website created by user */    
+    public ActionForward save(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException
+    {
+        NewWebsiteForm form = (NewWebsiteForm)actionForm;
+        ActionMessages msgs = new ActionMessages();
+        ActionMessages errors = validate(form, new ActionErrors());
+        if (!errors.isEmpty())
+        {
+            saveErrors(request, errors);
+        }
+        else try
+        {
+            // Add new user
+            RollerContext rollerContext = RollerContext.getRollerContext(request);
+            UserData user = 
+                RollerSession.getRollerSession(request).getAuthenticatedUser();
+            UserManager mgr = RollerFactory.getRoller().getUserManager(); 
+            
+            // Need system user to add new user
+            RollerFactory.getRoller().setUser(UserData.SYSTEM_USER);
+            HashMap pages = rollerContext.readThemeMacros(form.getTheme());
+            WebsiteData website = mgr.createWebsite(
+               user, 
+               pages, 
+               form.getHandle(), 
+               form.getName(), 
+               form.getDescription(), 
+               form.getTheme(), 
+               form.getLocale(), 
+               form.getTimeZone());
+            RollerFactory.getRoller().commit();
+
+            // Flush cache so user will immediately appear on index page
+            //PageCacheFilter.removeFromCache( request, ud );
+            //MainPageAction.flushMainPageCache();
+            
+            request.setAttribute("model", 
+                    new NewWebsitePageModel(request, response, mapping, website));                
+        }
+        catch (RollerException e)
+        {
+            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(e.getMessage()));
+            saveErrors(request,errors);          
+            mLogger.error("ERROR in createWebsite", e);
+        }
+        ActionForward forward = mapping.findForward("newWebsiteDone.page");
+        return forward;
+    }
+        
+    private ActionMessages validate(NewWebsiteForm form, ActionErrors errors)
+    {
+        return new ActionMessages();
+    }
+
+    public static class NewWebsitePageModel extends BasePageModel
+    {
+        private List themes; 
+        private String contextURL = null;
+        private String weblogURL = null;
+        private String rssURL = null;
+        public NewWebsitePageModel(HttpServletRequest request,
+                HttpServletResponse response, ActionMapping mapping, WebsiteData wd)
+        {
+            super(request, response, mapping);
+            RollerContext rollerContext = RollerContext.getRollerContext(request);
+            themes = Arrays.asList(rollerContext.getThemeNames());
+            if (wd != null) 
+            {
+                contextURL = rollerContext.getAbsoluteContextUrl(request);
+                weblogURL = contextURL + "/page/" + wd.getHandle();   
+                rssURL =    contextURL + "/rss/" + wd.getHandle();         
+            }
+        }
+        public String getContextURL()
+        {
+            return contextURL;
+        }
+        public void setContextURL(String contextURL)
+        {
+            this.contextURL = contextURL;
+        }
+        public String getRssURL()
+        {
+            return rssURL;
+        }
+        public void setRssURL(String rssURL)
+        {
+            this.rssURL = rssURL;
+        }
+        public List getThemes()
+        {
+            return themes;
+        }
+        public void setThemes(List themes)
+        {
+            this.themes = themes;
+        }
+        public String getWeblogURL()
+        {
+            return weblogURL;
+        }
+        public void setWeblogURL(String weblogURL)
+        {
+            this.weblogURL = weblogURL;
+        }
     }
 }

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserBaseAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserBaseAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserBaseAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserBaseAction.java Mon Jul 25 21:35:24 2005
@@ -2,10 +2,8 @@
 package org.roller.presentation.website.actions;
 
 import java.util.Collection;
-import java.util.Date;
 import java.util.Locale;
 import java.util.TimeZone;
-import java.util.TreeSet;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -24,6 +22,7 @@
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.website.formbeans.UserFormEx;
+import org.roller.util.DateUtil;
 import org.roller.util.Utilities;
 
 
@@ -37,9 +36,6 @@
     private static Log mLogger =
         LogFactory.getFactory().getInstance(UserBaseAction.class);
 
-    protected static Collection locales = null;
-    protected static Collection timezones = null;
-
     //------------------------------------------------------------------------
     /** Validate user form. TODO: replace with Struts validation. */
     protected ActionMessages validate( UserFormEx form, ActionMessages errors ) {
@@ -63,188 +59,6 @@
         }
         return errors;
     }
-
-    //-----------------------------------------------------------------------
-    /**
-     * Load Themes, Timezones, and Locales into the
-     * request for use in the UI.  As possible, also
-     * set the User's Website's Timezone and Locale
-     * into the Form object.
-     *
-     * @param request
-     * @param rreq
-     * @param ud
-     * @param form
-     * @throws RollerException
-     */
-    protected void loadRequestObjects(
-        HttpServletRequest request,
-        RollerRequest rreq,
-        UserData ud,
-        UserFormEx form)
-        throws RollerException
-    {
-        // prepare themes for interface
-        ServletContext ctx = rreq.getServletContext();
-        RollerContext rollerContext = RollerContext.getRollerContext(ctx);
-        String[] themes = rollerContext.getThemeNames();
-        request.setAttribute( "themes", themes );
-
-        // prepare locales & timezones
-        if (ud != null)
-        {
-            UserManager mgr = RollerFactory.getRoller().getUserManager();
-            WebsiteData website = (WebsiteData)mgr.getWebsites(ud, null).get(0);
-            //form.setLocale( website.getLocale() );
-            //form.setTimezone( website.getTimezone() );
-            form.setTheme( website.getEditorTheme() );
-        }
-        else
-        {
-            form.setLocale( Locale.getDefault().getDisplayName() );
-            form.setTimezone( TimeZone.getDefault().getID() );
-        }
-        loadOptionLists(request);
-    }
-
-    //-----------------------------------------------------------------------
-    /**
-     * If necessary, load the available Locales and Timezones
-     * into the static members.
-     * As a convenience this method places the Collections into
-     * request attributes roller.locales and roller.timezones.
-     *
-     * @author lance.lavandowska
-     */
-    protected void loadOptionLists(HttpServletRequest request)
-    {
-        // load Locales if necessary
-        if (UserBaseAction.locales == null)
-        {
-			loadLocaleCollection();
-        }
-        request.setAttribute("roller.locales", UserBaseAction.locales);
-
-        // load Timezones if necessary
-        if (UserBaseAction.timezones == null)
-        {
-			loadTimeZoneCollection();
-        }
-        request.setAttribute("roller.timezones", UserBaseAction.timezones);
-    }
-
-    //-----------------------------------------------------------------------
-	/**
-     * LabelValueBeans are Comparable but violate the
-     * equals() part of the TreeSet requirements.
-     * And the html:options tag won't recognize
-     * toString as a property.  So we have to put the
-     * Locales into a TreeSet to sort them, then convert
-     * them to LabelValueBeans to display them.
-     * Glad we only have to do this once.
-	 * 
-     * ROLLER_2.0: Website form needs these locale options too
-	 */
-    protected void loadLocaleCollection() 
-    {
-		java.util.ArrayList myLocales = new java.util.ArrayList();
-		TreeSet locTree = new TreeSet(new org.roller.util.LocaleComparator());
-		Locale[] localeArray = Locale.getAvailableLocales();
-		for (int i=0; i<localeArray.length; i++)
-		{
-			locTree.add(localeArray[i]);
-		}
-		java.util.Iterator it = locTree.iterator();
-		while (it.hasNext())
-		{
-			Locale loc = (Locale)it.next();
-		    myLocales.add(new org.apache.struts.util.LabelValueBean(
-		       loc.getDisplayName(),
-		       loc.toString()));
-		}
-		UserBaseAction.locales = myLocales;
-	}
-
-    //-----------------------------------------------------------------------
-    /**
-     * html:options tag recognizes "ID" as a property
-     * so we don't have to go through all the rigamarole (sp?)
-     * that we did for Locales.
-     * 
-     * ROLLER_2.0: Website form needs these locale options too
-     */
-    protected void loadTimeZoneCollection() 
-    {
-        Date today = new Date();
-        java.util.ArrayList myZones = new java.util.ArrayList();
-        TreeSet zoneTree = new TreeSet(new org.roller.util.TimeZoneComparator());
-        String[] zoneArray = TimeZone.getAvailableIDs();
-        for (int i=0; i<zoneArray.length; i++)
-        {
-            zoneTree.add((TimeZone)TimeZone.getTimeZone(zoneArray[i]));
-        }
-        java.util.Iterator it = zoneTree.iterator();
-        while (it.hasNext())
-        {
-            StringBuffer sb = new StringBuffer();
-            TimeZone zone = (TimeZone)it.next();
-            sb.append(zone.getDisplayName(zone.inDaylightTime(today), TimeZone.SHORT));
-            sb.append(" - ");
-            sb.append(zone.getID());
-            myZones.add(new org.apache.struts.util.LabelValueBean(
-               sb.toString(),
-               zone.getID()));
-        }
-        UserBaseAction.timezones = myZones;
-    }
-    
-//    //-----------------------------------------------------------------------
-//    /**
-//     * Check to see if the value of "userEnabled" has changed.
-//     * If so, update User's Website and save, and refresh the Index page cache.
-//     * 
-//     * @param request
-//     * @param rreq
-//     * @param uaf
-//     * @throws RollerException
-//     */
-//    protected void refreshIndexCache(HttpServletRequest request,
-//            RollerRequest rreq, UserAdminForm uaf) throws RollerException
-//    {
-//        WebsiteData website = RollerFactory.getRoller().getUserManager().getWebsite(
-//                uaf.getUserName(), false);
-//        boolean refreshIndexCache = false;
-//        if (request.getParameter("userEnabled") == null)
-//        {
-//            // only change it if it is a change
-//            if (uaf.getUserEnabled() == null
-//                    || website.getIsEnabled().booleanValue())
-//            {
-//                uaf.setUserEnabled(Boolean.FALSE);
-//                refreshIndexCache = true;
-//            }
-//        }
-//        else
-//        {
-//            // only change it if it is a change
-//            if (uaf.getUserEnabled() == null
-//                    || website.getIsEnabled().booleanValue() == false)
-//            {
-//                uaf.setUserEnabled(Boolean.TRUE);
-//                refreshIndexCache = true;
-//            }
-//        }
-//
-//        if (refreshIndexCache)
-//        {
-//            // set Website.isEnabled to match uaf.getUserEnabled()
-//            website.setIsEnabled(uaf.getUserEnabled());
-//            website.save();
-//
-//            // refresh the front page cache
-//            MainPageAction.flushMainPageCache();
-//        }
-//    }
 }
 
 

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserNewAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserNewAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserNewAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/UserNewAction.java Mon Jul 25 21:35:24 2005
@@ -3,6 +3,8 @@
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Locale;
+import java.util.TimeZone;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -23,6 +25,7 @@
 import org.roller.model.RollerFactory;
 import org.roller.model.UserManager;
 import org.roller.pojos.UserData;
+import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.website.formbeans.UserFormEx;
@@ -72,12 +75,12 @@
         try
         {
             UserFormEx userForm = (UserFormEx)actionForm;
-            loadRequestObjects(request, rreq, null, userForm);
-            userForm.setLocale(request.getLocale().toString());
-                
-            // User must set new password twice
+            userForm.setLocale( Locale.getDefault().getDisplayName() );
+            userForm.setTimeZone( TimeZone.getDefault().getID() );
             userForm.setPasswordText(null);
-            userForm.setPasswordConfirm(null);           
+            userForm.setPasswordConfirm(null);            
+            request.setAttribute(
+                    "model", new BasePageModel(request, response, mapping));
         }
         catch (Exception e)
         {
@@ -138,10 +141,10 @@
                   form.getPasswordText(), form.getPasswordConfirm());
             }
             
-            String theme = form.getTheme();
-            HashMap pages = rollerContext.readThemeMacros(theme);
+            //String theme = form.getTheme();
+            //HashMap pages = rollerContext.readThemeMacros(theme);
             mgr.addUser(ud);
-            mgr.createWebsite(ud, pages, theme, form.getLocale(), form.getTimezone());
+            //mgr.createWebsite(ud, pages, theme, form.getLocale(), form.getTimezone());
             RollerFactory.getRoller().commit();
 
 			// Flush cache so user will immediately appear on index page

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourProfileAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourProfileAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourProfileAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourProfileAction.java Mon Jul 25 21:35:24 2005
@@ -1,6 +1,8 @@
 package org.roller.presentation.website.actions;
 
 import java.io.IOException;
+import java.util.Locale;
+import java.util.TimeZone;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -18,6 +20,7 @@
 import org.roller.model.RollerFactory;
 import org.roller.model.UserManager;
 import org.roller.pojos.UserData;
+import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
 import org.roller.presentation.website.formbeans.UserFormEx;
@@ -34,8 +37,22 @@
     private static Log mLogger =
         LogFactory.getFactory().getInstance(YourProfileAction.class);
 
-    //-----------------------------------------------------------------------
-    /** Handle GET for user edit page */
+    /** If method param is not specified, use HTTP verb to pick method to call */
+    public ActionForward unspecified(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        if (request.getMethod().equals("GET"))
+        {
+            return edit(mapping, actionForm, request, response);
+        }
+        return save(mapping, actionForm, request, response);
+    }
+    
+    /** Load form with authenticated user and forward to your-profile page */
     public ActionForward edit(
         ActionMapping       mapping,
         ActionForm          actionForm,
@@ -46,55 +63,41 @@
         ActionForward forward = mapping.findForward("yourProfile.page");
         try
         {
-            RollerRequest rreq = RollerRequest.getRollerRequest(request);
             RollerSession rollerSession = RollerSession.getRollerSession(request);
-            if ( rollerSession.isUserAuthorizedToEdit() )
-            {
-                UserData ud = RollerSession.getRollerSession(request).getAuthenticatedUser();
-                request.setAttribute("user",ud);
-
-                UserFormEx form = (UserFormEx)actionForm;
-                form.copyFrom(ud, request.getLocale());
-                
-                // User must set new password twice
-                form.setPasswordText(null);
-                form.setPasswordConfirm(null);
-
-                loadRequestObjects(request, rreq, ud, form);
-            }
-            else
-            {
-                forward = mapping.findForward("access-denied");
-            }
+            UserData ud = rollerSession.getAuthenticatedUser();
+            UserFormEx form = (UserFormEx)actionForm;
+            form.copyFrom(ud, request.getLocale());
+            form.setPasswordText(null);
+            form.setPasswordConfirm(null);
+            form.setLocale(ud.getLocale());
+            form.setTimeZone(ud.getTimeZone());
+            request.setAttribute(
+                    "model", new BasePageModel(request, response, mapping));
         }
         catch (Exception e)
         {
             mLogger.error("ERROR in action",e);
             throw new ServletException(e);
-        }
-        
+        }        
         // if user logged in with a cookie, display a warning that they
         // can't change passwords
         if (mLogger.isDebugEnabled()) 
         {
             log.debug("checking for cookieLogin...");
         }
-
         if (request.getSession().getAttribute("cookieLogin") != null) {
             ActionMessages messages = new ActionMessages();
 
             // add warning messages
             messages.add(ActionMessages.GLOBAL_MESSAGE,
-                         new ActionMessage("userSettings.cookieLogin"));
+                         new ActionMessage("yourProfile.cookieLogin"));
             saveMessages(request, messages);
         }
-        
         return forward;
     }
 
-    //-----------------------------------------------------------------------
-    /** Handle POST from user edit form */
-    public ActionForward update(
+    /** Update user based on posted form data */
+    public ActionForward save(
         ActionMapping       mapping,
         ActionForm          actionForm,
         HttpServletRequest  request,
@@ -106,64 +109,51 @@
         ActionMessages msgs = new ActionMessages();
         try
         {
-            RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            RollerSession rollerSession = RollerSession.getRollerSession(request);
-            if (rollerSession.isUserAuthorizedToEdit())
+            ActionMessages errors = validate(form, new ActionErrors());
+            if (errors.size() == 0)
             {
-                ActionMessages errors = validate(form, new ActionErrors());
-                if (errors.size() == 0)
+                UserManager mgr = RollerFactory.getRoller().getUserManager();
+                UserData data = mgr.getUser( form.getUserName() );
+                
+                // Need system user to update user
+                RollerFactory.getRoller().setUser(UserData.SYSTEM_USER);
+                
+                // Copy data from form to object (won't copy over password)
+                form.copyTo(data, request.getLocale());
+                
+                // If user set both password and passwordConfirm then reset password
+                if (    !StringUtils.isEmpty(form.getPasswordText()) 
+                     && !StringUtils.isEmpty(form.getPasswordConfirm()))
                 {
-                    UserManager mgr = RollerFactory.getRoller().getUserManager();
-                    UserData data = mgr.getUser( form.getUserName() );
-                    
-                    // Need system user to update new user
-                    RollerFactory.getRoller().setUser(UserData.SYSTEM_USER);
-                    
-                    // Copy data from form to persistent object (won't copy over password)
-                    form.copyTo(data, request.getLocale());
-                    
-                    // If user set both password and passwordConfirm then reset password
-                    if (    !StringUtils.isEmpty(form.getPasswordText()) 
-                         && !StringUtils.isEmpty(form.getPasswordConfirm()))
+                    try
+                    {
+                        data.resetPassword(RollerFactory.getRoller(), 
+                           form.getPasswordText(), 
+                           form.getPasswordConfirm());
+                    }
+                    catch (RollerException e)
                     {
-                        try
-                        {
-                            data.resetPassword(RollerFactory.getRoller(), 
-                               form.getPasswordText(), 
-                               form.getPasswordConfirm());
-                        }
-                        catch (RollerException e)
-                        {
-                            msgs.add(ActionMessages.GLOBAL_MESSAGE, 
-                                new ActionMessage("userSettings.passwordResetError"));
-                        }
-                    } 
+                        msgs.add(ActionMessages.GLOBAL_MESSAGE, 
+                            new ActionMessage("yourProfile.passwordResetError"));
+                    }
+                } 
+                RollerSession rses = RollerSession.getRollerSession(request);
+                rses.setAuthenticatedUser(data);
+                mgr.storeUser( data );
                 
-                    // ROLLER_2.0: user needs locale and timezone 
-                    
-//                    WebsiteData website = mgr.getWebsite(data.getUserName());
-//                    website.setEditorTheme(form.getTheme());
-//                    website.setLocale(form.getLocale());
-//                    website.setTimezone(form.getTimezone());
-    
-                    // Persist changes
-                    mgr.storeUser( data );
-                    //mgr.storeWebsite( website );
-                    RollerFactory.getRoller().commit();
-                    
-                    // Changing user no longer requires cache flush
-                    //PageCacheFilter.removeFromCache(request, data);
-    
-                    msgs.add(null, new ActionMessage("userSettings.saved"));
-                    saveMessages(request, msgs);
-                }
-                else 
-                {
-                    saveErrors(request, errors);
-                }
-                return edit(mapping, actionForm, request, response);
+                RollerFactory.getRoller().commit();
+
+                request.setAttribute(
+                        "model", new BasePageModel(request, response, mapping));
+                
+                msgs.add(null, new ActionMessage("yourProfile.saved"));
+                saveMessages(request, msgs);
+            }
+            else 
+            {
+                saveErrors(request, errors);
             }
-            return mapping.findForward("access-denied");
+            return edit(mapping, actionForm, request, response);
         }
         catch (Exception e)
         {

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourWebsitesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourWebsitesAction.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourWebsitesAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/actions/YourWebsitesAction.java Mon Jul 25 21:35:24 2005
@@ -30,8 +30,23 @@
  */
 public class YourWebsitesAction extends DispatchAction
 {
-    private static Log mLogger =
+    private static Log mLogger = 
         LogFactory.getFactory().getInstance(YourWebsitesAction.class);
+    
+    /** If method param is not specified, use HTTP verb to pick method to call */
+    public ActionForward unspecified(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws Exception
+    {
+        if (request.getMethod().equals("GET"))
+        {
+            return edit(mapping, actionForm, request, response);
+        }
+        return select(mapping, actionForm, request, response);
+    }
     
     public ActionForward edit(
             ActionMapping       mapping,

Added: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/NewWebsiteForm.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/NewWebsiteForm.java?rev=225230&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/NewWebsiteForm.java (added)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/NewWebsiteForm.java Mon Jul 25 21:35:24 2005
@@ -0,0 +1,95 @@
+package org.roller.presentation.website.formbeans;
+
+import java.util.Locale;
+
+import org.apache.struts.action.ActionForm;
+import org.roller.pojos.WebsiteData;
+
+/**
+ * @struts.form name="newWebsiteForm"
+ * @author Dave M Johnson
+ */
+public class NewWebsiteForm extends ActionForm
+{
+    private String handle;
+    private String name;
+    private String description;
+    private String emailAddress;
+    private String locale;
+    private String timezone;
+    private String theme;
+    
+    public NewWebsiteForm()
+    {
+        
+    }
+    public String getDescription()
+    {
+        return description;
+    }
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+    public String getEmailAddress()
+    {
+        return emailAddress;
+    }
+    public void setEmailAddress(String emailAddress)
+    {
+        this.emailAddress = emailAddress;
+    }
+    public String getHandle()
+    {
+        return handle;
+    }
+    public void setHandle(String handle)
+    {
+        this.handle = handle;
+    }
+    public String getLocale()
+    {
+        return locale;
+    }
+    public void setLocale(String locale)
+    {
+        this.locale = locale;
+    }
+    public String getName()
+    {
+        return name;
+    }
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    public String getTheme()
+    {
+        return theme;
+    }
+    public void setTheme(String theme)
+    {
+        this.theme = theme;
+    }
+    public String getTimeZone()
+    {
+        return timezone;
+    }
+    public void setTimeZone(String timezone)
+    {
+        this.timezone = timezone;
+    }
+    
+    /**
+     * @param wd
+     * @param locale2
+     */
+    public void copyTo(WebsiteData wd, Locale locale)
+    {
+        wd.setHandle(handle);
+        wd.setName(name);
+        wd.setDescription(description);
+        wd.setLocale(this.locale);
+        wd.setTimezone(timezone);
+    }
+}

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/UserFormEx.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/UserFormEx.java?rev=225230&r1=225229&r2=225230&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/UserFormEx.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/website/formbeans/UserFormEx.java Mon Jul 25 21:35:24 2005
@@ -16,9 +16,6 @@
  */ 
 public class UserFormEx extends UserForm
 {
-	private String mTheme = null;
-    private String mLocale = null;
-    private String mTimezone = null;
     private String mPasswordText = null;
     private String mPasswordConfirm = null;
     private boolean adminCreated = false;
@@ -31,35 +28,6 @@
 	public UserFormEx( UserData userData, java.util.Locale locale ) throws RollerException
 	{
 		super(userData, locale);
-	}
-
-	public String getTheme()
-	{
-		return mTheme; 
-	}
-
-	public void setTheme( String theme )
-	{
-		mTheme = theme;
-	}
-	public String getLocale() 
-	{
-		return mLocale;
-	}
-
-	public void setLocale(String locale) 
-	{
-		mLocale = locale;
-	}
-
-	public String getTimezone() 
-	{
-		return mTimezone;
-	}
-
-	public void setTimezone(String timezone) 
-	{
-		mTimezone = timezone;
 	}
     
     /**



Mime
View raw message