You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/11/15 15:03:58 UTC
svn commit: r1846662 - in /tomcat/trunk:
java/org/apache/catalina/manager/ManagerServlet.java
webapps/docs/changelog.xml webapps/docs/manager-howto.xml
Author: markt
Date: Thu Nov 15 15:03:58 2018
New Revision: 1846662
URL: http://svn.apache.org/viewvc?rev=1846662&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=53553
Add the ability to specify a context.xml from the server to use when uploading a web application for deployment with the Manager web application.
Patch provided by Anton Lindström.
Modified:
tomcat/trunk/java/org/apache/catalina/manager/ManagerServlet.java
tomcat/trunk/webapps/docs/changelog.xml
tomcat/trunk/webapps/docs/manager-howto.xml
Modified: tomcat/trunk/java/org/apache/catalina/manager/ManagerServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/manager/ManagerServlet.java?rev=1846662&r1=1846661&r2=1846662&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/manager/ManagerServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/manager/ManagerServlet.java Thu Nov 15 15:03:58 2018
@@ -430,6 +430,7 @@ public class ManagerServlet extends Http
if (path != null) {
cn = new ContextName(path, request.getParameter("version"));
}
+ String config = request.getParameter("config");
String tag = request.getParameter("tag");
boolean update = false;
if ((request.getParameter("update") != null)
@@ -449,7 +450,7 @@ public class ManagerServlet extends Http
if (command == null) {
writer.println(smClient.getString("managerServlet.noCommand"));
} else if (command.equals("/deploy")) {
- deploy(writer, cn, tag, update, request, smClient);
+ deploy(writer, config, cn, tag, update, request, smClient);
} else {
writer.println(smClient.getString("managerServlet.unknownCommand",
command));
@@ -727,6 +728,7 @@ public class ManagerServlet extends Http
* at the specified context path.
*
* @param writer Writer to render results to
+ * @param config URL of the context configuration file to be installed
* @param cn Name of the application to be installed
* @param tag Tag to be associated with the webapp
* @param update Flag that indicates that any existing app should be
@@ -735,12 +737,21 @@ public class ManagerServlet extends Http
* @param smClient i18n messages using the locale of the client
*/
protected synchronized void deploy
- (PrintWriter writer, ContextName cn,
+ (PrintWriter writer, String config, ContextName cn,
String tag, boolean update, HttpServletRequest request,
StringManager smClient) {
+ if (config != null && config.length() == 0) {
+ config = null;
+ }
+
if (debug >= 1) {
- log("deploy: Deploying web application '" + cn + "'");
+ if (config == null) {
+ log("deploy: Deploying web application '" + cn + "'");
+ } else {
+ log("deploy: Deploying web application '" + cn + "' " +
+ "with context configuration at '" + config + "'");
+ }
}
// Validate the requested context path
@@ -760,6 +771,10 @@ public class ManagerServlet extends Http
return;
}
+ if (config != null && (config.startsWith("file:"))) {
+ config = config.substring("file:".length());
+ }
+
File deployedWar = new File(host.getAppBaseFile(), baseName + ".war");
// Determine full path for uploaded WAR
@@ -796,6 +811,18 @@ public class ManagerServlet extends Http
} else {
addServiced(name);
try {
+ if (config != null) {
+ if (!configBase.mkdirs() && !configBase.isDirectory()) {
+ writer.println(smClient.getString(
+ "managerServlet.mkdirFail",configBase));
+ return;
+ }
+ if (copy(new File(config),
+ new File(configBase, baseName + ".xml")) == false) {
+ throw new Exception("Could not copy config file from path '" +
+ config + "'");
+ }
+ }
// Upload WAR
uploadWar(writer, request, uploadedWar, smClient);
if (update && tag == null) {
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1846662&r1=1846661&r2=1846662&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Nov 15 15:03:58 2018
@@ -126,6 +126,15 @@
</update>
</changelog>
</subsection>
+ <subsection name="Web applications">
+ <changelog>
+ <add>
+ <bug>53553</bug>: Add the ability to specify a context.xml from the
+ server to use when uploading a web application for deployment with the
+ Manager web application. Patch provided by Anton Lindström. (markt)
+ </add>
+ </changelog>
+ </subsection>
<subsection name="Tribes">
<changelog>
<update>
Modified: tomcat/trunk/webapps/docs/manager-howto.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/manager-howto.xml?rev=1846662&r1=1846661&r2=1846662&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/manager-howto.xml (original)
+++ tomcat/trunk/webapps/docs/manager-howto.xml Thu Nov 15 15:03:58 2018
@@ -337,6 +337,10 @@ including a Context configuration XML fi
<li><code>tag</code>: Specifying a tag name, this allows associating the
deployed webapp with a tag or label. If the web application is undeployed,
it can be later redeployed when needed using only the tag.</li>
+<li><code>config </code>: URL of a Context configuration ".xml" file in the
+ format <strong>file:/absolute/path/to/a/context.xml</strong>. This must be
+ the absolute path of a web application Context configuration ".xml" file
+ which contains the Context configuration element.</li>
</ul>
<p><strong>NOTE</strong> - This command is the logical
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org