diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml index 2f614c09ec..57be4dbdf4 100644 --- a/config/alfresco/public-services-context.xml +++ b/config/alfresco/public-services-context.xml @@ -1377,11 +1377,11 @@ - getHrefManifestEntries + getHrefManifest + getBrokenHrefManifest getHrefDifference getHrefManifestBrokenByDelete getHrefManifestBrokenByNewOrMod - getHrefConcordanceEntries getHrefsDependentUponFile diff --git a/source/java/org/alfresco/linkvalidation/HrefDifference.java b/source/java/org/alfresco/linkvalidation/HrefDifference.java index 1e6fb19f43..ce35c0f784 100644 --- a/source/java/org/alfresco/linkvalidation/HrefDifference.java +++ b/source/java/org/alfresco/linkvalidation/HrefDifference.java @@ -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_;} diff --git a/source/java/org/alfresco/linkvalidation/HrefManifest.java b/source/java/org/alfresco/linkvalidation/HrefManifest.java index ab4f1f1049..97a0820fcb 100644 --- a/source/java/org/alfresco/linkvalidation/HrefManifest.java +++ b/source/java/org/alfresco/linkvalidation/HrefManifest.java @@ -38,13 +38,36 @@ import java.util.ArrayList; */ public class HrefManifest { - protected List manifest_entries_; + List manifest_entries_; + int base_snapshot_version_; + int latest_snapshot_version_; + int base_file_count_; + int base_link_count_; public HrefManifest() { manifest_entries_ = new ArrayList(); } + public HrefManifest(List 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 getManifestEntries() { return manifest_entries_;} synchronized void add( HrefManifestEntry entry ) diff --git a/source/java/org/alfresco/linkvalidation/LinkValidationAction.java b/source/java/org/alfresco/linkvalidation/LinkValidationAction.java index a95eea56e2..20f3a3eef5 100644 --- a/source/java/org/alfresco/linkvalidation/LinkValidationAction.java +++ b/source/java/org/alfresco/linkvalidation/LinkValidationAction.java @@ -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 manifests = this.linkValidationService.getBrokenHrefManifestEntries(webappPath); - - // create the report object using the link check results - report = new LinkValidationReport(storeName, webappName, monitor, manifests); + // + // Note that latestVersion >= baseVersion + // Whenever latestVersion > baseVersion, + // link validation is "behind". + + HrefManifest manifest = + this.linkValidationService.getBrokenHrefManifest(webappPath); + + List 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) diff --git a/source/java/org/alfresco/linkvalidation/LinkValidationService.java b/source/java/org/alfresco/linkvalidation/LinkValidationService.java index c147ca910c..d38eccd07d 100644 --- a/source/java/org/alfresco/linkvalidation/LinkValidationService.java +++ b/source/java/org/alfresco/linkvalidation/LinkValidationService.java @@ -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. *

* 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 getBrokenHrefManifestEntries( - String storeNameOrWebappPath) - throws AVMNotFoundException, - SocketException; + public HrefManifest getBrokenHrefManifest( String webappPath) + throws AVMNotFoundException, + 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 getHrefManifestEntries( - String storeNameOrWebappPath, - int statusGTE, - int statusLTE) - throws AVMNotFoundException, - SocketException; + public HrefManifest getHrefManifest( String webappPath, + int statusGTE, + int statusLTE) + throws AVMNotFoundException, + 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; //------------------------------------------------------------------------- /**