org.blojsom.extension.xmlrpc.handlers
Class MetaWeblogAPIHandler

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

public class MetaWeblogAPIHandler
extends AbstractBlojsomAPIHandler

Blojsom XML-RPC Handler for the MetaWeblog API

MetaWeblog API pec can be found at http://www.xmlrpc.com/metaWeblogApi

Version:
$Id: MetaWeblogAPIHandler.java,v 1.34 2006/01/25 02:55:53 czarneckid Exp $
Author:
Mark Lussier

Field Summary
static java.lang.String API_PREFIX
           
 
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
MetaWeblogAPIHandler()
          Default constructor
 
Method Summary
 boolean deletePost(java.lang.String appkey, java.lang.String postid, java.lang.String userid, java.lang.String password, boolean publish)
          Delete a Post
 boolean editPost(java.lang.String postid, java.lang.String userid, java.lang.String password, java.util.Hashtable struct, boolean publish)
          Edits a given post.
 java.lang.Object getCategories(java.lang.String blogid, java.lang.String userid, java.lang.String password)
          Authenticates a user and returns the categories available in the blojsom
 java.lang.String getName()
          Gets the name of API Handler.
 java.lang.Object getPost(java.lang.String postid, java.lang.String userid, java.lang.String password)
          Retrieves a given post from the blog
 java.lang.Object getRecentPosts(java.lang.String blogid, java.lang.String userid, java.lang.String password, int numberOfPosts)
          Retrieves a set of recent posts to the blog
 java.lang.String getTemplate(java.lang.String appkey, java.lang.String blogid, java.lang.String userid, java.lang.String password, java.lang.String templateType)
          Returns the main or archive index template of a given blog (NOT IMPLEMENTED)
 java.lang.Object getUsersBlogs(java.lang.String appkey, java.lang.String userid, java.lang.String password)
          Returns information on all the blogs a given user is a member of
 java.lang.Object newMediaObject(java.lang.String blogid, java.lang.String userid, java.lang.String password, java.util.Hashtable struct)
          Uploads an object to the blog to a specified directory
 java.lang.String newPost(java.lang.String blogid, java.lang.String userid, java.lang.String password, java.util.Hashtable struct, boolean publish)
          Makes a new post to a designated blog.
 void setBlogUser(BlogUser blogUser)
          Attach a Blog instance to the API Handler so that it can interact with the blog
 boolean setTemplate(java.lang.String appkey, java.lang.String blogid, java.lang.String userid, java.lang.String password, java.lang.String template, java.lang.String templateType)
          Edits the main or archive index template of a given blog (NOT IMPLEMENTED)
 
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_PREFIX

public static final java.lang.String API_PREFIX
See Also:
Constant Field Values
Constructor Detail

MetaWeblogAPIHandler

public MetaWeblogAPIHandler()
Default constructor

Method Detail

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: metaWeblog)

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 instance or properties for the handler
See Also:
BlogUser

getUsersBlogs

public java.lang.Object getUsersBlogs(java.lang.String appkey,
                                      java.lang.String userid,
                                      java.lang.String password)
                               throws java.lang.Exception
Returns information on all the blogs a given user is a member of

Parameters:
appkey - Unique identifier/passcode of the application sending the post
userid - Login for a Blogger user who has permission to post to the blog
password - Password for said username
Returns:
Blog category list
Throws:
org.apache.xmlrpc.XmlRpcException - If there are no categories or the user was not authenticated correctly
java.lang.Exception

getCategories

public java.lang.Object getCategories(java.lang.String blogid,
                                      java.lang.String userid,
                                      java.lang.String password)
                               throws java.lang.Exception
Authenticates a user and returns the categories available in the blojsom

Parameters:
blogid - Dummy Value for Blojsom
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
Returns:
Blog category list
Throws:
org.apache.xmlrpc.XmlRpcException - If there are no categories or the user was not authenticated correctly
java.lang.Exception

newPost

public java.lang.String newPost(java.lang.String blogid,
                                java.lang.String userid,
                                java.lang.String password,
                                java.util.Hashtable struct,
                                boolean publish)
                         throws java.lang.Exception
Makes a new post to a designated blog. Optionally, will publish the blog after making the post

Parameters:
blogid - Unique identifier of the blog the post will be added to
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
struct - Contents of the post
publish - If true, the blog will be published immediately after the post is made
Returns:
Post ID of the added entry
Throws:
org.apache.xmlrpc.XmlRpcException - If the user was not authenticated correctly or if there was an I/O exception
java.lang.Exception

editPost

public boolean editPost(java.lang.String postid,
                        java.lang.String userid,
                        java.lang.String password,
                        java.util.Hashtable struct,
                        boolean publish)
                 throws java.lang.Exception
Edits a given post. Optionally, will publish the blog after making the edit

Parameters:
postid - Unique identifier of the post to be changed
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
struct - Contents of the post
publish - If true, the blog will be published immediately after the post is made
Returns:
true if the entry was edited, false otherwise
Throws:
org.apache.xmlrpc.XmlRpcException - If the user was not authenticated correctly, if there was an I/O exception, or if the entry permalink ID is invalid
java.lang.Exception

getPost

public java.lang.Object getPost(java.lang.String postid,
                                java.lang.String userid,
                                java.lang.String password)
                         throws java.lang.Exception
Retrieves a given post from the blog

Parameters:
postid - Unique identifier of the post to be changed
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
Returns:
Structure containing the minimal attributes for the MetaWeblog API getPost() method: title, link, and description
Throws:
org.apache.xmlrpc.XmlRpcException - If the user was not authenticated correctly, if there was an I/O exception, or if the entry permalink ID is invalid
java.lang.Exception
Since:
blojsom 1.9.4

deletePost

public boolean deletePost(java.lang.String appkey,
                          java.lang.String postid,
                          java.lang.String userid,
                          java.lang.String password,
                          boolean publish)
                   throws java.lang.Exception
Delete a Post

Parameters:
appkey - Unique identifier/passcode of the application sending the post
postid - Unique identifier of the post to be changed
userid - Login for a Blogger user who has permission to post to the blog
password - Password for said username
publish - Ignored
Returns:
true if the entry was delete, false otherwise
Throws:
org.apache.xmlrpc.XmlRpcException
java.lang.Exception

getRecentPosts

public java.lang.Object getRecentPosts(java.lang.String blogid,
                                       java.lang.String userid,
                                       java.lang.String password,
                                       int numberOfPosts)
                                throws java.lang.Exception
Retrieves a set of recent posts to the blog

Parameters:
blogid - Unique identifier of the blog the post will be added to
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
numberOfPosts - Number of posts to be retrieved from the blog
Returns:
Array of structures containing the minimal attributes for the MetaWeblog API getPost() method: title, link, and description
Throws:
java.lang.Exception - If the user was not authenticated correctly
Since:
blojsom 1.9.5

newMediaObject

public java.lang.Object newMediaObject(java.lang.String blogid,
                                       java.lang.String userid,
                                       java.lang.String password,
                                       java.util.Hashtable struct)
                                throws java.lang.Exception
Uploads an object to the blog to a specified directory

Parameters:
blogid - Unique identifier of the blog the post will be added to
userid - Login for a MetaWeblog user who has permission to post to the blog
password - Password for said username
struct - Upload structure defined by the MetaWeblog API
Returns:
Structure containing a link to the uploaded media object
Throws:
org.apache.xmlrpc.XmlRpcException - If the user was not authenticated correctly, if there was an I/O exception, or if the MIME type of the upload object is not accepted
java.lang.Exception
Since:
blojsom 1.9.4

setTemplate

public boolean setTemplate(java.lang.String appkey,
                           java.lang.String blogid,
                           java.lang.String userid,
                           java.lang.String password,
                           java.lang.String template,
                           java.lang.String templateType)
                    throws java.lang.Exception
Edits the main or archive index template of a given blog (NOT IMPLEMENTED)

Parameters:
appkey - Unique identifier/passcode of the application sending the post
blogid - Unique identifier of the blog the post will be added to
userid - Login for a Blogger user who has permission to post to the blog
password - Password for said username
template - The text for the new template (usually mostly HTML). Must contain opening and closing tags, since they're needed to publish
templateType - Determines which of the blog's templates will be returned. Currently, either "main" or "archiveIndex"
Returns:
Throws:
org.apache.xmlrpc.XmlRpcException
java.lang.Exception

getTemplate

public java.lang.String getTemplate(java.lang.String appkey,
                                    java.lang.String blogid,
                                    java.lang.String userid,
                                    java.lang.String password,
                                    java.lang.String templateType)
                             throws java.lang.Exception
Returns the main or archive index template of a given blog (NOT IMPLEMENTED)

Parameters:
appkey - Unique identifier/passcode of the application sending the post
blogid - Unique identifier of the blog the post will be added to
userid - Login for a Blogger user who has permission to post to the blog
password - Password for said username
templateType - Determines which of the blog's templates will be returned. Currently, either "main" or "archiveIndex"
Returns:
Throws:
org.apache.xmlrpc.XmlRpcException
java.lang.Exception