org.codehaus.mojo.delicious
Class DeliciousService

java.lang.Object
  extended by org.codehaus.mojo.delicious.DeliciousService

public class DeliciousService
extends java.lang.Object

A high level service access class for Delicious bookmarks.

Author:
ashley

Constructor Summary
DeliciousService()
          Creates a service that can connect to the REST api.
DeliciousService(DeliciousConnection connection)
          Plugin an alternative connection - probably for testing.
 
Method Summary
 void addBookmark(Bookmark bookmark, java.lang.Boolean replace)
          Adds the given bookmark to the delicious service.
 void addBookmarks(BookmarkGroup group, java.lang.Boolean replace)
          Adds the given group of bookmarks.
 void addBookmarks(java.util.List bookmarks, java.lang.Boolean replace)
          Adds the given list of bookmars to the delicious service.
 void addBookmarks(java.io.Reader links, java.lang.Boolean replace)
          Adds the links found at the given reader to the delicious service.
 void addBookmarks(java.lang.String linksPage, java.lang.Boolean replace)
          Adds the links found at the given path, that can be a local file or net URL.
 void addPost(java.lang.String url, java.lang.String description, java.lang.String tags, java.lang.String extended, java.lang.Boolean replace)
          Adds the post with the given information.
 void deletePost(java.lang.String url)
          Deletes the post at the given url.
 void doService(java.lang.String category, java.lang.String command, java.util.HashMap formFields)
          Invokes the delicous service defined by the supplied url and query.
 void fetchAllPosts(java.lang.String tags)
          Fetches all posts.
 void fetchDates(java.lang.String tags)
          Fetches a list of dates with the number of posts at each date.
 void fetchPosts(java.lang.String tags, java.lang.String date, java.lang.String url)
          Fetches a list of posts with the given search criteria.
 void fetchRecentPosts(java.lang.String tags, java.lang.String count)
          Fetches a list of most recent posts, possibly filtered by tag, maxes out at 100.
 void fetchTags()
          Fetches the tags used by this account.
 void fetchUpdateTime()
          Gets the time of the last update.
 int getCode()
          The code of the most recent server communication.
 DeliciousListener getListener()
          Gets the currently set listener.
 boolean isServiceUnavailableException(java.lang.RuntimeException e)
          Returns true if the given exception represents the service unavailable exception.
 void renameTag(java.lang.String oldName, java.lang.String newName)
          Renames the given tag.
 void setListener(DeliciousListener listener)
          Currently sets the one and only listener.
 void setUser(java.lang.String userName, java.lang.String password)
          Sets the credential to be used for this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeliciousService

public DeliciousService(DeliciousConnection connection)
Plugin an alternative connection - probably for testing.


DeliciousService

public DeliciousService()
Creates a service that can connect to the REST api.

Method Detail

isServiceUnavailableException

public boolean isServiceUnavailableException(java.lang.RuntimeException e)
Returns true if the given exception represents the service unavailable exception.

Parameters:
e -
Returns:

getListener

public DeliciousListener getListener()
Gets the currently set listener.

Returns:

setListener

public void setListener(DeliciousListener listener)
Currently sets the one and only listener.

Parameters:
listener -

getCode

public int getCode()
The code of the most recent server communication.

Returns:

addBookmarks

public void addBookmarks(java.io.Reader links,
                         java.lang.Boolean replace)
                  throws java.io.IOException,
                         java.lang.InterruptedException
Adds the links found at the given reader to the delicious service. The reader is assumed to be for a valid xml file containing anchor tags.

Parameters:
links -
replace -
Throws:
java.io.IOException
java.lang.InterruptedException

addBookmarks

public void addBookmarks(BookmarkGroup group,
                         java.lang.Boolean replace)
                  throws java.io.IOException,
                         java.lang.InterruptedException
Adds the given group of bookmarks.

Parameters:
group -
replace -
Throws:
java.io.IOException
java.lang.InterruptedException

addBookmarks

public void addBookmarks(java.util.List bookmarks,
                         java.lang.Boolean replace)
                  throws java.io.IOException,
                         java.lang.InterruptedException
Adds the given list of bookmars to the delicious service.

Parameters:
bookmarks -
replace -
Throws:
java.lang.InterruptedException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
java.lang.InterruptedException

addBookmark

public void addBookmark(Bookmark bookmark,
                        java.lang.Boolean replace)
                 throws java.io.IOException,
                        java.lang.InterruptedException
Adds the given bookmark to the delicious service.

Parameters:
bookmark -
replace - TODO
Throws:
java.io.IOException
java.lang.InterruptedException

addBookmarks

public void addBookmarks(java.lang.String linksPage,
                         java.lang.Boolean replace)
                  throws java.io.IOException,
                         java.lang.InterruptedException
Adds the links found at the given path, that can be a local file or net URL. Convenience method.

Parameters:
replace -
links -
Throws:
java.io.IOException
java.lang.InterruptedException

setUser

public void setUser(java.lang.String userName,
                    java.lang.String password)
Sets the credential to be used for this service.

Parameters:
userName -
password -

fetchDates

public void fetchDates(java.lang.String tags)
                throws java.io.IOException,
                       java.lang.InterruptedException
Fetches a list of dates with the number of posts at each date.

Parameters:
tags -
Throws:
java.io.IOException
java.lang.InterruptedException

fetchPosts

public void fetchPosts(java.lang.String tags,
                       java.lang.String date,
                       java.lang.String url)
                throws java.io.IOException,
                       java.lang.InterruptedException
Fetches a list of posts with the given search criteria. Either specify a tags/date combination, just a date or just a url.

Parameters:
tags -
Throws:
java.io.IOException
java.lang.InterruptedException

fetchRecentPosts

public void fetchRecentPosts(java.lang.String tags,
                             java.lang.String count)
                      throws java.io.IOException,
                             java.lang.InterruptedException
Fetches a list of most recent posts, possibly filtered by tag, maxes out at 100.

Throws:
java.io.IOException
java.lang.InterruptedException

fetchAllPosts

public void fetchAllPosts(java.lang.String tags)
                   throws java.io.IOException,
                          java.lang.InterruptedException
Fetches all posts. use sparingly. call update function first to see if you need to fetch this at all.

Throws:
java.io.IOException
java.lang.InterruptedException

fetchUpdateTime

public void fetchUpdateTime()
                     throws java.io.IOException,
                            java.lang.InterruptedException
Gets the time of the last update.

Throws:
java.io.IOException
java.lang.InterruptedException

addPost

public void addPost(java.lang.String url,
                    java.lang.String description,
                    java.lang.String tags,
                    java.lang.String extended,
                    java.lang.Boolean replace)
             throws java.io.IOException,
                    java.lang.InterruptedException
Adds the post with the given information.

Parameters:
url -
description -
tags -
extended -
replace -
Throws:
java.io.IOException
java.lang.InterruptedException

deletePost

public void deletePost(java.lang.String url)
                throws java.io.IOException,
                       java.lang.InterruptedException
Deletes the post at the given url.

Parameters:
url -
Throws:
java.io.IOException
java.lang.InterruptedException

fetchTags

public void fetchTags()
               throws java.io.IOException,
                      java.lang.InterruptedException
Fetches the tags used by this account.

Throws:
java.io.IOException
java.lang.InterruptedException

renameTag

public void renameTag(java.lang.String oldName,
                      java.lang.String newName)
               throws java.io.IOException,
                      java.lang.InterruptedException
Renames the given tag.

Parameters:
url -
Throws:
java.io.IOException
java.lang.InterruptedException

doService

public void doService(java.lang.String category,
                      java.lang.String command,
                      java.util.HashMap formFields)
               throws java.io.IOException,
                      java.lang.InterruptedException
Invokes the delicous service defined by the supplied url and query. The username and password are supplied for http-auth basic authorisation. According to the guidelines at http://del.icio.us/doc/api this method: For an ordinairy internal server error this method will try up to a maximum number of times before bailing out.

Parameters:
category - TODO
command -
formFields -
Throws:
java.io.IOException
java.lang.InterruptedException


Copyright © 2005-2010. All Rights Reserved.