del.icio.us
Class Delicious

java.lang.Object
  extended bydel.icio.us.Delicious

public class Delicious
extends java.lang.Object

Delicious is a class for accessing the del.icio.us API.

Since:
1.0
Version:
$Id: Delicious.java,v 1.24 2007/01/19 00:14:43 czarneckid Exp $
Author:
David Czarnecki

Constructor Summary
Delicious(java.lang.String username, java.lang.String password)
          Create an object to interact with del.icio.us.
Delicious(java.lang.String username, java.lang.String password, java.lang.String apiEndpoint)
          Create an object to interact with del.icio.us
Delicious(java.lang.String username, java.lang.String password, java.lang.String apiEndpoint, java.lang.String proxyHost, int proxyPort)
          Create an object to interact with del.icio.us
 
Method Summary
 boolean addBundle(java.lang.String bundleName, java.lang.String tags)
          Add a new tag bundle.
 boolean addPost(java.lang.String url, java.lang.String description)
          Make a post to del.icio.us
 boolean addPost(java.lang.String url, java.lang.String description, java.lang.String extended, java.lang.String tags, java.util.Date date)
          Make a post to del.icio.us
 boolean addPost(java.lang.String url, java.lang.String description, java.lang.String extended, java.lang.String tags, java.util.Date date, boolean replace, boolean shared)
          Make a post to del.icio.us.
protected  void checkNotAuthorized(int result)
          Check to see if the user is not authorized.
protected  void clearResultMetaInformation()
          Clear the result meta information by setting the object to null.
 boolean deleteBundle(java.lang.String bundleName)
          Delete a bundle of the given name
 boolean deletePost(java.lang.String url)
          Deletes a post
 java.util.List getAllPosts()
          Return a list of all Post objects.
 java.util.List getAllPosts(java.lang.String filterTag)
          Return a list of all Post objects.
 java.util.List getBundles()
          Return a list of Bundle objects
 java.util.List getDatesWithInboxEntries()
          Return a list of DeliciousDate objects containing inbox entries
 java.util.List getDatesWithPost()
          Return list of DeliciousDate objects
 java.util.List getDatesWithPost(java.lang.String tag)
          Return list of DeliciousDate objects
 int getHttpResult()
          Return the HTTP status code of the last operation
 java.util.List getInboxEntries(java.util.Date date)
          Return a list of Post items in your inbox
 java.util.Date getLastUpdate()
          Get the time of the last update
 java.util.List getPostForURL(java.lang.String url)
          Return a list of Post objects for a given URL
 java.util.List getPosts()
          Return a list of Post objects
 java.util.List getPosts(java.lang.String filterTag, java.util.Date date, java.lang.String url)
          Return a list of Post objects
 java.util.List getPostsForDate(java.lang.String filterTag, java.util.Date date)
          Return a list of Post objects
 java.util.List getPostsForTag(java.lang.String tag)
          Return a list of Post objects for a given tag
 java.util.List getPostsForTags(java.lang.String[] tags)
          Return a list of Post objects for a given set of tags.
 java.util.List getRecentPosts()
          Return a list of recent Post objects; uses default number of items to retrieve DeliciousConstants.DEFAULT_POST_COUNT
 java.util.List getRecentPosts(java.lang.String filterTag)
          Return a list of Post objects
 java.util.List getRecentPosts(java.lang.String filterTag, int count)
          Return a list of Post objects
 java.lang.Object getResultMetaInformation()
          Retrieve an object containing meta information about the last call.
 java.util.List getSubscriptions()
          Return a list of Subscription objects
 java.util.List getTags()
          Return a list of Tag objects
 boolean renameTag(java.lang.String oldTag, java.lang.String newTag)
          Renames a tag
 void setApiEndpoint(java.lang.String apiEndpoint)
          Set a new API endpoint which may be different from the default DeliciousConstants.API_ENDPOINT
 void setProxyAuthenticationConfiguration(java.lang.String proxyUsername, java.lang.String proxyPassword)
          Sets proxy authentication information.
 void setProxyConfiguration(java.lang.String proxyHost, int proxyPort)
          Sets proxy configuration information.
 boolean subs(java.lang.String user, java.lang.String tag, boolean unsubscribe)
          Add or remove a subscription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Delicious

public Delicious(java.lang.String username,
                 java.lang.String password)
Create an object to interact with del.icio.us. API endpoint defaults to: http://del.icio.us/api/

Parameters:
username - del.icio.us username
password - del.icio.us password

Delicious

public Delicious(java.lang.String username,
                 java.lang.String password,
                 java.lang.String apiEndpoint)
Create an object to interact with del.icio.us

Parameters:
username - del.icio.us username
password - del.icio.us password
apiEndpoint - del.icio.us API endpoint

Delicious

public Delicious(java.lang.String username,
                 java.lang.String password,
                 java.lang.String apiEndpoint,
                 java.lang.String proxyHost,
                 int proxyPort)
Create an object to interact with del.icio.us

Parameters:
username - del.icio.us username
password - del.icio.us password
apiEndpoint - del.icio.us API endpoint
proxyHost - Proxy host
proxyPort - Proxy port
Since:
1.1
Method Detail

setProxyConfiguration

public void setProxyConfiguration(java.lang.String proxyHost,
                                  int proxyPort)
Sets proxy configuration information. This method must be called before any calls to the API if you require proxy configuration.

Parameters:
proxyHost - Proxy host
proxyPort - Proxy port
Since:
1.1

setProxyAuthenticationConfiguration

public void setProxyAuthenticationConfiguration(java.lang.String proxyUsername,
                                                java.lang.String proxyPassword)
Sets proxy authentication information. This method must be called before any calls to the API if you require proxy authentication.

Parameters:
proxyUsername - Username to access proxy
proxyPassword - Password to access proxy
Since:
1.8

setApiEndpoint

public void setApiEndpoint(java.lang.String apiEndpoint)
Set a new API endpoint which may be different from the default DeliciousConstants.API_ENDPOINT

Parameters:
apiEndpoint - New API endpoint
Since:
2.0

getHttpResult

public int getHttpResult()
Return the HTTP status code of the last operation

Returns:
HTTP status code

getDatesWithPost

public java.util.List getDatesWithPost(java.lang.String tag)
Return list of DeliciousDate objects

Parameters:
tag - Filter by this tag (optional)
Returns:
List of DeliciousDate objects

getDatesWithPost

public java.util.List getDatesWithPost()
Return list of DeliciousDate objects

Returns:
List of DeliciousDate objects
Since:
2.0

getTags

public java.util.List getTags()
Return a list of Tag objects

Returns:
List of Tag objects

getPosts

public java.util.List getPosts(java.lang.String filterTag,
                               java.util.Date date,
                               java.lang.String url)
Return a list of Post objects

Parameters:
filterTag - filter by this tag (optional)
date - Filter by this date
url - URL of post to retrieve (if present, only retrieves a single Post object
Returns:
List of Post objects
Since:
1.8

getPostsForDate

public java.util.List getPostsForDate(java.lang.String filterTag,
                                      java.util.Date date)
Return a list of Post objects

Parameters:
filterTag - filter by this tag (optional)
date - Filter by this date
Returns:
List of Post objects

getPosts

public java.util.List getPosts()
Return a list of Post objects

Returns:
List of Post objects
Since:
2.0

getPostForURL

public java.util.List getPostForURL(java.lang.String url)
Return a list of Post objects for a given URL

Parameters:
url - Filter by this URL
Returns:
List of Post objects for a given URL
Since:
1.8

getPostsForTag

public java.util.List getPostsForTag(java.lang.String tag)
Return a list of Post objects for a given tag

Parameters:
tag - Filter by this tag
Returns:
List of Post objects for a given tag
Since:
1.8

getPostsForTags

public java.util.List getPostsForTags(java.lang.String[] tags)
Return a list of Post objects for a given set of tags. Calls getPostsForTag(String) for each tag.

Parameters:
tags - Filter by these tags
Returns:
List of Post objects for the given set of tags
Since:
1.8

getRecentPosts

public java.util.List getRecentPosts(java.lang.String filterTag,
                                     int count)
Return a list of Post objects

Parameters:
filterTag - filter by this tag (optional)
count - Must be > 0 and < 100
Returns:
List of Post objects

getRecentPosts

public java.util.List getRecentPosts(java.lang.String filterTag)
Return a list of Post objects

Parameters:
filterTag - filter by this tag (optional)
Returns:
List of Post objects

getRecentPosts

public java.util.List getRecentPosts()
Return a list of recent Post objects; uses default number of items to retrieve DeliciousConstants.DEFAULT_POST_COUNT

Returns:
List of Post objects
Since:
2.0

getAllPosts

public java.util.List getAllPosts(java.lang.String filterTag)
Return a list of all Post objects. This method populates the result meta information field with a Date object containing the last update time.

Parameters:
filterTag - Filter by this tag
Returns:
List of all Post objects

getAllPosts

public java.util.List getAllPosts()
Return a list of all Post objects. This method populates the result meta information field with a Date object containing the last update time.

Returns:
List of all Post objects

addPost

public boolean addPost(java.lang.String url,
                       java.lang.String description,
                       java.lang.String extended,
                       java.lang.String tags,
                       java.util.Date date,
                       boolean replace,
                       boolean shared)
Make a post to del.icio.us. If either the url or description parameters are null or blank, this method immediately returns false.

Parameters:
url - URL for post
description - Description for post
extended - Extended for post
tags - Space-delimited list of tags
date - Date for post
replace - true if call should replace post
shared - Make the item private
Returns:
true if posted, false otherwise
Since:
1.8

addPost

public boolean addPost(java.lang.String url,
                       java.lang.String description,
                       java.lang.String extended,
                       java.lang.String tags,
                       java.util.Date date)
Make a post to del.icio.us

Parameters:
url - URL for post
description - Description for post
extended - Extended for post
tags - Space-delimited list of tags
date - Date for post
Returns:
true if posted, false otherwise

addPost

public boolean addPost(java.lang.String url,
                       java.lang.String description)
Make a post to del.icio.us

Parameters:
url - URL for post
description - Description for post
Returns:
true if posted, false otherwise
Since:
2.0

deletePost

public boolean deletePost(java.lang.String url)
Deletes a post

Parameters:
url - URL for post
Returns:
true if post deleted, false otherwise

renameTag

public boolean renameTag(java.lang.String oldTag,
                         java.lang.String newTag)
Renames a tag

Parameters:
oldTag - Old tag
newTag - New tag
Returns:
true if tag renamed, false otherwise

getInboxEntries

public java.util.List getInboxEntries(java.util.Date date)
Return a list of Post items in your inbox

Parameters:
date - Filter by this date
Returns:
List of Post items in your inbox

getDatesWithInboxEntries

public java.util.List getDatesWithInboxEntries()
Return a list of DeliciousDate objects containing inbox entries

Returns:
List of DeliciousDate objects containing inbox entries

getSubscriptions

public java.util.List getSubscriptions()
Return a list of Subscription objects

Returns:
List of Subscription objects

getBundles

public java.util.List getBundles()
Return a list of Bundle objects

Returns:
List of Bundle objects
Since:
1.9

addBundle

public boolean addBundle(java.lang.String bundleName,
                         java.lang.String tags)
Add a new tag bundle. If either the bundle name or tags is blank or null, false is returned immediately

Parameters:
bundleName - Bundle name
tags - Space-separated list of tags
Returns:
true if the bundle was created, false otherwise
Since:
1.9

deleteBundle

public boolean deleteBundle(java.lang.String bundleName)
Delete a bundle of the given name

Parameters:
bundleName - Bundle to delete
Returns:
true if the bundle was deleted, false otherwise
Since:
1.9

subs

public boolean subs(java.lang.String user,
                    java.lang.String tag,
                    boolean unsubscribe)
Add or remove a subscription

Parameters:
user - Username
tag - Optional, set to null for all posts
unsubscribe - If you want to unsubscribe
Returns:
true if add/remove subscription successful, false otherwise

getLastUpdate

public java.util.Date getLastUpdate()
Get the time of the last update

Returns:
Date object of last update time or null if there was an error in the call
Since:
1.3

checkNotAuthorized

protected void checkNotAuthorized(int result)
Check to see if the user is not authorized. If result is 401 (NOT_AUTHORIZED) a DeliciousNotAuthorizedException is thrown

Parameters:
result - Result code from executing HTTP method
Since:
1.4

clearResultMetaInformation

protected void clearResultMetaInformation()
Clear the result meta information by setting the object to null.

Since:
1.3

getResultMetaInformation

public java.lang.Object getResultMetaInformation()
Retrieve an object containing meta information about the last call. Only certain methods actually populate the result meta information such as the getAllPosts() method.

Returns:
Object containing meta information about the last call
Since:
1.3