org.blojsom.blog
Class FileBackedBlogEntry

java.lang.Object
  extended byorg.blojsom.blog.BlogEntry
      extended byorg.blojsom.blog.FileBackedBlogEntry
All Implemented Interfaces:
BlojsomConstants, BlojsomMetaDataConstants, java.io.Serializable

public class FileBackedBlogEntry
extends BlogEntry

FileBackedBlogEntry

Since:
blojsom 1.8
Version:
$Id: FileBackedBlogEntry.java,v 1.35 2006/05/16 19:59:34 czarneckid Exp $
Author:
David Czarnecki
See Also:
Serialized Form

Field Summary
protected  java.lang.String _blogFileEncoding
           
protected  java.lang.String _commentsDirectory
           
protected  org.apache.commons.logging.Log _logger
           
protected  java.lang.String _pingbacksDirectory
           
protected  java.io.File _source
           
protected  java.lang.String _trackbacksDirectory
           
 
Fields inherited from class org.blojsom.blog.BlogEntry
_blogCategory, _category, _comments, _description, _entryDate, _filename, _lastModified, _link, _metaData, _pingbacks, _title, _trackbacks
 
Fields inherited from interface org.blojsom.util.BlojsomConstants
ADMINISTRATORS_IP, BLOG_ADMIN_URL_IP, BLOG_ADMINISTRATION_LOCALE_IP, BLOG_AUTHORIZATION_IP, BLOG_BASE_URL_IP, BLOG_BLACKLIST_FILE_IP, BLOG_COMMENTS_DIRECTORY_IP, BLOG_COMMENTS_ENABLED_IP, BLOG_COUNTRY_DEFAULT, BLOG_COUNTRY_IP, BLOG_DEFAULT_CATEGORY_EXCLUSION_MAPPING_IP, BLOG_DEFAULT_CATEGORY_MAPPING_IP, BLOG_DEFAULT_FETCHER, BLOG_DEFAULT_FILE_EXTENSION_IP, BLOG_DEFAULT_FLAVOR_IP, BLOG_DEFAULT_PROPERTIES, BLOG_DEPTH_IP, BLOG_DESCRIPTION_IP, BLOG_DIRECTORY_FILTER_IP, BLOG_EMAIL_ENABLED_IP, BLOG_ENTRIES_DISPLAY_DEFAULT, BLOG_ENTRIES_DISPLAY_IP, BLOG_ENTRY_META_DATA_EXTENSION_IP, BLOG_FILE_ENCODING_IP, BLOG_FILE_EXTENSIONS_IP, BLOG_HOME_IP, BLOG_LANGUAGE_DEFAULT, BLOG_LANGUAGE_IP, BLOG_NAME_IP, BLOG_OWNER, BLOG_OWNER_EMAIL, BLOG_PERMISSIONS_IP, BLOG_PINGBACKS_DIRECTORY_IP, BLOG_PINGBACKS_ENABLED_IP, BLOG_PROPERTIES_EXTENSIONS_IP, BLOG_TRACKBACK_DIRECTORY_IP, BLOG_TRACKBACKS_ENABLED_IP, BLOG_URL_IP, BLOJSOM_ALL_CATEGORIES, BLOJSOM_AUTHORIZATION_PROVIDER_IP, BLOJSOM_BLOG, BLOJSOM_BLOG_HOME_IP, BLOJSOM_BROADCASTER_IP, BLOJSOM_CATEGORIES, BLOJSOM_COMMENTS_ENABLED, BLOJSOM_CONFIGURATION_BASE_DIRECTORY_IP, BLOJSOM_CONFIGURATION_IP, BLOJSOM_DATE, BLOJSOM_DATE_ISO8601, BLOJSOM_DATE_OBJECT, BLOJSOM_DATE_UTC, BLOJSOM_DEFAULT_BROADCASTER, BLOJSOM_DEFAULT_CONFIGURATION_BASE_DIRECTORY, BLOJSOM_DEFAULT_RESOURCE_DIRECTORY, BLOJSOM_DEFAULT_RESOURCE_MANAGER, BLOJSOM_DEFAULT_TEMPLATES_DIRECTORY, BLOJSOM_DEFAULT_USER_IP, BLOJSOM_EMAIL_ENABLED, BLOJSOM_ENTRIES, BLOJSOM_FETCHER_IP, BLOJSOM_FLAVOR_CONFIGURATION_IP, BLOJSOM_INSTALLATION_DIRECTORY_IP, BLOJSOM_INSTALLED_LOCALES_IP, BLOJSOM_LAST_MODIFIED, BLOJSOM_LISTENER_CONFIGURATION_IP, BLOJSOM_PERMALINK, BLOJSOM_PERMALINK_NEXT_ENTRY, BLOJSOM_PERMALINK_PREVIOUS_ENTRY, BLOJSOM_PLUGIN_CHAIN, BLOJSOM_PLUGIN_CONFIGURATION_IP, BLOJSOM_PLUGINS, BLOJSOM_REQUESTED_CATEGORY, BLOJSOM_REQUESTED_FLAVOR, BLOJSOM_RESOURCE_DIRECTORY_IP, BLOJSOM_RESOURCE_MANAGER_BUNDLES_IP, BLOJSOM_RESOURCE_MANAGER_CONTEXT_KEY, BLOJSOM_RESOURCE_MANAGER_IP, BLOJSOM_SITE_URL, BLOJSOM_TEMPLATES_DIRECTORY_IP, BLOJSOM_USER, BLOJSOM_USERS_IP, BLOJSOM_VERSION, BLOJSOM_VERSION_NUMBER, CACHE_CONTROL_HTTP_HEADER, CATEGORY_PARAM, COMMENT_EXTENSION, DEFAULT_AUTHORIZATION_PROVIDER, DEFAULT_COMMENTS_DIRECTORY, DEFAULT_DIGEST_ALGORITHM, DEFAULT_DISPATCHER_CONFIGURATION_FILE, DEFAULT_ENTRY_EXTENSION, DEFAULT_FLAVOR_CONFIGURATION_FILE, DEFAULT_FLAVOR_HTML, DEFAULT_METADATA_EXTENSION, DEFAULT_PERMISSIONS_CONFIGURATION_FILE, DEFAULT_PINGBACKS_DIRECTORY, DEFAULT_PLUGIN_CONFIGURATION_FILE, DEFAULT_PROPERTIES_EXTENSIONS, DEFAULT_TRACKBACK_DIRECTORY, DESCRIPTION_KEY, DIGEST_ALGORITHM, FLAVOR_PARAM, HTTP_ETAG, HTTP_LASTMODIFIED, INFINITE_BLOG_DEPTH, ISO_8601_DATE_FORMAT, LINE_SEPARATOR, LINEAR_NAVIGATION_ENABLED_IP, MAX_HASHABLE_LENGTH, NAME_KEY, NO_CACHE_HTTP_HEADER_VALUE, OVERRIDE_LASTMODIFIED_PARAM, PAGE_PARAM, PAGE_PARAM_ARCHIVE, PERMALINK_PARAM, PINGBACK_EXTENSION, PLUGINS_PARAM, PRAGMA_HTTP_HEADER, PREFERRED_SYNDICATION_FLAVOR, RECURSIVE_CATEGORIES, REDIRECT_TO_PARAM, RFC_822_DATE_FORMAT, SHORT_ISO_8601_DATE_FORMAT, TRACKBACK_EXTENSION, USE_ENCRYPTED_PASSWORDS, UTC_DATE_FORMAT, UTF8, WHITESPACE, XMLRPC_ENABLED_IP
 
Fields inherited from interface org.blojsom.util.BlojsomMetaDataConstants
BLOG_ENTRY_METADATA_AUTHOR, BLOG_ENTRY_METADATA_AUTHOR_EXT, BLOG_ENTRY_METADATA_TIMESTAMP, BLOG_METADATA_COMMENTS_DISABLED, BLOG_METADATA_HEADER, BLOG_METADATA_PINGBACKS_DISABLED, BLOG_METADATA_TRACKBACKS_DISABLED, SOURCE_ATTRIBUTE
 
Constructor Summary
FileBackedBlogEntry()
          Create a new blog entry with no data
FileBackedBlogEntry(java.lang.String title, java.lang.String link, java.lang.String description, java.io.File source)
          Create a new blog entry
 
Method Summary
 void delete(BlogUser blogUser)
          Delete the blog entry.
 java.lang.String getId()
          Returns the BlogId for this entry
 java.lang.String getPermalink()
          Return the permalink name for this blog entry
 java.io.File getSource()
          File containing the blog entry
 void load(BlogUser blogUser)
          Load a blog entry.
protected  void loadBlogCategory(BlogUser blogUser)
          Load the blog category information for this entry
protected  BlogComment loadComment(java.io.File commentFile, java.lang.String blogFileEncoding, BlogUser blogUser)
          Load a comment for this blog entry from disk Comments must always have the form:
author
author e-mail address
author url
everything else after is the comment
protected  void loadComments(BlogUser blogUser)
          Convenience method to load the comments for this blog entry.
protected  void loadMetaData(Blog blog)
          Load the meta data for the entry
protected  Pingback loadPingback(java.io.File pingbackFile, java.lang.String blogFileEncoding, BlogUser blogUser)
          Load a pingback for this blog entry from disk Pingbacks must always have the form:
title
url
blog_name
excerpt
protected  void loadPingbacks(BlogUser blogUser)
          Convenience method to load the pingbacks for this blog entry.
protected  Trackback loadTrackback(java.io.File trackbackFile, java.lang.String blogFileEncoding, BlogUser blogUser)
          Load a trackback for this blog entry from disk Trackbacks must always have the form:
title
excerpt
url
blog_name
protected  void loadTrackbacks(BlogUser blogUser)
          Convenience method to load the trackbacks for this blog entry.
protected  void reloadSource(Blog blog)
          Reload the blog entry from disk

The first line of the blog entry will be used as the title of the blog

 void save(BlogUser blogUser)
          Save the blog entry.
protected  void saveMetaData(Blog blog)
          Store the meta data for the entry
 void setAttributes(java.util.Map attributeMap)
          Set any attributes of the blog entry using data from the map.
 void setBlogFileEncoding(java.lang.String blogFileEncoding)
          Set the file encoding to use when loading the blog entry
 void setCommentsDirectory(java.lang.String commentsDirectory)
          Set the directory for comments
 void setPingbacksDirectory(java.lang.String pingbacksDirectory)
          Set the directory for pingbacks
 void setSource(java.io.File source)
          Set the file of the blog entry
 void setTrackbacksDirectory(java.lang.String trackbacksDirectory)
          Set the directory for trackbacks
 boolean supportsComments()
          Determines whether or not this blog entry supports comments by testing to see if the blog entry is writable.
 boolean supportsPingbacks()
          Determines whether or not this blog entry supports pingbacks.
 boolean supportsTrackbacks()
          Determines whether or not this blog entry supports trackbacks.
 
Methods inherited from class org.blojsom.blog.BlogEntry
equals, getBlogCategory, getCategory, getComments, getCommentsAsArray, getDate, getDateAsFormat, getDateAsFormat, getDescription, getEncodedCategory, getEscapedDescription, getEscapedLink, getEscapedTitle, getFilename, getISO8601Date, getLastModified, getLink, getMetaData, getNumComments, getNumPingbacks, getNumTrackbacks, getPingbacks, getPingbacksAsArray, getRFC822Date, getTitle, getTrackbacks, getTrackbacksAsArray, getUTCDate, setBlogCategory, setCategory, setComments, setDate, setDescription, setFilename, setLink, setMetaData, setPingbacks, setTitle, setTrackbacks, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_logger

protected transient org.apache.commons.logging.Log _logger

_source

protected transient java.io.File _source

_commentsDirectory

protected transient java.lang.String _commentsDirectory

_trackbacksDirectory

protected transient java.lang.String _trackbacksDirectory

_pingbacksDirectory

protected transient java.lang.String _pingbacksDirectory

_blogFileEncoding

protected transient java.lang.String _blogFileEncoding
Constructor Detail

FileBackedBlogEntry

public FileBackedBlogEntry()
Create a new blog entry with no data


FileBackedBlogEntry

public FileBackedBlogEntry(java.lang.String title,
                           java.lang.String link,
                           java.lang.String description,
                           java.io.File source)
Create a new blog entry

Parameters:
title - Entry title
link - Permalink to the entry
description - Entry description
source - File containing the blog entry
Method Detail

setBlogFileEncoding

public void setBlogFileEncoding(java.lang.String blogFileEncoding)
Set the file encoding to use when loading the blog entry

Parameters:
blogFileEncoding - File encoding
Since:
blojsom 1.9

getSource

public java.io.File getSource()
File containing the blog entry

Returns:
Blog entry file

setSource

public void setSource(java.io.File source)
Set the file of the blog entry

Parameters:
source - File for the blog entry

getId

public java.lang.String getId()
Returns the BlogId for this entry

Specified by:
getId in class BlogEntry
Returns:
Blog Id

getPermalink

public java.lang.String getPermalink()
Return the permalink name for this blog entry

Specified by:
getPermalink in class BlogEntry
Returns:
Permalink name

reloadSource

protected void reloadSource(Blog blog)
                     throws java.io.IOException
Reload the blog entry from disk

The first line of the blog entry will be used as the title of the blog

Parameters:
blog - Blog information
Throws:
java.io.IOException - If there is an error loading the blog entry

supportsComments

public boolean supportsComments()
Determines whether or not this blog entry supports comments by testing to see if the blog entry is writable.

Specified by:
supportsComments in class BlogEntry
Returns:
true if the blog entry is writable, false otherwise

supportsTrackbacks

public boolean supportsTrackbacks()
Determines whether or not this blog entry supports trackbacks.

Specified by:
supportsTrackbacks in class BlogEntry
Returns:
true if the blog entry supports trackbacks, false otherwise
Since:
blojsom 2.05

supportsPingbacks

public boolean supportsPingbacks()
Determines whether or not this blog entry supports pingbacks.

Specified by:
supportsPingbacks in class BlogEntry
Returns:
true if the blog entry supports pingbacks, false otherwise
Since:
blojsom 2.23

setCommentsDirectory

public void setCommentsDirectory(java.lang.String commentsDirectory)
Set the directory for comments

Parameters:
commentsDirectory - Comments directory

loadComments

protected void loadComments(BlogUser blogUser)
Convenience method to load the comments for this blog entry. A blog entry can have

Parameters:
blogUser - BlogUser information

loadComment

protected BlogComment loadComment(java.io.File commentFile,
                                  java.lang.String blogFileEncoding,
                                  BlogUser blogUser)
                           throws BlojsomException
Load a comment for this blog entry from disk Comments must always have the form:
author
author e-mail address
author url
everything else after is the comment

Parameters:
commentFile - Comment file
blogFileEncoding - Encoding for blog files
blogUser - BlogUser
Returns:
BlogComment Blog comment loaded from disk
Throws:
BlojsomException

setTrackbacksDirectory

public void setTrackbacksDirectory(java.lang.String trackbacksDirectory)
Set the directory for trackbacks

Parameters:
trackbacksDirectory - Trackbacks directory

loadTrackbacks

protected void loadTrackbacks(BlogUser blogUser)
Convenience method to load the trackbacks for this blog entry.

Parameters:
blogUser - BlogUser information

loadTrackback

protected Trackback loadTrackback(java.io.File trackbackFile,
                                  java.lang.String blogFileEncoding,
                                  BlogUser blogUser)
                           throws BlojsomException
Load a trackback for this blog entry from disk Trackbacks must always have the form:
title
excerpt
url
blog_name

Parameters:
trackbackFile - Trackback file
blogFileEncoding - Encoding for blog files
blogUser - BlogUser information
Returns:
Trackback Trackback loaded from disk
Throws:
BlojsomException

setPingbacksDirectory

public void setPingbacksDirectory(java.lang.String pingbacksDirectory)
Set the directory for pingbacks

Parameters:
pingbacksDirectory - Pingbacks directory
Since:
blojsom 2.23

loadPingbacks

protected void loadPingbacks(BlogUser blogUser)
Convenience method to load the pingbacks for this blog entry.

Parameters:
blogUser - BlogUser information
Since:
blojsom 2.23

loadPingback

protected Pingback loadPingback(java.io.File pingbackFile,
                                java.lang.String blogFileEncoding,
                                BlogUser blogUser)
                         throws BlojsomException
Load a pingback for this blog entry from disk Pingbacks must always have the form:
title
url
blog_name
excerpt

Parameters:
pingbackFile - Pingback file
blogFileEncoding - Encoding for blog files
blogUser - BlogUser
Returns:
Pingback loaded from disk
Throws:
BlojsomException
Since:
blojsom 2.23

loadMetaData

protected void loadMetaData(Blog blog)
Load the meta data for the entry

Parameters:
blog - Blog information
Since:
blojsom 1.9

saveMetaData

protected void saveMetaData(Blog blog)
Store the meta data for the entry

Parameters:
blog - Blog information
Since:
blojsom 1.9

loadBlogCategory

protected void loadBlogCategory(BlogUser blogUser)
Load the blog category information for this entry

Parameters:
blogUser - BlogUser information
Since:
blojsom 2.23

load

public void load(BlogUser blogUser)
          throws BlojsomException
Load a blog entry.

Specified by:
load in class BlogEntry
Parameters:
blogUser - User information
Throws:
BlojsomException - If there is an error loading the entry
Since:
blojsom 1.9

save

public void save(BlogUser blogUser)
          throws BlojsomException
Save the blog entry. This method does not write out the comments or trackbacks to disk.

Specified by:
save in class BlogEntry
Parameters:
blogUser - User information
Throws:
BlojsomException - If there is an error saving the entry
Since:
blojsom 1.9

delete

public void delete(BlogUser blogUser)
            throws BlojsomException
Delete the blog entry.

Specified by:
delete in class BlogEntry
Parameters:
blogUser - User information
Throws:
BlojsomException - If there is an error deleting the entry
Since:
blojsom 1.9

setAttributes

public void setAttributes(java.util.Map attributeMap)
Set any attributes of the blog entry using data from the map.

Overrides:
setAttributes in class BlogEntry
Parameters:
attributeMap - Attributes