org.opencms.relations
Class CmsRelationSystemValidator

java.lang.Object
  extended by org.opencms.relations.CmsRelationSystemValidator

public class CmsRelationSystemValidator
extends java.lang.Object

Validates relations of resources in the OpenCms VFS.

Relations are, for instance, href attribs in anchor tags and src attribs in image tags, as well as OpenCmsVfsFile values in Xml Content.

External links to targets outside the OpenCms VFS don't get validated.

Objects using this class are responsible to handle detected broken links.

Since:
6.3.0
Version:
$Revision: 1.1.2.4 $
Author:
Thomas Weckert, Michael Moossen

Field Summary
protected  CmsDriverManager m_driverManager
          The driver manager.
 
Constructor Summary
CmsRelationSystemValidator(CmsDriverManager driverManager)
          Default constructor.
 
Method Summary
protected  java.util.List validateLinks(CmsDbContext dbc, CmsResource resource, java.util.Map fileLookup, CmsProject project, I_CmsReport report)
          Validates the links for the specified resource.
 java.util.Map validateResources(CmsDbContext dbc, java.util.List resources, I_CmsReport report)
          Validates the relations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_driverManager

protected CmsDriverManager m_driverManager
The driver manager.

Constructor Detail

CmsRelationSystemValidator

public CmsRelationSystemValidator(CmsDriverManager driverManager)
Default constructor.

Parameters:
driverManager - The Cms driver manager
Method Detail

validateResources

public java.util.Map validateResources(CmsDbContext dbc,
                                       java.util.List resources,
                                       I_CmsReport report)
Validates the relations.

The result is printed to the given report.

If the resources list is null or empty, the whole current project will be validated.

If the resources list is not empty, Validating references 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.

Parameters:
dbc - the database context
resources - a list of offline resources, or null
report - a report to print messages
Returns:
a map with lists of invalid links (CmsRelation} objects) keyed by resource names

validateLinks

protected java.util.List validateLinks(CmsDbContext dbc,
                                       CmsResource resource,
                                       java.util.Map fileLookup,
                                       CmsProject project,
                                       I_CmsReport report)
Validates the links for the specified resource.

Parameters:
dbc - the database context
resource - the resource that will be validated
fileLookup - a map for faster lookup with all resources keyed by their rootpath
project - the project to validate
report - the report to write to
Returns:
a list with the broken links as CmsRelation objects for the specified resource, or an empty list if no broken links were found