📄 weblogentrydata.java
字号:
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(7); 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 /** * @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; } //------------------------------------------------------------------------- /** * Map attributes as set because XDoclet 1.2b4 map support is broken. * @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 */ 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> * * @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> * * @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 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. */ public boolean getCommentsStillAllowed() { boolean ret = false; if (getAllowComments() == null || getAllowComments().booleanValue()) { if (getCommentDays() == null || getCommentDays().intValue() == 0) { ret = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -