org.opencms.validation
Class CmsXmlDocumentLinkValidator

java.lang.Object
  extended byorg.opencms.validation.CmsXmlDocumentLinkValidator

public class CmsXmlDocumentLinkValidator
extends java.lang.Object

Validates HTML links in the (body) content of Cms resources in the OpenCms VFS. HTML links are considered as href attribs in anchor tags and src attribs in image tags.

Validating links means to answer the question, whether we would have broken links in the online project if a file or a list of files would get published. External links to targets outside the OpenCms VFS don't get validated.

Objects using the CmsHtmlLinkValidator are responsible to handle detected broken links.

Since:
6.0.0
Version:
$Revision: 1.9 $
Author:
Thomas Weckert

Field Summary
protected  CmsDriverManager m_driverManager
          The driver manager.
 
Constructor Summary
CmsXmlDocumentLinkValidator(CmsDriverManager driverManager)
          Default constructor.
 
Method Summary
protected  void finalize()
           
protected  java.util.List validateLinks(java.util.List links, java.util.Map offlineFileLookup)
          Validates the URIs in the specified link list.
 java.util.Map validateResources(CmsObject cms, java.util.List offlineResources)
          Validates HTML links (hrefs and img tags) in the (body) content of the specified list of Cms resources.
 java.util.Map validateResources(CmsObject cms, java.util.List offlineResources, I_CmsReport report)
          Validates HTML links (hrefs and img tags) in the (body) content of the specified list of Cms resources.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_driverManager

protected CmsDriverManager m_driverManager
The driver manager.

Constructor Detail

CmsXmlDocumentLinkValidator

public CmsXmlDocumentLinkValidator(CmsDriverManager driverManager)
Default constructor.

Parameters:
driverManager - The Cms driver manager
Method Detail

validateResources

public java.util.Map validateResources(CmsObject cms,
                                       java.util.List offlineResources)
Validates HTML links (hrefs and img tags) in the (body) content of the specified list of Cms resources.

The result is printed to a shell report.

Parameters:
cms - the current user's Cms object the current request context
offlineResources - a list of offline Cms resources
Returns:
a Map with Lists of invalid hrefs keyed by resource names

validateResources

public java.util.Map validateResources(CmsObject cms,
                                       java.util.List offlineResources,
                                       I_CmsReport report)
Validates HTML links (hrefs and img tags) in the (body) content of the specified list of Cms resources.

The result is printed to the given report.

Parameters:
cms - the current user's Cms object
offlineResources - a list of offline Cms resources
report - an instance of I_CmsReport to print messages
Returns:
a map with lists of invalid links keyed by resource names

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable
See Also:
Object.finalize()

validateLinks

protected java.util.List validateLinks(java.util.List links,
                                       java.util.Map offlineFileLookup)
Validates the URIs in the specified link list.

Parameters:
links - a list of URIs inside a CmsResource
offlineFileLookup - a map for faster lookup with all (offline) resources that get actually published keyed by their resource names (including the site root)
Returns:
a list with the broken links in the specified link list, or an empty list if no broken links were found