dion 02/05/20 00:07:31
Modified: src/java/org/apache/maven/j2ee WarValidator.java
Log:
Refactored exception handling
Revision Changes Path
1.18 +71 -105
jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarValidator.java
Index: WarValidator.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/j2ee/WarValidator.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WarValidator.java 20 May 2002 06:36:23 -0000 1.17
+++ WarValidator.java 20 May 2002 07:07:31 -0000 1.18
@@ -95,7 +95,7 @@
* <taglib-location></code> that exists in the war</li>
* </ol>
* @author dIon Gillard
- * @version $Id: WarValidator.java,v 1.17 2002/05/20 06:36:23 dion Exp $
+ * @version $Id: WarValidator.java,v 1.18 2002/05/20 07:07:31 dion Exp $
*/
public class WarValidator extends AbstractExecutor
{
@@ -237,78 +237,60 @@
* <code><servlet></code> tag in web.xml), making sure that their
* class defined can be loaded from the war and is not part of the
* external classpath
+ * @throws IOException when there are any issues reading the war file
*/
- private void validateServlets(WarFile war)
+ private void validateServlets(WarFile war) throws IOException
{
- try
+ Map servlets = war.getServlets();
+ if (servlets.size() != 0)
{
- Map servlets = war.getServlets();
- if (servlets.size() != 0)
+ ClassLoader classLoader = new WarClassLoader(war, getClass().
+ getClassLoader());
+ String className = null;
+ Map.Entry entry = null;
+ for (Iterator entries = servlets.entrySet().iterator();
+ entries.hasNext();)
{
- ClassLoader classLoader = new WarClassLoader(war,
- getClass().getClassLoader());
- String className = null;
- Map.Entry entry = null;
- for (Iterator entries = servlets.entrySet().iterator();
- entries.hasNext();)
- {
- entry = (Map.Entry) entries.next();
- className = (String) entry.getValue();
- getBroadcaster().fireInformationEvent( new
- ValidationEvent(this, getWarFileName(),
- "validating servlet name: " + entry.getKey() +
- " class: " + className));
- // check each servlet by loadClass
- validateClass(className, classLoader);
- }
+ entry = (Map.Entry) entries.next();
+ className = (String) entry.getValue();
+ getBroadcaster().fireInformationEvent( new ValidationEvent(this,
+ getWarFileName(), "validating servlet name: " +
+ entry.getKey() + " class: " + className));
+ // check each servlet by loading the class
+ validateClass(className, classLoader);
}
}
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- getBroadcaster().fireErrorEvent(new ValidationEvent(this,
- getWarFileName(), "Error reading WEB-INF/web.xml"));
- }
}
/** Validate the jsps defined in the war file (as defined by a
* <code><servlet></code> tag with a nested <code><jsp-file>
* </code> in web.xml), making sure that the resource specifed by
* <code><jsp-file></code> exists in the war file
+ * @throws IOException when there are any issues reading the war file
*/
- private void validateJSPs(WarFile war)
+ private void validateJSPs(WarFile war) throws IOException
{
- try
+ Map jsps = war.getJSPs();
+ if (jsps.size() != 0)
{
- Map jsps = war.getJSPs();
- if (jsps.size() != 0)
+ Map.Entry entry = null;
+ for (Iterator entries = jsps.entrySet().iterator();
+ entries.hasNext();)
{
- Map.Entry entry = null;
- for (Iterator entries = jsps.entrySet().iterator();
- entries.hasNext();)
+ entry = (Map.Entry)entries.next();
+ String jspFile = (String)entry.getValue();
+ getBroadcaster().fireInformationEvent( new ValidationEvent(this,
+ getWarFileName(), "validating servlet name: " +
+ entry.getKey() + " jsp file: " + jspFile));
+
+ if (!war.hasFile(jspFile))
{
- entry = (Map.Entry)entries.next();
- String jspFile = (String)entry.getValue();
- getBroadcaster().fireInformationEvent( new
- ValidationEvent(this, getWarFileName(),
- "validating servlet name: " + entry.getKey() +
- " jsp file: " + jspFile));
-
- if (!war.hasFile(jspFile))
- {
- getBroadcaster().fireErrorEvent( new ValidationEvent(
- this, getWarFileName(), "JSP File: '" + jspFile +
- "' not found"));
- }
+ getBroadcaster().fireErrorEvent( new ValidationEvent(this,
+ getWarFileName(), "JSP File: '" + jspFile +
+ "' not found"));
}
}
}
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- getBroadcaster().fireErrorEvent(new ValidationEvent(this,
- getWarFileName(), "Error reading WEB-INF/web.xml"));
- }
}
/** Validate that the given className can be loaded by the given
@@ -347,82 +329,66 @@
* <code><taglib></code> tag in web.xml), making sure that the
* resource specifed by <code><taglib-location></code> exists in the
* war file
+ * @throws IOException when there are any issues reading the war file
*/
- private void validateTaglibs(WarFile war)
+ private void validateTaglibs(WarFile war) throws IOException
{
- try
+ Map taglibs = war.getTaglibs();
+ if (taglibs.size() != 0)
{
- Map taglibs = war.getTaglibs();
- if (taglibs.size() != 0)
+ Map.Entry entry = null;
+ for (Iterator entries = taglibs.entrySet().iterator();
+ entries.hasNext();)
{
- Map.Entry entry = null;
- for (Iterator entries = taglibs.entrySet().iterator();
- entries.hasNext();)
+ entry = (Map.Entry)entries.next();
+ String uri = (String)entry.getKey();
+ String location = (String)entry.getValue();
+ getBroadcaster().fireInformationEvent( new ValidationEvent(this,
+ getWarFileName(), "validating taglib uri: " + uri));
+ if (!war.hasFile(location))
{
- entry = (Map.Entry)entries.next();
- String uri = (String)entry.getKey();
- String location = (String)entry.getValue();
- getBroadcaster().fireInformationEvent( new
- ValidationEvent(this, getWarFileName(),
- "validating taglib uri: " + uri));
- if (!war.hasFile(location))
- {
- getBroadcaster().fireErrorEvent( new ValidationEvent(
- this, getWarFileName(), "Taglib location: '" +
- location + "' not found"));
- }
+ getBroadcaster().fireErrorEvent( new ValidationEvent(this,
+ getWarFileName(), "Taglib location: '" + location +
+ "' not found"));
}
}
}
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- getBroadcaster().fireErrorEvent(new ValidationEvent(this,
- getWarFileName(), "Error reading WEB-INF/web.xml"));
- }
}
/** Validate the error pages defined in the war file (as defined by a
* <code><error-page></code> tag in web.xml), making sure that the
* location specifed by the nested <code><location></code> exists in
* the war file
+ * @throws IOException when there are any issues reading the war file
*/
- public void validateErrorPages(WarFile war)
+ public void validateErrorPages(WarFile war) throws IOException
{
- try
+ Map pages = war.getErrorPages();
+ if (pages.size() != 0)
{
- Map pages = war.getErrorPages();
- if (pages.size() != 0)
+ Map.Entry entry = null;
+ for (Iterator entries = pages.entrySet().iterator();
+ entries.hasNext();)
{
- Map.Entry entry = null;
- for (Iterator entries = pages.entrySet().iterator();
- entries.hasNext();)
+ entry = (Map.Entry)entries.next();
+ String errorQualifier = (String)entry.getKey();
+ String location = (String)entry.getValue();
+ getBroadcaster().fireInformationEvent( new ValidationEvent(this,
+ getWarFileName(), "validating error page for: " +
+ errorQualifier));
+ if (!war.hasFile(location))
{
- entry = (Map.Entry)entries.next();
- String errorQualifier = (String)entry.getKey();
- String location = (String)entry.getValue();
- getBroadcaster().fireInformationEvent( new
- ValidationEvent(this, getWarFileName(),
- "validating error page for: " + errorQualifier));
- if (!war.hasFile(location))
- {
- getBroadcaster().fireErrorEvent( new ValidationEvent(
- this, getWarFileName(), "Error page location: '" +
- location + "' not found"));
- }
+ getBroadcaster().fireErrorEvent( new ValidationEvent(this,
+ getWarFileName(), "Error page location: '" + location +
+ "' not found"));
}
}
}
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- getBroadcaster().fireErrorEvent(new ValidationEvent(this,
- getWarFileName(), "Error reading WEB-INF/web.xml"));
- }
}
/** validate that the <code><form-login-config></code> element, if it
* exists contains valid login and error pages
+ * @throws IOException when there are any issues reading the war file
*/
public void validateFormLoginConfig(WarFile war) throws IOException
{
@@ -433,13 +399,13 @@
{
getBroadcaster().fireErrorEvent( new ValidationEvent(this,
getWarFileName(), "<form-config-login> login-page location:"
- + "' " + config.getLoginPage() + "' not found"));
+ + " '" + config.getLoginPage() + "' not found"));
}
if (!war.hasFile(config.getErrorPage()))
{
getBroadcaster().fireErrorEvent( new ValidationEvent(this,
getWarFileName(), "<form-config-login> error-page location:"
- + "' " + config.getErrorPage() + "' not found"));
+ + " '" + config.getErrorPage() + "' not found"));
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>