Author: rwatler
Date: Fri May 16 16:40:04 2014
New Revision: 1595260
URL: http://svn.apache.org/r1595260
Log:
JS2-1274: Support portal application web.xml rewriting for servlet 2.5, 3.0, and 3.1 versions.
Added:
portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_5.java
portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_0.java
portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_1.java
Modified:
portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_4.java
portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriterFactory.java
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_4.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_4.java?rev=1595260&r1=1595259&r2=1595260&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_4.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_4.java Fri May 16 16:40:04 2014
@@ -16,11 +16,11 @@
*/
package org.apache.jetspeed.tools.deploy;
-import javax.xml.xpath.XPathConstants;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import javax.xml.xpath.XPathConstants;
+
/**
* Utilities for manipulating the web.xml deployment descriptor version 2.4
*
@@ -35,18 +35,6 @@ class JetspeedWebApplicationRewriter2_4
public static final String PORTLET_TAGLIB_XPATH = "/js:web-app/js:jsp-config/js:taglib/js:taglib-uri[contains(child::text(), \"http://java.sun.com/portlet\")]";
public static final String PORTLET20_TAGLIB_XPATH = "/js:web-app/js:jsp-config/js:taglib/js:taglib-uri[contains(child::text(), \"http://java.sun.com/portlet_2_0\")]";
- protected static final String[] ELEMENTS_BEFORE_SERVLET = new String[]{"description", "display-name", "icon",
- "distributable", "context-param", "filter", "filter-mapping", "listener", "servlet"};
- protected static final String[] ELEMENTS_BEFORE_SERVLET_MAPPING = new String[]{"description", "display-name", "icon",
- "distributable", "context-param", "filter", "filter-mapping", "listener", "servlet",
- "servlet-mapping"};
-
- protected static final String[] ELEMENTS_BEFORE_JSP_CONFIG = new String[]{"description", "display-name", "icon",
- "distributable", "context-param", "filter", "filter-mapping", "listener", "servlet",
- "servlet-mapping", "session-config", "mime-mapping", "welcome-file-list", "error-page", "jsp-config"};
-
- protected static final String[] ELEMENTS_BEFORE_TAGLIB_MAPPING = new String[]{"taglib"};
-
public JetspeedWebApplicationRewriter2_4(Document doc, String portletApplication)
{
super(doc, portletApplication);
@@ -121,7 +109,7 @@ class JetspeedWebApplicationRewriter2_4
jetspeedServletElement.appendChild(servletClass);
insertContextNameParam(jetspeedServletElement);
insertLoadOnStartup(jetspeedServletElement);
- insertElementCorrectly(root, jetspeedServletElement, ELEMENTS_BEFORE_SERVLET);
+ insertElementCorrectly(root, jetspeedServletElement, getElementsBeforeServlet());
}
/**
@@ -143,7 +131,7 @@ class JetspeedWebApplicationRewriter2_4
jetspeedServletMappingElement.appendChild(servletMapName);
jetspeedServletMappingElement.appendChild(servletUrlPattern);
- insertElementCorrectly(root, jetspeedServletMappingElement, ELEMENTS_BEFORE_SERVLET_MAPPING);
+ insertElementCorrectly(root, jetspeedServletMappingElement, getElementsBeforeServletMapping());
}
/**
@@ -159,7 +147,7 @@ class JetspeedWebApplicationRewriter2_4
if (jspConfig == null)
{
jspConfig = root.getOwnerDocument().createElementNS(namespace,"jsp-config");
- insertElementCorrectly(root, jspConfig, ELEMENTS_BEFORE_JSP_CONFIG);
+ insertElementCorrectly(root, jspConfig, getElementsBeforeJspConfig());
}
Element taglib = root.getOwnerDocument().createElementNS(namespace, "taglib");
Element taguri = root.getOwnerDocument().createElementNS(namespace, "taglib-uri");
@@ -170,7 +158,7 @@ class JetspeedWebApplicationRewriter2_4
taglib.appendChild(taguri);
taglib.appendChild(taglocation);
- insertElementCorrectly(jspConfig, taglib, ELEMENTS_BEFORE_TAGLIB_MAPPING);
+ insertElementCorrectly(jspConfig, taglib, getElementsBeforeJspConfigTaglib());
}
/**
@@ -186,7 +174,7 @@ class JetspeedWebApplicationRewriter2_4
if (jspConfig == null)
{
jspConfig = root.getOwnerDocument().createElementNS(namespace,"jsp-config");
- insertElementCorrectly(root, jspConfig, ELEMENTS_BEFORE_JSP_CONFIG);
+ insertElementCorrectly(root, jspConfig, getElementsBeforeJspConfig());
}
Element taglib = root.getOwnerDocument().createElementNS(namespace, "taglib");
Element taguri = root.getOwnerDocument().createElementNS(namespace, "taglib-uri");
@@ -197,6 +185,46 @@ class JetspeedWebApplicationRewriter2_4
taglib.appendChild(taguri);
taglib.appendChild(taglocation);
- insertElementCorrectly(jspConfig, taglib, ELEMENTS_BEFORE_TAGLIB_MAPPING);
+ insertElementCorrectly(jspConfig, taglib, getElementsBeforeJspConfigTaglib());
+ }
+
+ /**
+ * Return 'web-app' element names before 'servlet' in the ordered web.xml 2.4 schema.
+ *
+ * @return element names
+ */
+ protected String [] getElementsBeforeServlet() {
+ return new String[]{"description", "display-name", "icon", "distributable", "context-param", "filter",
+ "filter-mapping", "listener", "servlet"};
+ }
+
+ /**
+ * Return 'web-app' element names before 'servlet-mapping' in the ordered web.xml 2.4 schema.
+ *
+ * @return element names
+ */
+ protected String [] getElementsBeforeServletMapping() {
+ return new String[]{"description", "display-name", "icon", "distributable", "context-param", "filter",
+ "filter-mapping", "listener", "servlet", "servlet-mapping"};
+ }
+
+ /**
+ * Return 'web-app' element names before 'jsp-config' in the ordered web.xml 2.4 schema.
+ *
+ * @return element names
+ */
+ protected String [] getElementsBeforeJspConfig() {
+ return new String[]{"description", "display-name", "icon", "distributable", "context-param", "filter",
+ "filter-mapping", "listener", "servlet", "servlet-mapping", "session-config", "mime-mapping",
+ "welcome-file-list", "error-page", "jsp-config"};
+ }
+
+ /**
+ * Return 'jsp-config' element names before 'taglib' in the ordered web.xml 2.4 schema.
+ *
+ * @return element names
+ */
+ protected String [] getElementsBeforeJspConfigTaglib() {
+ return new String[]{"taglib"};
}
}
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_5.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_5.java?rev=1595260&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_5.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter2_5.java Fri May 16 16:40:04 2014
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.tools.deploy;
+
+import org.w3c.dom.Document;
+
+/**
+ * Utilities for manipulating the web.xml deployment descriptor version 2.5
+ *
+ * @author <a href="mailto:[email protected]">Randy Watler</a>
+ * @version $Id: JetspeedWebApplicationRewriter2_5.java $
+ */
+public class JetspeedWebApplicationRewriter2_5 extends JetspeedWebApplicationRewriter2_4 {
+
+ /**
+ * Constructor taking XML document for web.xml and portlet application context name.
+ *
+ * @param doc parsed web.xml document
+ * @param portletApplication portlet application context name
+ */
+ public JetspeedWebApplicationRewriter2_5(Document doc, String portletApplication) {
+ super(doc, portletApplication);
+ }
+
+ /**
+ * Constructor taking XML document for web.xml.
+ *
+ * @param doc parsed web.xml document
+ */
+ public JetspeedWebApplicationRewriter2_5(Document doc) {
+ super(doc);
+ }
+}
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_0.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_0.java?rev=1595260&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_0.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_0.java Fri May 16 16:40:04 2014
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.tools.deploy;
+
+import org.w3c.dom.Document;
+
+/**
+ * Utilities for manipulating the web.xml deployment descriptor version 3.0.
+ *
+ * @author <a href="mailto:[email protected]">Randy Watler</a>
+ * @version $Id: JetspeedWebApplicationRewriter3.0.java $
+ */
+public class JetspeedWebApplicationRewriter3_0 extends JetspeedWebApplicationRewriter2_5 {
+
+ /**
+ * Constructor taking XML document for web.xml and portlet application context name.
+ *
+ * @param doc parsed web.xml document
+ * @param portletApplication portlet application context name
+ */
+ public JetspeedWebApplicationRewriter3_0(Document doc, String portletApplication) {
+ super(doc, portletApplication);
+ }
+
+ /**
+ * Constructor taking XML document for web.xml.
+ *
+ * @param doc parsed web.xml document
+ */
+ public JetspeedWebApplicationRewriter3_0(Document doc) {
+ super(doc);
+ }
+
+ /**
+ * Return 'web-app' element names before 'servlet' in the ordered web.xml 3.0 schema.
+ *
+ * @return element names
+ */
+ @Override
+ protected String [] getElementsBeforeServlet() {
+ return new String[]{"module-name", "description", "display-name", "icon", "distributable", "context-param",
+ "filter", "filter-mapping", "listener", "servlet"};
+ }
+
+ /**
+ * Return 'web-app' element names before 'servlet-mapping' in the ordered web.xml 3.0 schema.
+ *
+ * @return element names
+ */
+ @Override
+ protected String [] getElementsBeforeServletMapping() {
+ return new String[]{"module-name", "description", "display-name", "icon", "distributable", "context-param",
+ "filter", "filter-mapping", "listener", "servlet", "servlet-mapping"};
+ }
+
+ /**
+ * Return 'web-app' element names before 'jsp-config' in the ordered web.xml 3.0 schema.
+ *
+ * @return element names
+ */
+ @Override
+ protected String [] getElementsBeforeJspConfig() {
+ return new String[]{"module-name", "description", "display-name", "icon", "distributable", "context-param",
+ "filter", "filter-mapping", "listener", "servlet", "servlet-mapping", "session-config", "mime-mapping",
+ "welcome-file-list", "error-page", "jsp-config"};
+ }
+}
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_1.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_1.java?rev=1595260&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_1.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriter3_1.java Fri May 16 16:40:04 2014
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.tools.deploy;
+
+import org.w3c.dom.Document;
+
+/**
+ * Utilities for manipulating the web.xml deployment descriptor version 3.1.
+ *
+ * @author <a href="mailto:[email protected]">Randy Watler</a>
+ * @version $Id: JetspeedWebApplicationRewriter3.1.java $
+ */
+public class JetspeedWebApplicationRewriter3_1 extends JetspeedWebApplicationRewriter3_0 {
+
+ /**
+ * Constructor taking XML document for web.xml and portlet application context name.
+ *
+ * @param doc parsed web.xml document
+ * @param portletApplication portlet application context name
+ */
+ public JetspeedWebApplicationRewriter3_1(Document doc, String portletApplication) {
+ super(doc, portletApplication);
+ }
+
+ /**
+ * Constructor taking XML document for web.xml.
+ *
+ * @param doc parsed web.xml document
+ */
+ public JetspeedWebApplicationRewriter3_1(Document doc) {
+ super(doc);
+ }
+}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriterFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriterFactory.java?rev=1595260&r1=1595259&r2=1595260&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriterFactory.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-deploy-tools/src/main/java/org/apache/jetspeed/tools/deploy/JetspeedWebApplicationRewriterFactory.java Fri May 16 16:40:04 2014
@@ -70,7 +70,7 @@ public class JetspeedWebApplicationRewri
version = "2.3";
}
}
-
+
try
{
// Check version is a valid number
@@ -85,10 +85,22 @@ public class JetspeedWebApplicationRewri
{
return new JetspeedWebApplicationRewriter2_3(doc, portletApplication);
}
- else if(version.compareTo("2.4") >= 0)
+ else if(version.equals("2.4"))
{
return new JetspeedWebApplicationRewriter2_4(doc, portletApplication);
}
+ else if(version.equals("2.5"))
+ {
+ return new JetspeedWebApplicationRewriter2_5(doc, portletApplication);
+ }
+ else if(version.equals("3.0"))
+ {
+ return new JetspeedWebApplicationRewriter3_0(doc, portletApplication);
+ }
+ else if(version.compareTo("3.1") >= 0)
+ {
+ return new JetspeedWebApplicationRewriter3_1(doc, portletApplication);
+ }
else
{
throw new Exception("Unable to create JetspeedWebApplicationRewriter for version " + version);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.