Update of /cvsroot/roller/roller/src/org/roller/presentation/velocity
In directory sc8-pr-cvs1:/tmp/cvs-serv9057/src/org/roller/presentation/velocity
Modified Files:
Macros.java
Log Message:
Fixes for ROL-107 and ROL-113: RssServlet now obeys if-modified-since and uses
last update time as blog date.
Index: Macros.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/presentation/velocity/Macros.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** Macros.java 12 Nov 2002 02:41:42 -0000 1.43
--- Macros.java 23 Nov 2002 14:41:50 -0000 1.44
***************
*** 83,98 ****
public String formatCurrentDate( String pattern )
{
try
{
SimpleDateFormat format = new SimpleDateFormat( pattern );
! return format.format( new Date() );
}
catch (RuntimeException e)
{
! e.printStackTrace();
}
! return "ERROR: formatting date";
}
//------------------------------------------------------------------------
/**
--- 83,149 ----
public String formatCurrentDate( String pattern )
{
+ String date = null;
try
{
SimpleDateFormat format = new SimpleDateFormat( pattern );
! date = format.format( new Date() );
}
catch (RuntimeException e)
{
! date = "ERROR: formatting date";
}
! return date;
}
+ //------------------------------------------------------------------------
+ /**
+ * Returns most recent update time of collection of weblog entries using
+ * the specified pattern.
+ * @param weblogEntries Collection of weblog entries.
+ * @param Date format pattern, @see java.text.SimpleDateFormat.
+ * @return Most recent update time formatted by pattern.
+ */
+ public String formatUpdateTime( ArrayList weblogEntries, String pattern )
+ {
+ String date = null;
+ Date updateTime = getUpdateTime(weblogEntries);
+ Iterator iter = weblogEntries.iterator();
+ try
+ {
+ SimpleDateFormat format = new SimpleDateFormat( pattern );
+ date = format.format( updateTime );
+ }
+ catch (RuntimeException e)
+ {
+ date = "ERROR: formatting date";
+ }
+ return date;
+ }
+
+ //------------------------------------------------------------------------
+ /**
+ * Returns most recent update time of collection of weblog entries.
+ * @param weblogEntries Collection of weblog entries.
+ * @return Most recent update time.
+ */
+ public Date getUpdateTime( ArrayList weblogEntries )
+ {
+ Date updateTime = null;
+ Iterator iter = weblogEntries.iterator();
+ while (iter.hasNext())
+ {
+ WeblogEntryData wd = (WeblogEntryData)iter.next();
+ if ( updateTime == null )
+ {
+ updateTime = wd.getUpdateTime();
+ }
+ else if ( updateTime.compareTo(wd.getUpdateTime()) < 0 )
+ {
+ updateTime = wd.getUpdateTime();
+ }
+ }
+ return updateTime;
+ }
+
//------------------------------------------------------------------------
/**
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
|