Prettier exception when virt server is down.

Optimization for initial validation (no rescan necessary on empty store).
Now emulating forgiving (non RFC-2396/3987 compliant) behavior most 
browsers exhibit on links like: <a href="mind the gap.html">...</a>
Also bumped schema version to deal with link canonicalization


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6190 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jon Cox
2007-07-08 04:03:06 +00:00
parent c5d97bfebe
commit cce11fa38b
2 changed files with 84 additions and 69 deletions

View File

@@ -1,16 +1,16 @@
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Copyright 2007 Alfresco Inc. * Copyright 2007 Alfresco Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special
@@ -19,8 +19,8 @@
* Software ("FLOSS") applications as described in Alfresco's FLOSS exception. * Software ("FLOSS") applications as described in Alfresco's FLOSS exception.
* You should have received a copy of the text describing the FLOSS exception, * You should have received a copy of the text describing the FLOSS exception,
* and it is also available here: http://www.alfresco.com/legal/licensing * and it is also available here: http://www.alfresco.com/legal/licensing
* *
* *
* Author Jon Cox <jcox@alfresco.com> * Author Jon Cox <jcox@alfresco.com>
* File HrefDifference.java * File HrefDifference.java
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@@ -36,20 +36,20 @@ import java.util.Map;
public class HrefDifference public class HrefDifference
{ {
/** /**
* The href_status_map_ is a map of URLs the tuple of their * The href_status_map_ is a map of URLs the tuple of their
* return status & list of dependencies. * return status & list of dependencies.
*/ */
protected HrefStatusMap href_status_map_; // status of links/maybe dep info protected HrefStatusMap href_status_map_; // status of links/maybe dep info
/** /**
* The href_manifest_ contains a List<HrefManifestEntry> objects. * The href_manifest_ contains a List<HrefManifestEntry> objects.
* Each HrefManifestEntry contains a file name, * Each HrefManifestEntry contains a file name,
* and possibly a list of hrefs within that file. * and possibly a list of hrefs within that file.
*/ */
protected HrefManifest href_manifest_; protected HrefManifest href_manifest_;
// Lazily computed values // Lazily computed values
protected HrefManifest broken_in_newmod_; // errors in new files protected HrefManifest broken_in_newmod_; // errors in new files
protected HrefManifest broken_by_deletion_; // err via new deletions protected HrefManifest broken_by_deletion_; // err via new deletions
// Only computed when merging diffs // Only computed when merging diffs
@@ -60,28 +60,40 @@ public class HrefDifference
protected HashMap<String, List<String>> broken_manifest_map_; protected HashMap<String, List<String>> broken_manifest_map_;
protected HashMap<String,String> deleted_file_md5_; protected HashMap<String,String> deleted_file_md5_;
String href_attr_; // href attribute lookup prefix String href_attr_; // href attribute lookup prefix
String src_store_;
int src_version_;
String src_store_;
int dst_version_;
String dst_store_; String dst_store_;
String src_webapp_url_base_; String src_webapp_url_base_;
String dst_webapp_url_base_; String dst_webapp_url_base_;
HrefDifference(String href_attr, HrefDifference(String href_attr,
int src_version,
String src_store, String src_store,
int dst_version,
String dst_store, String dst_store,
String src_webapp_url_base, String src_webapp_url_base,
String dst_webapp_url_base) String dst_webapp_url_base)
{ {
href_attr_ = href_attr; href_attr_ = href_attr;
src_version_ = src_version;
src_store_ = src_store; src_store_ = src_store;
dst_version_ = dst_version;
dst_store_ = dst_store; dst_store_ = dst_store;
src_webapp_url_base_ = src_webapp_url_base; src_webapp_url_base_ = src_webapp_url_base;
dst_webapp_url_base_ = dst_webapp_url_base; dst_webapp_url_base_ = dst_webapp_url_base;
href_manifest_ = new HrefManifest(); href_manifest_ = new HrefManifest();
href_status_map_ = new HrefStatusMap(); href_status_map_ = new HrefStatusMap();
broken_manifest_map_ = new HashMap<String, List<String>>(); broken_manifest_map_ = new HashMap<String, List<String>>();
deleted_file_md5_ = new HashMap<String,String>(); deleted_file_md5_ = new HashMap<String,String>();
} }
@@ -89,17 +101,19 @@ public class HrefDifference
public HrefManifest getHrefManifest() { return href_manifest_; } public HrefManifest getHrefManifest() { return href_manifest_; }
public HrefStatusMap getHrefStatusMap() { return href_status_map_; } public HrefStatusMap getHrefStatusMap() { return href_status_map_; }
public int getSrcVersion() { return src_version_;}
public int getDstVersion() { return dst_version_;}
String getHrefAttr() { return href_attr_;} String getHrefAttr() { return href_attr_;}
String getSrcStore() { return src_store_;} String getSrcStore() { return src_store_;}
String getDstStore() { return dst_store_;} String getDstStore() { return dst_store_;}
String getSrcWebappUrlBase() { return src_webapp_url_base_; } String getSrcWebappUrlBase() { return src_webapp_url_base_; }
String getDstWebappUrlBase() { return dst_webapp_url_base_; } String getDstWebappUrlBase() { return dst_webapp_url_base_; }
Map<String,String> getDeletedFileMd5() { return deleted_file_md5_; } Map<String,String> getDeletedFileMd5() { return deleted_file_md5_; }
Map<String, List<String>> getBrokenManifestMap() Map<String, List<String>> getBrokenManifestMap()
{ {
return broken_manifest_map_; return broken_manifest_map_;
} }
} }

View File

@@ -1,16 +1,16 @@
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Copyright 2007 Alfresco Inc. * Copyright 2007 Alfresco Inc.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special
@@ -19,8 +19,8 @@
* Software ("FLOSS") applications as described in Alfresco's FLOSS exception. * Software ("FLOSS") applications as described in Alfresco's FLOSS exception.
* You should have received a copy of the text describing the FLOSS exception, * You should have received a copy of the text describing the FLOSS exception,
* and it is also available here: http://www.alfresco.com/legal/licensing * and it is also available here: http://www.alfresco.com/legal/licensing
* *
* *
* Author Jon Cox <jcox@alfresco.com> * Author Jon Cox <jcox@alfresco.com>
* File LinkValidationService.java * File LinkValidationService.java
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@@ -41,7 +41,7 @@ public interface LinkValidationService
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* This function is just a convenience wrapper for calling * This function is just a convenience wrapper for calling
* getHrefManifestEntries with statusGTE=400 and statusLTE=599. * getHrefManifestEntries with statusGTE=400 and statusLTE=599.
* <p> * <p>
* Note: Files and urls within this list of manifests pertain to * Note: Files and urls within this list of manifests pertain to
@@ -51,24 +51,26 @@ public interface LinkValidationService
* snapshot as new as possible, automatically. * snapshot as new as possible, automatically.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
public List<HrefManifestEntry> getBrokenHrefManifestEntries( public List<HrefManifestEntry> getBrokenHrefManifestEntries(
String storeNameOrWebappPath String storeNameOrWebappPath)
) throws AVMNotFoundException; throws AVMNotFoundException,
SocketException;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* Returns a manifest consisting of just the broken hrefs * Returns a manifest consisting of just the broken hrefs
* within each file containing one or more broken href. * within each file containing one or more broken href.
* The HrefManifestEntry list is sorted in increasing lexicographic * The HrefManifestEntry list is sorted in increasing lexicographic
* order by file name. The hrefs within each HrefManifestEntry * order by file name. The hrefs within each HrefManifestEntry
* are also sorted in increasing lexicographic order. * are also sorted in increasing lexicographic order.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
public List<HrefManifestEntry> getHrefManifestEntries( public List<HrefManifestEntry> getHrefManifestEntries(
String storeNameOrWebappPath, String storeNameOrWebappPath,
int statusGTE, int statusGTE,
int statusLTE) throws int statusLTE)
AVMNotFoundException; throws AVMNotFoundException,
SocketException;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -80,9 +82,9 @@ public interface LinkValidationService
* snapshot, but it's async, so it might be older. * snapshot, but it's async, so it might be older.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
public HrefDifference getHrefDifference( public HrefDifference getHrefDifference(
String srcWebappPath, String srcWebappPath,
String dstWebappPath, String dstWebappPath,
HrefValidationProgress progress) HrefValidationProgress progress)
throws AVMNotFoundException, throws AVMNotFoundException,
SocketException, SocketException,
@@ -93,16 +95,16 @@ public interface LinkValidationService
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* Fetches a manifest of all hyperlinks broken by files * Fetches a manifest of all hyperlinks broken by files
* deleted in a HrefDifference. Files and hrefs in this * deleted in a HrefDifference. Files and hrefs in this
* manifest will be in the namespace of the src in the * manifest will be in the namespace of the src in the
* HrefDifference. For example, suppose the "test" * HrefDifference. For example, suppose the "test"
* web project had a ROOT webapp with a link within * web project had a ROOT webapp with a link within
* "moo.html" that pointed to: "hamlet.html". * "moo.html" that pointed to: "hamlet.html".
* Now suppose that user 'alice' proposes to delete "hamlet.html". * Now suppose that user 'alice' proposes to delete "hamlet.html".
* Because 'alice' is the 'src' and staging is the 'dst' * Because 'alice' is the 'src' and staging is the 'dst'
* in the HrefDifference, all files and hyperlinks appear from * in the HrefDifference, all files and hyperlinks appear from
* the perspective of the main working store within * the perspective of the main working store within
* alice's sandbox. Thus, the broken link info is as follows: * alice's sandbox. Thus, the broken link info is as follows:
* *
* <pre> * <pre>
@@ -113,7 +115,7 @@ public interface LinkValidationService
* http://alice.test.www--sandbox.version--v-1.127-0-0-1.ip.alfrescodemo.net:8180/hamlet.html * http://alice.test.www--sandbox.version--v-1.127-0-0-1.ip.alfrescodemo.net:8180/hamlet.html
* </pre> * </pre>
* *
* @param hdiff The difference between two webapps obtained * @param hdiff The difference between two webapps obtained
* by calling getHrefDifference(). * by calling getHrefDifference().
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -125,11 +127,11 @@ public interface LinkValidationService
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* Fetches a manifest of all hyperlinks broken in new or modified files in * Fetches a manifest of all hyperlinks broken in new or modified files in
* an HrefDifference. Similar to getHrefManifestBrokenByDelete(), * an HrefDifference. Similar to getHrefManifestBrokenByDelete(),
* the entries in this manifest are in the 'src' namespace of the * the entries in this manifest are in the 'src' namespace of the
* HrefDifference operation (i.e.: files & urls from alice, not staging). * HrefDifference operation (i.e.: files & urls from alice, not staging).
* *
* @param hdiff The difference between two webapps obtained * @param hdiff The difference between two webapps obtained
* by calling getHrefDifference(). * by calling getHrefDifference().
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -140,48 +142,48 @@ public interface LinkValidationService
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* WARNING: this function won't be part of the public interface for long. * WARNING: this function won't be part of the public interface for long.
* Updates href status and href file dependencies for path. * Updates href status and href file dependencies for path.
* *
* @param path * @param path
* <ul> * <ul>
* <li> If null, do all stores & all webapps in them. * <li> If null, do all stores & all webapps in them.
* <li> If store, do all webapps in store * <li> If store, do all webapps in store
* <li> If webapp, do webapp. * <li> If webapp, do webapp.
* </ul> * </ul>
* *
* @param incremental * @param incremental
* If true, updates information incrementally, based on the * If true, updates information incrementally, based on the
* files that have changed and prior calculations regarding * files that have changed and prior calculations regarding
* url-to-file dependencies. If false, first deletes all URL * url-to-file dependencies. If false, first deletes all URL
* info associated with the store/webapp (if any), then does * info associated with the store/webapp (if any), then does
* a full rescan to update info. * a full rescan to update info.
* *
* @validateExternal * @validateExternal
* Currently does nothing. Perhaps one day you'll be able to * Currently does nothing. Perhaps one day you'll be able to
* turn off validation of external links. * turn off validation of external links.
* *
* @param progress * @param progress
* While updateHrefInfo() is a synchronous function, * While updateHrefInfo() is a synchronous function,
* 'status' may be polled in a separate thread to * 'status' may be polled in a separate thread to
* observe its progress. * observe its progress.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
public void updateHrefInfo( String path, public void updateHrefInfo( String path,
boolean incremental, boolean incremental,
boolean validateExternal, boolean validateExternal,
HrefValidationProgress progress) HrefValidationProgress progress)
throws AVMNotFoundException, throws AVMNotFoundException,
SocketException, SocketException,
SSLException, SSLException,
LinkValidationAbortedException; LinkValidationAbortedException;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
/** /**
* Fetch all hyperlinks that rely upon the existence of the file specified * Fetch all hyperlinks that rely upon the existence of the file specified
* by 'path', directly or indirectly. The list of hrefs returnd is * by 'path', directly or indirectly. The list of hrefs returnd is
* sorted in increasing lexicographic order. For example, in * sorted in increasing lexicographic order. For example, in
* alfresco-sample-website.war, the hrefs dependent upon * alfresco-sample-website.war, the hrefs dependent upon
* <code>mysite:/www/avm_webapps/ROOT/assets/footer.html</code> are: * <code>mysite:/www/avm_webapps/ROOT/assets/footer.html</code> are:
* <pre> * <pre>
@@ -191,10 +193,9 @@ public interface LinkValidationService
* http://mysite.www--sandbox.version--v-1.127-0-0-1.ip.alfrescodemo.net:8180/media/releases/index.jsp * http://mysite.www--sandbox.version--v-1.127-0-0-1.ip.alfrescodemo.net:8180/media/releases/index.jsp
* </pre> * </pre>
* Note that this list may contain links that are functionally equivalent * Note that this list may contain links that are functionally equivalent
* (e.g.: the first and third links), and may also contain links that * (e.g.: the first and third links), and may also contain links that
* don't actually appear an any web page, but are implicitly present * don't actually appear an any web page, but are implicitly present
* in the site because any asset can be "dead reckoned". * in the site because any asset can be "dead reckoned".
*
* *
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------