Clearspace API (1.10.16) Core Javadocs

com.jivesoftware.community.util
Class BlogUtils

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

public class BlogUtils
extends java.lang.Object

Collection of utility methods used across blogs

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


Method Summary
static java.lang.String format8601Date(java.util.Date date)
           
static java.lang.String getAuthorFeedURL(Blog blog, User author)
          Returns a string containing the path to the author feed for a specific blog / author combination.
static java.lang.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 java.lang.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 java.lang.String getBlogCommentFeedURL()
          Returns a string containing the path to a feed which contains recent comments across the entire system.
static java.lang.String getBlogFeedURL()
          Returns a string containing the path to a feed which contains newly created blogs across the entire system.
static java.lang.String getBlogTrackbackFeedURL()
          Returns a string containing the path to a feed which contains recent trackbacks across the entire system.
static java.lang.String getBlogURL(Blog blog)
          Returns the URL for the blog which is a combination of the base URL and the blog display name.
static java.lang.String getCommentFeedURL(Blog blog)
          Returns a string containing the path to the comments feed for a blog.
static java.lang.String getCommentFeedURL(BlogPost post)
          Returns a string containing the path to the comments feed for a specific post.
static java.lang.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 java.lang.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 java.lang.String getFeedURL()
          Returns a string containing the path to a feed which contains recent posts across the entire system.
static java.lang.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 java.lang.String getFromEmail()
          Get an available email address to use for outbound emails.
static java.lang.String getFromName()
          Get an available from name to use for outbound emails.
static java.lang.String getHumanFriendlyDate(java.util.Date dateToFormat)
          Deprecated. Replaced by DateUtils.displayFriendly(long)
static java.lang.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 java.util.List<java.lang.String> getReservedURIs()
          Returns a list of reserved words that cannot be used by blog authors as display names.
static java.lang.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 java.lang.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 java.lang.String getTagFeedURL(Blog blog, java.util.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 java.lang.String getTagFeedURL(Blog blog, java.lang.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 java.lang.String getTagFeedURL(ContentTag tag)
          Returns a string containing the path to the tag feed for the system and a given tag.
static java.lang.String getTagFeedURL(java.util.List<ContentTag> tags)
          Returns a string containing the path to the tag feed for the system and a given list of tags.
static java.lang.String getTagFeedURLPrefix()
          Returns the tag feed URL prefix for the system tag feeds, which the getTagFeedURL(com.jivesoftware.community.ContentTag) methods depend on.
static java.lang.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 java.lang.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 java.lang.String getTagPermalink(Blog blog, java.util.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 java.lang.String getTagPermalink(Blog blog, java.lang.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 java.lang.String getTagPermalink(java.lang.String tag)
          Returns a tag permalink for the system which is a combination of the base URL, the word 'tags' and the tag.
static java.lang.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 java.lang.String getTrackbackFeedURL(Blog blog)
          Returns a string containing the path to the trackbacks feed for a blog.
static java.lang.String getTrackbackFeedURL(BlogPost post)
          Returns a string containing the path to the trackbacks feed for a specific post.
static java.lang.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 java.lang.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 java.lang.String getUserFeedURL(java.lang.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 java.lang.String getUserFeedURLPrefix()
           
static boolean isReservedURI(java.lang.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(java.lang.String str)
          Method to validate a display name for a blog.
static java.lang.String makeURLSafe(java.lang.String str)
          Trims spaces from the start and end of the string, replaces punctuation, and then replaces occurences of non-alphanumeric characters (except dashes) with a dash.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFeedURL

public static java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getUserFeedURL(java.lang.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 java.lang.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 java.lang.String getTagFeedURL(java.util.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getTagFeedURL(Blog blog,
                                             java.util.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 java.lang.String getTagFeedURL(Blog blog,
                                             java.lang.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 java.lang.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 java.lang.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 java.lang.String getUserFeedURLPrefix()

getBlogURL

public static java.lang.String getBlogURL(Blog blog)
Returns the URL for the blog which is a combination of the base URL and the blog display name.

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

getPostPermalink

public static java.lang.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

getCommentPermalink

public static java.lang.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 java.lang.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 java.lang.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 java.lang.String getTagPermalink(java.lang.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 java.lang.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 java.lang.String getTagPermalink(Blog blog,
                                               java.util.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 java.lang.String getTagPermalink(Blog blog,
                                               java.lang.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 java.lang.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 java.lang.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 java.lang.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(java.lang.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()

makeURLSafe

public static java.lang.String makeURLSafe(java.lang.String str)
Trims spaces from the start and end of the string, replaces punctuation, and then replaces occurences of non-alphanumeric characters (except dashes) with a dash.

Examples:

If no string can be generated (for example, if there's no ASCII characters in the argument), retur the absolute value of hash code of the argument.

String returned is lower case.

Parameters:
str - The string to make a safe url from.
Returns:
The safe url string, or a hash code if none can be generated.

getFromEmail

public static java.lang.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 java.lang.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(java.lang.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 java.util.List<java.lang.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 java.lang.String format8601Date(java.util.Date date)

getHumanFriendlyDate

@Deprecated
public static java.lang.String getHumanFriendlyDate(java.util.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.