public class CmsRelationSystemValidator extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
protected CmsDriverManager |
m_driverManager
The driver manager.
|
Constructor and Description |
---|
CmsRelationSystemValidator(CmsDriverManager driverManager)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkLinkForDeletedLinkTarget(CmsRelation relation,
java.lang.String link,
java.util.Map<java.lang.String,CmsResource> fileLookup,
com.google.common.collect.HashMultimap<java.lang.String,java.lang.String> relationTargets)
Checks a link to a resource which has been deleted.
|
protected boolean |
checkLinkForNewOrChangedLinkSource(CmsDbContext dbc,
CmsResource resource,
CmsRelation relation,
java.lang.String link,
CmsProject project,
java.util.Map<java.lang.String,CmsResource> fileLookup)
Checks a link from a resource which has changed.
|
protected java.util.List<CmsRelation> |
validateLinks(CmsDbContext dbc,
CmsResource resource,
java.util.Map<java.lang.String,CmsResource> fileLookup,
CmsProject project,
I_CmsReport report)
Validates the links for the specified resource.
|
java.util.Map<java.lang.String,java.util.List<CmsRelation>> |
validateResources(CmsDbContext dbc,
CmsPublishList publishList,
I_CmsReport report)
Validates the relations against the online project.
|
protected CmsDriverManager m_driverManager
public CmsRelationSystemValidator(CmsDriverManager driverManager)
driverManager
- The Cms driver managerpublic java.util.Map<java.lang.String,java.util.List<CmsRelation>> validateResources(CmsDbContext dbc, CmsPublishList publishList, I_CmsReport report) throws java.lang.Exception
The result is printed to the given report.
Validating references means to answer the question, whether we would have broken links in the online project if the given publish list would get published.
dbc
- the database contextpublishList
- the publish list to validatereport
- a report to print messagesCmsRelation
}
objects)
keyed by root pathsjava.lang.Exception
- if something goes wrongprotected boolean checkLinkForDeletedLinkTarget(CmsRelation relation, java.lang.String link, java.util.Map<java.lang.String,CmsResource> fileLookup, com.google.common.collect.HashMultimap<java.lang.String,java.lang.String> relationTargets)
relation
- link
- the URI of the resource which has a link to the deleted resourcefileLookup
- a lookup table of files to be publishedrelationTargets
- protected boolean checkLinkForNewOrChangedLinkSource(CmsDbContext dbc, CmsResource resource, CmsRelation relation, java.lang.String link, CmsProject project, java.util.Map<java.lang.String,CmsResource> fileLookup)
dbc
- the current dbcresource
- the link sourcerelation
- the relationlink
- the link targetproject
- the current projectfileLookup
- a lookup table which contains the files which are going to be publishedprotected java.util.List<CmsRelation> validateLinks(CmsDbContext dbc, CmsResource resource, java.util.Map<java.lang.String,CmsResource> fileLookup, CmsProject project, I_CmsReport report)
dbc
- the database contextresource
- the resource that will be validatedfileLookup
- a map for faster lookup with all resources keyed by their rootpathproject
- the project to validatereport
- the report to write toCmsRelation
objects for the specified resource,
or an empty list if no broken links were found