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 2006/05/25 21:06:37 UTC
svn commit: r409435 [3/3] - in /incubator/roller/branches/roller_3.0:
src/org/apache/roller/business/ src/org/apache/roller/business/hibernate/
src/org/apache/roller/business/search/
src/org/apache/roller/business/search/operations/ src/org/apache/roll...
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java Thu May 25 12:06:35 2006
@@ -1,20 +1,20 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.pojos;
@@ -48,24 +48,21 @@
/**
* Represents a Weblog Entry.
- *
- * @author David M Johnson
*
* @ejb:bean name="WeblogEntryData"
* @struts.form include-all="true"
* @hibernate.class lazy="false" table="weblogentry"
* @hibernate.cache usage="read-write"
*/
-public class WeblogEntryData extends PersistentObject implements Serializable
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(WeblogEntryData.class);
-
+public class WeblogEntryData extends PersistentObject implements Serializable, WeblogEntry {
+ private static Log mLogger =
+ LogFactory.getFactory().getInstance(WeblogEntryData.class);
+
public static final long serialVersionUID = 2341505386843044125L;
- public static final String DRAFT = "DRAFT";
- public static final String PENDING = "PENDING";
+ public static final String DRAFT = "DRAFT";
public static final String PUBLISHED = "PUBLISHED";
+ public static final String PENDING = "PENDING";
// Simple properies
private String id = null;
@@ -89,30 +86,28 @@
private UserData creator = null;
private WebsiteData website = null;
private WeblogCategoryData category = null;
-
+
// Collection of name/value entry attributes
private Map attMap = new HashMap();
private Set attSet = new TreeSet();
//----------------------------------------------------------- Construction
-
- public WeblogEntryData()
- {
+
+ public WeblogEntryData() {
}
-
+
public WeblogEntryData(
- java.lang.String id,
- WeblogCategoryData category,
- WebsiteData website,
- UserData creator,
- String title,
- String link,
- String text,
- String anchor,
- Timestamp pubTime,
- Timestamp updateTime,
- String status)
- {
+ java.lang.String id,
+ WeblogCategoryData category,
+ WebsiteData website,
+ UserData creator,
+ String title,
+ String link,
+ String text,
+ String anchor,
+ Timestamp pubTime,
+ Timestamp updateTime,
+ String status) {
this.id = id;
this.category = category;
this.website = website;
@@ -125,19 +120,17 @@
this.updateTime = updateTime;
this.status = status;
}
-
- public WeblogEntryData(WeblogEntryData otherData)
- {
+
+ public WeblogEntryData(WeblogEntryData otherData) {
this.setData(otherData);
}
-
+
//---------------------------------------------------------- Initializaion
-
+
/**
* Setter is needed in RollerImpl.storePersistentObject()
*/
- public void setData(org.apache.roller.pojos.PersistentObject otherData)
- {
+ public void setData(org.apache.roller.pojos.PersistentObject otherData) {
WeblogEntryData other = (WeblogEntryData)otherData;
this.id = other.getId();
@@ -157,358 +150,338 @@
this.rightToLeft = other.getRightToLeft();
this.pinnedToMain = other.getPinnedToMain();
}
-
+
//------------------------------------------------------ Simple properties
- /**
+ /**
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
*/
- public java.lang.String getId()
- {
+ public java.lang.String getId() {
return this.id;
}
-
+
/** @ejb:persistent-field */
- public void setId(java.lang.String id)
- {
+ public void setId(java.lang.String id) {
this.id = id;
}
-
- /**
+
+ /**
* @roller.wrapPojoMethod type="pojo"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.many-to-one column="categoryid" cascade="none" not-null="true"
*/
- public org.apache.roller.pojos.WeblogCategoryData getCategory()
- {
+ public org.apache.roller.pojos.WeblogCategoryData getCategory() {
return this.category;
}
-
+
/** @ejb:persistent-field */
- public void setCategory(org.apache.roller.pojos.WeblogCategoryData category)
- {
+ public void setCategory(org.apache.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
- {
+ public void setCategoryId(String id) throws RollerException {
WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
setCategory(wmgr.getWeblogCategory(id));
}
-
- /**
+
+ /**
+ * Return collection of WeblogCategoryData objects of this entry.
+ * Added for symetry with PlanetEntryData object.
+ * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.WeblogCategoryData"
+ */
+ public List getCategories() {
+ List cats = new ArrayList();
+ cats.add(getCategory());
+ return cats;
+ }
+
+ /** No-op method to please XDoclet */
+ public void setCategories(List cats) {
+ // no-op
+ }
+
+ /**
* @roller.wrapPojoMethod type="pojo"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.many-to-one column="websiteid" cascade="none" not-null="true"
*/
- public WebsiteData getWebsite()
- {
+ public WebsiteData getWebsite() {
return this.website;
}
-
+
/** @ejb:persistent-field */
- public void setWebsite(WebsiteData website)
- {
+ public void setWebsite(WebsiteData website) {
this.website = website;
}
-
- /**
+
+ /**
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.many-to-one column="userid" cascade="none" not-null="true"
*/
- public UserData getCreator()
- {
+ public UserData getCreator() {
return this.creator;
}
-
+
/** @ejb:persistent-field */
- public void setCreator(UserData creator)
- {
+ public void setCreator(UserData creator) {
this.creator = creator;
}
- /**
+ /**
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="title" non-null="true" unique="false"
*/
- public java.lang.String getTitle()
- {
+ public java.lang.String getTitle() {
return this.title;
}
-
+
/** @ejb:persistent-field */
- public void setTitle(java.lang.String title)
- {
+ public void setTitle(java.lang.String title) {
this.title = title;
}
-
- /**
+
+ /**
* Get summary for weblog entry (maps to RSS description and Atom summary).
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="summary" non-null="false" unique="false"
*/
public String getSummary() {
return summary;
}
-
- /**
+
+ /**
* Set summary for weblog entry (maps to RSS description and Atom summary).
- * @ejb:persistent-field
+ * @ejb:persistent-field
*/
public void setSummary(String summary) {
this.summary = summary;
}
-
- /**
+
+ /**
* Get content text for weblog entry (maps to RSS content:encoded and Atom content).
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="text" non-null="true" unique="false"
*/
- public java.lang.String getText()
- {
+ public java.lang.String getText() {
return this.text;
}
-
- /**
+
+ /**
* Set content text for weblog entry (maps to RSS content:encoded and Atom content).
- * @ejb:persistent-field
+ * @ejb:persistent-field
*/
- public void setText(java.lang.String text)
- {
+ public void setText(java.lang.String text) {
this.text = text;
}
- /**
+ /**
* Get content type (text, html, xhtml or a MIME content type)
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="content_type" non-null="false" unique="false"
*/
public String getContentType() {
return contentType;
}
-
- /**
+
+ /**
* Set content type (text, html, xhtml or a MIME content type)
- * @ejb:persistent-field
+ * @ejb:persistent-field
*/
public void setContentType(String contentType) {
this.contentType = contentType;
}
-
- /**
+
+ /**
* Get URL for out-of-line content.
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="content_src" non-null="false" unique="false"
*/
public String getContentSrc() {
return contentSrc;
}
-
- /**
+
+ /**
* Set URL for out-of-line content.
- * @ejb:persistent-field
+ * @ejb:persistent-field
*/
public void setContentSrc(String contentSrc) {
this.contentSrc = contentSrc;
}
-
- /**
+
+ /**
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="anchor" non-null="true" unique="false"
*/
- public java.lang.String getAnchor()
- {
+ public java.lang.String getAnchor() {
return this.anchor;
}
-
+
/** @ejb:persistent-field */
- public void setAnchor(java.lang.String anchor)
- {
+ 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.apache.roller.pojos.EntryAttributeData"
* @ejb:persistent-field
- * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all-delete-orphan"
+ * @hibernate.set lazy="true" order-by="name" inverse="true" cascade="all-delete-orphan"
* @hibernate.collection-key column="entryid" type="String"
* @hibernate.collection-one-to-many class="org.apache.roller.pojos.EntryAttributeData"
*/
- public Set getEntryAttributes()
- {
+ public Set getEntryAttributes() {
return attSet;
}
/** @ejb:persistent-field */
- public void setEntryAttributes(Set attSet)
- {
+ public void setEntryAttributes(Set attSet) {
this.attSet = attSet;
// copy set to map
- if (attSet != null)
- {
+ if (attSet != null) {
this.attSet = attSet;
this.attMap = new HashMap();
Iterator iter = this.attSet.iterator();
- while (iter.hasNext())
- {
+ while (iter.hasNext()) {
EntryAttributeData att = (EntryAttributeData)iter.next();
attMap.put(att.getName(), att);
}
- }
- else
- {
+ } 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)
- {
+ 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
- {
+ public void putEntryAttribute(String name, String value) throws Exception {
EntryAttributeData att = (EntryAttributeData)attMap.get(name);
- if (att == null)
- {
+ if (att == null) {
att = new EntryAttributeData();
att.setEntry(this);
att.setName(name);
att.setValue(value);
- attMap.put(name, att);
+ attMap.put(name, att);
attSet.add(att);
- }
- else
- {
+ } else {
att.setValue(value);
}
}
- public void removeEntryAttribute(String name) throws RollerException
- {
+ public void removeEntryAttribute(String name) throws RollerException {
EntryAttributeData att = (EntryAttributeData)attMap.get(name);
- if (att != null)
- {
+ if (att != null) {
attMap.remove(att);
attSet.remove(att);
}
}
//-------------------------------------------------------------------------
- /**
+ /**
* <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>
- *
+ * for viewing by newsfeed readers and visitors to the Roller site.</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
+ * 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
+ * <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
+ * @ejb:persistent-field
* @hibernate.property column="pubtime" non-null="true" unique="false"
*/
- public java.sql.Timestamp getPubTime()
- {
+ public java.sql.Timestamp getPubTime() {
return this.pubTime;
}
-
+
/** @ejb:persistent-field */
- public void setPubTime(java.sql.Timestamp pubTime)
- {
+ 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>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
+ * 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
+ * <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
+ * @ejb:persistent-field
* @hibernate.property column="updatetime" non-null="true" unique="false"
*/
- public java.sql.Timestamp getUpdateTime()
- {
+ public java.sql.Timestamp getUpdateTime() {
return this.updateTime;
}
-
+
/** @ejb:persistent-field */
- public void setUpdateTime(java.sql.Timestamp updateTime)
- {
+ public void setUpdateTime(java.sql.Timestamp updateTime) {
this.updateTime = updateTime;
}
-
- /**
+
+ /**
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="status" non-null="true" unique="false"
*/
- public String getStatus()
- {
+ public String getStatus() {
return this.status;
}
-
+
/** @ejb:persistent-field */
- public void setStatus(String status)
- {
+ public void setStatus(String status) {
this.status = status;
}
-
+
/**
* Some weblog entries are about one specific link.
* @return Returns the link.
*
* @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.property column="link" non-null="false" unique="false"
*/
- public java.lang.String getLink()
- {
+ public java.lang.String getLink() {
return link;
}
-
+
/**
* @ejb:persistent-field
* @param link The link to set.
*/
- public void setLink(java.lang.String link)
- {
+ public void setLink(java.lang.String link) {
this.link = link;
}
-
+
/**
* Comma-delimited list of this entry's Plugins.
*
@@ -516,17 +489,15 @@
* @ejb:persistent-field
* @hibernate.property column="plugins" non-null="false" unique="false"
*/
- public java.lang.String getPlugins()
- {
+ public java.lang.String getPlugins() {
return plugins;
}
-
+
/** @ejb:persistent-field */
- public void setPlugins(java.lang.String string)
- {
+ public void setPlugins(java.lang.String string) {
plugins = string;
}
-
+
/**
* True if comments are allowed on this weblog entry.
@@ -581,74 +552,66 @@
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
+ * @ejb:persistent-field
* @hibernate.property column="pinnedtomain" non-null="true" unique="false"
*/
- public Boolean getPinnedToMain()
- {
+ 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
+ *
+ * @ejb:persistent-field
*/
- public void setPinnedToMain(Boolean pinnedToMain)
- {
+ public void setPinnedToMain(Boolean pinnedToMain) {
this.pinnedToMain = pinnedToMain;
}
//------------------------------------------------------------------------
- /**
- * True if comments are still allowed on this entry considering the
+ /**
+ * True if comments are still allowed on this entry considering the
* allowComments and commentDays fields.
*
* @roller.wrapPojoMethod type="simple"
*/
- public boolean getCommentsStillAllowed()
- {
+ public boolean getCommentsStillAllowed() {
if(DRAFT.equals(this.status) || PENDING.equals(this.status))
return false;
- 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;
+ 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.
*
@@ -656,26 +619,22 @@
* @see java.text.SimpleDateFormat
* @return Publish time formatted according to pattern.
*/
- public String formatPubTime(String pattern)
- {
- try
- {
- SimpleDateFormat format = new SimpleDateFormat(pattern,
+ public String formatPubTime(String pattern) {
+ try {
+ SimpleDateFormat format = new SimpleDateFormat(pattern,
this.getWebsite().getLocaleInstance());
-
+
return format.format(getPubTime());
- }
- catch (RuntimeException e)
- {
+ } 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.
*
@@ -683,22 +642,18 @@
* @see java.text.SimpleDateFormat
* @return Update time formatted according to pattern.
*/
- public String formatUpdateTime(String pattern)
- {
- try
- {
+ public String formatUpdateTime(String pattern) {
+ try {
SimpleDateFormat format = new SimpleDateFormat(pattern);
-
+
return format.format(getUpdateTime());
- }
- catch (RuntimeException e)
- {
+ } catch (RuntimeException e) {
mLogger.error("Unexpected exception", e);
}
-
+
return "ERROR: formatting date";
}
-
+
//------------------------------------------------------------------------
/**
@@ -725,19 +680,18 @@
approvedOnly ? Boolean.TRUE : null, // approved
ignoreSpam ? Boolean.FALSE : null, // spam
false, // we want chrono order
- 0, // offset
+ 0, // offset
-1); // no limit
} catch (RollerException alreadyLogged) {}
return list;
}
-
+
//------------------------------------------------------------------------
/**
* @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.RefererData"
*/
- public List getReferers()
- {
+ public List getReferers() {
List referers = null;
try {
referers = RollerFactory.getRoller().getRefererManager().getReferersToEntry(getId());
@@ -746,85 +700,35 @@
}
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()
- {
+ public String getPermaLink() {
String lAnchor = this.getAnchor();
- try
- {
+ try {
lAnchor = URLEncoder.encode(anchor, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
// go with the "no encoding" version
}
WebsiteData website = this.getWebsite();
- String plink = "/page/" + website.getHandle() +
+ String plink = "/page/" + website.getHandle() +
"?entry=" + lAnchor;
return plink;
}
/**
- * Get the "relative" URL to this entry. Proper use of this will
- * require prepending the baseURL (either the full root
+ * 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.
*
@@ -832,8 +736,7 @@
* @param category The category name to insert into the permalink.
* @return String
*/
- public String getPermaLink(String categoryPath)
- {
+ 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
@@ -843,19 +746,15 @@
/**
* @roller.wrapPojoMethod type="simple"
*/
- public String getCommentsLink()
- {
+ public String getCommentsLink() {
String dayString = DateUtil.format8chars(this.getPubTime());
String lAnchor = this.getAnchor();
- try
- {
+ try {
lAnchor = URLEncoder.encode(anchor, "UTF-8");
- }
- catch (UnsupportedEncodingException e)
- {
+ } catch (UnsupportedEncodingException e) {
// go with the "no encoding" version
- }
- String clink = "/page/" + this.getWebsite().getHandle() + "?anchor=" + lAnchor;
+ }
+ String clink = "/page/" + this.getWebsite().getHandle() + "?entry=" + lAnchor;
return clink;
}
/** to please XDoclet */
@@ -864,14 +763,12 @@
/**
* 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("") )
- {
+ public String getDisplayTitle() {
+ if ( getTitle()==null || getTitle().trim().equals("") ) {
return StringUtils.left(Utilities.removeHTML(text),255);
}
return Utilities.removeHTML(getTitle());
@@ -879,161 +776,125 @@
//------------------------------------------------------------------------
- public String toString()
- {
+ public String toString() {
StringBuffer str = new StringBuffer("{");
-
- str.append("id=" + id + " " +
- "category=" + category + " " +
- "title=" + title + " " +
- "text=" + text + " " +
- "anchor=" + anchor + " " +
- "pubTime=" + pubTime + " " +
- "updateTime=" + updateTime + " " +
- "status=" + status + " " +
- "plugins=" + plugins);
+
+ str.append("id=" + id + " " +
+ "category=" + category + " " +
+ "title=" + title + " " +
+ "text=" + text + " " +
+ "anchor=" + anchor + " " +
+ "pubTime=" + pubTime + " " +
+ "updateTime=" + updateTime + " " +
+ "status=" + status + " " +
+ "plugins=" + plugins);
str.append('}');
-
+
return (str.toString());
}
-
+
//------------------------------------------------------------------------
- public boolean equals(Object pOther)
- {
- if (pOther instanceof WeblogEntryData)
- {
+ public boolean equals(Object pOther) {
+ if (pOther instanceof WeblogEntryData) {
WeblogEntryData lTest = (WeblogEntryData) pOther;
boolean lEquals = true;
-
- if (this.id == null)
- {
+
+ if (this.id == null) {
lEquals = lEquals && (lTest.getId() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.id.equals(lTest.getId());
}
-
- if (this.category == null)
- {
+
+ if (this.category == null) {
lEquals = lEquals && (lTest.getCategory() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.category.equals(lTest.getCategory());
}
-
- if (this.website == null)
- {
+
+ if (this.website == null) {
lEquals = lEquals && (lTest.getWebsite() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.website.equals(lTest.getWebsite());
}
-
- if (this.title == null)
- {
+
+ if (this.title == null) {
lEquals = lEquals && (lTest.getTitle() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.title.equals(lTest.getTitle());
}
-
- if (this.text == null)
- {
+
+ if (this.text == null) {
lEquals = lEquals && (lTest.getText() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.text.equals(lTest.getText());
}
-
- if (this.anchor == null)
- {
+
+ if (this.anchor == null) {
lEquals = lEquals && (lTest.getAnchor() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.anchor.equals(lTest.getAnchor());
}
-
- if (this.pubTime == null)
- {
+
+ if (this.pubTime == null) {
lEquals = lEquals && (lTest.getPubTime() == null);
- }
- else
- {
+ } else {
lEquals = lEquals && this.pubTime.equals(lTest.getPubTime());
}
-
- if (this.updateTime == null)
- {
+
+ if (this.updateTime == null) {
lEquals = lEquals && (lTest.getUpdateTime() == null);
+ } else {
+ lEquals = lEquals &&
+ this.updateTime.equals(lTest.getUpdateTime());
}
- else
- {
- lEquals = lEquals &&
- this.updateTime.equals(lTest.getUpdateTime());
- }
-
- if (this.status == null)
- {
+
+ if (this.status == null) {
lEquals = lEquals && (lTest.getStatus() == null);
+ } else {
+ lEquals = lEquals &&
+ this.status.equals(lTest.getStatus());
}
- else
- {
- lEquals = lEquals &&
- this.status.equals(lTest.getStatus());
- }
-
- if (this.plugins == null)
- {
+
+ if (this.plugins == null) {
lEquals = lEquals && (lTest.getPlugins() == null);
+ } else {
+ lEquals = lEquals &&
+ this.plugins.equals(lTest.getPlugins());
}
- else
- {
- lEquals = lEquals &&
- this.plugins.equals(lTest.getPlugins());
- }
-
-
+
+
return lEquals;
- }
- else
- {
+ } else {
return false;
}
}
-
+
//------------------------------------------------------------------------
- public int hashCode()
- {
+ 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.website != null) ? this.website.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.status != null) ? this.status.hashCode() : 0);
- result = (37 * result) +
- ((this.plugins != null) ? this.plugins.hashCode() : 0);
-
+ result = (37 * result) +
+ ((this.id != null) ? this.id.hashCode() : 0);
+ result = (37 * result) +
+ ((this.category != null) ? this.category.hashCode() : 0);
+ result = (37 * result) +
+ ((this.website != null) ? this.website.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.status != null) ? this.status.hashCode() : 0);
+ result = (37 * result) +
+ ((this.plugins != null) ? this.plugins.hashCode() : 0);
+
return result;
}
@@ -1042,51 +903,43 @@
*
* @roller.wrapPojoMethod type="simple"
*/
- public String getRss09xDescription()
- {
+ 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)
- {
+ public String getRss09xDescription(int maxLength) {
String ret = Utilities.escapeHTML(text);
- if (maxLength != -1 && ret.length() > maxLength)
- {
- ret = ret.substring(0,maxLength-3)+"...";
+ if (maxLength != -1 && ret.length() > maxLength) {
+ ret = ret.substring(0,maxLength-3)+"...";
}
- return ret;
+ return ret;
}
-
+
/** Create anchor for weblog entry, based on title or text */
- protected String createAnchor() throws RollerException
- {
+ protected String createAnchor() throws RollerException {
return RollerFactory.getRoller().getWeblogManager().createAnchor(this);
}
-
+
/** Create anchor for weblog entry, based on title or text */
- public String createAnchorBase()
- {
+ public String createAnchorBase() {
// Use title or text for base anchor
String base = getTitle();
- if (base == null || base.trim().equals(""))
- {
+ if (base == null || base.trim().equals("")) {
base = getText();
}
- if (base != null && !base.trim().equals(""))
- {
+ 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)
- {
+ while (toker.hasMoreTokens() && count < 5) {
String s = toker.nextToken();
s = s.toLowerCase();
tmp = (tmp == null) ? s : tmp + "_" + s;
@@ -1096,39 +949,35 @@
}
// No title or text, so instead we will use the items date
// in YYYYMMDD format as the base anchor
- else
- {
+ else {
base = DateUtil.format8chars(getPubTime());
}
-
+
return base;
}
-
+
/**
* A no-op.
- * TODO: fix formbean generation so this is not needed.
+ * TODO: fix formbean generation so this is not needed.
* @param string
*/
- public void setPermaLink(String string)
- {
+ public void setPermaLink(String string) {
}
-
+
/**
* A no-op.
- * TODO: fix formbean generation so this is not needed.
+ * TODO: fix formbean generation so this is not needed.
* @param string
*/
- public void setDisplayTitle(String string)
- {
+ public void setDisplayTitle(String string) {
}
-
+
/**
* A no-op.
- * TODO: fix formbean generation so this is not needed.
+ * TODO: fix formbean generation so this is not needed.
* @param string
*/
- public void setRss09xDescription(String string)
- {
+ public void setRss09xDescription(String string) {
}
@@ -1138,53 +987,44 @@
* @roller.wrapPojoMethod type="simple"
* @return
*/
- public List getPluginsList()
- {
- if (plugins != null)
- {
+ public List getPluginsList() {
+ if (plugins != null) {
return Arrays.asList( StringUtils.split(plugins, ",") );
}
return new ArrayList();
}
-
+
/**
* Set creator by user id (for use in form's copyTo method)
* @param creatorId
*/
- public void setCreatorId(String creatorId) throws RollerException
- {
+ public void setCreatorId(String creatorId) throws RollerException {
UserManager umgr = RollerFactory.getRoller().getUserManager();
- setCreator(umgr.getUser(creatorId));
+ setCreator(umgr.getUser(creatorId));
}
-
+
/** Convenience method for checking status */
- public boolean isDraft()
- {
+ public boolean isDraft() {
return status.equals(DRAFT);
}
/** no-op: needed only to satisfy XDoclet, use setStatus() instead */
- public void setDraft(boolean value)
- {
+ public void setDraft(boolean value) {
}
/** Convenience method for checking status */
- public boolean isPending()
- {
+ public boolean isPending() {
return status.equals(PENDING);
}
/** no-op: needed only to satisfy XDoclet, use setStatus() instead */
- public void setPending(boolean value)
- {
+ public void setPending(boolean value) {
}
/** Convenience method for checking status */
- public boolean isPublished()
- {
+ public boolean isPublished() {
return status.equals(PUBLISHED);
}
/** no-op: needed only to satisfy XDoclet, use setStatus() instead */
- public void setPublished(boolean value)
- {
+ public void setPublished(boolean value) {
}
@@ -1209,5 +1049,5 @@
return false;
}
-
+
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java Thu May 25 12:06:35 2006
@@ -115,7 +115,7 @@
public List getAggregation(int num) throws RollerException
{
Roller roller = RollerFactory.getRoller();
- return roller.getPlanetManager().getAggregation(num);
+ return roller.getPlanetManager().getAggregation(0, num);
}
/**
* Get named group
@@ -144,7 +144,7 @@
{
Roller roller = RollerFactory.getRoller();
PlanetGroupData group= roller.getPlanetManager().getGroup(name);
- ret = roller.getPlanetManager().getAggregation(group, num);
+ ret = roller.getPlanetManager().getAggregation(group, 0, num);
}
catch (RollerException e)
{
@@ -161,7 +161,7 @@
try
{
Roller roller = RollerFactory.getRoller();
- ret = roller.getPlanetManager().getTopSubscriptions(num);
+ ret = roller.getPlanetManager().getTopSubscriptions(0, num);
}
catch (RollerException e)
{
@@ -180,7 +180,7 @@
{
Roller roller = RollerFactory.getRoller();
PlanetGroupData group= roller.getPlanetManager().getGroup(name);
- ret = roller.getPlanetManager().getTopSubscriptions(group,num);
+ ret = roller.getPlanetManager().getTopSubscriptions(group, 0, num);
}
catch (RollerException e)
{
@@ -194,7 +194,7 @@
public List getPopularWebsites(int num) throws RollerException
{
Roller roller = RollerFactory.getRoller();
- return roller.getRefererManager().getDaysPopularWebsites(num);
+ return roller.getRefererManager().getDaysPopularWebsites(-1, 0, num);
}
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/SyncWebsitesTask.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/SyncWebsitesTask.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/SyncWebsitesTask.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/SyncWebsitesTask.java Thu May 25 12:06:35 2006
@@ -100,7 +100,7 @@
String baseSiteURL = baseURL + "/page/";
// get list of all enabled and active weblogs
Iterator websites =
- roller.getUserManager().getWebsites(null, Boolean.TRUE, Boolean.TRUE).iterator();
+ roller.getUserManager().getWebsites(null, Boolean.TRUE, Boolean.TRUE, 0, -1).iterator();
while (websites.hasNext()) {
WebsiteData website = (WebsiteData)websites.next();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java Thu May 25 12:06:35 2006
@@ -102,7 +102,7 @@
List list = null;
mLogger.debug("Refreshing popular websites list");
Roller roller = RollerFactory.getRoller();
- list = roller.getRefererManager().getDaysPopularWebsites(num);
+ list = roller.getRefererManager().getDaysPopularWebsites(-1, 0, num);
return list;
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java Thu May 25 12:06:35 2006
@@ -1,22 +1,22 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.ui.rendering.velocity;
+
import java.util.ArrayList;
import java.util.List;
@@ -28,59 +28,71 @@
/**
* Allow Roller page templates to get the main Planet aggregation (the 'all'
- * and 'external' group), custom aggregations, specified by handle, and
- * subscription entries (specified by feedUrl).
+ * and 'external' group), custom aggregations, specified by handle, and
+ * subscription entries (specified by feedUrl).
* @author Dave Johnson
*/
-public class PlanetPageModel extends PageModel
-{
+public class PlanetPageModel extends PageModel {
PlanetManager planetManager = null;
- public void init(RollerRequest rreq)
- {
+
+ public void init(RollerRequest rreq) {
super.init(rreq);
- try
- {
+ try {
planetManager = RollerFactory.getRoller().getPlanetManager();
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR initializing page model",e);
}
}
- /**
- * Get main aggregation (of 'all' and 'external' groups)
- * @returns List of PlanetEntryData objects
+
+ /**
+ * Get move recent WeblogEntry objects from 'all' and
+ * 'exernal' Planet groups. in reverse chrono order.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
*/
- public List getPlanetAggregation(int max) throws Exception
- {
- return planetManager.getAggregation(max);
+ public List getAggregation(int offset, int len) {
+ //return planetManager.getAggregation(offset, len);
+ return null;
}
- /**
- * Get aggregation by group handle
- * @returns List of PlanetEntryData objects
+
+ /**
+ * Get move recent WeblogEntry objects from specified
+ * Planet groups in reverse chrono order.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
*/
- public List getPlanetAggregation(String groupHandle, int max) throws Exception
- {
+ public List getAggregation(String group, int offset, int len) {
List list = new ArrayList();
- PlanetGroupData group = planetManager.getGroup(groupHandle);
- if (group != null)
- {
- list = planetManager.getAggregation(group, max);
- }
+ //PlanetGroupData group = planetManager.getGroup(group);
+ //if (group != null) {
+ // list = planetManager.getAggregation(group, offset, len);
+ //}
return list;
}
- /**
- * Get entries in a subscription specified by feedUrl.
- * @returns List of PlanetEntryData objects
+
+ /**
+ * Get move recent WeblogEntry objects from specified
+ * Planet subscription in reverse chrono order.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
*/
- public List getPlanetSubscriptionEntries(String feedUrl, int max) throws Exception
- {
+ public List getFeed(String feedUrl, int offset, int len) {
List list = new ArrayList();
- PlanetSubscriptionData sub = planetManager.getSubscription(feedUrl);
- if (sub != null)
- {
- list = sub.getEntries();
- }
+ //PlanetSubscriptionData sub = planetManager.getSubscription(feedUrl);
+ //if (sub != null) {
+ //list = sub.getEntries();
+ //}
return list;
}
+
+ /**
+ * Get PlanetSubscription objects in descending order by Planet ranking.
+ * @param sinceDays Only consider weblogs updated in the last sinceDays
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getRankedBlogs(int sinceDays, int offset, int len) {
+ return null;
+ }
+
}
Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/SitePageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/SitePageModel.java?rev=409435&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/SitePageModel.java (added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/SitePageModel.java Thu May 25 12:06:35 2006
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.ui.rendering.velocity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ */
+public class SitePageModel {
+
+ /**
+ * Get most collection of Website objects,
+ * in reverse chrono order by creationDate.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getWeblogs(int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most collection of most commented Website objects,
+ * in descending order by number of comments.
+ * @param sinceDays Only consider weblogs updated in the last sinceDays
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getCommentedWeblogs(int sinceDays ,int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most recent WeblogEntry objects across all weblogs,
+ * in reverse chrono order by pubTime.
+ * @param cats To limit results to list of category names
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getWeblogEntries(List cats, int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most commented WeblogEntry objects across all weblogs,
+ * in descending order by number of comments.
+ * @param sinceDays Only consider weblogs updated in the last sinceDays
+ * @param cats To limit results to list of category names
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getCommentedWeblogEntries(List cats, int sinceDays, int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most recent WeblogEntry objects across all weblogs,
+ * in reverse chrono order by pubTime.
+ * @param username Limit entries to those created by this user
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getUserWeblogEntries(String username, int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most recent Comment objects across all weblogs,
+ * in reverse chrono order by postTime.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getComments(int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get most recent User objects, in reverse chrono order by creationDate.
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getUsers(int offset, int len) {
+ return null;
+ }
+
+ /**
+ * Get list of WebsiteDisplay objects, ordered by number of hits.
+ * @param sinceDays Only consider weblogs updated in the last sinceDays
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getHotBlogs(int sinceDays, int offset, int len) {
+ return null;
+ }
+
+ /** Get User object by username */
+ //public UserDataWrapper getUser(String username) {}
+
+ /** Get Website object by handle */
+ //public WebsiteDataWrapper getWeblog(String handle) {}
+
+ /**
+ * Get map with 26 entries, one for each letter A-Z and
+ * containing integers reflecting the number of users whose
+ * names start with each letter.
+ */
+ public Map getUsernameLetterMap() {
+ return null;
+ }
+
+ /** Get collection of users whose names begin with specified letter */
+ public List getUsersByLetter(char letter) {
+ return null;
+ }
+
+ /**
+ * Get map with 26 entries, one for each letter A-Z and
+ * containing integers reflecting the number of weblogs whose
+ * names start with each letter.
+ */
+ public Map getWeblogHandleLetterMap() {
+ return null;
+ }
+
+ /** Get collection of weblogs whose handles begin with specified letter */
+ public List getWeblogsByLetter(char letter) {
+ return null;
+ }
+}
+
+
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/BloggerAPIHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/BloggerAPIHandler.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/BloggerAPIHandler.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/BloggerAPIHandler.java Thu May 25 12:06:35 2006
@@ -285,7 +285,7 @@
UserManager umgr = RollerFactory.getRoller().getUserManager();
UserData user = umgr.getUserByUsername(userid);
// get list of user's enabled websites
- List websites = umgr.getWebsites(user, Boolean.TRUE, null);
+ List websites = umgr.getWebsites(user, Boolean.TRUE, null, 0, -1);
Iterator iter = websites.iterator();
while (iter.hasNext()) {
WebsiteData website = (WebsiteData)iter.next();
Modified: incubator/roller/branches/roller_3.0/testdata/roller-custom.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/testdata/roller-custom.properties?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/testdata/roller-custom.properties (original)
+++ incubator/roller/branches/roller_3.0/testdata/roller-custom.properties Thu May 25 12:06:35 2006
@@ -1,2 +1,3 @@
# Uncomment this to use JDO backend
#persistence.roller.classname=org.apache.roller.business.JDO.JDORollerImpl
+search.index.dir=search-index
\ No newline at end of file
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/RollerTestBase.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/RollerTestBase.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/RollerTestBase.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/RollerTestBase.java Thu May 25 12:06:35 2006
@@ -134,7 +134,7 @@
"TestUser",
"testuser@example.com");
UserManager umgr = getRoller().getUserManager();
- mWebsite = (WebsiteData)umgr.getWebsites(mUser, null, null).get(0);
+ mWebsite = (WebsiteData)umgr.getWebsites(mUser, null, null, 0, -1).get(0);
PropertiesManager propmgr = getRoller().getPropertiesManager();
Map props = propmgr.getProperties();
@@ -212,7 +212,7 @@
"test"+i+"@test.com" // emailAddress
);
ud.setEnabled(new Boolean(i%2 == 0)); // half of users are disabled
- WebsiteData website = (WebsiteData)umgr.getWebsites(ud, null, null).get(0);
+ WebsiteData website = (WebsiteData)umgr.getWebsites(ud, null, null, 0, -1).get(0);
mWebsitesCreated.add(website);
mUsersCreated.add(ud);
@@ -389,7 +389,7 @@
UserData user = umgr.getUserByUsername(deleteMe);
- WebsiteData website = (WebsiteData)umgr.getWebsites(user, null, null).get(0);
+ WebsiteData website = (WebsiteData)umgr.getWebsites(user, null, null, 0, -1).get(0);
umgr.removeWebsite(website);
umgr.removeUser(user);
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/IndexManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/IndexManagerTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/IndexManagerTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/IndexManagerTest.java Thu May 25 12:06:35 2006
@@ -17,68 +17,94 @@
*/
package org.apache.roller.business;
+import java.sql.Timestamp;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.roller.business.search.operations.AddEntryOperation;
+import org.apache.roller.business.search.operations.RemoveEntryOperation;
import org.apache.roller.business.search.operations.SearchOperation;
import org.apache.roller.model.IndexManager;
import org.apache.roller.model.RollerFactory;
+import org.apache.roller.pojos.UserData;
import org.apache.roller.pojos.WeblogEntryData;
+import org.apache.roller.pojos.WebsiteData;
/**
* Test Search Manager business layer operations.
*/
public class IndexManagerTest extends TestCase {
-
-
+
public IndexManagerTest(String name) {
super(name);
}
-
-
+
public static Test suite() {
return new TestSuite(IndexManagerTest.class);
}
-
-
+
public void testSearch() throws Exception {
try {
IndexManager imgr = RollerFactory.getRoller().getIndexManager();
- WeblogEntryData wd1 = new WeblogEntryData();
- wd1.setId("dummy");
+ WebsiteData website = new WebsiteData();
+ website.setHandle("trekker");
+
+ UserData user = new UserData();
+ user.setUserName("nimoy");
+
+ WeblogEntryData wd1 = new WeblogEntryData();
+ wd1.setId("dummy1");
+ wd1.setAnchor("dummy1");
+ wd1.setCreator(user);
+ wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
+ wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
wd1.setTitle("The Tholian Web");
+ wd1.setWebsite(website);
wd1.setText(
- "When the Enterprise attempts to ascertain the fate of the U.S.S. "
- +"Defiant which vanished 3 weeks ago, the warp engines begin to lose "
- +"power, and Spock reports strange sensor readings.");
+ "When the Enterprise attempts to ascertain the fate of the "
+ +"U.S.S. Defiant which vanished 3 weeks ago, the warp engines "
+ +"begin to lose power, and Spock reports strange sensor readings.");
imgr.executeIndexOperationNow(
- new AddEntryOperation((IndexManagerImpl)imgr, wd1));
+ new AddEntryOperation((IndexManagerImpl) imgr, wd1));
WeblogEntryData wd2 = new WeblogEntryData();
- wd2.setId("dummy");
+ wd2.setId("dummy2");
+ wd2.setAnchor("dummy2");
+ wd2.setCreator(user);
+ wd2.setUpdateTime(new Timestamp(System.currentTimeMillis()));
+ wd2.setPubTime(new Timestamp(System.currentTimeMillis()));
wd2.setTitle("A Piece of the Action");
+ wd2.setWebsite(website);
wd2.setText(
- "The crew of the Enterprise attempts to make contact with "
- +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
- +"in communication with Boss Oxmyx.");
- imgr.executeIndexOperationNow(
- new AddEntryOperation((IndexManagerImpl)imgr, wd2));
+ "The crew of the Enterprise attempts to make contact with "
+ +"the inhabitants of planet Sigma Iotia II, and Uhura puts Kirk "
+ +"in communication with Boss Oxmyx.");
+ imgr.executeIndexOperationNow(
+ new AddEntryOperation((IndexManagerImpl) imgr, wd2));
SearchOperation search = new SearchOperation(imgr);
search.setTerm("Enterprise");
imgr.executeIndexOperationNow(search);
- assertTrue(search.getResultsCount() == 2);
+ assertEquals(2, search.getResultsCount());
SearchOperation search2 = new SearchOperation(imgr);
search2.setTerm("Tholian");
imgr.executeIndexOperationNow(search2);
- assertTrue(search2.getResultsCount() == 1);
+ assertEquals(1, search2.getResultsCount());
+
+ // Clean up
+ imgr.removeEntryIndexOperation(wd1);
+ imgr.removeEntryIndexOperation(wd2);
+
+ SearchOperation search3 = new SearchOperation(imgr);
+ search3.setTerm("Enterprise");
+ imgr.executeIndexOperationNow(search3);
+ assertEquals(0, search3.getResultsCount());
+
} catch (Exception e) {
e.printStackTrace();
}
- }
-
+ }
}
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PermissionTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PermissionTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PermissionTest.java Thu May 25 12:06:35 2006
@@ -225,7 +225,7 @@
// assert that user is member of weblog
assertFalse(mgr.getPermissions(testWeblog, user).isPending());
- List weblogs = mgr.getWebsites(user, null, null);
+ List weblogs = mgr.getWebsites(user, null, null, 0, -1);
assertEquals(1, weblogs.size());
assertEquals(testWeblog.getId(), ((WebsiteData)weblogs.get(0)).getId());
@@ -238,7 +238,7 @@
TestUtils.endSession(true);
user = mgr.getUser(user.getId());
- weblogs = mgr.getWebsites(user, null, null);
+ weblogs = mgr.getWebsites(user, null, null, 0, -1);
assertEquals(0, weblogs.size());
// cleanup the extra test user
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerLocalTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerLocalTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerLocalTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerLocalTest.java Thu May 25 12:06:35 2006
@@ -57,7 +57,7 @@
refreshTask.init(getRoller(), "dummy");
refreshTask.run();
- List agg = planet.getAggregation(10000);
+ List agg = planet.getAggregation(0, -1);
int size = agg.size();
assertEquals(mBlogCount * mExpectedPublishedEntryCount, size);
}
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/PlanetManagerTest.java Thu May 25 12:06:35 2006
@@ -300,6 +300,9 @@
TestUtils.endSession(true);
assertTrue(entriesSize > 0);
+
+ Object feed = planet.getSubscription(feed_url1);
+ assertNull(feed);
}
}
@@ -351,10 +354,10 @@
PlanetGroupData group = planet.getGroup("test_handle");
assertNotNull(group);
- List bigag = planet.getAggregation(group, 30);
+ List bigag = planet.getAggregation(group, 0, 30);
assertEquals(30, bigag.size());
- List littleag = planet.getAggregation(group, 10);
+ List littleag = planet.getAggregation(group, 0, 10);
assertEquals(10, littleag.size());
planet.deleteGroup(group);
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/RefererTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/RefererTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/RefererTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/RefererTest.java Thu May 25 12:06:35 2006
@@ -1,20 +1,20 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
package org.apache.roller.business;
import java.sql.Timestamp;
@@ -36,6 +36,7 @@
import org.apache.roller.pojos.RollerPropertyData;
import org.apache.roller.pojos.UserData;
import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.pojos.WebsiteDisplayData;
import org.apache.roller.util.DateUtil;
@@ -48,6 +49,7 @@
UserData testUser = null;
WebsiteData testWeblog = null;
+ WebsiteData testWeblog2 = null;
int count = 20;
String testDay;
@@ -71,7 +73,8 @@
try {
testUser = TestUtils.setupUser("referTestUser");
- testWeblog = TestUtils.setupWeblog("referTestWeblog", testUser);
+ testWeblog = TestUtils.setupWeblog("referTestWeblog1", testUser);
+ testWeblog2 = TestUtils.setupWeblog("referTestWeblog2", testUser);
// add "spamtest" to refererSpamWords
PropertiesManager pmgr = RollerFactory.getRoller().getPropertiesManager();
@@ -90,7 +93,11 @@
testDay = DateUtil.format8chars(day);
rmgr.processReferrer("http://test"+i, "http://test"+i,
- testWeblog.getHandle(), null, testDay);
+ testWeblog.getHandle(), null, testDay);
+ if (i % 2 == 0) { // half the referrers from weblog 2
+ rmgr.processReferrer("http://test"+i, "http://test"+i,
+ testWeblog2.getHandle(), null, testDay);
+ }
}
TestUtils.endSession(true);
@@ -111,9 +118,11 @@
pmgr.saveProperty(spamprop);
TestUtils.teardownWeblog(testWeblog.getId());
+ TestUtils.teardownWeblog(testWeblog2.getId());
TestUtils.teardownUser(testUser.getId());
TestUtils.endSession(true);
+
} catch (Exception ex) {
log.error(ex);
throw new Exception("Test teardown failed", ex);
@@ -249,5 +258,26 @@
assertEquals(0, refs.size());
}
+ public void testGetDaysPopularWebsites() throws Exception {
+ log.info("Test apply referers (weblog)");
+ RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
+
+ List sites = rmgr.getDaysPopularWebsites(0, 0, 1);
+ assertEquals(1, sites.size());
+
+ sites = rmgr.getDaysPopularWebsites(0, 1, 1);
+ assertEquals(1, sites.size());
+
+ sites = rmgr.getDaysPopularWebsites(0, 0, 20);
+ assertEquals(2, sites.size());
+
+ WebsiteDisplayData site1 = (WebsiteDisplayData)sites.get(0);
+ assertEquals(testWeblog.getHandle(), site1.getWebsiteHandle());
+ assertEquals(count, site1.getHits().intValue());
+
+ WebsiteDisplayData site2 = (WebsiteDisplayData)sites.get(1);
+ assertEquals(testWeblog2.getHandle(), site2.getWebsiteHandle());
+ assertEquals(count/2, site2.getHits().intValue());
+ }
}
Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogTest.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogTest.java Thu May 25 12:06:35 2006
@@ -179,16 +179,22 @@
// get all weblogs for user
weblog = null;
- List weblogs1 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE);
+ List weblogs1 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, 0, Integer.MAX_VALUE);
assertEquals(2, weblogs1.size());
weblog = (WebsiteData) weblogs1.get(0);
assertNotNull(weblog);
+ // testing paging
+ List weblogs11 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, 0, 1);
+ assertEquals(1, weblogs11.size());
+ List weblogs12 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, 1, 1);
+ assertEquals(1, weblogs11.size());
+
// make sure disabled weblogs are not returned
weblog.setEnabled(Boolean.FALSE);
mgr.saveWebsite(weblog);
TestUtils.endSession(true);
- List weblogs2 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE);
+ List weblogs2 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, 0, Integer.MAX_VALUE);
assertEquals(1, weblogs2.size());
weblog = (WebsiteData) weblogs2.get(0);
assertNotNull(weblog);
@@ -197,7 +203,7 @@
weblog.setActive(Boolean.FALSE);
mgr.saveWebsite(weblog);
TestUtils.endSession(true);
- List weblogs3 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE);
+ List weblogs3 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, 0, Integer.MAX_VALUE);
assertEquals(0, weblogs3.size());
// remove test weblogs