Clearspace API (2.5.18) Core Javadocs

com.jivesoftware.community.util
Class BlogUtils

java.lang.Object
  extended by com.jivesoftware.community.util.BlogUtils

public class BlogUtils
extends Object

Collection of utility methods used across blogs

 Includes replaceNonAlphanumeric() from Roller Weblogger server (Apache license).
 


Field Summary
static String VALID_BLOG_NAME_CHARS
           
 
Method Summary
static String format8601Date(Date date)
           
static String getAuthorFeedURL(Blog blog, User author)
          Returns a string containing the path to the author feed for a specific blog / author combination.
static String getAuthorPermalink(Blog blog)
          Returns a author permalink for a blog which is a combination of the base URL, the blog display name and the word 'authors'.
static String getAuthorPermalink(Blog blog, User author)
          Returns a author permalink for a blog and author which is a combination of the base URL, the blog display name and the word 'authors' and the authors username.
static String getBlogCommentFeedURL()
          Returns a string containing the path to a feed which contains recent comments across the entire system.
static String getBlogFeedURL()
          Returns a string containing the path to a feed which contains newly created blogs across the entire system.
static String getBlogTrackbackFeedURL()
          Returns a string containing the path to a feed which contains recent trackbacks across the entire system.
static String getBlogURL(Blog blog)
          Returns the URL for the blog as a fully-qualified path based on jiveHome.
static String getBlogURL(Blog blog, boolean absolute)
          Returns the URL for the blog as either a fully qualified URL or as a relative resource depending on the absolute parameter.
static String getBlogURL(Blog blog, String context)
          Returns the URL for the blog which is a combination of the base URL and the blog display name.
static String getCommentFeedURL(Blog blog)
          Returns a string containing the path to the comments feed for a blog.
static String getCommentFeedURL(BlogPost post)
          Returns a string containing the path to the comments feed for a specific post.
static String getCommentPermalink(Comment comment)
          Returns a permalink for a blog comment which is a combination of the base URL, the blog display name, the year / month / day, the entry name and a suffix / comment ID.
static String getCommentURL(BlogPost post)
          Returns a string containing the path to the script that accepts comment postings which is a combination of the base URL, the blog display name and the post permalink.
static String getFeedURL()
          Returns a string containing the path to a feed which contains recent posts across the entire system.
static String getFeedURL(Blog blog)
          Returns a string containing the path to the feed which is a combination of the base URL, the blog display name and the default system feed type.
static String getFromEmail()
          Get an available email address to use for outbound emails.
static String getFromName()
          Get an available from name to use for outbound emails.
static String getHumanFriendlyDate(Date dateToFormat)
          Deprecated. Replaced by DateUtils#displayFriendly(long)
static String getNestedContainerContext(Community community)
           
static String getNestedContainerContext(Project project)
           
static String getPostPermalink(BlogPost post)
          Returns a permalink for a blog post which is a combination of the base URL, the blog display name and the post permalink.
static String getRelativePostLink(BlogPost post)
           
static List<String> getReservedURIs()
          Returns a list of reserved words that cannot be used by blog authors as display names.
static String getSearchURL(Blog blog)
          Returns a string containing the path to the script that accepts search queries for a blog which is a combination of the base URL, the blog display name and the search path.
static String getTagFeedURL(Blog blog, ContentTag tag)
          Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.
static String getTagFeedURL(Blog blog, List<ContentTag> tags)
          Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.
static String getTagFeedURL(Blog blog, String tags)
          Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.
static String getTagFeedURL(ContentTag tag)
          Returns a string containing the path to the tag feed for the system and a given tag.
static String getTagFeedURL(List<ContentTag> tags)
          Returns a string containing the path to the tag feed for the system and a given list of tags.
static String getTagFeedURLPrefix()
          Returns the tag feed URL prefix for the system tag feeds, which the getTagFeedURL(com.jivesoftware.community.ContentTag) methods depend on.
static String getTagFeedURLPrefix(Blog blog)
          Returns the tag feed URL prefix for a given blog, which the getTagFeedURL(com.jivesoftware.community.ContentTag) methods depend on.
static String getTagPermalink(Blog blog, ContentTag tag)
          Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and the given tag..
static String getTagPermalink(Blog blog, List<ContentTag> tags)
          Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and a list of tags.
static String getTagPermalink(Blog blog, String tags)
          Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and the given tag or tags, delimited using a plus (+) sign.
static String getTagPermalink(String tag)
          Returns a tag permalink for the system which is a combination of the base URL, the word 'tags' and the tag.
static String getTagsPermalink(Blog blog)
          Returns a tag permalink for a blog which is a combination of the base URL, the blog display name and the word 'tags'.
static String getTrackbackFeedURL(Blog blog)
          Returns a string containing the path to the trackbacks feed for a blog.
static String getTrackbackFeedURL(BlogPost post)
          Returns a string containing the path to the trackbacks feed for a specific post.
static String getTrackbackPermalink(Trackback trackback)
          Returns a permalink for a blog trackback which is a combination of the base URL, the blog display name, the year / month / day, the entry name and a suffix / trackback ID.
static String getTrackbackURL(BlogPost post)
          Returns a trackback URL for a blog post which is a combination of the base URL, the blog display name and the post permalink.
static String getUserFeedURL(String username)
          Returns a string containing the path to the feed which is a combination of the base URL, the username and the default system feed type.
static String getUserFeedURLPrefix()
           
static boolean isReservedURI(String displayName)
          Used by blog config to make sure a display name provided by a user does not conflict with one of the reserved names in the /blog/ namespace.
static boolean isValidDisplayName(String str)
          Method to validate a display name for a blog.
static boolean isValidName(String str)
          Method to validate the name for a blog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALID_BLOG_NAME_CHARS

public static final String VALID_BLOG_NAME_CHARS
Method Detail

getFeedURL

public static String getFeedURL()
Returns a string containing the path to a feed which contains recent posts across the entire system.

Returns:
the feed URL for the system

getBlogFeedURL

public static String getBlogFeedURL()
Returns a string containing the path to a feed which contains newly created blogs across the entire system.

Returns:
the feed URL for the system

getBlogCommentFeedURL

public static String getBlogCommentFeedURL()
Returns a string containing the path to a feed which contains recent comments across the entire system.

Returns:
the feed URL for the system

getBlogTrackbackFeedURL

public static String getBlogTrackbackFeedURL()
Returns a string containing the path to a feed which contains recent trackbacks across the entire system.

Returns:
the feed URL for the system

getUserFeedURL

public static String getUserFeedURL(String username)
Returns a string containing the path to the feed which is a combination of the base URL, the username and the default system feed type.

Parameters:
username - the username of the user to display the feed for
Returns:
the feed URL for this user

getTagFeedURL

public static String getTagFeedURL(ContentTag tag)
Returns a string containing the path to the tag feed for the system and a given tag.

Parameters:
tag - The tag to get the feed url for.
Returns:
the tag feed url

getTagFeedURL

public static String getTagFeedURL(List<ContentTag> tags)
Returns a string containing the path to the tag feed for the system and a given list of tags.

Parameters:
tags - The list of tags to get the feed url for.
Returns:
the tag feed url

getFeedURL

public static String getFeedURL(Blog blog)
Returns a string containing the path to the feed which is a combination of the base URL, the blog display name and the default system feed type.

Parameters:
blog - the blog to display the feed for
Returns:
the feed URL for this blog

getCommentFeedURL

public static String getCommentFeedURL(Blog blog)
Returns a string containing the path to the comments feed for a blog.

Parameters:
blog - the blog to display the comments feed for
Returns:
the feed URL for comments on this blog.

getCommentFeedURL

public static String getCommentFeedURL(BlogPost post)
Returns a string containing the path to the comments feed for a specific post.

Parameters:
post - the post to display the feed for
Returns:
the feed URL for comments on this post

getAuthorFeedURL

public static String getAuthorFeedURL(Blog blog,
                                      User author)
Returns a string containing the path to the author feed for a specific blog / author combination.

Parameters:
blog - the blog to display the feed for
author - the user to display the feed for
Returns:
the feed URL for the author feed for the given blog / user combination

getAuthorPermalink

public static String getAuthorPermalink(Blog blog)
Returns a author permalink for a blog which is a combination of the base URL, the blog display name and the word 'authors'.

Parameters:
blog - The blog to get a author permalink for.
Returns:
the author permalink

getAuthorPermalink

public static String getAuthorPermalink(Blog blog,
                                        User author)
Returns a author permalink for a blog and author which is a combination of the base URL, the blog display name and the word 'authors' and the authors username.

Parameters:
blog - The blog to get an author permalink for.
author - The user to get an author permalink for
Returns:
the author permalink

getTrackbackFeedURL

public static String getTrackbackFeedURL(Blog blog)
Returns a string containing the path to the trackbacks feed for a blog.

Parameters:
blog - the blog to display the trackbacks feed for
Returns:
the feed URL for trackbacks on this blog.

getTrackbackFeedURL

public static String getTrackbackFeedURL(BlogPost post)
Returns a string containing the path to the trackbacks feed for a specific post.

Parameters:
post - the post to display the feed for
Returns:
the feed URL for trackbacks on this post

getTagFeedURL

public static String getTagFeedURL(Blog blog,
                                   ContentTag tag)
Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.

Parameters:
blog - the blog to get the feed for
tag - the tag to get the feed for
Returns:
the tag feed url

getTagFeedURL

public static String getTagFeedURL(Blog blog,
                                   List<ContentTag> tags)
Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.

Parameters:
blog - The blog to get a feed url for.
tags - List of tags under the blog to get a feed url for.
Returns:
the tag feed url

getTagFeedURL

public static String getTagFeedURL(Blog blog,
                                   String tags)
Returns a string containing the path to the tag feed which is a combination of the base URL, the blog display name, the word 'feed-tags' and the given tag or tags.

Parameters:
blog - The blog to get a feed url for.
tags - List of tags under the blog to get a feed url for.
Returns:
the tag feed url

getTagFeedURLPrefix

public static String getTagFeedURLPrefix(Blog blog)
Returns the tag feed URL prefix for a given blog, which the getTagFeedURL(com.jivesoftware.community.ContentTag) methods depend on. Useful for classes that need to build a tag feed URL without knowing what tags will be used.

Parameters:
blog - The blog to get the url tag feed url prefix for.
Returns:
the tag feed url prefix

getTagFeedURLPrefix

public static String getTagFeedURLPrefix()
Returns the tag feed URL prefix for the system tag feeds, which the getTagFeedURL(com.jivesoftware.community.ContentTag) methods depend on. Useful for classes that need to build a tag feed URL without knowing what tags will be used.

Returns:
the tag feed url prefix

getUserFeedURLPrefix

public static String getUserFeedURLPrefix()

getBlogURL

public static String getBlogURL(Blog blog,
                                boolean absolute)
Returns the URL for the blog as either a fully qualified URL or as a relative resource depending on the absolute parameter.

Parameters:
blog -
absolute -
Returns:

getBlogURL

public static String getBlogURL(Blog blog)
Returns the URL for the blog as a fully-qualified path based on jiveHome. This should be avoided in favor of relative paths when accessed from a web-facing request.

Parameters:
blog - The blog to get a url for.
Returns:
the permalink for this blog

getBlogURL

public static String getBlogURL(Blog blog,
                                String context)
Returns the URL for the blog which is a combination of the base URL and the blog display name. Passing a null context to this method is the equivalent of calling getBlogURL(blog, flase).

Parameters:
blog - The blog to get a url for.
context - The context to append to the beginning of the URL.
Returns:
the permalink for this blog

getNestedContainerContext

public static final String getNestedContainerContext(Community community)

getNestedContainerContext

public static final String getNestedContainerContext(Project project)

getPostPermalink

public static String getPostPermalink(BlogPost post)
Returns a permalink for a blog post which is a combination of the base URL, the blog display name and the post permalink.

More information: http://en.wikipedia.org/wiki/Permalink

Parameters:
post - The blog post to get a perma link for.
Returns:
the permalink for this post

getRelativePostLink

public static String getRelativePostLink(BlogPost post)

getCommentPermalink

public static String getCommentPermalink(Comment comment)
Returns a permalink for a blog comment which is a combination of the base URL, the blog display name, the year / month / day, the entry name and a suffix / comment ID.

Parameters:
comment - the comment to get a link for
Returns:
the permalink for this comment

getTrackbackPermalink

public static String getTrackbackPermalink(Trackback trackback)
Returns a permalink for a blog trackback which is a combination of the base URL, the blog display name, the year / month / day, the entry name and a suffix / trackback ID.

Parameters:
trackback - the trackback to get a link for
Returns:
the permalink for this trackback

getTagsPermalink

public static String getTagsPermalink(Blog blog)
Returns a tag permalink for a blog which is a combination of the base URL, the blog display name and the word 'tags'.

Parameters:
blog - The blog to get a tag permalink for.
Returns:
the tags permalink

getTagPermalink

public static String getTagPermalink(String tag)
Returns a tag permalink for the system which is a combination of the base URL, the word 'tags' and the tag.

Parameters:
tag - The tag to get a permalink for.
Returns:
the tags permalink

getTagPermalink

public static String getTagPermalink(Blog blog,
                                     ContentTag tag)
Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and the given tag..

Parameters:
blog - The blog to get a permalink for.
tag - The tag under the blog to get a permalink for.
Returns:
the tags permalink

getTagPermalink

public static String getTagPermalink(Blog blog,
                                     List<ContentTag> tags)
Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and a list of tags.

Parameters:
blog - The blog to get a permalink for.
tags - The tags under the blog to get a permalink for.
Returns:
the tags permalink

getTagPermalink

public static String getTagPermalink(Blog blog,
                                     String tags)
Returns a tag permalink for a blog which is a combination of the base URL, the blog display name, the word 'tags' and the given tag or tags, delimited using a plus (+) sign.

Parameters:
blog - The blog to get a permalink for.
tags - The tags under the blog to get a permalink for.
Returns:
the tags permalink

getCommentURL

public static String getCommentURL(BlogPost post)
Returns a string containing the path to the script that accepts comment postings which is a combination of the base URL, the blog display name and the post permalink.

Parameters:
post - The blog post to get a comment url for.
Returns:
the comment URL for this post

getSearchURL

public static String getSearchURL(Blog blog)
Returns a string containing the path to the script that accepts search queries for a blog which is a combination of the base URL, the blog display name and the search path.

Parameters:
blog - The blog to get a search url for.
Returns:
the search URL for this blog

getTrackbackURL

public static String getTrackbackURL(BlogPost post)
Returns a trackback URL for a blog post which is a combination of the base URL, the blog display name and the post permalink. This URL is for HTTP clients needing to create a reference to a blog post.

Parameters:
post - The blog post to get a track back url for.
Returns:
the trackback permalink for this post

isValidDisplayName

public static boolean isValidDisplayName(String str)
Method to validate a display name for a blog. A display name is valid if it contains one or more letters, numbers, periods, dashes or underscores and does not start with any of the reserved words in the blog namespace.

Parameters:
str - the blog display name to check.
Returns:
true if only letters, numbers, periods, dashes and underscores and doesn't start with one of the blog reserved words. False if null, zero length or fails the alphanumeric + dashes / underscores and periods test.
See Also:
getReservedURIs()

isValidName

public static boolean isValidName(String str)
Method to validate the name for a blog. A name is valid if it contains one or more letters, numbers, periods, dashes or underscores, characters listed in StringUtils.OTHER_SAFE_CHARS, and ampersand.

Parameters:
str - the blog name to check.
Returns:
true if only letters, numbers, periods, dashes and underscores and characters listed in StringUtils.OTHER_SAFE_CHARS, and ampersand.

getFromEmail

public static String getFromEmail()
Get an available email address to use for outbound emails. To customize this value, set the system property
blogs.email.fromEmail
.

Returns:
an available email address to use for outbound blog emails.

getFromName

public static String getFromName()
Get an available from name to use for outbound emails. To customize this value, set the system property
blogs.email.fromName
.

Returns:
an available from name to use for outbound blog emails.

isReservedURI

public static boolean isReservedURI(String displayName)
Used by blog config to make sure a display name provided by a user does not conflict with one of the reserved names in the /blog/ namespace. A blog display name cannot start with any of the following words:

Parameters:
displayName - The display name of the blog.
Returns:
true if the given display name is reserved, false if the display name is ok to use as a blog display name.

getReservedURIs

public static List<String> getReservedURIs()
Returns a list of reserved words that cannot be used by blog authors as display names.

Returns:
a list of reserved words that cannot be used by blog authors as display names

format8601Date

public static String format8601Date(Date date)

getHumanFriendlyDate

@Deprecated
public static String getHumanFriendlyDate(Date dateToFormat)
Deprecated. Replaced by DateUtils#displayFriendly(long)

Turn a Unix seconds-since-epoch timestamp into a human friendly string such as "3 days ago" or "an hour ago".

Ported from JavaScript library by Nelson Minar.

Parameters:
dateToFormat - The date to format.
Returns:
string formatted in a human friendly manner.

Clearspace Project Page

Copyright © 1999-2007 Jive Software.