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/06/08 18:06:46 UTC
svn commit: r189602 [13/50] - in /incubator/roller/trunk: ./ 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/src/org/roller/presentation/velocity/
contrib/plugins/src/org/roller/presentation/velocity/plugins/
contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/
contrib/plugins/src/org/roller/presentation/velocity/plugins/bookmarks/
contrib/plugins/src/org/roller/presentation/velocity/plugins/email/
contrib/plugins/src/org/roller/presentation/velocity/plugins/jspwiki/
contrib/plugins/src/org/roller/presentation/velocity/plugins/radeox/
contrib/plugins/src/org/roller/presentation/velocity/plugins/readmore/
contrib/plugins/src/org/roller/presentation/velocity/plugins/smileys/
contrib/plugins/src/org/roller/presentation/velocity/plugins/textile/ docs/
docs/images/ docs/installguide/ docs/installguide/old/ docs/userguide/
docs/userguide/images/ docs/userguide/old/ metadata/ metadata/database/
metadata/database/hibernate/ metadata/xdoclet/ personal/ personal/eclipse/
personal/testing/ src/ src/org/ src/org/roller/ src/org/roller/business/
src/org/roller/business/hibernate/ src/org/roller/business/utils/
src/org/roller/model/ src/org/roller/pojos/ src/org/roller/presentation/
src/org/roller/presentation/atom/ src/org/roller/presentation/bookmarks/
src/org/roller/presentation/bookmarks/actions/
src/org/roller/presentation/bookmarks/formbeans/
src/org/roller/presentation/bookmarks/tags/
src/org/roller/presentation/filters/ src/org/roller/presentation/forms/
src/org/roller/presentation/newsfeeds/ src/org/roller/presentation/pagecache/
src/org/roller/presentation/pagecache/rollercache/
src/org/roller/presentation/tags/ src/org/roller/presentation/tags/calendar/
src/org/roller/presentation/tags/menu/
src/org/roller/presentation/velocity/ src/org/roller/presentation/weblog/
src/org/roller/presentation/weblog/actions/
src/org/roller/presentation/weblog/formbeans/
src/org/roller/presentation/weblog/search/
src/org/roller/presentation/weblog/search/operations/
src/org/roller/presentation/weblog/tags/ src/org/roller/presentation/website/
src/org/roller/presentation/website/actions/
src/org/roller/presentation/website/formbeans/
src/org/roller/presentation/website/tags/
src/org/roller/presentation/xmlrpc/ src/org/roller/util/ tests/ tests/org/
tests/org/roller/ tests/org/roller/business/ tests/org/roller/model/
tests/org/roller/persistence/ tests/org/roller/presentation/
tests/org/roller/presentation/atom/ tests/org/roller/presentation/bookmarks/
tests/org/roller/presentation/velocity/
tests/org/roller/presentation/velocity/plugins/
tests/org/roller/presentation/velocity/plugins/smileys/
tests/org/roller/presentation/velocity/plugins/textile/
tests/org/roller/presentation/xmlrpc/ tests/org/roller/util/ tools/
tools/buildtime/ tools/buildtime/mockrunner-0.2.6/
tools/buildtime/mockrunner-0.2.6/lib/ tools/buildtime/tomcat-4.1.24/
tools/buildtime/xdoclet-1.2/ tools/buildtime/xdoclet-1.2/lib/
tools/hibernate-2.1/ tools/hibernate-2.1/lib/ tools/lib/
tools/standard-1.0.3/ tools/standard-1.0.3/lib/ tools/standard-1.0.3/tld/
tools/struts-1.1/ tools/struts-1.1/lib/ web/ web/WEB-INF/
web/WEB-INF/classes/ web/WEB-INF/classes/flavors/
web/WEB-INF/classes/themes/ web/bookmarks/ web/images/ web/images/editor/
web/images/midas/ web/images/preview/ web/images/smileys/ web/tags/
web/templates/ web/theme/ web/theme/images/ web/theme/lavender/
web/theme/scripts/ web/theme/scripts/classes/ web/themes/ web/themes/basic/
web/themes/berkley/ web/themes/berkley/images/ web/themes/cheb/
web/themes/cheb/images/ web/themes/cheb/scripts/ web/themes/clean/
web/themes/currency-i18n/ web/themes/currency-i18n/images/
web/themes/currency/ web/themes/currency/images/ web/themes/grey2/
web/themes/moonshine/ web/themes/pacifica/ web/themes/robot/
web/themes/rolling/ web/themes/rolling/images/ web/themes/sotto/
web/themes/sotto/images/ web/themes/sotto/styles/ web/themes/sunsets/
web/themes/sunsets/images/ web/themes/sunsets/scripts/
web/themes/sunsets/styles/ web/themes/werner/ web/themes/x2/
web/themes/x2/images/ web/themes/x2/scripts/ web/themes/x2/styles/
web/weblog/ web/website/
Added: incubator/roller/trunk/src/org/roller/pojos/WeblogCategoryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogCategoryData.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogCategoryData.java (added)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogCategoryData.java Wed Jun 8 09:06:16 2005
@@ -0,0 +1,468 @@
+package org.roller.pojos;
+
+import org.roller.RollerException;
+import org.roller.model.RollerFactory;
+import org.roller.model.WeblogManager;
+import org.roller.util.PojoUtil;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * WeblogCategory bean.
+ * @author David M Johnson
+ *
+ * @ejb:bean name="WeblogCategoryData"
+ * @struts.form include-all="true"
+ * @hibernate.class table="weblogcategory"
+ * hibernate.jcs-cache usage="read-write"
+ */
+public class WeblogCategoryData extends HierarchicalPersistentObject
+ implements java.io.Serializable
+{
+ static final long serialVersionUID = 1435782148712018954L;
+
+ protected java.lang.String id = null;
+ protected java.lang.String name;
+ protected java.lang.String description;
+ protected java.lang.String image;
+
+ protected String cachedPath = null;
+
+ protected WebsiteData mWebsite;
+ protected List mWeblogCategories;
+
+ public WeblogCategoryData()
+ {
+ }
+
+ public WeblogCategoryData(
+ java.lang.String id,
+ WebsiteData website,
+ WeblogCategoryData parent,
+ java.lang.String name,
+ java.lang.String description,
+ java.lang.String image)
+ {
+ this.id = id;
+ this.mWebsite = website;
+ this.mNewParent = parent;
+ this.name = name;
+ this.description = description;
+ this.image = image;
+ }
+
+ public WeblogCategoryData(WeblogCategoryData otherData)
+ {
+ this.id = otherData.id;
+ this.mWebsite = otherData.mWebsite;
+ this.mNewParent = otherData.mNewParent;
+ this.name = otherData.name;
+ this.description = otherData.description;
+ this.image = otherData.image;
+ }
+
+ /** Setter is needed in RollerImpl.storePersistentObject(). */
+ public void setData(org.roller.pojos.PersistentObject otherData)
+ {
+ this.id = ((WeblogCategoryData) otherData).id;
+ this.mWebsite = ((WeblogCategoryData) otherData).mWebsite;
+ this.mNewParent = ((WeblogCategoryData) otherData).mNewParent;
+ this.name = ((WeblogCategoryData) otherData).name;
+ this.description = ((WeblogCategoryData) otherData).description;
+ this.image = ((WeblogCategoryData) otherData).image;
+ }
+
+ public void save() throws RollerException
+ {
+ if (RollerFactory.getRoller().getWeblogManager().isDuplicateWeblogCategoryName(this))
+ {
+ throw new RollerException("Duplicate category name");
+ }
+ super.save();
+ }
+
+ /**
+ * Remove this category and recategorize all entries in this category and
+ * in all subcategories to a specified destination category (destCat).
+ * @param destCat New category for entries in remove categories (or null if none).
+ */
+ public void remove(WeblogCategoryData destCat) throws RollerException
+ {
+ WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+
+ // recategorize entries in this category
+ if (destCat != null)
+ {
+ wmgr.moveWeblogCategoryContents(getId(), destCat.getId());
+ }
+ // delete this category
+ super.remove();
+
+ if (getWebsite().getBloggerCategory().equals(this))
+ {
+ WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(getWebsite());
+ getWebsite().setBloggerCategory(rootCat);
+ }
+
+ if (getWebsite().getDefaultCategory().equals(this))
+ {
+ WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(getWebsite());
+ getWebsite().setDefaultCategory(rootCat);
+ }
+
+ getWebsite().save();
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getAssocClass()
+ */
+ public Class getAssocClass()
+ {
+ return WeblogCategoryAssoc.class;
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getObjectPropertyName()
+ */
+ public String getObjectPropertyName()
+ {
+ return "category";
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getAncestorPropertyName()
+ */
+ public String getAncestorPropertyName()
+ {
+ return "ancestorCategory";
+ }
+
+ //------------------------------------------------------- Simple properties
+
+ /**
+ * @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.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="image" non-null="true" unique="false"
+ */
+ public java.lang.String getImage()
+ {
+ return this.image;
+ }
+ /** @ejb:persistent-field */
+ public void setImage(java.lang.String image)
+ {
+ this.image = image;
+ }
+
+ /**
+ * Get path in category hierarhcy.
+ */
+ public String getPath()
+ {
+ if (null == cachedPath)
+ {
+ try
+ {
+ cachedPath = RollerFactory.getRoller().getWeblogManager().getPath(this);
+ }
+ catch (RollerException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return cachedPath;
+ }
+
+ //------------------------------------------------------------ Associations
+
+ /**
+ * @ejb:persistent-field
+ *
+ * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
+ */
+ public WebsiteData getWebsite()
+ {
+ return mWebsite;
+ }
+ /** @ejb:persistent-field */
+ public void setWebsite(WebsiteData website)
+ {
+ mWebsite = website;
+ }
+
+// /**
+// * @ejb:persistent-field
+// *
+// * @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
+// */
+// public WeblogCategoryAssoc getWeblogCategoryAssoc()
+// {
+// return mWeblogCategoryAssoc;
+// }
+// /** @ejb:persistent-field */
+// public void setWeblogCategoryAssoc(WebsiteData website)
+// {
+// WeblogCategoryAssoc = weblogCategoryAssoc;
+// }
+
+ /** Return parent category, or null if category is root of hierarchy. */
+ public WeblogCategoryData getParent() throws RollerException
+ {
+ if (mNewParent != null)
+ {
+ // Category has new parent, so return that
+ return (WeblogCategoryData)mNewParent;
+ }
+ else if (getParentAssoc() != null)
+ {
+ // Return parent found in database
+ return ((WeblogCategoryAssoc)getParentAssoc()).getAncestorCategory();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /** Set parent category, database will be updated when object is saved. */
+ public void setParent(HierarchicalPersistentObject parent)
+ {
+ mNewParent = parent;
+ }
+
+ /** Query to get child categories of this category. */
+ public List getWeblogCategories() throws RollerException
+ {
+ if (mWeblogCategories == null)
+ {
+ mWeblogCategories = new LinkedList();
+ List childAssocs = getChildAssocs();
+ Iterator childIter = childAssocs.iterator();
+ while (childIter.hasNext())
+ {
+ WeblogCategoryAssoc assoc =
+ (WeblogCategoryAssoc) childIter.next();
+ mWeblogCategories.add(assoc.getCategory());
+ }
+ }
+ return mWeblogCategories;
+ }
+
+ /**
+ * Determine if category is in use. Returns true if any weblog entries
+ * use this category or any of it's subcategories.
+ */
+ public boolean isInUse()
+ {
+ try
+ {
+ return RollerFactory.getRoller().getWeblogManager().isWeblogCategoryInUse(this);
+ }
+ catch (RollerException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /** TODO: fixed form generation so this is not needed. */
+ public void setInUse(boolean dummy) {}
+
+ //------------------------------------------------------------------------
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#createAssoc(
+ * org.roller.pojos.HierarchicalPersistentObject,
+ * org.roller.pojos.HierarchicalPersistentObject, java.lang.String)
+ */
+ public Assoc createAssoc(
+ HierarchicalPersistentObject object,
+ HierarchicalPersistentObject associatedObject,
+ String relation) throws RollerException
+ {
+ WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ return wmgr.createWeblogCategoryAssoc(
+ (WeblogCategoryData)object,
+ (WeblogCategoryData)associatedObject,
+ relation);
+ }
+
+ //------------------------------------------------------------------------
+
+ /**
+ * Move all weblog entries that exist in this category and all
+ * subcategories of this category to a single new category.
+ */
+ public void moveContents(WeblogCategoryData dest) throws RollerException
+ {
+ Iterator entries = retrieveWeblogEntries(true).iterator();
+ while (entries.hasNext())
+ {
+ WeblogEntryData entry = (WeblogEntryData) entries.next();
+ entry.setCategory(dest);
+ entry.save();
+ }
+ }
+
+ /**
+ * Retrieve all weblog entries in this category and, optionally, include
+ * weblog entries all sub-categories.
+ * @param subcats True if entries from sub-categories are to be returned.
+ * @return List of WeblogEntryData objects.
+ * @throws RollerException
+ */
+ public List retrieveWeblogEntries(boolean subcats)
+ throws RollerException
+ {
+ WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ return wmgr.retrieveWeblogEntries(this, subcats);
+ }
+
+ //-------------------------------------------------------- Good citizenship
+
+ public String toString()
+ {
+ StringBuffer str = new StringBuffer("{");
+
+ str.append(
+ "id="
+ + id
+ + " "
+ + "name="
+ + name
+ + " "
+ + "description="
+ + description
+ + " "
+ + "image="
+ + image);
+ str.append('}');
+
+ return (str.toString());
+ }
+
+ public boolean equals(Object pOther)
+ {
+ if (pOther == null) return false;
+ if (pOther instanceof WeblogCategoryData)
+ {
+ WeblogCategoryData lTest = (WeblogCategoryData) pOther;
+ boolean lEquals = true;
+ lEquals = PojoUtil.equals(lEquals, this.id, lTest.id);
+ lEquals = PojoUtil.equals(lEquals, this.mWebsite.getId(), lTest.mWebsite.getId());
+ lEquals = PojoUtil.equals(lEquals, this.name, lTest.name);
+ lEquals = PojoUtil.equals(lEquals, this.description, lTest.description);
+ lEquals = PojoUtil.equals(lEquals, this.image, lTest.image);
+ 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.image != null) ? this.image.hashCode() : 0);
+ return result;
+ }
+
+ /** TODO: fix Struts form generation template so this is not needed. */
+ public void setAssocClassName(String dummy) {};
+
+ /** TODO: fix Struts form generation template so this is not needed. */
+ public void setObjectPropertyName(String dummy) {};
+
+ /** TODO: fix Struts form generation template so this is not needed. */
+ public void setAncestorPropertyName(String dummy) {};
+
+ /** TODO: fix formbean generation so this is not needed. */
+ public void setPath(String string) {}
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getParentAssoc()
+ */
+ protected Assoc getParentAssoc() throws RollerException
+ {
+ return RollerFactory.getRoller().getWeblogManager().getWeblogCategoryParentAssoc(this);
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getChildAssocs()
+ */
+ protected List getChildAssocs() throws RollerException
+ {
+ return RollerFactory.getRoller().getWeblogManager().getWeblogCategoryChildAssocs(this);
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getAllDescendentAssocs()
+ */
+ public List getAllDescendentAssocs() throws RollerException
+ {
+ return RollerFactory.getRoller().getWeblogManager().getAllWeblogCategoryDecscendentAssocs(this);
+ }
+
+ /**
+ * @see org.roller.pojos.HierarchicalPersistentObject#getAncestorAssocs()
+ */
+ public List getAncestorAssocs() throws RollerException
+ {
+ return RollerFactory.getRoller().getWeblogManager().getWeblogCategoryAncestorAssocs(this);
+ }
+
+}
Added: incubator/roller/trunk/src/org/roller/pojos/WeblogEntryComparator.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogEntryComparator.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogEntryComparator.java (added)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogEntryComparator.java Wed Jun 8 09:06:16 2005
@@ -0,0 +1,40 @@
+/*
+ * Created on Apr 16, 2004
+ */
+package org.roller.pojos;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ * Sorts WeblogEntryData objects in reverse chronological order
+ * (most recently published entries first). If they happen to
+ * have the same pubTime, then sort alphabetically by title.
+ *
+ * @author lance.lavandowska
+ */
+public class WeblogEntryComparator implements Comparator, Serializable
+{
+ public int compare(Object val1, Object val2)
+ throws ClassCastException
+ {
+ WeblogEntryData entry1 = (WeblogEntryData)val1;
+ WeblogEntryData entry2 = (WeblogEntryData)val2;
+ long pubTime1 = entry1.getPubTime().getTime();
+ long pubTime2 = entry2.getPubTime().getTime();
+
+ if (pubTime1 > pubTime2)
+ {
+ return -1;
+ }
+ else if (pubTime1 < pubTime2)
+ {
+ return 1;
+ }
+
+ // if pubTimes are the same, return
+ // results of String.compareTo() on Title
+ return entry1.getTitle().compareTo(entry2.getTitle());
+ }
+
+}
Added: incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java (added)
+++ incubator/roller/trunk/src/org/roller/pojos/WeblogEntryData.java Wed Jun 8 09:06:16 2005
@@ -0,0 +1,880 @@
+
+package org.roller.pojos;
+
+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.RollerFactory;
+import org.roller.model.WeblogManager;
+import org.roller.util.DateUtil;
+import org.roller.util.Utilities;
+
+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.List;
+import java.util.StringTokenizer;
+
+
+/**
+ * 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(7);
+ protected Boolean rightToLeft = Boolean.FALSE;
+ protected Boolean pinnedToMain = Boolean.FALSE;
+
+ //----------------------------------------------------------- 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
+
+ /**
+ * @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="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));
+ }
+
+ /**
+ * @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="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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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.
+ *
+ * @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.
+ * @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.
+ * @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.
+ * @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.
+ * @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.
+ *
+ * @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 pinned The pinned to set.
+ *
+ * @ejb:persistent-field
+ */
+ public void setPinnedToMain(Boolean pinnedToMain)
+ {
+ this.pinnedToMain = pinnedToMain;
+ }
+
+ //------------------------------------------------------------------------
+
+ /**
+ * @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());
+ }
+ super.save();
+ }
+
+ //------------------------------------------------------------------------
+
+ /**
+ * True if comments are still allowed on this entry considering the
+ * allowComments and commentDays fields.
+ */
+ 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.
+ * @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.
+ * @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";
+ }
+
+ //------------------------------------------------------------------------
+
+ public List getComments()
+ {
+ return getComments(true);
+ }
+
+ public List getComments(boolean ignoreSpam)
+ {
+ List list = new ArrayList();
+ try
+ {
+ return RollerFactory.getRoller().getWeblogManager().getComments(getId(), ignoreSpam);
+ }
+ catch (RollerException alreadyLogged) {}
+ return list;
+ }
+
+ //------------------------------------------------------------------------
+
+ 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
+ */
+ 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.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.
+ * @return
+ */
+ public String getPermaLink()
+ {
+ return getPermaLink(null);
+ }
+
+ /**
+ * 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.
+ * @param category The category name to insert into the permalink.
+ * @return String
+ */
+ public String getPermaLink(String categoryPath)
+ {
+ SimpleDateFormat formatter = DateUtil.get8charDateFormat();
+ String dayString = formatter.format(this.getPubTime());
+ String lAnchor = this.getAnchor();
+ if ("".equals(categoryPath)) categoryPath = null;
+ String lCategory = categoryPath;
+ try
+ {
+ lAnchor = URLEncoder.encode(anchor, "UTF-8");
+ if (categoryPath != null)
+ {
+ lCategory = URLEncoder.encode(categoryPath, "UTF-8");
+ }
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // go with the "no encoding" version
+ }
+
+ String plink = "/page/" + this.getWebsite().getUser().getUserName() + "/" + dayString;
+ if (lCategory != null)
+ {
+ plink += "?catname=" + lCategory;
+ }
+ plink += "#" + lAnchor;
+
+ return plink;
+ }
+
+ /**
+ * Return the Title of this post, or the first 255 characters of the
+ * entry's text.
+ *
+ * @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) */
+ public String getRss09xDescription()
+ {
+ return getRss09xDescription(-1);
+ }
+
+ /** Return RSS 09x style description (escaped HTML version of entry text) */
+ 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 = (String) 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
+ * @return
+ */
+ public List getPluginsList()
+ {
+ if (mPlugins != null)
+ {
+ return Arrays.asList( StringUtils.split(mPlugins, ",") );
+ }
+ return new ArrayList();
+ }
+
+}
Added: incubator/roller/trunk/src/org/roller/pojos/WebsiteData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WebsiteData.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WebsiteData.java (added)
+++ incubator/roller/trunk/src/org/roller/pojos/WebsiteData.java Wed Jun 8 09:06:16 2005
@@ -0,0 +1,583 @@
+package org.roller.pojos;
+
+import org.apache.commons.lang.StringUtils;
+import org.roller.RollerException;
+import org.roller.model.RollerFactory;
+import org.roller.util.PojoUtil;
+
+import java.util.Locale;
+import java.util.TimeZone;
+/**
+ * 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;
+ 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);
+ }
+
+ /**
+ * Id of the Website.
+ * @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.
+ * @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;
+ }
+
+ /**
+ * Id of owner.
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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.
+ *
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * EditorTheme of the Website.
+ * @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.
+ * @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.
+ * @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.
+ * @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;
+ }
+
+ /**
+ * @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.
+ * @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.
+ * @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();
+ }
+
+}
\ No newline at end of file
Added: incubator/roller/trunk/src/org/roller/pojos/WebsiteDisplayData.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/WebsiteDisplayData.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/WebsiteDisplayData.java (added)
+++ incubator/roller/trunk/src/org/roller/pojos/WebsiteDisplayData.java Wed Jun 8 09:06:16 2005
@@ -0,0 +1,116 @@
+/*
+ * 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
+{
+ 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/trunk/src/org/roller/pojos/package.html
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/pojos/package.html?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/pojos/package.html (added)
+++ incubator/roller/trunk/src/org/roller/pojos/package.html Wed Jun 8 09:06:16 2005
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title></title>
+</head>
+<body>
+Persistent objects and supporting classes. Source for XDoclet generation of Hibernate mappings,
+Struts form beans, and Struts validation configuration file.<br>
+</body>
+</html>
Added: incubator/roller/trunk/src/org/roller/presentation/AccessDeniedException.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/AccessDeniedException.java?rev=189602&view=auto
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/AccessDeniedException.java (added)
+++ incubator/roller/trunk/src/org/roller/presentation/AccessDeniedException.java Wed Jun 8 09:06:16 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();
+ }
+}
+