org.blojsom.extension.xmlrpc.handlers
Class PingbackHandler

java.lang.Object
  extended byorg.blojsom.extension.xmlrpc.handlers.AbstractBlojsomAPIHandler
      extended byorg.blojsom.extension.xmlrpc.handlers.PingbackHandler
All Implemented Interfaces:
BlojsomConstants, BlojsomMetaDataConstants, BlojsomXMLRPCConstants

public class PingbackHandler
extends AbstractBlojsomAPIHandler

Pingback handler provides support for the Pingback 1.0 specification.

Since:
blojsom 2.23
Version:
$Id: PingbackHandler.java,v 1.9 2006/03/15 02:28:10 czarneckid Exp $
Author:
David Czarnecki

Field Summary
protected static java.lang.String API_NAME
           
protected static int PINGBACK_ACCESS_DENIED_CODE
           
protected static int PINGBACK_ALREADY_REGISTERED_CODE
           
protected static int PINGBACK_GENERIC_FAULT_CODE
           
protected static int PINGBACK_NO_LINK_TO_TARGET_URI_CODE
           
protected static int PINGBACK_SOURCE_URI_NON_EXISTENT_CODE
           
protected static int PINGBACK_TARGET_URI_NON_EXISTENT_CODE
           
protected static int PINGBACK_TARGET_URI_NOT_ENABLED_CODE
           
protected static int PINGBACK_UPSTREAM_SERVER_ERROR_CODE
           
 
Fields inherited from class org.blojsom.extension.xmlrpc.handlers.AbstractBlojsomAPIHandler
_authorizationProvider, _blog, _blogEntryExtension, _blogUser, _configuration, _fetcher, _httpServletRequest, _httpServletResponse, _servletConfig, AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG, INVALID_POSTID, INVALID_POSTID_MSG, NOBLOGS_EXCEPTION, NOBLOGS_EXCEPTION_MSG, PERMISSION_EXCEPTION, PERMISSION_EXCEPTION_MSG, UNKNOWN_EXCEPTION, UNKNOWN_EXCEPTION_MSG, UNSUPPORTED_EXCEPTION, UNSUPPORTED_EXCEPTION_MSG
 
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
 
Fields inherited from interface org.blojsom.extension.xmlrpc.BlojsomXMLRPCConstants
BLOG_XMLRPC_CONFIGURATION_IP, BLOG_XMLRPC_ENTRY_EXTENSION_IP, DEFAULT_BLOG_XMLRPC_ENTRY_EXTENSION, DEFAULT_XMLRPC_HANDLER_KEY
 
Constructor Summary
PingbackHandler()
          Construct a new Pingback handler
 
Method Summary
protected  java.lang.Integer addPingback(java.util.Map context, java.lang.String category, java.lang.String permalink, java.lang.String title, java.lang.String excerpt, java.lang.String url, java.lang.String blogName, java.lang.String[] blogFileExtensions, java.lang.String blogHome, java.lang.String blogPingbackDirectory, java.lang.String blogFileEncoding, java.util.Map pingbackMetaData, Pingback pingback, java.lang.String id)
          Add a pingback for a given blog ID
protected  BlogCategory getBlogCategory(BlogUser user, javax.servlet.http.HttpServletRequest httpServletRequest)
          Determine the blog category based on the request
protected  java.lang.String getExcerptFromSource(java.lang.String source, java.lang.String targetURI)
          Try to extract an excerpt from the source text.
 java.lang.String getName()
          Gets the name of API Handler.
protected  java.lang.String getTitleFromSource(java.lang.String source)
          Try to find the <title></title> tags from the source text
 java.lang.String ping(java.lang.String sourceURI, java.lang.String targetURI)
          Notifies the server that a link has been added to sourceURI, pointing to targetURI.
 void setBlogUser(BlogUser blogUser)
          Attach a blog instance to the API Handler so that it can interact with the blog
 
Methods inherited from class org.blojsom.extension.xmlrpc.handlers.AbstractBlojsomAPIHandler
checkXMLRPCPermission, getBlogCategoryDirectory, setAuthorizationProvider, setConfiguration, setFetcher, setHttpServletRequest, setHttpServletResponse, setServletConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

API_NAME

protected static final java.lang.String API_NAME
See Also:
Constant Field Values

PINGBACK_GENERIC_FAULT_CODE

protected static final int PINGBACK_GENERIC_FAULT_CODE
See Also:
Constant Field Values

PINGBACK_SOURCE_URI_NON_EXISTENT_CODE

protected static final int PINGBACK_SOURCE_URI_NON_EXISTENT_CODE
See Also:
Constant Field Values

PINGBACK_NO_LINK_TO_TARGET_URI_CODE

protected static final int PINGBACK_NO_LINK_TO_TARGET_URI_CODE
See Also:
Constant Field Values

PINGBACK_TARGET_URI_NON_EXISTENT_CODE

protected static final int PINGBACK_TARGET_URI_NON_EXISTENT_CODE
See Also:
Constant Field Values

PINGBACK_TARGET_URI_NOT_ENABLED_CODE

protected static final int PINGBACK_TARGET_URI_NOT_ENABLED_CODE
See Also:
Constant Field Values

PINGBACK_ALREADY_REGISTERED_CODE

protected static final int PINGBACK_ALREADY_REGISTERED_CODE
See Also:
Constant Field Values

PINGBACK_ACCESS_DENIED_CODE

protected static final int PINGBACK_ACCESS_DENIED_CODE
See Also:
Constant Field Values

PINGBACK_UPSTREAM_SERVER_ERROR_CODE

protected static final int PINGBACK_UPSTREAM_SERVER_ERROR_CODE
See Also:
Constant Field Values
Constructor Detail

PingbackHandler

public PingbackHandler()
Construct a new Pingback handler

Method Detail

setBlogUser

public void setBlogUser(BlogUser blogUser)
                 throws BlojsomException
Attach a blog instance to the API Handler so that it can interact with the blog

Specified by:
setBlogUser in class AbstractBlojsomAPIHandler
Parameters:
blogUser - an instance of BlogUser
Throws:
BlojsomException - If there is an error setting the blog user instance or properties for the handler
See Also:
BlogUser

getName

public java.lang.String getName()
Gets the name of API Handler. Used to bind to XML-RPC

Specified by:
getName in class AbstractBlojsomAPIHandler
Returns:
The API Name (ie: pingback)

getTitleFromSource

protected java.lang.String getTitleFromSource(java.lang.String source)
Try to find the <title></title> tags from the source text

Parameters:
source - Source URI text
Returns:
Title of text or null if title tags are not found

getExcerptFromSource

protected java.lang.String getExcerptFromSource(java.lang.String source,
                                                java.lang.String targetURI)
Try to extract an excerpt from the source text. Currently looks ahead 200 and ahead 200 characters from the location of the targetURI within the source.

Parameters:
source - Source URI text
targetURI - Target URI from which to start the excerpt
Returns:
Excerpt of text or null if we cannot find the targetURI

ping

public java.lang.String ping(java.lang.String sourceURI,
                             java.lang.String targetURI)
                      throws org.apache.xmlrpc.XmlRpcException
Notifies the server that a link has been added to sourceURI, pointing to targetURI.

Parameters:
sourceURI - The absolute URI of the post on the source page containing the link to the target site.
targetURI - The absolute URI of the target of the link, as given on the source page.
Returns:
Throws:
org.apache.xmlrpc.XmlRpcException

addPingback

protected java.lang.Integer addPingback(java.util.Map context,
                                        java.lang.String category,
                                        java.lang.String permalink,
                                        java.lang.String title,
                                        java.lang.String excerpt,
                                        java.lang.String url,
                                        java.lang.String blogName,
                                        java.lang.String[] blogFileExtensions,
                                        java.lang.String blogHome,
                                        java.lang.String blogPingbackDirectory,
                                        java.lang.String blogFileEncoding,
                                        java.util.Map pingbackMetaData,
                                        Pingback pingback,
                                        java.lang.String id)
                                 throws org.apache.xmlrpc.XmlRpcException
Add a pingback for a given blog ID

Parameters:
context - Context
category - Category
permalink - Permalink
title - Pingback title
excerpt - Pingback excerpt
url - Pingback URL
blogName - Pingback blog name
blogFileExtensions - File extensions
blogHome - Blog home
blogPingbackDirectory - Pingbacks directory
blogFileEncoding - Blog file encoding
pingbackMetaData - Pingback meta-data
pingback - Pingback
id - ID to use for pingback
Returns:
0 if the pingback was registered, otherwise a fault code is returned
Throws:
org.apache.xmlrpc.XmlRpcException

getBlogCategory

protected BlogCategory getBlogCategory(BlogUser user,
                                       javax.servlet.http.HttpServletRequest httpServletRequest)
Determine the blog category based on the request

Parameters:
httpServletRequest - Request
Returns:
BlogCategory of the requested category