vmassol 2005/02/10 11:51:34
Modified: documentation/docs/xdocs changes.xml
integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp
WebXml.java WebXmlMerger.java WebXmlTag.java
Log:
CACTUS-189: Added support for merging <code><run-as></code> element
from a provided <code>web.xml</code> file in the cactifywar Ant task. Thanks to
Magnus Grimsell for the patch.
Revision Changes Path
1.214 +4 -0 jakarta-cactus/documentation/docs/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -r1.213 -r1.214
--- changes.xml 1 Feb 2005 08:54:44 -0000 1.213
+++ changes.xml 10 Feb 2005 19:51:34 -0000 1.214
@@ -91,6 +91,10 @@
</devs>
<release version="1.8dev" date="in CVS">
+ <action dev="VMA" type="update" issue="CACTUS-189" due-to="Magnus
Grimsell">
+ Added support for merging <code><run-as></code> element from
a
+ provided <code>web.xml</code> file in the cactifywar Ant task.
+ </action>
<action dev="VMA" type="add">
Added new public
<code>PageContextWrapper.getOriginalPageContext()</code> method
1.2 +48 -3
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXml.java
Index: WebXml.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXml.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebXml.java 31 May 2004 20:05:23 -0000 1.1
+++ WebXml.java 10 Feb 2005 19:51:34 -0000 1.2
@@ -1,7 +1,7 @@
/*
* ========================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@
*/
public class WebXml
{
-
// Private Constants
-------------------------------------------------------
/**
@@ -544,6 +543,23 @@
}
/**
+ * Adds a run-as declaration to the specified servlet.
+ *
+ * @param theServletName the name of the servlet to manipulate
+ * @param theRoleName the role name that the servlet should be running as
+ */
+ public final void addServletRunAsRoleName(String theServletName,
+ String theRoleName)
+ {
+ Element servlet = getServlet(theServletName);
+ Element runAsElement =
+ this.document.createElement(WebXmlTag.RUN_AS.getTagName());
+ runAsElement.appendChild(createNestedText(WebXmlTag.ROLE_NAME,
+ theRoleName));
+ servlet.appendChild(runAsElement);
+ }
+
+ /**
* Adds a servlet mapping to the descriptor.
*
* @param theServletName The name of the servlet
@@ -621,6 +637,35 @@
}
/**
+ * Returns the role name that the servlet is running as.
+ *
+ * @param theServletName The name of the servlet of which the role name
+ * should be retrieved
+ * @return the roleName or null if non is specified
+ */
+ public final String getServletRunAsRoleName(String theServletName)
+ {
+ if (theServletName == null)
+ {
+ throw new NullPointerException();
+ }
+ String roleName = null;
+ Element servlet = getServlet(theServletName);
+ NodeList nodeList =
+ servlet.getElementsByTagName(WebXmlTag.RUN_AS.getTagName());
+ if (nodeList != null)
+ {
+ Element e = (Element) nodeList.item(0);
+ if (e != null)
+ {
+ roleName = getNestedText(e, WebXmlTag.ROLE_NAME);
+ }
+ }
+
+ return roleName;
+ }
+
+ /**
* Returns the URL-patterns that the specified servlet is mapped to in an
* ordered list. If there are no mappings for the specified servlet, an
* iterator over an empty list is returned.
1.2 +8 -3
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXmlMerger.java
Index: WebXmlMerger.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXmlMerger.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebXmlMerger.java 31 May 2004 20:05:23 -0000 1.1
+++ WebXmlMerger.java 10 Feb 2005 19:51:34 -0000 1.2
@@ -1,7 +1,7 @@
/*
* ========================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@
*/
public class WebXmlMerger
{
-
// Instance Variables
------------------------------------------------------
/**
@@ -223,6 +222,12 @@
webXml.addServletInitParam(
servletName, paramName, paramValue);
}
+ String roleName =
+ theWebXml.getServletRunAsRoleName(servletName);
+ if (roleName != null)
+ {
+ webXml.addServletRunAsRoleName(servletName, roleName);
+ }
}
// merge the mappings
Iterator servletMappings =
1.2 +8 -3
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXmlTag.java
Index: WebXmlTag.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/deployment/webapp/WebXmlTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebXmlTag.java 31 May 2004 20:05:23 -0000 1.1
+++ WebXmlTag.java 10 Feb 2005 19:51:34 -0000 1.2
@@ -1,7 +1,7 @@
/*
* ========================================================================
*
- * Copyright 2003 The Apache Software Foundation.
+ * Copyright 2003-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
*/
public final class WebXmlTag
{
-
// Public Constants
--------------------------------------------------------
/**
@@ -140,6 +139,12 @@
new WebXmlTag("load-on-startup");
/**
+ * Element name 'run-as'.
+ */
+ public static final WebXmlTag RUN_AS =
+ new WebXmlTag("run-as");
+
+ /**
* Element name 'servlet-mapping'.
*/
public static final WebXmlTag SERVLET_MAPPING =
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]