Provided an API to get a merged list of broken links between 2 areas,

and what the baseline & latest versions were, as well as the number
of files and links checked in staging.  Made LinkValidationAction 
use the new apis, and annotated the source code so that it's obvious 
what should be done to use the base & latest snapshot version info  
(see "Gav TODO" within LinkValidationAction.java).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6219 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jon Cox
2007-07-12 03:01:38 +00:00
parent 212a9ce947
commit 32054c773c
5 changed files with 165 additions and 35 deletions

View File

@@ -1377,11 +1377,11 @@
</property>
<property name="mappedNames">
<list>
<value>getHrefManifestEntries</value>
<value>getHrefManifest</value>
<value>getBrokenHrefManifest</value>
<value>getHrefDifference</value>
<value>getHrefManifestBrokenByDelete</value>
<value>getHrefManifestBrokenByNewOrMod</value>
<value>getHrefConcordanceEntries</value>
<value>getHrefsDependentUponFile</value>
</list>
</property>

View File

@@ -66,7 +66,8 @@ public class HrefDifference
int src_version_;
String src_store_;
int dst_version_;
int dst_base_version_;
int dst_latest_version_;
String dst_store_;
String src_webapp_url_base_;
@@ -75,8 +76,9 @@ public class HrefDifference
HrefDifference(String href_attr,
int src_version,
String src_store,
int dst_version,
int dst_base_version,
String dst_store,
int dst_latest_version,
String src_webapp_url_base,
String dst_webapp_url_base)
{
@@ -85,9 +87,11 @@ public class HrefDifference
src_version_ = src_version;
src_store_ = src_store;
dst_version_ = dst_version;
dst_base_version_ = dst_base_version;
dst_store_ = dst_store;
dst_latest_version_ = dst_latest_version;
src_webapp_url_base_ = src_webapp_url_base;
dst_webapp_url_base_ = dst_webapp_url_base;
@@ -102,7 +106,8 @@ public class HrefDifference
public HrefManifest getHrefManifest() { return href_manifest_; }
public HrefStatusMap getHrefStatusMap() { return href_status_map_; }
public int getSrcVersion() { return src_version_;}
public int getDstVersion() { return dst_version_;}
public int getDstBaseVersion() { return dst_base_version_;}
public int getDstLatestVersion() { return dst_latest_version_;}
String getHrefAttr() { return href_attr_;}
String getSrcStore() { return src_store_;}

View File

@@ -38,13 +38,36 @@ import java.util.ArrayList;
*/
public class HrefManifest
{
protected List<HrefManifestEntry> manifest_entries_;
List<HrefManifestEntry> manifest_entries_;
int base_snapshot_version_;
int latest_snapshot_version_;
int base_file_count_;
int base_link_count_;
public HrefManifest()
{
manifest_entries_ = new ArrayList<HrefManifestEntry>();
}
public HrefManifest(List<HrefManifestEntry> entries,
int base_snapshot_version,
int latest_snapshot_version,
int base_file_count,
int base_link_count)
{
manifest_entries_ = entries;
base_snapshot_version_ = base_snapshot_version;
latest_snapshot_version_ = latest_snapshot_version;
base_file_count_ = base_file_count;
base_link_count_ = base_link_count;
}
public int getLatestSnapshotVersion() { return latest_snapshot_version_; }
public int getBaseSnapshotVersion() { return base_snapshot_version_; }
public int getBaseFileCount() { return base_file_count_;}
public int getBaseLinkCount() { return base_link_count_;}
public List<HrefManifestEntry> getManifestEntries() { return manifest_entries_;}
synchronized void add( HrefManifestEntry entry )

View File

@@ -157,24 +157,114 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
webappPath, destWebappPath, monitor);
// get the broken files created due to deletions and new/modified files
HrefManifest brokenByDelete = this.linkValidationService.getHrefManifestBrokenByDelete(hdiff);
HrefManifest brokenByNewOrMod = this.linkValidationService.getHrefManifestBrokenByNewOrMod(hdiff);
// Gav TODO:
// Instead of calling
// getHrefManifestBrokenByDelete(hdiff)
// and getHrefManifestBrokenByNewOrMod(hdiff)
//
// You can now call:
// HrefManifest manifest =
// this.linkValidationService.getBrokenHrefManifest(hdiff);
//
// This will give you a pre-merged manifest of all the broken items
//
// This means you can also clean up the broken link report calling
// signature, and remove your merge logic from the implementation.
//
//
// HrefManifest brokenByDelete = this.linkValidationService.getHrefManifestBrokenByDelete(hdiff);
// HrefManifest brokenByNewOrMod = this.linkValidationService.getHrefManifestBrokenByNewOrMod(hdiff);
//
//
HrefManifest manifest = this.linkValidationService.getBrokenHrefManifest( hdiff );
int baseVersion = manifest.getBaseSnapshotVersion(); // Gav TODO: make use of this
int latestVersion = manifest.getLatestSnapshotVersion(); // Gav TODO: make use of this
int fileCount = manifest.getBaseFileCount(); // Gav TODO: make use of this
int linkCount = manifest.getBaseLinkCount(); // Gav TODO: make use of this
HrefManifest bogus = new HrefManifest(); // Gav TODO: make this go away
// create the report object using the 2 sets of results
report = new LinkValidationReport(storeName, webappName, monitor, brokenByDelete, brokenByNewOrMod);
report = new LinkValidationReport(
storeName,
webappName,
monitor,
// Gav TODO:
// Here's where you can enhance the report:
//
// Pass the following extra parameters
// to the report generator so it can
// put up some sort of indication when
// we're "behind" (and by how much):
//
// baseVersion,
// latestVersion,
// Gav TODO: You can replace brokenByDelete
// and brokenByNewOrMod with the
// new pre-merged manifest.
//
// brokenByDelete,
// brokenByNewOrMod
manifest,
bogus); // Gav TODO:
// Remove this last 'bogus' arg when you re-work the report
// It's just here to satisfy your merge logic
// (which should also probably go away)
}
else
{
// Not calling linkValidationService.updateHrefInfo explicitly anymore
// so tell the system we're done. Note that the monitor won't have
// valid update counts
// Not updating href info explicitly anymore,
// so tell the system that's already done.
// Note that the monitor won't have valid update counts
monitor.setDone( true );
// retrieve the manifest of all the broken links and files for the webapp
List<HrefManifestEntry> manifests = this.linkValidationService.getBrokenHrefManifestEntries(webappPath);
//
// Note that latestVersion >= baseVersion
// Whenever latestVersion > baseVersion,
// link validation is "behind".
// create the report object using the link check results
report = new LinkValidationReport(storeName, webappName, monitor, manifests);
HrefManifest manifest =
this.linkValidationService.getBrokenHrefManifest(webappPath);
List<HrefManifestEntry> manifests =
manifest.getManifestEntries();
int baseVersion = manifest.getBaseSnapshotVersion(); // Gav TODO: make use of this
int latestVersion = manifest.getLatestSnapshotVersion(); // Gav TODO: make use of this
int fileCount = manifest.getBaseFileCount(); // Gav TODO: make use of this
int linkCount = manifest.getBaseLinkCount(); // Gav TODO: make use of this
// Create the report object using the link check results
report = new LinkValidationReport(
storeName,
webappName,
monitor,
//
// Gav TODO:
// Here's where you can enhance the report:
//
// Pass the following extra parameters
// to the report generator so it can
// put up some sort of indication when
// we're "behind" (and by how much):
//
// baseVersion,
// latestVersion,
manifests
);
}
}
catch (Throwable err)

View File

@@ -41,8 +41,9 @@ public interface LinkValidationService
//-------------------------------------------------------------------------
/**
* This function is just a convenience wrapper for calling
* getHrefManifestEntries with statusGTE=400 and statusLTE=599.
* This function is applied to a webapp in staging, and is just a
* convenience wrapper for calling getHrefManifestEntries
* with statusGTE=400 and statusLTE=599.
* <p>
* Note: Files and urls within this list of manifests pertain to
* the latest validated snapshot of staging (which may be
@@ -51,26 +52,27 @@ public interface LinkValidationService
* snapshot as new as possible, automatically.
*/
//-------------------------------------------------------------------------
public List<HrefManifestEntry> getBrokenHrefManifestEntries(
String storeNameOrWebappPath)
public HrefManifest getBrokenHrefManifest( String webappPath)
throws AVMNotFoundException,
SocketException;
SocketException,
IllegalArgumentException;
//-------------------------------------------------------------------------
/**
* Returns a manifest consisting of just the broken hrefs
* within each file containing one or more broken href.
* The HrefManifestEntry list is sorted in increasing lexicographic
* order by file name. The hrefs within each HrefManifestEntry
* are also sorted in increasing lexicographic order.
* This function is applied to webapps in staging and returns a manifest
* consisting of just the broken hrefs within each file containing
* one or more broken href. The HrefManifestEntry list is sorted in
* increasing lexicographic order by file name. The hrefs within each
* HrefManifestEntry are also sorted in increasing lexicographic order.
*/
//-------------------------------------------------------------------------
public List<HrefManifestEntry> getHrefManifestEntries(
String storeNameOrWebappPath,
public HrefManifest getHrefManifest( String webappPath,
int statusGTE,
int statusLTE)
throws AVMNotFoundException,
SocketException;
SocketException,
IllegalArgumentException;
//-------------------------------------------------------------------------
@@ -92,6 +94,16 @@ public interface LinkValidationService
LinkValidationAbortedException;
//-------------------------------------------------------------------------
/**
* This function is applied to difference objects created by comparing
* webapps in an author or workflow store to the staging area they
* overlay.
*/
//-------------------------------------------------------------------------
public HrefManifest getBrokenHrefManifest( HrefDifference hdiff )
throws AVMNotFoundException,
SocketException;
//-------------------------------------------------------------------------
/**