01: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.tools.checks;
07:
08: import javax.xml.parsers.DocumentBuilderFactory;
09: import javax.xml.parsers.ParserConfigurationException;
10:
11: import org.apache.commons.logging.Log;
12: import org.apache.commons.logging.LogFactory;
13: import org.w3c.dom.Document;
14:
15: /**
16: * Checks that DOM level 3 is present.
17: * uPortal requires level 3 of the DOM (org.w3c.dom) APIs.
18: * JDK 1.4 shipped with a DOM 2 implementation of this API in its rt.jar, so
19: * deployers using JDK 1.4 must override with the JAXP 1.3
20: * implementation of these APIs. Deployers using JDK 1.5 need do nothing as
21: * JAXP 1.3 is included in baseline JDK 1.5.
22: *
23: * This check verifies that level 3 of the APIs is available
24: * by exercising a method that exists in DOM3 but not in DOM2.
25: *
26: * @version $Revision: 35857 $ $Date: 2005-05-25 10:55:44 -0700 (Wed, 25 May 2005) $
27: * @since uPortal 2.5
28: */
29: public final class Dom3Check implements ICheck {
30:
31: protected final Log log = LogFactory.getLog(getClass());
32:
33: public CheckResult doCheck() {
34:
35: CheckResult checkResult;
36:
37: try {
38: Document doc = DocumentBuilderFactory.newInstance()
39: .newDocumentBuilder().newDocument();
40: doc.normalizeDocument();
41:
42: checkResult = CheckResult
43: .createSuccess("Successfully invoked the DOM3 method Document.normalizeDocument()");
44:
45: } catch (NoSuchMethodError noSuchMethod) {
46: // deliberately logging without stack trace since
47: // it is the exception message and not the stack trace that matters here.
48: log
49: .error(
50: "DOM3 check failing because DOM3 method not found: ",
51: noSuchMethod);
52: checkResult = CheckResult
53: .createFailure(
54: "DOM3 API method Document.normalizeDocument() not found.",
55: "uPortal requires the DOM3 API which you make available under JDK 1.4 by installing "
56: + "the JAXP 1.3 jars into the endorsed directory of your JDK and of "
57: + "your servlet container. "
58: + "However, under JDK 1.5 you should not install extra XML API jars into tomcat/common/endorsed. "
59: + "See also the README.txt in the /lib/jaxp/ directory.");
60: } catch (ParserConfigurationException e) {
61: log
62: .error(
63: "Dom3Check could not run because it could not obtain a Document at all.",
64: e);
65: checkResult = CheckResult
66: .createFailure(
67: "Dom3Check could not run because it could not obtain a Document at all: "
68: + e,
69: "uPortal requires the DOM3 API which you make available under JDK 1.4 by installing "
70: + "the JAXP 1.3 jars into the endorsed directory of your JDK and of "
71: + "your servlet container. "
72: + "See also the README.txt in the /lib/jaxp/ directory.");
73: }
74:
75: return checkResult;
76: }
77:
78: public String getDescription() {
79: return "Attempts to execute a DOM3 method to verify that DOM3 "
80: + "is present.";
81: }
82:
83: }
|