net.sourceforge.cvsgrab
Class CvsWebInterface

java.lang.Object
  extended by net.sourceforge.cvsgrab.CvsWebInterface
Direct Known Subclasses:
ViewCvsInterface

public abstract class CvsWebInterface
extends Object

Abstracts the web interface available for a CVS repository. This allows us to support different web interfaces such as viewcvs, cvsweb, sourcecast and others.

Version:
$Revision: 1.18 $ $Date: 2005/06/25 19:51:33 $
Author:
Ludovic Claude
Created:
on 6 oct. 2003

Field Summary
static String DETECTED_WEB_INTERFACE
           
 
Constructor Summary
CvsWebInterface(CVSGrab grabber)
          Constructor for CvsWebInterface
 
Method Summary
abstract  void detect(Document htmlPage)
          Detects if the web page is compatible with this web interface, and if yes initialize it.
static CvsWebInterface findInterface(CVSGrab grabber)
          Find the cvs web interface that could have generated this html page
 String getAltBaseUrl()
           
abstract  String getBaseUrl()
           
static String[] getBaseUrls(CVSGrab grabber)
           
abstract  String[] getDirectories(Document doc)
           
abstract  String getDirectoryUrl(String rootUrl, String directoryName)
           
abstract  String getDownloadUrl(RemoteFile file)
           
abstract  RemoteFile[] getFiles(Document doc)
           
 CVSGrab getGrabber()
           
abstract  String getId()
           
static CvsWebInterface getInterface(CVSGrab grabber, String interfaceId)
          Explicitely select a web interface capable of handle the web pages.
static String[] getInterfaceIds(CVSGrab grabber)
           
 String getQueryParams()
           
abstract  String getType()
           
 String getVersionTag()
           
static Properties getWebProperties(CVSGrab grabber, String rootUrl)
          Guess the connection properties by parsing the full url used when connecting to the web repository
abstract  Properties guessWebProperties(String fullUrl)
          Guess the web properties frmo the full url
abstract  void init()
          Initialize the web interface
 boolean presetMatch(String rootUrl, String packagePath)
          Returns true if there is a rule that matches this web interface to the given url
static void registerDocument(String url, Document doc)
          For test purposes
 void setQueryParams(String params)
          Sets the additional query parameters
 void setVersionTag(String versionTag)
          Sets the version tag
 boolean validate(List errors)
          Validate that this web interface can be used on the remote repository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DETECTED_WEB_INTERFACE

public static final String DETECTED_WEB_INTERFACE
See Also:
Constant Field Values
Constructor Detail

CvsWebInterface

public CvsWebInterface(CVSGrab grabber)
Constructor for CvsWebInterface

Method Detail

getInterface

public static final CvsWebInterface getInterface(CVSGrab grabber,
                                                 String interfaceId)
                                          throws Exception
Explicitely select a web interface capable of handle the web pages.

Parameters:
grabber - The cvs grabber
interfaceId - The id of the interface
Returns:
the selected web interface, or null if the id is not recognized
Throws:
Exception - if initialisation of the web interface fails

getInterfaceIds

public static final String[] getInterfaceIds(CVSGrab grabber)
Returns:
an array containing the ids of the registered web interfaces

getBaseUrls

public static final String[] getBaseUrls(CVSGrab grabber)

findInterface

public static CvsWebInterface findInterface(CVSGrab grabber)
                                     throws Exception
Find the cvs web interface that could have generated this html page

Returns:
the cvs web interface that matches best this page
Throws:
Exception

getWebProperties

public static Properties getWebProperties(CVSGrab grabber,
                                          String rootUrl)
Guess the connection properties by parsing the full url used when connecting to the web repository

Parameters:
rootUrl - the rool url
Returns:
the properties compatible with the naming scheme of WebOptions, or an empty list of properties if nothing is found

registerDocument

public static void registerDocument(String url,
                                    Document doc)
For test purposes


getGrabber

public CVSGrab getGrabber()

presetMatch

public boolean presetMatch(String rootUrl,
                           String packagePath)
Returns true if there is a rule that matches this web interface to the given url

Parameters:
rootUrl - The root url
packagePath - The package path

validate

public boolean validate(List errors)
Validate that this web interface can be used on the remote repository

Parameters:
errors - A list of errors to fill if any error is found
Returns:
true if this interface can work on the remote repository

getVersionTag

public String getVersionTag()
Returns:
the version tag

setVersionTag

public void setVersionTag(String versionTag)
Sets the version tag

Parameters:
versionTag -

getQueryParams

public String getQueryParams()
Returns:
the queryParams.

setQueryParams

public void setQueryParams(String params)
Sets the additional query parameters

Parameters:
params -

init

public abstract void init()
                   throws Exception
Initialize the web interface

Throws:
Exception - if initialisation fails

detect

public abstract void detect(Document htmlPage)
                     throws MarkerNotFoundException,
                            InvalidVersionException
Detects if the web page is compatible with this web interface, and if yes initialize it.

Parameters:
htmlPage - The web page
Throws:
MarkerNotFoundException - if the version marker for the web interface was not found.
InvalidVersionException - if the version detected is incompatible with the version supported by this web interface.
IncompatibleInterfaceException - if the web page is not compatible with this type of web interface

getId

public abstract String getId()
Returns:
the id identifying the web interface, and used for initialisation

getType

public abstract String getType()
Returns:
the type of the web interface as detected from the actual website

getBaseUrl

public abstract String getBaseUrl()
Returns:
the base url to use when trying to auto-detect this type of web interface

getAltBaseUrl

public String getAltBaseUrl()
Returns:
an alternate base url to use when trying to auto-detect this type of web interface

getDirectoryUrl

public abstract String getDirectoryUrl(String rootUrl,
                                       String directoryName)
Parameters:
rootUrl -
directoryName -
Returns:
the url to use to access the contents of the repository

getFiles

public abstract RemoteFile[] getFiles(Document doc)
Parameters:
doc -
Returns:

getDirectories

public abstract String[] getDirectories(Document doc)
Parameters:
doc -
Returns:

getDownloadUrl

public abstract String getDownloadUrl(RemoteFile file)
Parameters:
file -
Returns:

guessWebProperties

public abstract Properties guessWebProperties(String fullUrl)
Guess the web properties frmo the full url

Parameters:
fullUrl - the full url
Returns:
a list of Properties guessed from the full url, or an empty property list if no match was possible


Copyright © 2002-2005 Ludovic Claude. All Rights Reserved.