ate 2004/06/14 05:32:30
Modified: portal/src/java/org/apache/jetspeed/util/descriptor
PortletApplicationWar.java
Log:
- fixed offline building (real offline: without network, not just maven -o) by
resolving web.xml dtd locally
- fixed infusing web.xml: determining element insertion point by retrieving its
content position.
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.6 +26 -17
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
Index: PortletApplicationWar.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PortletApplicationWar.java 11 Jun 2004 18:01:35 -0000 1.5
+++ PortletApplicationWar.java 14 Jun 2004 12:32:30 -0000 1.6
@@ -53,6 +53,9 @@
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.jdom.xpath.XPath;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* This class facilitates opertions a portlet applications WAR file or WAR file-like
@@ -438,6 +441,24 @@
try
{
+ // Use the local dtd instead of remote dtd. This
+ // allows to deploy the application offline
+ builder.setEntityResolver(new EntityResolver()
+ {
+ public InputSource resolveEntity(java.lang.String publicId,
java.lang.String systemId)
+ throws SAXException, java.io.IOException
+ {
+
+ if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
+ {
+ return new
InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
+ }
+ else
+ return null;
+ }
+ });
+
+
Document doc = builder.build(webXmlIn);
Element root = doc.getRootElement();
@@ -541,31 +562,19 @@
List elementsBeforeList = Arrays.asList(elementsBefore);
toInsert.detach();
int insertAfter = 0;
- boolean moreAfter = false;
for (int i = 0; i < allChildren.size(); i++)
{
Element element = (Element) allChildren.get(i);
if (elementsBeforeList.contains(element.getName()))
{
- insertAfter = i;
- moreAfter = false;
- }
- else
- {
- moreAfter = true;
+ // determine the Content index of the element to insert after
+ insertAfter = root.indexOf(element);
}
}
-
+
try
{
- if ( moreAfter )
- {
- root.addContent((insertAfter+2), toInsert);
- }
- else
- {
- root.addContent((insertAfter+3), toInsert);
- }
+ root.addContent((insertAfter+1), toInsert);
}
catch (ArrayIndexOutOfBoundsException e)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]