roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r289295 - in /incubator/roller/branches/roller_2.0: src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java web/weblog/WeblogEdit.jsp
Date Thu, 15 Sep 2005 19:21:53 GMT
Author: agilliland
Date: Thu Sep 15 12:21:41 2005
New Revision: 289295

URL: http://svn.apache.org/viewcvs?rev=289295&view=rev
Log:
new process for setting entry pubtime.  pubtime is now NULL by default until it is set manually
by the user, or the entry is first published.


Modified:
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
    incubator/roller/branches/roller_2.0/web/weblog/WeblogEdit.jsp

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java?rev=289295&r1=289294&r2=289295&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
Thu Sep 15 12:21:41 2005
@@ -285,6 +285,26 @@
                     entry = weblogMgr.retrieveWeblogEntry(wf.getId());
                     entry.save(); // should throw if save not permitted
                 }
+                
+                mLogger.debug("setting update time now");
+                wf.setUpdateTime(new Timestamp(new Date().getTime()));
+                
+                if("PUBLISHED".equals(wf.getStatus()) &&
+                        "0/0/0".equals(wf.getDateString())) {
+                    mLogger.debug("setting pubtime now");
+                    
+                    /* NOTE: the wf.copyTo() method will override this value
+                     * based on data submitted with the form if that data is
+                     * not null.  check the method to verify.
+                     *
+                     * this means that setting the pubtime here only takes
+                     * effect if the entry is being published for the first
+                     * time.
+                     */
+                    wf.setPubTime(wf.getUpdateTime());
+                }
+                
+                mLogger.debug("copying submitted form data to entry object");
                 wf.copyTo(entry, request.getLocale(),request.getParameterMap());
 
                 // Fetch MediaCast content type and length

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java?rev=289295&r1=289294&r2=289295&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
(original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/weblog/formbeans/WeblogEntryFormEx.java
Thu Sep 15 12:21:41 2005
@@ -15,6 +15,8 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.roller.RollerException;
 import org.roller.pojos.CommentData;
 import org.roller.pojos.EntryAttributeData;
@@ -32,6 +34,9 @@
  */
 public class WeblogEntryFormEx extends WeblogEntryForm
 {
+    private static Log mLogger =
+        LogFactory.getFactory().getInstance(WeblogEntryFormEx.class);
+    
     private String mCategoryId = null;
     private String mCreatorId = null;
     private String mWebsiteId = null;
@@ -50,11 +55,13 @@
     public WeblogEntryFormEx()
     {
         super();
+        mLogger.debug("default construction");
     }
 
     public WeblogEntryFormEx(WeblogEntryData entryData, java.util.Locale locale) 
         throws RollerException
     {
+        mLogger.debug("construction from existing entry");
         copyFrom(entryData, locale);
     }
     
@@ -64,6 +71,8 @@
      */
     public void initNew(HttpServletRequest request, HttpServletResponse response) 
     {
+        mLogger.debug("init new called");
+        
         RollerRequest rreq = RollerRequest.getRollerRequest(request);
         RollerSession rses = RollerSession.getRollerSession(request); 
         if (rreq.getWebsite().getDefaultPlugins() != null)
@@ -73,9 +82,11 @@
         }
         status = WeblogEntryData.DRAFT;
         allowComments = Boolean.TRUE;
-        updateTime = new Timestamp(new Date().getTime());
-        pubTime = updateTime;
-        initPubTimeDateStrings(rreq.getWebsite(), request.getLocale());        
+        
+        // we want pubTime and updateTime to be empty for new entries -- AG
+        //updateTime = new Timestamp(new Date().getTime());
+        //pubTime = updateTime;
+        //initPubTimeDateStrings(rreq.getWebsite(), request.getLocale());        
     }
     
     /**
@@ -84,14 +95,17 @@
     public void copyTo(WeblogEntryData entry, Locale locale, Map paramMap) 
         throws RollerException
     {
+        mLogger.debug("copy to called");
+        
         super.copyTo(entry, locale);
         
         // First parts the date string from the calendar 
         final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
-        final Date newDate;
+        Date newDate = null;
         try
         {
-            newDate = df.parse(getDateString());
+            if(getDateString() != null && !"0/0/0".equals(getDateString()))
+                newDate = df.parse(getDateString());
         }
         catch (ParseException e)
         {
@@ -99,13 +113,15 @@
         }
         
         // Now handle the time from the hour, minute and second combos
-        final Calendar cal = Calendar.getInstance(locale);
-        cal.setTime(newDate);
-        cal.setTimeZone(entry.getWebsite().getTimeZoneInstance());
-        cal.set(Calendar.HOUR_OF_DAY, getHours().intValue());
-        cal.set(Calendar.MINUTE, getMinutes().intValue());
-        cal.set(Calendar.SECOND, getSeconds().intValue());
-        entry.setPubTime(new Timestamp(cal.getTimeInMillis()));
+        if(newDate != null) {
+            final Calendar cal = Calendar.getInstance(locale);
+            cal.setTime(newDate);
+            cal.setTimeZone(entry.getWebsite().getTimeZoneInstance());
+            cal.set(Calendar.HOUR_OF_DAY, getHours().intValue());
+            cal.set(Calendar.MINUTE, getMinutes().intValue());
+            cal.set(Calendar.SECOND, getSeconds().intValue());
+            entry.setPubTime(new Timestamp(cal.getTimeInMillis()));
+        }
         
         entry.setPlugins( StringUtils.join(this.pluginsArray,",") );
         
@@ -151,6 +167,8 @@
     public void copyFrom(WeblogEntryData entry, Locale locale) 
         throws RollerException
     {
+        mLogger.debug("copy from called");
+        
         super.copyFrom(entry, locale);
         mCategoryId = entry.getCategory().getId();
         mCreatorId = entry.getCreator().getId();       
@@ -203,16 +221,27 @@
      */
     private void initPubTimeDateStrings(WebsiteData website, Locale locale)
     {
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(getPubTime()); 
-        cal.setTimeZone(website.getTimeZoneInstance());
-        mHours = new Integer(cal.get(Calendar.HOUR_OF_DAY));
-        mMinutes = new Integer(cal.get(Calendar.MINUTE));
-        mSeconds = new Integer(cal.get(Calendar.SECOND));
+        mLogger.debug("init pub time date sting called");
         
-        DateFormat df = DateFormat.getDateInstance(
-           DateFormat.SHORT, locale);
-        mDateString = df.format(getPubTime());
+        if(getPubTime() != null) {
+            mLogger.debug("figuring pubtime values");
+            
+            Calendar cal = Calendar.getInstance();
+            cal.setTime(getPubTime());
+            cal.setTimeZone(website.getTimeZoneInstance());
+            mHours = new Integer(cal.get(Calendar.HOUR_OF_DAY));
+            mMinutes = new Integer(cal.get(Calendar.MINUTE));
+            mSeconds = new Integer(cal.get(Calendar.SECOND));
+            
+            DateFormat df = DateFormat.getDateInstance(
+                    DateFormat.SHORT, locale);
+            mDateString = df.format(getPubTime());
+            
+        } else {
+            mLogger.debug("pubtime is null, must be a draft");
+            
+            mDateString = "0/0/0";
+        }
     }
 
     /**
@@ -286,6 +315,7 @@
      */
     public void setDateString(String dateString) throws ParseException
     {
+        mLogger.debug("somebody setting date string");
         mDateString = dateString;
     }
 
@@ -346,10 +376,12 @@
             javax.servlet.ServletRequest request)
     {
         super.doReset(mapping, request);
+        mLogger.debug("reset called");
         
         pluginsArray = new String[0];
         
         // reset time fields to current time
+        /* we want the date fields to be empty by default now -- Allen G
         Calendar cal = Calendar.getInstance(request.getLocale());
         Date now = new Date();
         cal.setTime(now);        
@@ -358,6 +390,8 @@
         mSeconds = new Integer(cal.get(Calendar.SECOND));        
         DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, request.getLocale());
         mDateString = df.format(now);
+        */
+        mDateString = "0/0/0";
     }
 
     /**

Modified: incubator/roller/branches/roller_2.0/web/weblog/WeblogEdit.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/weblog/WeblogEdit.jsp?rev=289295&r1=289294&r2=289295&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/weblog/WeblogEdit.jsp (original)
+++ incubator/roller/branches/roller_2.0/web/weblog/WeblogEdit.jsp Thu Sep 15 12:21:41 2005
@@ -84,7 +84,8 @@
     <html:hidden property="creatorId"/>
     <html:hidden property="websiteId"/>
     <html:hidden property="anchor"/>
-    <html:hidden property="updateTime"/>
+    <%-- updateTime is now set after the entry is submitted -- Allen G
+    <html:hidden property="updateTime"/> --%>
     <html:hidden property="status"/>
     <html:hidden property="link"/>
     <html:hidden name="method" property="method" value="save"/>



Mime
View raw message