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/10/21 23:46:28 UTC

svn commit: r327589 [27/72] - in /incubator/roller/branches/roller_1.x: ./ contrib/ contrib/lib/ contrib/plugins/ contrib/plugins/src/ contrib/plugins/src/org/ contrib/plugins/src/org/roller/ contrib/plugins/src/org/roller/presentation/ contrib/plugins...

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogEntryData.java?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogEntryData.java (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogEntryData.java Fri Oct 21 14:27:36 2005
@@ -0,0 +1,1072 @@
+
+package org.roller.pojos;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+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.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.model.WeblogManager;
+import org.roller.util.DateUtil;
+import org.roller.util.Utilities;
+
+/**
+ * Represents a Weblog Entry.
+ * 
+ * @author David M Johnson
+ *
+ * @ejb:bean name="WeblogEntryData"
+ * @struts.form include-all="true"
+ * @hibernate.class table="weblogentry"
+ * hibernate.jcs-cache usage="read-write"
+ */
+public class WeblogEntryData extends org.roller.pojos.PersistentObject
+    implements java.io.Serializable
+{
+    private static Log mLogger = LogFactory.getFactory()
+                                           .getInstance(WeblogEntryData.class);
+                                           
+    static final long serialVersionUID = 2341505386843044125L;
+    
+    protected String id=null;
+    protected org.roller.pojos.WeblogCategoryData category=null;
+    protected String title=null;
+    protected String link=null;
+    protected String text=null;
+    protected String anchor=null;
+    protected Timestamp pubTime=null;
+    protected Timestamp updateTime=null;
+    protected Boolean publishEntry=null;
+    protected WebsiteData mWebsite=null;
+    protected String mPlugins;
+    protected Boolean allowComments = Boolean.TRUE;
+    protected Integer commentDays = new Integer(0);
+    protected Boolean rightToLeft = Boolean.FALSE;
+    protected Boolean pinnedToMain = Boolean.FALSE;
+    
+    private Map attMap = new HashMap();
+    private Set attSet = new TreeSet();
+    
+    //----------------------------------------------------------- Construction
+
+    public WeblogEntryData()
+    {
+    }
+
+    public WeblogEntryData(
+       java.lang.String id, 
+       org.roller.pojos.WeblogCategoryData category, 
+       WebsiteData website, 
+       java.lang.String title, 
+       java.lang.String link,
+       java.lang.String text, 
+       java.lang.String anchor, 
+       java.sql.Timestamp pubTime, 
+       java.sql.Timestamp updateTime, 
+       java.lang.Boolean publishEntry)
+    {
+        this.id = id;
+        this.category = category;
+        this.mWebsite = website;
+        this.title = title;
+        this.link = link;
+        this.text = text;
+        this.anchor = anchor;
+        this.pubTime = pubTime;
+        this.updateTime = updateTime;
+        this.publishEntry = publishEntry;
+    }
+
+    public WeblogEntryData(WeblogEntryData otherData)
+    {
+        setData(otherData);
+    }
+
+    //---------------------------------------------------------- Initializaion
+
+    /**
+     * Setter is needed in RollerImpl.storePersistentObject()
+     */
+    public void setData(org.roller.pojos.PersistentObject otherData)
+    {
+        WeblogEntryData other = (WeblogEntryData)otherData;
+        this.id = other.id;
+        this.category = other.category;
+        this.mWebsite = other.mWebsite;
+        this.title = other.title;
+        this.link = other.link;
+        this.text = other.text;
+        this.anchor = other.anchor;
+        this.pubTime = other.pubTime;
+        this.updateTime = other.updateTime;
+        this.publishEntry = other.publishEntry;
+        this.mPlugins = other.mPlugins;
+        this.allowComments = other.allowComments;
+        this.commentDays = other.commentDays;
+        this.rightToLeft = other.rightToLeft;
+        this.pinnedToMain = other.pinnedToMain;
+    }
+
+    //------------------------------------------------------ Simple properties
+    
+    /** 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.id column="id" type="string"
+     *  generator-class="uuid.hex" unsaved-value="null"
+     */
+    public java.lang.String getId()
+    {
+        return this.id;
+    }
+
+    /** @ejb:persistent-field */
+    public void setId(java.lang.String id)
+    {
+        this.id = id;
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="pojo"
+     * @ejb:persistent-field 
+     * @hibernate.many-to-one column="categoryid" cascade="none" not-null="true"
+     */
+    public org.roller.pojos.WeblogCategoryData getCategory()
+    {
+        return this.category;
+    }
+
+    /** @ejb:persistent-field */
+    public void setCategory(org.roller.pojos.WeblogCategoryData category)
+    {
+        this.category = category;
+    }
+
+    /**
+     * Set weblog category via weblog category ID.
+     * @param id Weblog category ID.
+     */
+    public void setCategoryId(String id) throws RollerException
+    {
+        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+        setCategory(wmgr.retrieveWeblogCategory(id));
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="pojo"
+     * @ejb:persistent-field 
+     * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
+     */
+    public WebsiteData getWebsite()
+    {
+        return this.mWebsite;
+    }
+
+    /** @ejb:persistent-field */
+    public void setWebsite(WebsiteData website)
+    {
+        this.mWebsite = website;
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="title" non-null="true" unique="false"
+     */
+    public java.lang.String getTitle()
+    {
+        return this.title;
+    }
+
+    /** @ejb:persistent-field */
+    public void setTitle(java.lang.String title)
+    {
+        this.title = title;
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="text" non-null="true" unique="false"
+     */
+    public java.lang.String getText()
+    {
+        return this.text;
+    }
+
+    /** @ejb:persistent-field */
+    public void setText(java.lang.String text)
+    {
+        this.text = text;
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="anchor" non-null="true" unique="false"
+     */
+    public java.lang.String getAnchor()
+    {
+        return this.anchor;
+    }
+
+    /** @ejb:persistent-field */
+    public void setAnchor(java.lang.String anchor)
+    {
+        this.anchor = anchor;
+    }
+
+    //-------------------------------------------------------------------------
+    /** 
+     * Map attributes as set because XDoclet 1.2b4 map support is broken.
+     *
+     * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.EntryAttributeData"
+     * @ejb:persistent-field
+     * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all" 
+     * @hibernate.collection-key column="entryid" type="String"
+     * @hibernate.collection-one-to-many class="org.roller.pojos.EntryAttributeData"
+     */
+    public Set getEntryAttributes()    
+    {
+        return attSet;
+    }
+    /** @ejb:persistent-field */
+    public void setEntryAttributes(Set attSet)
+    {
+        this.attSet = attSet;
+        
+        // copy set to map
+        if (attSet != null)
+        {
+            this.attSet = attSet;
+            this.attMap = new HashMap();
+            Iterator iter = this.attSet.iterator();
+            while (iter.hasNext()) 
+            {
+                EntryAttributeData att = (EntryAttributeData)iter.next();
+                attMap.put(att.getName(), att);
+            }
+        }
+        else 
+        {
+            this.attSet = new TreeSet();
+            this.attMap = new HashMap();
+        }
+    }
+    
+    
+    /** 
+     * Would be named getEntryAttribute, but that would set off XDoclet
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String findEntryAttribute(String name)
+    {
+        EntryAttributeData att = ((EntryAttributeData)attMap.get(name));
+        return (att != null) ? att.getValue() : null;
+    }
+    
+    
+    public void putEntryAttribute(String name, String value) throws Exception
+    {
+        EntryAttributeData att = (EntryAttributeData)attMap.get(name);
+        if (att == null) 
+        {
+            att = new EntryAttributeData();
+            att.setEntry(this);
+            att.setName(name);
+            att.setValue(value);
+            attMap.put(name, att);    
+            attSet.add(att);
+        }
+        else 
+        {
+            att.setValue(value);
+        }
+    }
+    public void removeEntryAttribute(String name) throws RollerException
+    {
+        EntryAttributeData att = (EntryAttributeData)attMap.get(name);
+        if (att != null) 
+        {
+            attMap.remove(att);
+            attSet.remove(att);
+            att.remove();
+        }
+    }
+    //-------------------------------------------------------------------------
+    
+    /**  
+     * <p>Publish time is the time that an entry is to be (or was) made available
+     * for viewing by newsfeed readers and visitors to the Roller site.</p> 
+     * 
+     * <p>Roller stores time in universal time. When times are displayed in a 
+     * user's weblog they must be translated to the user's timezone.</p>
+     *
+     * <p>NOTE: Times are stored using the SQL TIMESTAMP datatype, which on 
+     * MySQL has only a one-second resolution.</p>
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="pubtime" non-null="true" unique="false"
+     */
+    public java.sql.Timestamp getPubTime()
+    {
+        return this.pubTime;
+    }
+
+    /** @ejb:persistent-field */
+    public void setPubTime(java.sql.Timestamp pubTime)
+    {
+        this.pubTime = pubTime;
+    }
+
+    /** 
+     * <p>Update time is the last time that an weblog entry was saved in the 
+     * Roller weblog editor or via web services API (XML-RPC or Atom).</p> 
+     *
+     * <p>Roller stores time using the timezone of the server itself. When
+     * times are displayed  in a user's weblog they must be translated 
+     * to the user's timezone.</p>
+     *
+     * <p>NOTE: Times are stored using the SQL TIMESTAMP datatype, which on 
+     * MySQL has only a one-second resolution.</p>
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="updatetime" non-null="true" unique="false"
+     */
+    public java.sql.Timestamp getUpdateTime()
+    {
+        return this.updateTime;
+    }
+
+    /** @ejb:persistent-field */
+    public void setUpdateTime(java.sql.Timestamp updateTime)
+    {
+        this.updateTime = updateTime;
+    }
+
+    /** 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="publishentry" non-null="true" unique="false"
+     */
+    public java.lang.Boolean getPublishEntry()
+    {
+        return this.publishEntry;
+    }
+
+    /** @ejb:persistent-field */
+    public void setPublishEntry(java.lang.Boolean publishEntry)
+    {
+        this.publishEntry = publishEntry;
+    }
+
+    /**
+     * Some weblog entries are about one specific link.
+     * @return Returns the link.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="link" non-null="false" unique="false"
+     */
+    public java.lang.String getLink()
+    {
+        return link;
+    }
+
+    /**
+     * @ejb:persistent-field
+     * @param link The link to set.
+     */
+    public void setLink(java.lang.String link)
+    {
+        this.link = link;
+    }
+
+    /**
+     * Comma-delimited list of this entry's Plugins.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="plugins" non-null="false" unique="false"
+     */
+    public java.lang.String getPlugins()
+    {
+        return mPlugins;
+    }
+
+    /** @ejb:persistent-field */
+    public void setPlugins(java.lang.String string)
+    {
+        mPlugins = string;
+    }
+
+    
+    /**
+     * True if comments are allowed on this weblog entry.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="allowcomments" non-null="true" unique="false"
+     */
+    public Boolean getAllowComments() {
+        return allowComments;
+    }
+    /**
+     * True if comments are allowed on this weblog entry.
+     * @ejb:persistent-field
+     */
+    public void setAllowComments(Boolean allowComments) {
+        this.allowComments = allowComments;
+    }
+    
+    /**
+     * Number of days after pubTime that comments should be allowed, or 0 for no limit.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="commentdays" non-null="true" unique="false"
+     */
+    public Integer getCommentDays() {
+        return commentDays;
+    }
+    /**
+     * Number of days after pubTime that comments should be allowed, or 0 for no limit.
+     * @ejb:persistent-field
+     */
+    public void setCommentDays(Integer commentDays) {
+        this.commentDays = commentDays;
+    }
+    
+    /**
+     * True if this entry should be rendered right to left.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="righttoleft" non-null="true" unique="false"
+     */
+    public Boolean getRightToLeft() {
+        return rightToLeft;
+    }
+    /**
+     * True if this entry should be rendered right to left.
+     * @ejb:persistent-field
+     */
+    public void setRightToLeft(Boolean rightToLeft) {
+        this.rightToLeft = rightToLeft;
+    }
+
+    /**
+     * True if story should be pinned to the top of the Roller site main blog.
+     * @return Returns the pinned.
+     * 
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field 
+     * @hibernate.property column="pinnedtomain" non-null="true" unique="false"
+     */
+    public Boolean getPinnedToMain()
+    {
+        return pinnedToMain;
+    }
+    /**
+     * True if story should be pinned to the top of the Roller site main blog.
+     * @param pinnedToMain The pinned to set.
+     * 
+     * @ejb:persistent-field 
+     */
+    public void setPinnedToMain(Boolean pinnedToMain)
+    {
+        this.pinnedToMain = pinnedToMain;
+    }
+
+    //------------------------------------------------------------------------
+
+    /**
+     * Save the entry and queue applicable web log update pings if the entry is published.
+     * @see org.roller.pojos.PersistentObject#save()
+     */
+    public void save() throws RollerException
+    {
+        // If no anchor then create one
+        if (getAnchor()==null || getAnchor().trim().equals(""))
+        {
+            setAnchor(createAnchor());
+        }
+        if (getPublishEntry() != null && getPublishEntry().booleanValue()) {
+            // Queue applicable pings for this update.
+            RollerFactory.getRoller().getAutopingManager().queueApplicableAutoPings(this);
+        }
+        super.save();
+    }
+    
+    //------------------------------------------------------------------------
+    
+    /** 
+     * True if comments are still allowed on this entry considering the 
+     * allowComments and commentDays fields.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public boolean getCommentsStillAllowed() 
+    {
+    		boolean ret = false;
+    		if (getAllowComments() == null || getAllowComments().booleanValue()) 
+    		{
+    			if (getCommentDays() == null || getCommentDays().intValue() == 0)
+    			{
+    				ret = true;
+    			}
+    			else 
+    			{
+    				Calendar expireCal = Calendar.getInstance(getWebsite().getLocaleInstance());
+    				expireCal.setTime(getPubTime());
+    				expireCal.add(Calendar.DATE, getCommentDays().intValue());
+    				Date expireDay = expireCal.getTime();
+    				Date today = new Date();
+    				if (today.before(expireDay))
+    				{
+    					ret = true;
+    				}
+    			}
+    		}
+    		return ret;
+    }
+    public void setCommentsStillAllowed(boolean ignored) {
+        // no-op
+    }
+
+    
+    //------------------------------------------------------------------------
+    
+    /** 
+     * Format the publish time of this weblog entry using the specified pattern.
+     * See java.text.SimpleDateFormat for more information on this format.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @see java.text.SimpleDateFormat
+     * @return Publish time formatted according to pattern.
+     */
+    public String formatPubTime(String pattern)
+    {
+        try
+        {
+            SimpleDateFormat format = new SimpleDateFormat(pattern, 
+                    this.getWebsite().getLocaleInstance());
+
+            return format.format(getPubTime());
+        }
+        catch (RuntimeException e)
+        {
+            mLogger.error("Unexpected exception", e);
+        }
+
+        return "ERROR: formatting date";
+    }
+
+    //------------------------------------------------------------------------
+    
+    /** 
+     * Format the update time of this weblog entry using the specified pattern.
+     * See java.text.SimpleDateFormat for more information on this format.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @see java.text.SimpleDateFormat
+     * @return Update time formatted according to pattern.
+     */
+    public String formatUpdateTime(String pattern)
+    {
+        try
+        {
+            SimpleDateFormat format = new SimpleDateFormat(pattern);
+
+            return format.format(getUpdateTime());
+        }
+        catch (RuntimeException e)
+        {
+            mLogger.error("Unexpected exception", e);
+        }
+
+        return "ERROR: formatting date";
+    }
+
+    //------------------------------------------------------------------------
+    
+    /**
+     * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.CommentData"
+     */
+    public List getComments()
+    {
+        return getComments(true);
+    }
+    
+    /**
+     * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.CommentData"
+     */
+    public List getComments(boolean ignoreSpam)
+    {
+        List list = new ArrayList();
+        try
+        {
+            return RollerFactory.getRoller().getWeblogManager().getComments(getId(), ignoreSpam);
+        }
+        catch (RollerException alreadyLogged) {}
+        return list;
+    }
+
+    //------------------------------------------------------------------------
+    
+    /**
+     * @roller.wrapPojoMethod type="pojo-collection" class="org.roller.pojos.RefererData"
+     */
+    public List getReferers()
+    {
+        List referers = null;
+        try {
+            referers = RollerFactory.getRoller().getRefererManager().getReferersToEntry(getId());
+        } catch (RollerException e) {
+            mLogger.error("Unexpected exception", e);
+        }
+        return referers;
+    }
+
+    //------------------------------------------------------------------------
+    
+    /**
+     * @param entry
+     * @param url
+     * @param title
+     * @param excerpt
+     * @param blogName
+     */
+    /* moved to trackback servlet -- Allen G
+    public void addTrackback(
+        String url, String title, String excerpt, String blogName) 
+        throws RollerException
+    {
+        String modTitle = blogName + ": "  + title;
+        if (modTitle.length() >= 250)
+        {
+            modTitle = modTitle.substring(0, 257);
+            modTitle += "...";
+        }
+        
+        // Track trackbacks as comments
+        CommentData comment = new CommentData();
+        comment.setContent("[Trackback] "+excerpt);
+        comment.setName(blogName);
+        comment.setUrl(url);
+        comment.setWeblogEntry(this);
+        comment.setNotify(Boolean.FALSE);
+        comment.setPostTime(new Timestamp(new Date().getTime()));
+        comment.save();
+         
+        // Alternative: treat trackbacks as referers
+        //RefererData ref = new RefererData();
+        //ref.setWebsite(getWebsite());
+        //ref.setWeblogEntry(this);
+        //ref.setRequestUrl("(trackback)");
+        //ref.setRefererUrl(url);
+        //ref.setTitle(modTitle);
+        //ref.setExcerpt(excerpt);
+        //ref.setVisible(Boolean.TRUE);
+        //ref.setDayHits(new Integer(0));
+        //ref.setTotalHits(new Integer(0));
+        //ref.setDuplicate(Boolean.FALSE);        
+        //ref.setDateString(formatPubTime("yyyyMMdd"));        
+        //mRoller.getRefererManager().storeReferer(ref);
+    }
+    */
+    
+    /**
+     * Convenience method for getPermalink(category)
+     * where no category is necessary.
+     * 
+     * @roller.wrapPojoMethod type="simple"
+     * @return
+     */
+    public String getPermaLink()
+    {
+        String lAnchor = this.getAnchor();
+        
+        try
+        {
+            lAnchor = URLEncoder.encode(anchor, "UTF-8");
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            // go with the "no encoding" version
+        }
+        
+        WebsiteData website = this.getWebsite();
+        String plink = "/page/" + website.getUser().getUserName() + 
+                "?entry=" + lAnchor;
+        
+        return plink;
+    }
+    
+    /**
+     * Get the "relative" URL to this entry.  Proper use of this will 
+     * require prepending the baseURL (either the full root 
+     * [http://server.com/context] or at least the context
+     * [/context]) in order to generate a functional link.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @param category The category name to insert into the permalink.
+     * @return String
+     */
+    public String getPermaLink(String categoryPath)
+    {
+        // i don't really understand the purpose of this method since
+        // WeblogEntryData.getPermaLink() is only meant to point to this entry
+        
+        return this.getPermaLink();
+    }
+    
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String getCommentsLink()
+    {
+        String dayString = DateUtil.format8chars(this.getPubTime());
+        String lAnchor = this.getAnchor();
+        try
+        {
+            lAnchor = URLEncoder.encode(anchor, "UTF-8");
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            // go with the "no encoding" version
+        }        
+        String clink = "/page/" + this.getWebsite().getUser().getUserName() + "?anchor=" + lAnchor;
+        return clink;
+    }
+    /** to please XDoclet */
+    public void setCommentsLink(String ignored) {}
+    
+    /**
+     * Return the Title of this post, or the first 255 characters of the
+     * entry's text.
+     * 
+     * @roller.wrapPojoMethod type="simple"
+     * @return String
+     */
+    public String getDisplayTitle()
+    {
+        if ( getTitle()==null || getTitle().trim().equals("") )
+        {
+            return StringUtils.left(Utilities.removeHTML(text),255);
+        }
+        return Utilities.removeHTML(getTitle());
+    }
+    
+    //------------------------------------------------------------------------
+    
+    public String toString()
+    {
+        StringBuffer str = new StringBuffer("{");
+
+        str.append("id=" + id + " " + 
+                   "category=" + category + " " + 
+                   "title=" + title + " " + 
+                    "text=" + text + " " + 
+                    "anchor=" + anchor + " " + 
+                    "pubTime=" + pubTime + " " + 
+                    "updateTime=" + updateTime + " " + 
+                    "publishEntry=" + publishEntry + " " + 
+                    "plugins=" + mPlugins);
+        str.append('}');
+
+        return (str.toString());
+    }
+
+    //------------------------------------------------------------------------
+    
+    public boolean equals(Object pOther)
+    {
+        if (pOther instanceof WeblogEntryData)
+        {
+            WeblogEntryData lTest = (WeblogEntryData) pOther;
+            boolean lEquals = true;
+
+            if (this.id == null)
+            {
+                lEquals = lEquals && (lTest.id == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.id.equals(lTest.id);
+            }
+
+            if (this.category == null)
+            {
+                lEquals = lEquals && (lTest.category == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.category.equals(lTest.category);
+            }
+
+            if (this.mWebsite == null)
+            {
+                lEquals = lEquals && (lTest.mWebsite == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.mWebsite.equals(lTest.mWebsite);
+            }
+
+            if (this.title == null)
+            {
+                lEquals = lEquals && (lTest.title == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.title.equals(lTest.title);
+            }
+
+            if (this.text == null)
+            {
+                lEquals = lEquals && (lTest.text == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.text.equals(lTest.text);
+            }
+
+            if (this.anchor == null)
+            {
+                lEquals = lEquals && (lTest.anchor == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.anchor.equals(lTest.anchor);
+            }
+
+            if (this.pubTime == null)
+            {
+                lEquals = lEquals && (lTest.pubTime == null);
+            }
+            else
+            {
+                lEquals = lEquals && this.pubTime.equals(lTest.pubTime);
+            }
+
+            if (this.updateTime == null)
+            {
+                lEquals = lEquals && (lTest.updateTime == null);
+            }
+            else
+            {
+                lEquals = lEquals && 
+                          this.updateTime.equals(lTest.updateTime);
+            }
+
+            if (this.publishEntry == null)
+            {
+                lEquals = lEquals && (lTest.publishEntry == null);
+            }
+            else
+            {
+                lEquals = lEquals && 
+                          this.publishEntry.equals(lTest.publishEntry);
+            }
+
+            if (this.mPlugins == null)
+            {
+                lEquals = lEquals && (lTest.mPlugins == null);
+            }
+            else
+            {
+                lEquals = lEquals && 
+                          this.mPlugins.equals(lTest.mPlugins);
+            }
+
+
+            return lEquals;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    //------------------------------------------------------------------------
+    
+    public int hashCode()
+    {
+        int result = 17;
+        result = (37 * result) + 
+                 ((this.id != null) ? this.id.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.category != null) ? this.category.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.mWebsite != null) ? this.mWebsite.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.title != null) ? this.title.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.text != null) ? this.text.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.anchor != null) ? this.anchor.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.pubTime != null) ? this.pubTime.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.updateTime != null) ? this.updateTime.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.publishEntry != null) ? this.publishEntry.hashCode() : 0);
+        result = (37 * result) + 
+                 ((this.mPlugins != null) ? this.mPlugins.hashCode() : 0);
+
+        return result;
+    }
+    
+    /**
+     * Return RSS 09x style description (escaped HTML version of entry text)
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String getRss09xDescription()
+    {
+        return getRss09xDescription(-1);
+    }
+    
+    /** 
+     * Return RSS 09x style description (escaped HTML version of entry text)
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String getRss09xDescription(int maxLength)
+    {
+        String ret = Utilities.escapeHTML(text);
+        if (maxLength != -1 && ret.length() > maxLength) 
+        {  
+            ret = ret.substring(0,maxLength-3)+"..."; 
+        }
+        return ret;     
+    }
+
+    /** Create anchor for weblog entry, based on title or text */
+    protected String createAnchor() throws RollerException
+    {
+        return RollerFactory.getRoller().getWeblogManager().createAnchor(this);
+    }
+
+    /** Create anchor for weblog entry, based on title or text */
+    public String createAnchorBase()
+    {
+        // Use title or text for base anchor
+        String base = getTitle();
+        if (base == null || base.trim().equals(""))
+        {
+            base = getText();
+        }
+        if (base != null && !base.trim().equals(""))
+        {
+            base = Utilities.replaceNonAlphanumeric(base, ' ');
+
+            // Use only the first 4 words
+            StringTokenizer toker = new StringTokenizer(base);
+            String tmp = null;
+            int count = 0;
+            while (toker.hasMoreTokens() && count < 5)
+            {
+                String s = toker.nextToken();
+                s = s.toLowerCase();
+                tmp = (tmp == null) ? s : tmp + "_" + s;
+                count++;
+            }
+            base = tmp;
+        }
+        // No title or text, so instead we will use the items date
+        // in YYYYMMDD format as the base anchor
+        else
+        {
+            base = DateUtil.format8chars(getPubTime());
+        }
+
+        return base;
+    }
+
+    /**
+     * A no-op.
+     * TODO: fix formbean generation so this is not needed. 
+     * @param string
+     */
+    public void setPermaLink(String string)
+    {
+    }
+
+    /**
+     * A no-op.
+     * TODO: fix formbean generation so this is not needed. 
+     * @param string
+     */
+    public void setDisplayTitle(String string)
+    {
+    }
+
+    /**
+     * A no-op.
+     * TODO: fix formbean generation so this is not needed. 
+     * @param string
+     */
+    public void setRss09xDescription(String string)
+    {
+    }
+    
+    /** 
+     * @see org.roller.pojos.PersistentObject#remove()
+     */
+    public void remove() throws RollerException
+    {
+        RollerFactory.getRoller().getWeblogManager().removeWeblogEntryContents(this);
+        super.remove();
+    }
+    
+    /**
+     * Convenience method to transform mPlugins to a List
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @return
+     */
+    public List getPluginsList()
+    {
+        if (mPlugins != null)
+        {
+            return Arrays.asList( StringUtils.split(mPlugins, ",") );
+        }
+        return new ArrayList();
+    }
+
+    public boolean canSave() throws RollerException
+    {
+        Roller roller = RollerFactory.getRoller();
+        if (roller.getUser().equals(UserData.SYSTEM_USER)) 
+        {
+            return true;
+        }
+        if (roller.getUser().equals(getWebsite().getUser()))
+        {
+            return true;
+        }
+        return false;
+    }
+}

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogTemplate.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogTemplate.java?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogTemplate.java (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/pojos/WeblogTemplate.java Fri Oct 21 14:27:36 2005
@@ -0,0 +1,311 @@
+package org.roller.pojos;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.roller.RollerException;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.Template;
+
+
+/**
+ * Pojo that represents a single user defined template page.
+ *
+ * This template is different from the generic template because it also
+ * contains a reference to the website it is part of.
+ *
+ * @author David M Johnson
+ * 
+ * @ejb:bean name="WeblogTemplate"
+ * @struts.form include-all="true"
+ * @hibernate.class table="webpage" 
+ * hibernate.jcs-cache usage="read-write"
+ */
+public class WeblogTemplate extends PersistentObject
+   implements Serializable, Template
+{
+   static final long serialVersionUID = -613737191638263428L;
+
+   private java.lang.String id;
+   private java.lang.String name;
+   private java.lang.String description;
+   private java.lang.String link;
+   private java.lang.String contents;
+   private java.util.Date lastModified;
+
+   protected WebsiteData mWebsite = null;
+
+   public WeblogTemplate()
+   {
+   }
+
+   public WeblogTemplate( 
+       java.lang.String id,
+       WebsiteData website,
+       java.lang.String name,
+       java.lang.String description,
+       java.lang.String link,
+       java.lang.String template,
+       java.util.Date updateTime )
+   {
+      this.id = id;
+      this.mWebsite = website;
+      this.name = name;
+      this.description = description;
+      this.link = link;
+      this.contents = template;
+      this.lastModified = (Date)updateTime.clone();
+   }
+
+   public WeblogTemplate( WeblogTemplate otherData )
+   {
+      this.id = otherData.id;
+      this.mWebsite = otherData.mWebsite;
+      this.name = otherData.name;
+      this.description = otherData.description;
+      this.link = otherData.link;
+      this.contents = otherData.contents;
+      this.lastModified = otherData.lastModified;
+
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.id column="id" type="string"
+    *  generator-class="uuid.hex" unsaved-value="null"
+    */
+   public java.lang.String getId()
+   {
+      return this.id;
+   }
+   /** @ejb:persistent-field */ 
+   public void setId( java.lang.String id )
+   {
+      this.id = id;
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
+    */
+   public WebsiteData getWebsite()
+   {
+      return this.mWebsite;
+   }
+   /** @ejb:persistent-field */ 
+   public void setWebsite( WebsiteData website )
+   {
+      this.mWebsite = website;
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.property column="name" non-null="true" unique="false"
+    */
+   public java.lang.String getName()
+   {
+      return this.name;
+   }
+   /** @ejb:persistent-field */ 
+   public void setName( java.lang.String name )
+   {
+      this.name = name;
+   }
+
+   /** 
+    * Description
+    * @ejb:persistent-field 
+    * @hibernate.property column="description" non-null="true" unique="false"
+    */
+   public java.lang.String getDescription()
+   {
+      return this.description;
+   }
+   /** @ejb:persistent-field */ 
+   public void setDescription( java.lang.String description )
+   {
+      this.description = description;
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.property column="link" non-null="true" unique="false"
+    */
+   public java.lang.String getLink()
+   {
+      return this.link;
+   }
+   /** @ejb:persistent-field */ 
+   public void setLink( java.lang.String link )
+   {
+      this.link = link;
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.property column="template" non-null="true" unique="false"
+    */
+   public java.lang.String getContents()
+   {
+      return this.contents;
+   }
+   /** @ejb:persistent-field */ 
+   public void setContents( java.lang.String template )
+   {
+      this.contents = template;
+   }
+
+   /** 
+    * @ejb:persistent-field 
+    * @hibernate.property column="updatetime" non-null="true" unique="false"
+    */
+   public java.util.Date getLastModified()
+   {
+      return (Date)this.lastModified.clone();
+   }   
+   /** @ejb:persistent-field */ 
+   public void setLastModified(final java.util.Date newtime )
+   {
+      if (newtime != null)	
+      {
+      	 lastModified = (Date)newtime.clone();
+      }
+      else 
+      {
+      	 lastModified = null;
+      }
+   }
+
+   public String toString()
+   {
+      StringBuffer str = new StringBuffer("{");
+
+      str.append("id=" + id + " " + "name=" + name + " " + "description=" 
+      + description + " " + "link=" + link + " " + "template=" + contents 
+      + " " + "updateTime=" + lastModified);
+      str.append('}');
+
+      return(str.toString());
+   }
+
+   public boolean equals( Object pOther )
+   {
+      if( pOther instanceof WeblogTemplate )
+      {
+         WeblogTemplate lTest = (WeblogTemplate) pOther;
+         boolean lEquals = true;
+
+         if( this.id == null )
+         {
+            lEquals = lEquals && ( lTest.id == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.id.equals( lTest.id );
+         }
+         if( this.mWebsite == null )
+         {
+            lEquals = lEquals && ( lTest.mWebsite == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.mWebsite.equals( lTest.mWebsite );
+         }
+         if( this.name == null )
+         {
+            lEquals = lEquals && ( lTest.name == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.name.equals( lTest.name );
+         }
+         if( this.description == null )
+         {
+            lEquals = lEquals && ( lTest.description == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.description.equals( lTest.description );
+         }
+         if( this.link == null )
+         {
+            lEquals = lEquals && ( lTest.link == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.link.equals( lTest.link );
+         }
+         if( this.contents == null )
+         {
+            lEquals = lEquals && ( lTest.contents == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.contents.equals( lTest.contents );
+         }
+         if( this.lastModified == null )
+         {
+            lEquals = lEquals && ( lTest.lastModified == null );
+         }
+         else
+         {
+            lEquals = lEquals && this.lastModified.equals( lTest.lastModified );
+         }
+
+         return lEquals;
+      }
+      else
+      {
+         return false;
+      }
+   }
+
+   public int hashCode()
+   {
+      int result = 17;
+      result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
+      result = 37*result + ((this.mWebsite != null) ? this.mWebsite.hashCode() : 0);
+      result = 37*result + ((this.name != null) ? this.name.hashCode() : 0);
+      result = 37*result + ((this.description != null) ? this.description.hashCode() : 0);
+      result = 37*result + ((this.link != null) ? this.link.hashCode() : 0);
+      result = 37*result + ((this.contents != null) ? this.contents.hashCode() : 0);
+      result = 37*result + ((this.lastModified != null) ? this.lastModified.hashCode() : 0);
+      return result;
+      }
+
+   /**
+	* Setter is needed in RollerImpl.storePersistentObject()
+    */
+   public void setData( org.roller.pojos.PersistentObject otherData )
+   {
+
+      this.id = ((WeblogTemplate) otherData).id;
+
+      this.mWebsite = ((WeblogTemplate) otherData).mWebsite;
+
+      this.name = ((WeblogTemplate) otherData).name;
+
+      this.description = ((WeblogTemplate) otherData).description;
+
+      this.link = ((WeblogTemplate) otherData).link;
+
+      this.contents = ((WeblogTemplate) otherData).contents;
+
+      this.lastModified = ((WeblogTemplate) otherData).lastModified;
+   }
+
+   public boolean canSave() throws RollerException
+   {
+       Roller roller = RollerFactory.getRoller();
+       if (roller.getUser().equals(UserData.SYSTEM_USER)) 
+       {
+           return true;
+       }
+       if (roller.getUser().equals(getWebsite().getUser()))
+       {
+           return true;
+       }
+       return false;
+   }
+
+}

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteData.java?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteData.java (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteData.java Fri Oct 21 14:27:36 2005
@@ -0,0 +1,853 @@
+package org.roller.pojos;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.roller.RollerException;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.util.PojoUtil;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.ThemeNotFoundException;
+import org.roller.pojos.Template;
+import org.roller.model.ThemeManager;
+import org.roller.model.UserManager;
+
+
+/**
+ * A user's website is a weweblog, newsfeed channels and bookmarks.
+ * @author David M Johnson
+ *
+ * @ejb:bean name="WebsiteData"
+ * @struts.form include-all="true"
+ * @hibernate.class table="website"
+ * hibernate.jcs-cache usage="read-write"
+ */
+public class WebsiteData extends org.roller.pojos.PersistentObject
+    implements java.io.Serializable
+{
+    static final long serialVersionUID = 206437645033737127L;
+    
+    private static Log mLogger = 
+        LogFactory.getFactory().getInstance(WebsiteData.class);
+    
+    protected java.lang.String id;
+    protected java.lang.String name;
+    protected java.lang.String description;
+    protected java.lang.String defaultPageId;
+    protected java.lang.String weblogDayPageId;
+    protected java.lang.Boolean enableBloggerApi;
+    protected WeblogCategoryData bloggerCategory;
+    protected WeblogCategoryData defaultCategory;
+    protected java.lang.String editorPage;
+    protected java.lang.String ignoreWords;
+    protected java.lang.Boolean allowComments;
+    protected java.lang.Boolean emailComments;
+    protected java.lang.String emailFromAddress;
+    protected java.lang.String editorTheme;
+    protected java.lang.String locale;
+    protected java.lang.String timezone;
+    protected java.lang.String mDefaultPlugins;
+    protected java.lang.Boolean isEnabled;
+
+    protected UserData mUser = null;
+
+    public WebsiteData()
+    {
+    }
+
+    public WebsiteData(final java.lang.String id, 
+                       final java.lang.String name,
+                       final java.lang.String description,
+                       final UserData user,
+                       final java.lang.String defaultPageId,
+                       final java.lang.String weblogDayPageId,
+                       final java.lang.Boolean enableBloggerApi,
+                       final WeblogCategoryData bloggerCategory,
+                       final WeblogCategoryData defaultCategory,
+                       final java.lang.String editorPage,
+                       final java.lang.String ignoreWords,
+                       final java.lang.Boolean allowComments,
+                       final java.lang.Boolean emailComments,
+                       final java.lang.String emailFromAddress,
+                       final java.lang.Boolean isEnabled)
+    {
+        this.id = id;
+        this.name = name;
+        this.description = description;
+        this.mUser = user;
+        this.defaultPageId = defaultPageId;
+        this.weblogDayPageId = weblogDayPageId;
+        this.enableBloggerApi = enableBloggerApi;
+        this.bloggerCategory = bloggerCategory;
+        this.defaultCategory = defaultCategory;
+        this.editorPage = editorPage;
+        this.ignoreWords = ignoreWords;
+        this.allowComments = allowComments;
+        this.emailComments = emailComments;
+        this.emailFromAddress = emailFromAddress;
+        this.isEnabled = isEnabled;
+    }
+
+    public WebsiteData(WebsiteData otherData)
+    {
+        this.setData(otherData);
+    }
+
+    
+    /**
+     * Lookup the default page for this website.
+     */
+    public Template getDefaultPage() throws RollerException {
+        
+        Template template = null;
+        
+        // first check if this user has selected a theme
+        // if so then return the themes Weblog template
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            try {
+                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                
+                // this is a bit iffy :/
+                // we assume that all theme use "Weblog" for a default template
+                template = usersTheme.getTemplate("Weblog");
+                
+            } catch(ThemeNotFoundException tnfe) {
+                // i sure hope not!
+                mLogger.error(tnfe);
+            }
+        }
+        
+        // if we didn't get the Template from a theme then look in the db
+        if(template == null) {
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            template = userMgr.retrievePage(this.defaultPageId);
+        }
+        
+        if(template != null)
+            mLogger.debug("returning default template id ["+template.getId()+"]");
+        
+        return template;
+    }
+    
+    
+    /**
+     * Lookup a Template for this website by id.
+     */
+    public Template getPageById(String id) throws RollerException {
+        
+        if(id == null)
+            return null;
+        
+        Template template = null;
+        
+        // first check if this user has selected a theme
+        // if so then return the proper theme template
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            
+            // we don't actually expect to get lookups for theme pages by id
+            // but we have to be thorough and check anyways
+            String[] split = id.split(":",  2);
+            
+            // only continue if this looks like a theme id
+            // and the theme name matches this users current theme
+            if(split.length == 2 && split[0].equals(this.editorTheme)) {
+                try {
+                    ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                    Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                    template = usersTheme.getTemplate(split[1]);
+                    
+                } catch(ThemeNotFoundException tnfe) {
+                    // i sure hope not!
+                    mLogger.error(tnfe);
+                }
+            }
+            
+        }
+        
+        // if we didn't get the Template from a theme then look in the db
+        if(template == null) {
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            template = userMgr.getPageByName(this, name);
+        }
+        
+        return template;
+    }
+    
+    
+    /**
+     * Lookup a Template for this website by name.
+     */
+    public Template getPageByName(String name) throws RollerException {
+        
+        if(name == null)
+            return null;
+        
+        mLogger.debug("looking up template ["+name+"]");
+        
+        Template template = null;
+        
+        // first check if this user has selected a theme
+        // if so then return the proper theme template
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            
+            try {
+                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                template = usersTheme.getTemplate(name);
+
+            } catch(ThemeNotFoundException tnfe) {
+                // i sure hope not!
+                mLogger.error(tnfe);
+            }
+            
+        }
+        
+        // if we didn't get the Template from a theme then look in the db
+        if(template == null) {
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            template = userMgr.getPageByName(this, name);
+        }
+        
+        if(template != null)
+            mLogger.debug("returning template ["+template.getId()+"]");
+        
+        return template;
+    }
+    
+    
+    /**
+     * Lookup a template for this website by link.
+     */
+    public Template getPageByLink(String link) throws RollerException {
+        
+        if(link == null)
+            return null;
+        
+        mLogger.debug("looking up template ["+link+"]");
+        
+        Template template = null;
+        
+        // first check if this user has selected a theme
+        // if so then return the proper theme template
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            
+            try {
+                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                template = usersTheme.getTemplateByLink(link);
+
+            } catch(ThemeNotFoundException tnfe) {
+                // i sure hope not!
+                mLogger.error(tnfe);
+            }
+            
+        }
+        
+        // if we didn't get the Template from a theme then look in the db
+        if(template == null) {
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            template = userMgr.getPageByLink(this, link);
+        }
+        
+        if(template != null)
+            mLogger.debug("returning template ["+template.getId()+"]");
+        
+        return template;
+    }
+    
+    
+    /**
+     * Get a list of all pages that are part of this website.
+     */
+    public List getPages() {
+        
+        Map pages = new HashMap();
+        
+        // first get the pages from the db
+        try {
+            Template template = null;
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            Iterator dbPages = userMgr.getPages(this).iterator();
+            while(dbPages.hasNext()) {
+                template = (Template) dbPages.next();
+                pages.put(template.getName(), template);
+            }
+        } catch(Exception e) {
+            // db error
+            mLogger.error(e);
+        }
+        
+            
+        // now get theme pages if needed and put them in place of db pages
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            try {
+                Template template = null;
+                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                Iterator themePages = usersTheme.getTemplates().iterator();
+                while(themePages.hasNext()) {
+                    template = (Template) themePages.next();
+                    
+                    // note that this will put theme pages over custom
+                    // pages in the pages list, which is what we want
+                    pages.put(template.getName(), template);
+                }
+            } catch(Exception e) {
+                // how??
+                mLogger.error(e);
+            }
+        }
+        
+        return new ArrayList(pages.values());
+    }
+    
+    
+    /**
+     * Id of the Website.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.id column="id" type="string"
+     *  generator-class="uuid.hex" unsaved-value="null"
+     */
+    public java.lang.String getId()
+    {
+        return this.id;
+    }
+
+    /** @ejb:persistent-field */
+    public void setId(java.lang.String id)
+    {
+        this.id = id;
+    }
+
+    /**
+     * Name of the Website.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="name" non-null="true" unique="false"
+     */
+    public java.lang.String getName()
+    {
+        return this.name;
+    }
+
+    /** @ejb:persistent-field */
+    public void setName(java.lang.String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Description
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="description" non-null="true" unique="false"
+     */
+    public java.lang.String getDescription()
+    {
+        return this.description;
+    }
+
+    /** @ejb:persistent-field */
+    public void setDescription(java.lang.String description)
+    {
+        this.description = description;
+    }
+
+    /**
+     * Id of owner.
+     *
+     * @roller.wrapPojoMethod type="pojo"
+     * @ejb:persistent-field
+     * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
+     */
+    public org.roller.pojos.UserData getUser()
+    {
+        return mUser;
+    }
+
+    /** @ejb:persistent-field */
+    public void setUser( org.roller.pojos.UserData ud )
+    {
+        mUser = ud;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="defaultpageid" non-null="true" unique="false"
+     */
+    public java.lang.String getDefaultPageId()
+    {
+        return this.defaultPageId;
+    }
+
+    /**
+     * @ejb:persistent-field
+     */
+    public void setDefaultPageId(java.lang.String defaultPageId)
+    {
+        this.defaultPageId = defaultPageId;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @deprecated
+     * @ejb:persistent-field
+     * @hibernate.property column="weblogdayid" non-null="true" unique="false"
+     */
+    public java.lang.String getWeblogDayPageId()
+    {
+        return this.weblogDayPageId;
+    }
+
+    /**
+     * @deprecated
+     * @ejb:persistent-field
+     */
+    public void setWeblogDayPageId(java.lang.String weblogDayPageId)
+    {
+        this.weblogDayPageId = weblogDayPageId;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="enablebloggerapi" non-null="true" unique="false"
+     */
+    public java.lang.Boolean getEnableBloggerApi()
+    {
+        return this.enableBloggerApi;
+    }
+
+    /** @ejb:persistent-field */
+    public void setEnableBloggerApi(java.lang.Boolean enableBloggerApi)
+    {
+        this.enableBloggerApi = enableBloggerApi;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.many-to-one column="bloggercatid" non-null="false"
+     */
+    public WeblogCategoryData getBloggerCategory()
+    {
+        return bloggerCategory;
+    }
+
+    /** @ejb:persistent-field */
+    public void setBloggerCategory(WeblogCategoryData bloggerCategory)
+    {
+        this.bloggerCategory = bloggerCategory;
+    }
+
+    /**
+     * By default,the default category for a weblog is the root and all macros
+     * work with the top level categories that are immediately under the root.
+     * Setting a different default category allows you to partition your weblog.
+     * 
+     * @roller.wrapPojoMethod type="pojo"
+     * @ejb:persistent-field
+     * @hibernate.many-to-one column="defaultcatid" non-null="false"
+     */
+    public WeblogCategoryData getDefaultCategory() 
+    {
+        return defaultCategory;
+    }
+
+    /** @ejb:persistent-field */
+    public void setDefaultCategory(WeblogCategoryData defaultCategory)
+    {
+        this.defaultCategory = defaultCategory;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="editorpage" non-null="true" unique="false"
+     */
+    public java.lang.String getEditorPage()
+    {
+        return this.editorPage;
+    }
+
+    /** @ejb:persistent-field */
+    public void setEditorPage(java.lang.String editorPage)
+    {
+        this.editorPage = editorPage;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="ignorewords" non-null="true" unique="false"
+     */
+    public java.lang.String getIgnoreWords()
+    {
+        return this.ignoreWords;
+    }
+
+    /** @ejb:persistent-field */
+    public void setIgnoreWords(java.lang.String ignoreWords)
+    {
+        this.ignoreWords = ignoreWords;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="allowcomments" non-null="true" unique="false"
+     */
+    public java.lang.Boolean getAllowComments()
+    {
+        return this.allowComments;
+    }
+
+    /** @ejb:persistent-field */
+    public void setAllowComments(java.lang.Boolean allowComments)
+    {
+        this.allowComments = allowComments;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="emailcomments" non-null="true" unique="false"
+     */
+    public java.lang.Boolean getEmailComments()
+    {
+        return this.emailComments;
+    }
+
+    /** @ejb:persistent-field */
+    public void setEmailComments(java.lang.Boolean emailComments)
+    {
+        this.emailComments = emailComments;
+    }
+    
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="emailfromaddress" non-null="true" unique="false"
+     */
+    public java.lang.String getEmailFromAddress()
+    {
+        return this.emailFromAddress;
+    }
+
+    /** @ejb:persistent-field */
+    public void setEmailFromAddress(java.lang.String emailFromAddress)
+    {
+        this.emailFromAddress = emailFromAddress;
+    }
+    
+    /**
+     * Theme of the Website.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="editortheme" non-null="true" unique="false"
+     */
+    public java.lang.String getEditorTheme()
+    {
+        return this.editorTheme;
+    }
+
+    /** @ejb:persistent-field */
+    public void setEditorTheme(java.lang.String editorTheme)
+    {
+        this.editorTheme = editorTheme;
+    }
+
+    /**
+     * Locale of the Website.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="locale" non-null="true" unique="false"
+     */
+    public java.lang.String getLocale()
+    {
+        return this.locale;
+    }
+
+    /** @ejb:persistent-field */
+    public void setLocale(java.lang.String locale)
+    {
+        this.locale = locale;
+    }
+
+    /**
+     * Timezone of the Website.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="timezone" non-null="true" unique="false"
+     */
+    public java.lang.String getTimezone()
+    {
+        return this.timezone;
+    }
+
+    /** @ejb:persistent-field */
+    public void setTimezone(java.lang.String timezone)
+    {
+        this.timezone = timezone;
+    }
+
+    /**
+     * Comma-delimited list of user's default Plugins.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="defaultplugins" non-null="false" unique="false"
+     */
+    public java.lang.String getDefaultPlugins()
+    {
+        return mDefaultPlugins;
+    }
+
+    /** @ejb:persistent-field */
+    public void setDefaultPlugins(java.lang.String string)
+    {
+        mDefaultPlugins = string;
+    }
+
+    /**
+     * @roller.wrapPojoMethod type="simple"
+     * @ejb:persistent-field
+     * @hibernate.property column="isenabled" non-null="true" unique="false"
+     */
+    public java.lang.Boolean getIsEnabled()
+    {
+        return this.isEnabled;
+    }
+    
+    /** @ejb:persistent-field */ 
+    public void setIsEnabled(java.lang.Boolean isEnabled)
+    {
+        this.isEnabled = isEnabled;
+    }
+
+    public String toString()
+    {
+        StringBuffer str = new StringBuffer("{");
+
+        str.append("id=" + id + " " + "name=" + name + " " + "description=" +
+                   description + " " +
+                   "defaultPageId=" + defaultPageId + " " +
+                   "weblogDayPageId=" + weblogDayPageId + " " +
+                   "enableBloggerApi=" + enableBloggerApi + " " +
+                   "bloggerCategory=" + bloggerCategory + " " +
+                   "defaultCategory=" + defaultCategory + " " +
+                   "editorPage=" + editorPage + " " +
+                   "ignoreWords=" + ignoreWords + " " +
+                   "allowComments=" + allowComments + " " +
+                   "emailComments=" + emailComments + " " + 
+                   "emailFromAddress=" + emailFromAddress + " " +
+                   "editorTheme=" + editorTheme + " " +
+                   "locale=" + locale + " " +
+                   "timezone=" + timezone + " " +
+                   "defaultPlugins=" + mDefaultPlugins);
+        str.append('}');
+
+        return (str.toString());
+    }
+
+    public boolean equals(Object pOther)
+    {
+        if (pOther instanceof WebsiteData)
+        {
+            WebsiteData lTest = (WebsiteData) pOther;
+            boolean lEquals = true;
+
+            lEquals = PojoUtil.equals(lEquals, this.id, lTest.id);
+
+            lEquals = PojoUtil.equals(lEquals, this.name, lTest.name);
+
+            lEquals = PojoUtil.equals(lEquals, this.description, lTest.description);
+
+            lEquals = PojoUtil.equals(lEquals, this.mUser, lTest.mUser);
+
+            lEquals = PojoUtil.equals(lEquals, this.defaultPageId, lTest.defaultPageId);
+
+            lEquals = PojoUtil.equals(lEquals, this.weblogDayPageId, lTest.weblogDayPageId);
+
+            lEquals = PojoUtil.equals(lEquals, this.enableBloggerApi, lTest.enableBloggerApi);
+
+            lEquals = PojoUtil.equals(lEquals, this.bloggerCategory.getId(), lTest.bloggerCategory.getId());
+
+            lEquals = PojoUtil.equals(lEquals, this.defaultCategory.getId(), lTest.defaultCategory.getId());
+
+            lEquals = PojoUtil.equals(lEquals, this.editorPage, lTest.editorPage);
+
+            lEquals = PojoUtil.equals(lEquals, this.ignoreWords, lTest.ignoreWords);
+
+            lEquals = PojoUtil.equals(lEquals, this.allowComments, lTest.allowComments);
+            
+            lEquals = PojoUtil.equals(lEquals, this.emailComments, lTest.emailComments);
+            
+            lEquals = PojoUtil.equals(lEquals, this.emailFromAddress, lTest.emailFromAddress);
+
+            lEquals = PojoUtil.equals(lEquals, this.editorTheme, lTest.editorTheme);
+
+            lEquals = PojoUtil.equals(lEquals, this.locale, lTest.locale);
+
+            lEquals = PojoUtil.equals(lEquals, this.timezone, lTest.timezone);
+
+            lEquals = PojoUtil.equals(lEquals, this.mDefaultPlugins, lTest.mDefaultPlugins);
+            
+            return lEquals;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    public int hashCode()
+    {
+        int result = 17;
+        result = PojoUtil.addHashCode(result, this.id);
+        result = PojoUtil.addHashCode(result, this.name);
+        result = PojoUtil.addHashCode(result, this.description);
+        result = PojoUtil.addHashCode(result, this.mUser);
+        result = PojoUtil.addHashCode(result, this.defaultPageId);
+        result = PojoUtil.addHashCode(result, this.weblogDayPageId);
+        result = PojoUtil.addHashCode(result, this.enableBloggerApi);
+        //result = PojoUtil.addHashCode(result, this.bloggerCategory);
+        //result = PojoUtil.addHashCode(result, this.defaultCategory);
+        result = PojoUtil.addHashCode(result, this.editorPage);
+        result = PojoUtil.addHashCode(result, this.ignoreWords);
+        result = PojoUtil.addHashCode(result, this.allowComments);
+        result = PojoUtil.addHashCode(result, this.emailComments);
+        result = PojoUtil.addHashCode(result, this.emailFromAddress);
+        result = PojoUtil.addHashCode(result, this.editorTheme);
+        result = PojoUtil.addHashCode(result, this.locale);
+        result = PojoUtil.addHashCode(result, this.timezone);
+        result = PojoUtil.addHashCode(result, this.mDefaultPlugins);
+
+        return result;
+    }
+
+    /**
+     * Setter is needed in RollerImpl.storePersistentObject()
+     */
+    public void setData(org.roller.pojos.PersistentObject otherData)
+    {
+        WebsiteData other = (WebsiteData)otherData;
+
+        this.id = other.id;
+        this.name = other.name;
+        this.description = other.description;
+        this.mUser = other.mUser;
+        this.defaultPageId = other.defaultPageId;
+        this.weblogDayPageId = other.weblogDayPageId;
+        this.enableBloggerApi = other.enableBloggerApi;
+        this.bloggerCategory = other.bloggerCategory;
+        this.defaultCategory = other.defaultCategory;
+        this.editorPage = other.editorPage;
+        this.ignoreWords = other.ignoreWords;
+        this.allowComments = other.allowComments;
+        this.emailComments = other.emailComments;
+        this.emailFromAddress = other.emailFromAddress;
+        this.editorTheme = other.editorTheme;
+        this.locale = other.locale;
+        this.timezone = other.timezone;
+        this.mDefaultPlugins = other.mDefaultPlugins;
+        this.isEnabled = other.isEnabled;
+    }
+    
+    /**
+     * Parse locale value and instantiate a Locale object,
+     * otherwise return default Locale.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @return Locale
+     */
+    public Locale getLocaleInstance()
+    {
+        if (locale != null)
+        {
+            String[] localeStr = StringUtils.split(locale,"_");
+            if (localeStr.length == 1)
+            {
+                if (localeStr[0] == null) localeStr[0] = "";
+                return new Locale(localeStr[0]);
+            }
+            else if (localeStr.length == 2)
+            {
+                if (localeStr[0] == null) localeStr[0] = "";
+                if (localeStr[1] == null) localeStr[1] = "";
+                return new Locale(localeStr[0], localeStr[1]);
+            }
+            else if (localeStr.length == 3)
+            {
+                if (localeStr[0] == null) localeStr[0] = "";
+                if (localeStr[1] == null) localeStr[1] = "";
+                if (localeStr[2] == null) localeStr[2] = "";
+                return new Locale(localeStr[0], localeStr[1], localeStr[2]);
+            } 
+        } 
+        return Locale.getDefault();
+    }
+    
+    /**
+     * Return TimeZone instance for value of timezone,
+     * otherwise return system default instance.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     * @return TimeZone
+     */
+    public TimeZone getTimeZoneInstance()
+    {
+    	if (timezone == null) 
+        {
+            if (TimeZone.getDefault() != null) 
+            {
+                this.setTimezone( TimeZone.getDefault().getID() );
+            }
+            else
+            {
+                this.setTimezone("America/New_York");
+            }
+        }
+        return TimeZone.getTimeZone(timezone);
+    }
+    
+    /** 
+     * @see org.roller.pojos.PersistentObject#remove()
+     */
+    public void remove() throws RollerException
+    {
+        RollerFactory.getRoller().getUserManager().removeWebsiteContents(this);        
+        super.remove();
+    }
+
+    public boolean canSave() throws RollerException
+    {
+        Roller roller = RollerFactory.getRoller();
+        if (roller.getUser().equals(UserData.SYSTEM_USER)) 
+        {
+            return true;
+        }
+        if (roller.getUser().equals(getUser()))
+        {
+            return true;
+        }
+        return false;
+    }
+
+}
\ No newline at end of file

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteDisplayData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteDisplayData.java?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteDisplayData.java (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/pojos/WebsiteDisplayData.java Fri Oct 21 14:27:36 2005
@@ -0,0 +1,118 @@
+/*
+ * Created on Apr 15, 2003
+ */
+package org.roller.pojos;
+
+
+/**
+ * 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" 
+ */
+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);    
+
+    /**
+     * 
+     */
+    public WebsiteDisplayData()
+    {
+        super();
+    }
+
+    /**
+     * 
+     */
+    public WebsiteDisplayData(String id, String userName, String websiteName, Integer hits)
+    {
+        super();
+        mId = id;
+        mUserName = userName;
+        mWebsiteName = websiteName;
+        mHits = hits;
+    }
+
+    /** 
+     * No-op.
+     * @see org.roller.pojos.PersistentObject#setData(org.roller.pojos.PersistentObject)
+     */
+    public void setData(PersistentObject vo)
+    {
+    }
+
+    /** 
+     * @ejb:persistent-field 
+     */
+    public String getId()
+    {
+        return mId;
+    }
+
+    /** 
+     * @see org.roller.pojos.PersistentObject#setId(java.lang.String)
+     */
+    public void setId(String id)
+    {
+        mId = id;
+    }
+
+
+    /** 
+     * @ejb:persistent-field 
+     */
+    public String getUserName()
+    {
+        return mUserName;
+    }
+
+    /**
+     * @param string
+     */
+    public void setUserName(String string)
+    {
+        mUserName = string;
+    }
+
+    /** 
+     * @ejb:persistent-field 
+     */
+    public Integer getHits()
+    {
+        return mHits;
+    }
+
+    /**
+     * @param integer
+     */
+    public void setHits(Integer integer)
+    {
+        mHits = integer;
+    }
+
+
+    /**
+     * @return Returns the title.
+     */
+    public String getWebsiteName()
+    {
+        return mWebsiteName;
+    }
+    
+    /**
+     * @param title The title to set.
+     */
+    public void setWebsiteName(String name)
+    {
+        mWebsiteName = name;
+    }
+}

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/package.html
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/package.html?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/pojos/package.html (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/pojos/package.html Fri Oct 21 14:27:36 2005
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+Persistent objects stored/retrieved by business layer.
+
+<p>At this level we avoid dependance on specific persistence engines 
+(e.g. Hibernate). We do this by using an interface named 
+{@link org.roller.business.PersistenceStrategy PersistenceStrategy} 
+to store, retrieve and remove 
+{@link org.roller.pojos.PersistentObject PersistentObjects}.</p>
+
+<img src="../business/roller-persistence.png" 
+    alt="diagram of Roller persistent object and strategy" />
+
+<p>The diagram below shows the objects in the Roller data model and the
+relationships between them.</p>
+
+<img src="roller-datamodel.png" alt="diagram of Roller data model" />
+
+</body>
+</html>

Added: incubator/roller/branches/roller_1.x/src/org/roller/pojos/roller-datamodel.png
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/pojos/roller-datamodel.png?rev=327589&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/roller/branches/roller_1.x/src/org/roller/pojos/roller-datamodel.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/roller/branches/roller_1.x/src/org/roller/presentation/AccessDeniedException.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_1.x/src/org/roller/presentation/AccessDeniedException.java?rev=327589&view=auto
==============================================================================
--- incubator/roller/branches/roller_1.x/src/org/roller/presentation/AccessDeniedException.java (added)
+++ incubator/roller/branches/roller_1.x/src/org/roller/presentation/AccessDeniedException.java Fri Oct 21 14:27:36 2005
@@ -0,0 +1,28 @@
+
+package org.roller.presentation;
+
+import javax.servlet.jsp.JspException;
+
+/** 
+ * Indicates user is not authorized to access a resource.
+ */ 
+public class AccessDeniedException extends JspException 
+{
+	public AccessDeniedException(String s,Throwable t)
+	{
+		super(s,t);
+	}
+	public AccessDeniedException(Throwable t)
+	{
+		super(t);
+	}
+	public AccessDeniedException(String s)
+	{
+		super(s);
+	}
+	public AccessDeniedException()
+	{
+		super();
+	}
+}
+