com.ibm.rational.rpe.common.utils
Class URLDataProvider

java.lang.Object
  extended by com.ibm.rational.rpe.common.utils.URLDataProvider

public class URLDataProvider
extends java.lang.Object

Utility class for accessing remote resources.

Author:
Spurlos

Constructor Summary
URLDataProvider()
          WARNING: for use during RRDG Document Generation do NOT create new instances of this object.
 
Method Summary
 java.lang.String cacheResource(java.lang.String url, Credential credential)
          Returns the path to a cached copy of the resource.
 java.lang.String cacheResource(java.lang.String url, Credential credential, com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
          Returns the path to a cached copy of the resource.
 void cleanup()
          Deletes all cached data.
static java.io.InputStream doNone(java.lang.String url, com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
          Downloads the content from the specified URL in the given path with the provided connection arguments
static java.lang.String downloadFile(java.net.URL url)
           
static void downloadFile(java.net.URL url, java.lang.String localPath, com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
          Downloads the content from the specified URL in the given path with the provided connection arguments
 java.lang.String expandLibraryURL(java.lang.String url)
           
 com.ibm.rational.rpe.common.utils.IConnectionConfigurator getConnectionConfigurator()
           
 java.lang.String getLibraryResourceTitle(java.lang.String relativeResourceURL)
           
 boolean isCached(java.lang.String url)
          Returns true if the url is already cached locally
 java.io.InputStream openDataStream(java.lang.String url, Credential credential)
          Returns a stream to the desired resource with no caching.
 java.io.InputStream openDataStream(java.lang.String url, Credential credential, com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
          Returns a stream to the desired resource with no caching.
 void registerFile(java.lang.String file)
           
 void setConnectionConfigurator(com.ibm.rational.rpe.common.utils.IConnectionConfigurator connectionConfigurator)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLDataProvider

public URLDataProvider()
WARNING: for use during RRDG Document Generation do NOT create new instances of this object. Use the one from the engine to ensure you get one fully configured by the provider

Method Detail

setConnectionConfigurator

public void setConnectionConfigurator(com.ibm.rational.rpe.common.utils.IConnectionConfigurator connectionConfigurator)

getConnectionConfigurator

public com.ibm.rational.rpe.common.utils.IConnectionConfigurator getConnectionConfigurator()

isCached

public boolean isCached(java.lang.String url)
                 throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                        com.ibm.rational.rpe.common.utils.conn.ConnectionException
Returns true if the url is already cached locally

Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

cacheResource

public java.lang.String cacheResource(java.lang.String url,
                                      Credential credential,
                                      com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
                               throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                      com.ibm.rational.rpe.common.utils.conn.ConnectionException
Returns the path to a cached copy of the resource. If the resource was not cached it is cached before it is returned.

Parameters:
url - - cannot be empty
credential - - cannot be null
acceptHeader - - the accept header to use
Returns:
an open stream for the data
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

cacheResource

public java.lang.String cacheResource(java.lang.String url,
                                      Credential credential)
                               throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                      com.ibm.rational.rpe.common.utils.conn.ConnectionException
Returns the path to a cached copy of the resource. If the resource was not cached it is cached before it is returned.

Parameters:
url - - cannot be empty
credential - - cannot be null
Returns:
an open stream for the data
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

openDataStream

public java.io.InputStream openDataStream(java.lang.String url,
                                          Credential credential)
                                   throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                          com.ibm.rational.rpe.common.utils.conn.ConnectionException
Returns a stream to the desired resource with no caching.

Parameters:
url - - cannot be empty
credential - - cannot be null
Returns:
an open stream for the data
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

openDataStream

public java.io.InputStream openDataStream(java.lang.String url,
                                          Credential credential,
                                          com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
                                   throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                          com.ibm.rational.rpe.common.utils.conn.ConnectionException
Returns a stream to the desired resource with no caching.

Parameters:
url - - cannot be empty
credential - - cannot be null
acceptHeader - - the accept header to use
Returns:
an open stream for the data
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

doNone

public static java.io.InputStream doNone(java.lang.String url,
                                         com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
                                  throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                         com.ibm.rational.rpe.common.utils.conn.ConnectionException
Downloads the content from the specified URL in the given path with the provided connection arguments

Parameters:
url - - cannot be NULL
localPath - - cannot be NULL
connectionArgs - - cannot be NULL
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

cleanup

public void cleanup()
Deletes all cached data.


downloadFile

public static java.lang.String downloadFile(java.net.URL url)
                                     throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                            com.ibm.rational.rpe.common.utils.conn.ConnectionException
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

downloadFile

public static void downloadFile(java.net.URL url,
                                java.lang.String localPath,
                                com.ibm.rational.rpe.common.utils.ConnectionArguments connectionArgs)
                         throws com.ibm.rational.rpe.common.auth.AuthenticationException,
                                com.ibm.rational.rpe.common.utils.conn.ConnectionException
Downloads the content from the specified URL in the given path with the provided connection arguments

Parameters:
url - - cannot be NULL
localPath - - cannot be NULL
connectionArgs - - cannot be NULL
Throws:
com.ibm.rational.rpe.common.auth.AuthenticationException
com.ibm.rational.rpe.common.utils.conn.ConnectionException

registerFile

public void registerFile(java.lang.String file)

expandLibraryURL

public java.lang.String expandLibraryURL(java.lang.String url)

getLibraryResourceTitle

public java.lang.String getLibraryResourceTitle(java.lang.String relativeResourceURL)
                                         throws java.io.IOException,
                                                com.ibm.rational.rpe.common.auth.AuthenticationException
Throws:
java.io.IOException
com.ibm.rational.rpe.common.auth.AuthenticationException