You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2005/09/26 22:14:31 UTC

svn commit: r291727 - in /incubator/roller/branches/roller_2.0: src/org/roller/business/hibernate/HibernateRefererManagerImpl.java src/org/roller/pojos/WebsiteDisplayData.java src/org/roller/presentation/MainPageAction.java web/main-sidebar.jsp

Author: snoopdave
Date: Mon Sep 26 13:14:23 2005
New Revision: 291727

URL: http://svn.apache.org/viewcvs?rev=291727&view=rev
Log:
Hot blogs list was still using username rather than weblog handle

Modified:
    incubator/roller/branches/roller_2.0/src/org/roller/business/hibernate/HibernateRefererManagerImpl.java
    incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteDisplayData.java
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/MainPageAction.java
    incubator/roller/branches/roller_2.0/web/main-sidebar.jsp

Modified: incubator/roller/branches/roller_2.0/src/org/roller/business/hibernate/HibernateRefererManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/business/hibernate/HibernateRefererManagerImpl.java?rev=291727&r1=291726&r2=291727&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/business/hibernate/HibernateRefererManagerImpl.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/business/hibernate/HibernateRefererManagerImpl.java Mon Sep 26 13:14:23 2005
@@ -38,224 +38,196 @@
  * @author David M Johnson
  */
 public class HibernateRefererManagerImpl extends RefererManagerImpl
-    implements RefererManager
-{
+        implements RefererManager {
     static final long serialVersionUID = -4966091850482256435L;
     
     private static Log mLogger =
-         LogFactory.getFactory().getInstance(HibernateRefererManagerImpl.class);
-
+            LogFactory.getFactory().getInstance(HibernateRefererManagerImpl.class);
+    
     //-------------------------------------------------- Startup and Shutdown
     public HibernateRefererManagerImpl(PersistenceStrategy support)
-        throws RollerException
-	{
+    throws RollerException {
         super();
-		mStrategy = (HibernateStrategy)support;
-                mLogger.debug("Instantiating Referer Manager");
-	}
-
+        mStrategy = (HibernateStrategy)support;
+        mLogger.debug("Instantiating Referer Manager");
+    }
+    
     //-----------------------------------------------------------------------
     /**
      * Apply ignoreWord/spam filters to all referers in system.
      */
-    public void applyRefererFilters() throws RollerException
-    {
-        try
-        {
+    public void applyRefererFilters() throws RollerException {
+        try {
             Session session = ((HibernateStrategy)mStrategy).getSession();
             Criteria criteria = session.createCriteria(RefererData.class);
             
             String spamwords = RollerRuntimeConfig.getProperty("spam.referers.ignorewords");
             
             String[] ignoreWords = StringUtils.split(
-                StringUtils.deleteWhitespace(spamwords),",");
-            Junction or = Expression.disjunction();          
-            for (int i=0; i<ignoreWords.length; i++) 
-            {
+                    StringUtils.deleteWhitespace(spamwords),",");
+            Junction or = Expression.disjunction();
+            for (int i=0; i<ignoreWords.length; i++) {
                 String ignoreWord = ignoreWords[i].trim();
                 or.add(Expression.ilike("refererUrl","%"+ignoreWord+"%"));
             }
             criteria.add(Expression.conjunction()
-                .add(Expression.isNull("excerpt"))
-                .add(or)
+            .add(Expression.isNull("excerpt"))
+            .add(or)
             );
             
             Iterator referers = criteria.list().iterator();
-            while (referers.hasNext())
-            {
+            while (referers.hasNext()) {
                 removeReferer( ((RefererData)referers.next()).getId() );
             }
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
     /**
      * Apply ignoreWord/spam filters to all referers in website.
      */
-    public void applyRefererFilters(WebsiteData website) throws RollerException
-    {
+    public void applyRefererFilters(WebsiteData website) throws RollerException {
         if (null == website) throw new RollerException("website is null");
         if (null == website.getIgnoreWords()) return;
-
-        try
-        {
+        
+        try {
             Session session = ((HibernateStrategy)mStrategy).getSession();
             Criteria criteria = session.createCriteria(RefererData.class);
             
             String[] ignoreWords = StringUtils.split(
-                StringUtils.deleteWhitespace(website.getIgnoreWords()),",");
+                    StringUtils.deleteWhitespace(website.getIgnoreWords()),",");
             if (ignoreWords.length == 0) return;
             
-            Junction or = Expression.disjunction();          
-            for (int i=0; i<ignoreWords.length; i++) 
-            {
+            Junction or = Expression.disjunction();
+            for (int i=0; i<ignoreWords.length; i++) {
                 String ignoreWord = ignoreWords[i].trim();
                 or.add(Expression.ilike("refererUrl","%"+ignoreWord+"%"));
             }
             criteria.add(Expression.conjunction()
-                .add(Expression.isNull("excerpt"))
-                .add(Expression.eq("website",website))
-                .add(or)
+            .add(Expression.isNull("excerpt"))
+            .add(Expression.eq("website",website))
+            .add(or)
             );
             
             Iterator referers = criteria.list().iterator();
-            while (referers.hasNext())
-            {
+            while (referers.hasNext()) {
                 removeReferer( ((RefererData)referers.next()).getId() );
             }
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
-    /** 
+    
+    /**
      * Use Hibernate directly because Roller's Query API does too much allocation.
      */
     protected List getExistingReferers(WebsiteData website, String dateString,
-                    String permalink) throws RollerException
-    {
+            String permalink) throws RollerException {
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.conjunction()
-                        .add(Expression.eq("website",website))
-                        .add(Expression.eq("dateString",dateString))
-                        .add(Expression.eq("refererPermalink",permalink)));
-        try
-        {
+        .add(Expression.eq("website",website))
+        .add(Expression.eq("dateString",dateString))
+        .add(Expression.eq("refererPermalink",permalink)));
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
     
     //-----------------------------------------------------------------------
-
-    /** 
+    
+    /**
      * Use Hibernate directly because Roller's Query API does too much allocation.
      */
     protected List getMatchingReferers(WebsiteData website, String requestUrl,
-                    String refererUrl) throws RollerException
-    {
+            String refererUrl) throws RollerException {
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.conjunction()
-                        .add(Expression.eq("website",website))
-                        .add(Expression.eq("requestUrl",requestUrl))
-                        .add(Expression.eq("refererUrl",refererUrl)));
-        try
-        {
+        .add(Expression.eq("website",website))
+        .add(Expression.eq("requestUrl",requestUrl))
+        .add(Expression.eq("refererUrl",refererUrl)));
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
     
     //-----------------------------------------------------------------------
-
+    
     /**
      * Use raw SQL because Hibernate can't handle sorting by sum.
      */
-    public List getDaysPopularWebsites(int max) throws RollerException
-    {
+    public List getDaysPopularWebsites(int max) throws RollerException {
         // TODO Hibernate version of getDaysPopularWebsites
         // TODO Move to full use of mSupport
         String msg = "Getting popular websites";
         Session ses = null; // the session will eventually be release by RequestFilter
         Connection con = null;
-        try
-        {
+        try {
             List list = new ArrayList();
-
+            
             ses = ((HibernateStrategy)mStrategy).getSession();
             con = ses.connection();
-
+            
             final PreparedStatement stmt;
-            if (con.getMetaData().getDriverName().startsWith("HSQL"))
-            {
-            		// special handling for HSQLDB
+            if (con.getMetaData().getDriverName().startsWith("HSQL")) {
+                // special handling for HSQLDB
                 stmt = con.prepareStatement(
-                        "select top ? u.username,w.name,w.name,sum(r.dayhits) as s "+
+                        "select top ? u.username,w.name,w.name,w.handle,sum(r.dayhits) as s "+
                         "from rolleruser as u, website as w, referer as r "+
                         "where r.websiteid=w.id and w.userid=u.id and w.isenabled=? " +
                         "group by u.username,w.name,w.id order by s desc");
                 stmt.setInt(1, max);
                 stmt.setBoolean(2, true);
-            }
-            else 
-            {
-               stmt = con.prepareStatement(
-                    "select u.username,w.name,w.name,sum(r.dayhits) as s "+
-                    "from rolleruser as u, website as w, referer as r "+
-                    "where r.websiteid=w.id and w.userid=u.id and w.isenabled= ? " +
-                    // Ben Walding (a Postgres SQL user): Basically, you have
-                    // to have all non-aggregated columns that exist in your
-                    // 'SELECT' section, in the 'GROUP BY' section as well:
-                    "group by u.username,w.name,w.id order by s desc limit ?");
-                    // and not this: "group by w.id order by s desc");
+            } else {
+                stmt = con.prepareStatement(
+                        "select u.username,w.name,w.name,w.handle,sum(r.dayhits) as s "+
+                        "from rolleruser as u, website as w, referer as r "+
+                        "where r.websiteid=w.id and w.userid=u.id and w.isenabled= ? " +
+                        // Ben Walding (a Postgres SQL user): Basically, you have
+                        // to have all non-aggregated columns that exist in your
+                        // 'SELECT' section, in the 'GROUP BY' section as well:
+                        "group by u.username,w.name,w.id order by s desc limit ?");
+                // and not this: "group by w.id order by s desc");
                 stmt.setBoolean(1, true);
                 stmt.setInt(2, max);
             }
             ResultSet rs = stmt.executeQuery();
-            if ( rs.next() )
-            {
+            if ( rs.next() ) {
                 do
                 {
                     String userName = rs.getString(1);
                     String name = rs.getString(2);
                     String websiteName = rs.getString(3);
-                    Integer hits = new Integer(rs.getInt(4));
+                    String websiteHandle = rs.getString(4);
+                    Integer hits = new Integer(rs.getInt(5));
                     list.add(new WebsiteDisplayData(
-                       name, 
-                       userName, 
-                       websiteName, 
-                       hits));
+                            name,
+                            userName,
+                            websiteName,
+                            websiteHandle,
+                            hits));
                 }
                 while ( rs.next() );
             }
             return list;
-        }
-        catch (Throwable pe)
-        {
+        } catch (Throwable pe) {
             mLogger.error(msg, pe);
             throw new RollerException(msg, pe);
         }
         
 // Don't close connection, Hibernate is holding it
-//        finally 
+//        finally
 //        {
-//            try 
+//            try
 //            {
 //                if (con != null) con.close();
 //            }
@@ -268,112 +240,92 @@
     }
     
     //-----------------------------------------------------------------------
-
+    
     /**
      * Use raw SQL because Hibernate can't handle the query.
      */
     protected int getHits(WebsiteData website, String type)
-        throws RollerException
-    {
+    throws RollerException {
         int hits = 0;
-        if (mLogger.isDebugEnabled())
-        {
+        if (mLogger.isDebugEnabled()) {
             mLogger.debug("getHits: " + website.getName());
         }
-
+        
         Object[] args = { Boolean.TRUE, website.getId() };
         Type[] types = { Hibernate.BOOLEAN, Hibernate.STRING };
-
+        
         // For a query like this, Hibernate returns a list of lists
         Session session = ((HibernateStrategy)mStrategy).getSession();
         List results;
-        try
-        {
+        try {
             Query q = session.createQuery(
-               "select sum(h.dayHits),sum(h.totalHits) from h in class " +
-               "org.roller.pojos.RefererData " +
-               "where h.website.enabled=? and h.website.id=? ");
+                    "select sum(h.dayHits),sum(h.totalHits) from h in class " +
+                    "org.roller.pojos.RefererData " +
+                    "where h.website.enabled=? and h.website.id=? ");
             q.setParameters(args, types);
             results = q.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
         Object[] resultsArray = (Object[]) results.get(0);
-
-        if (resultsArray.length > 0 && type.equals(DAYHITS))
-        {
-            if ( resultsArray[0] != null )
-            {
+        
+        if (resultsArray.length > 0 && type.equals(DAYHITS)) {
+            if ( resultsArray[0] != null ) {
                 hits = ((Integer) resultsArray[0]).intValue();
             }
-        }
-        else if ( resultsArray.length > 0 )
-        {
-            if ( resultsArray[0] != null )
-            {
+        } else if ( resultsArray.length > 0 ) {
+            if ( resultsArray[0] != null ) {
                 hits = ((Integer) resultsArray[1]).intValue();
             }
-        }
-        else
-        {
+        } else {
             hits = 0;
         }
-
+        
         return hits;
     }
     
     /**
      * @see org.roller.pojos.RefererManager#getReferers(java.lang.String)
      */
-    public List getReferers(WebsiteData website) throws RollerException
-    {
+    public List getReferers(WebsiteData website) throws RollerException {
         if (website==null )
             throw new RollerException("website is null");
-
+        
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.eq("website",website));
         criteria.addOrder(Order.desc("totalHits"));
-        try
-        {
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * @see org.roller.pojos.RefererManager#getTodaysReferers(String)
      */
     public List getTodaysReferers(WebsiteData website)
-        throws RollerException
-    {
+    throws RollerException {
         if (website==null )
             throw new RollerException("website is null");
-
+        
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.eq("website", website));
         criteria.add(Expression.gt("dayHits", new Integer(0)));
         criteria.addOrder(Order.desc("dayHits"));
-        try
-        {
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * Returns referers for a specified day. Duplicate enties are not
      * included in this list so the hit counts may not be accurate.
@@ -381,43 +333,37 @@
      * org.roller.pojos.WebsiteData, java.lang.String)
      */
     public List getReferersToDate(WebsiteData website, String date)
-        throws RollerException
-    {
+    throws RollerException {
         if (website==null )
             throw new RollerException("website is null");
-
+        
         if (date==null )
             throw new RollerException("Date is null");
-
+        
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.eq("website", website));
         criteria.add(Expression.eq("dateString", date));
         criteria.add(Expression.eq("duplicate", Boolean.FALSE));
         criteria.addOrder(Order.desc("totalHits"));
-        try
-        {
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * @see org.roller.pojos.RefererManager#getReferersToEntry(
      * java.lang.String, java.lang.String)
      */
-    public List getReferersToEntry(String entryid) throws RollerException
-    {
+    public List getReferersToEntry(String entryid) throws RollerException {
         if (null == entryid)
             throw new RollerException("entryid is null");
-
-        try
-        {
+        
+        try {
             Session session = ((HibernateStrategy)mStrategy).getSession();
             Criteria criteria = session.createCriteria(RefererData.class);
             criteria.createAlias("weblogEntry","e");
@@ -427,81 +373,68 @@
             criteria.add(Expression.isNotNull("excerpt"));
             
             criteria.addOrder(Order.desc("totalHits"));
-        
+            
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * @see org.roller.pojos.RefererManager#getReferersToEntry(
      * java.lang.String, java.lang.String)
      */
-    public void removeReferersForEntry(String entryid) throws RollerException
-    {
+    public void removeReferersForEntry(String entryid) throws RollerException {
         if (null == entryid)
             throw new RollerException("entryid is null");
-
-        try
-        {
+        
+        try {
             Session session = ((HibernateStrategy)mStrategy).getSession();
             Criteria criteria = session.createCriteria(RefererData.class);
-            criteria.createAlias("weblogEntry","e");            
+            criteria.createAlias("weblogEntry","e");
             criteria.add(Expression.eq("e.id", entryid));
-        
+            
             Iterator referers = criteria.list().iterator();
-            while (referers.hasNext())
-            {
+            while (referers.hasNext()) {
                 removeReferer( ((RefererData)referers.next()).getId() );
             }
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * Query for collection of referers.
      */
     protected List getReferersToWebsite(WebsiteData website, String refererUrl)
-        throws RollerException
-    {
+    throws RollerException {
         Session session = ((HibernateStrategy)mStrategy).getSession();
         Criteria criteria = session.createCriteria(RefererData.class);
         criteria.add(Expression.eq("website", website));
         criteria.add(Expression.eq("refererUrl", refererUrl));
-        try
-        {
+        try {
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
-
+    
     //-----------------------------------------------------------------------
-
+    
     /**
      * Query for collection of referers.
      */
     protected List getReferersWithSameTitle(
-        WebsiteData website, 
-        String requestUrl, 
-        String title, 
-        String excerpt)
-        throws RollerException
-    {
-        try
-        {
+            WebsiteData website,
+            String requestUrl,
+            String title,
+            String excerpt)
+            throws RollerException {
+        try {
             Session session = ((HibernateStrategy)mStrategy).getSession();
             Criteria criteria = session.createCriteria(RefererData.class);
             
@@ -512,14 +445,12 @@
             Junction disjunction = Expression.conjunction();
             disjunction.add(Expression.eq("title", title));
             disjunction.add(Expression.eq("excerpt", excerpt));
-        
+            
             criteria.add(conjunction);
             criteria.add(disjunction);
             
             return criteria.list();
-        }
-        catch (HibernateException e)
-        {
+        } catch (HibernateException e) {
             throw new RollerException(e);
         }
     }
@@ -529,66 +460,53 @@
      * referers that do not have excerpts.
      */
     public void checkForTurnover( boolean forceTurnover, String websiteId )
-        throws RollerException
-    {
+    throws RollerException {
         // Note, this method doesn't need to be synchronized anymore since
         // it's called from the timer task now, and will never be executed
         // by two threads simultaneously.
-        if (mLogger.isDebugEnabled())
-        {
+        if (mLogger.isDebugEnabled()) {
             mLogger.debug("checkForTurnover");
         }
-
+        
         Date now = new Date();
-
+        
         if (forceTurnover ||
-                !mDateFormat.format(now).equals(mDateFormat.format(mRefDate)))
-        {
-            try
-            {
+                !mDateFormat.format(now).equals(mDateFormat.format(mRefDate))) {
+            try {
                 if (websiteId == null) mRefDate = now;
-
+                
                 List refs;
-                try
-                {
+                try {
                     Session session = ((HibernateStrategy)mStrategy).getSession();
                     Criteria criteria = session.createCriteria(RefererData.class);
                     criteria.add(Expression.gt("dayHits", new Integer(0)));
-                    if (websiteId != null)
-                    {
+                    if (websiteId != null) {
                         criteria.add(Expression.eq("website.id", websiteId));
                     }
                     refs = criteria.list();
-                }
-                catch (HibernateException e1)
-                {
+                } catch (HibernateException e1) {
                     throw new RollerException(e1);
                 }
-
+                
                 Integer zero = new Integer(0);
                 for (Iterator rdItr = refs.iterator(); rdItr.hasNext();) {
                     RefererData referer = (RefererData) rdItr.next();
-
+                    
                     if (   (referer.getExcerpt() != null) &&
-                            (referer.getExcerpt().trim().length() > 0))
-                    {
+                            (referer.getExcerpt().trim().length() > 0)) {
                         // Zero out dayHits of referers with excerpts
                         referer.setDayHits(zero);
                         storeReferer(referer);
-                    }
-                    else
-                    {
+                    } else {
                         // Throw away referers without excerpts
                         removeReferer(referer.getId());
                     }
                 }
-            }
-            catch (RollerException e)
-            {
+            } catch (RollerException e) {
                 mLogger.error("EXCEPTION resetting referers",e);
             }
         }
     }
-
-
+    
+    
 }

Modified: incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteDisplayData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteDisplayData.java?rev=291727&r1=291726&r2=291727&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteDisplayData.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/pojos/WebsiteDisplayData.java Mon Sep 26 13:14:23 2005
@@ -7,112 +7,115 @@
 /**
  * For most popular website display on Roller main page.
  * The id property is the website's name.
- * 
+ *
  * @author David M Johnson
  *
  * @ejb:bean name="WebsiteDisplayData"
- * @struts.form include-all="true" 
+ * @struts.form include-all="true"
  */
-public class WebsiteDisplayData extends PersistentObject
-{    
+public class WebsiteDisplayData extends PersistentObject {
     static final long serialVersionUID = 5264701383470813687L;
     
     private String mId;
     private String mUserName = null;
     private String mWebsiteName = null;
-    private Integer mHits = new Integer(0);    
-
+    private String mWebsiteHandle = null;
+    private Integer mHits = new Integer(0);
+    
     /**
-     * 
+     *
      */
-    public WebsiteDisplayData()
-    {
+    public WebsiteDisplayData() {
         super();
     }
-
+    
     /**
-     * 
+     *
      */
-    public WebsiteDisplayData(String id, String userName, String websiteName, Integer hits)
-    {
+    public WebsiteDisplayData(
+            String id,
+            String userName,
+            String websiteName,
+            String websiteHandle,
+            Integer hits) {
         super();
         mId = id;
         mUserName = userName;
         mWebsiteName = websiteName;
+        mWebsiteHandle = websiteHandle;
         mHits = hits;
     }
-
-    /** 
+    
+    /**
      * No-op.
      * @see org.roller.pojos.PersistentObject#setData(org.roller.pojos.PersistentObject)
      */
-    public void setData(PersistentObject vo)
-    {
+    public void setData(PersistentObject vo) {
     }
-
-    /** 
-     * @ejb:persistent-field 
+    
+    /**
+     * @ejb:persistent-field
      */
-    public String getId()
-    {
+    public String getId() {
         return mId;
     }
-
-    /** 
+    
+    /**
      * @see org.roller.pojos.PersistentObject#setId(java.lang.String)
      */
-    public void setId(String id)
-    {
+    public void setId(String id) {
         mId = id;
     }
-
-
-    /** 
-     * @ejb:persistent-field 
+    
+    
+    /**
+     * @ejb:persistent-field
      */
-    public String getUserName()
-    {
+    public String getUserName() {
         return mUserName;
     }
-
+    
     /**
      * @param string
      */
-    public void setUserName(String string)
-    {
+    public void setUserName(String string) {
         mUserName = string;
     }
-
-    /** 
-     * @ejb:persistent-field 
+    
+    /**
+     * @ejb:persistent-field
      */
-    public Integer getHits()
-    {
+    public Integer getHits() {
         return mHits;
     }
-
+    
     /**
      * @param integer
      */
-    public void setHits(Integer integer)
-    {
+    public void setHits(Integer integer) {
         mHits = integer;
     }
-
-
+    
+    
     /**
      * @return Returns the title.
      */
-    public String getWebsiteName()
-    {
+    public String getWebsiteName() {
         return mWebsiteName;
     }
     
     /**
      * @param title The title to set.
      */
-    public void setWebsiteName(String name)
-    {
+    public void setWebsiteName(String name) {
         mWebsiteName = name;
+    }
+    
+    public String getWebsiteHandle() {
+        return mWebsiteHandle;
+    }
+    
+    public void setWebsiteHandle(String mWebsiteHandle) {
+        this.mWebsiteHandle = mWebsiteHandle;
     }
 }

Modified: incubator/roller/branches/roller_2.0/src/org/roller/presentation/MainPageAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/MainPageAction.java?rev=291727&r1=291726&r2=291727&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/MainPageAction.java (original)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/MainPageAction.java Mon Sep 26 13:14:23 2005
@@ -25,26 +25,24 @@
  * @struts.action name="main" path="/main" scope="request"
  * @struts.action-forward name="main.page" path=".main"
  */
-public class MainPageAction extends Action
-{
+public class MainPageAction extends Action {
     // TODO: make timeouts configurable
     private static TimedHolder mPopularWebsites = new TimedHolder(30 * 60 * 1000);
     private static TimedHolder mRecentEntries = new TimedHolder(120 * 60 * 1000);
     private static TimedHolder mPinnedEntries = new TimedHolder(120 * 60 * 1000);
     
-    private static Log mLogger = 
-        LogFactory.getFactory().getInstance(MainPageAction.class);
-        
-	/**
-	 * Loads model and forwards to main.page.
+    private static Log mLogger =
+            LogFactory.getFactory().getInstance(MainPageAction.class);
+    
+    /**
+     * Loads model and forwards to main.page.
      */
-	public ActionForward execute(
-		ActionMapping mapping, ActionForm form,
-		HttpServletRequest req, HttpServletResponse res)
-		throws Exception
-	{        
+    public ActionForward execute(
+            ActionMapping mapping, ActionForm form,
+            HttpServletRequest req, HttpServletResponse res)
+            throws Exception {
         RollerContext rctx = RollerContext.getRollerContext(req);
-		
+        
         req.setAttribute("version",rctx.getRollerVersion());
         req.setAttribute("buildTime",rctx.getRollerBuildTime());
         req.setAttribute("baseURL", rctx.getContextUrl(req));
@@ -54,106 +52,92 @@
         req.setAttribute("data", model);
         
         // Determines if register new sers
-        boolean allowNewUsers = 
+        boolean allowNewUsers =
                 RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
-
+        
         java.security.Principal prince = req.getUserPrincipal();
-        if (prince != null) 
-        {
+        if (prince != null) {
             req.setAttribute("loggedIn",Boolean.TRUE);
             req.setAttribute("userName",prince.getName());
-        } 
-        else if (allowNewUsers)
-        {   
+        } else if (allowNewUsers) {
             req.setAttribute("allowNewUsers",Boolean.TRUE);
         }
         req.setAttribute("leftPage","/theme/status.jsp");
         
         return mapping.findForward("main.page");
-	}
+    }
     
-    public static void flushMainPageCache()
-    {
+    public static void flushMainPageCache() {
         mLogger.debug("Flushing recent and pinned entries");
-        mRecentEntries.expire();    
-        mPinnedEntries.expire();    
+        mRecentEntries.expire();
+        mPinnedEntries.expire();
     }
     
     /**
-     * Page model. 
+     * Page model.
      */
-    public static class MainPageData extends BasePageModel
-    {
+    public static class MainPageData extends BasePageModel {
         private HttpServletRequest mRequest = null;
         
         public MainPageData(
-                HttpServletRequest req, 
-                HttpServletResponse res, 
-                ActionMapping mapping) 
-        {
+                HttpServletRequest req,
+                HttpServletResponse res,
+                ActionMapping mapping) {
             super("dummyTitleKey", req, res, mapping);
             mRequest = req;
         }
         
-        /** 
+        /**
          * Get list of most popular websites in terms of day hits.
          * @param num Number of entries to return (takes effect on next cache refresh)
          */
-        public List getPopularWebsites(int num) throws RollerException
-        {
+        public List getPopularWebsites(int num) throws RollerException {
             List list = (List)mPopularWebsites.getObject();
-            if (list == null)
-            {
+            if (list == null) {
                 mLogger.debug("Refreshing popular websites list");
-                Roller roller = RollerFactory.getRoller();            
+                Roller roller = RollerFactory.getRoller();
                 list = roller.getRefererManager().getDaysPopularWebsites(num);
                 mPopularWebsites.setObject(list);
             }
             return list;
-       }
+        }
         
-        /** 
+        /**
          * Get list of recent weblog entries.
          * @param num Number of entries to return (takes effect on next cache refresh)
          */
-        public List getRecentWeblogEntries(int num) throws RollerException
-        {
+        public List getRecentWeblogEntries(int num) throws RollerException {
             List list = (List)mRecentEntries.getObject();
             try {
-            if (list == null)
-            {
-                mLogger.debug("Refreshing recent entries list");
-                Roller roller = RollerFactory.getRoller();		                      
-                list = roller.getWeblogManager().getWeblogEntries(
-                    null,                   // userName
-                    null,                   // startDate
-                    new Date(),             // endDate
-                    null,                   // catName
-                    WeblogEntryData.PUBLISHED, // status
-                    new Integer(num));       // maxEntries
-                mRecentEntries.setObject(list);
-            }
-            } 
-            catch (Exception e) 
-            {
+                if (list == null) {
+                    mLogger.debug("Refreshing recent entries list");
+                    Roller roller = RollerFactory.getRoller();
+                    list = roller.getWeblogManager().getWeblogEntries(
+                            null,                   // userName
+                            null,                   // startDate
+                            new Date(),             // endDate
+                            null,                   // catName
+                            WeblogEntryData.PUBLISHED, // status
+                            new Integer(num));       // maxEntries
+                    mRecentEntries.setObject(list);
+                }
+            } catch (Exception e) {
                 mLogger.error(e);
             }
             return list;
         }
         
-        /** 
-         * Get list of recent weblog pinned entries 
+        /**
+         * Get list of recent weblog pinned entries
          * @param num Number of entries to return (takes effect on next cache refresh)
          */
-        public List getWeblogEntriesPinnedToMain(int num) throws RollerException
-        {
+        public List getWeblogEntriesPinnedToMain(int num) throws RollerException {
             List list = (List)mPinnedEntries.getObject();
-            if (list == null)
-            {
+            if (list == null) {
                 mLogger.debug("Refreshing pinned entries list");
                 Roller roller = RollerFactory.getRoller();
                 list = roller.getWeblogManager()
-                    .getWeblogEntriesPinnedToMain(new Integer(num));  
+                .getWeblogEntriesPinnedToMain(new Integer(num));
                 mPinnedEntries.setObject(list);
             }
             return list;
@@ -161,38 +145,30 @@
     }
     
     /** Hold object and expire after timeout passes. */
-    public static class TimedHolder 
-    {
+    public static class TimedHolder {
         private Object obj = null;
         private long updated = 0L;
         private long timeout = 3000L;  // 3 seconds ?? -Lance
         
         /** Create holder with timeout */
-        public TimedHolder(long timeout)
-        {
+        public TimedHolder(long timeout) {
             this.timeout = timeout;
         }
         /** Set object and reset the timeout clock */
-        public synchronized void setObject(Object obj)
-        {
+        public synchronized void setObject(Object obj) {
             this.obj = obj;
             this.updated = new Date().getTime();
         }
         /** Force object to expire */
-        public synchronized void expire()
-        {
+        public synchronized void expire() {
             this.obj = null;
         }
         /** Get object or null if object has expired */
-        public Object getObject()
-        {
+        public Object getObject() {
             long currentTime = new Date().getTime();
-            if ((currentTime - this.updated) > this.timeout)
-            {
+            if ((currentTime - this.updated) > this.timeout) {
                 return null;
-            }
-            else 
-            {
+            } else {
                 return this.obj;
             }
         }

Modified: incubator/roller/branches/roller_2.0/web/main-sidebar.jsp
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/web/main-sidebar.jsp?rev=291727&r1=291726&r2=291727&view=diff
==============================================================================
--- incubator/roller/branches/roller_2.0/web/main-sidebar.jsp (original)
+++ incubator/roller/branches/roller_2.0/web/main-sidebar.jsp Mon Sep 26 13:14:23 2005
@@ -13,8 +13,8 @@
     <ul>
         <c:forEach var="site" items="${popularWebsites}">
            <li>
-               <a href='<c:out value="${baseURL}" />/page/<c:out value="${site.userName}" />'
-                  title='<c:out value="${site.userName}" />' >
+               <a href='<c:out value="${baseURL}" />/page/<c:out value="${site.websiteHandle}" />'
+                  title='<c:out value="${site.websiteHandle}" />' >
                   <str:truncateNicely lower="45" 
                     upper="45" ><c:out 
                     value="${site.websiteName}" /></str:truncateNicely></a>: