Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C99D960B6 for ; Fri, 3 Jun 2011 22:23:01 +0000 (UTC) Received: (qmail 75169 invoked by uid 500); 3 Jun 2011 22:23:01 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 75109 invoked by uid 500); 3 Jun 2011 22:23:01 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 75100 invoked by uid 99); 3 Jun 2011 22:23:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jun 2011 22:23:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jun 2011 22:22:57 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ABB3A23889ED; Fri, 3 Jun 2011 22:22:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1131267 - in /tomcat/trunk: java/org/apache/catalina/ant/ webapps/docs/ Date: Fri, 03 Jun 2011 22:22:35 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110603222235.ABB3A23889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Fri Jun 3 22:22:35 2011 New Revision: 1131267 URL: http://svn.apache.org/viewvc?rev=1131267&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51251 Add web application version support to the Ant tasks. Based on a patch provided by Eiji Takahashi. Added: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java (with props) Modified: tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java tomcat/trunk/java/org/apache/catalina/ant/StartTask.java tomcat/trunk/java/org/apache/catalina/ant/StopTask.java tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java tomcat/trunk/webapps/docs/changelog.xml Added: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java?rev=1131267&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java (added) +++ tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java Fri Jun 3 22:22:35 2011 @@ -0,0 +1,84 @@ +/* + * 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.catalina.ant; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +import org.apache.tools.ant.BuildException; + +public abstract class AbstractCatalinaCommandTask extends + AbstractCatalinaTask { + + /** + * The context path of the web application we are managing. + */ + protected String path = null; + + public String getPath() { + return (this.path); + } + + public void setPath(String path) { + this.path = path; + } + + /** + * The context version of the web application we are managing. + */ + protected String version = null; + + public String getVersion() { + return (this.version); + } + + public void setVersion(String version) { + this.version = version; + } + + // --------------------------------------------------------- Public Methods + + /** + * Create query string for the specified command. + * + * @param command Command to be executed + * + * @exception BuildException if an error occurs + */ + public StringBuilder createQueryString(String command) throws BuildException { + StringBuilder buffer = new StringBuilder(); + + try { + buffer.append(command); + if (path == null) { + throw new BuildException("Must specify 'path' attribute"); + } else { + buffer.append("?path="); + buffer.append(URLEncoder.encode(this.path, getCharset())); + if (this.version != null) { + buffer.append("&version="); + buffer.append(URLEncoder.encode(this.version, getCharset())); + } + } + } catch (UnsupportedEncodingException e) { + throw new BuildException + ("Invalid 'charset' attribute: " + getCharset()); + } + return buffer; + } + +} \ No newline at end of file Propchange: tomcat/trunk/java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java (original) +++ tomcat/trunk/java/org/apache/catalina/ant/ReloadTask.java Fri Jun 3 22:22:35 2011 @@ -19,8 +19,6 @@ package org.apache.catalina.ant; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; import org.apache.tools.ant.BuildException; @@ -33,28 +31,7 @@ import org.apache.tools.ant.BuildExcepti * @version $Id$ * @since 4.1 */ -public class ReloadTask extends AbstractCatalinaTask { - - - // ------------------------------------------------------------- Properties - - - /** - * The context path of the web application we are managing. - */ - protected String path = null; - - public String getPath() { - return (this.path); - } - - public void setPath(String path) { - this.path = path; - } - - - // --------------------------------------------------------- Public Methods - +public class ReloadTask extends AbstractCatalinaCommandTask { /** * Execute the requested operation. @@ -65,17 +42,7 @@ public class ReloadTask extends Abstract public void execute() throws BuildException { super.execute(); - if (path == null) { - throw new BuildException - ("Must specify 'path' attribute"); - } - try { - execute("/reload?path=" + URLEncoder.encode(this.path, getCharset())); - } catch (UnsupportedEncodingException e) { - throw new BuildException - ("Invalid 'charset' attribute: " + getCharset()); - } - + execute(createQueryString("/reload").toString()); } Modified: tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java (original) +++ tomcat/trunk/java/org/apache/catalina/ant/SessionsTask.java Fri Jun 3 22:22:35 2011 @@ -19,9 +19,6 @@ package org.apache.catalina.ant; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - import org.apache.tools.ant.BuildException; @@ -32,25 +29,29 @@ import org.apache.tools.ant.BuildExcepti * @author Vivek Chopra * @version $Revision$ */ -public class SessionsTask extends AbstractCatalinaTask { - - // Properties +public class SessionsTask extends AbstractCatalinaCommandTask { - /** - * The context path of the web application we are managing. - */ - protected String path = null; - public String getPath() { - return (this.path); + protected String idle = null; + + public String getIdle() { + return this.idle; } - - public void setPath(String path) { - this.path = path; + + public void setIdle(String idle) { + this.idle = idle; } - - // Public Methods - + + @Override + public StringBuilder createQueryString(String command) { + StringBuilder buffer = super.createQueryString(command); + if (path != null && idle != null) { + buffer.append("&idle="); + buffer.append(this.idle); + } + return buffer; + } + /** * Execute the requested operation. * @@ -60,17 +61,7 @@ public class SessionsTask extends Abstra public void execute() throws BuildException { super.execute(); - if (path == null) { - throw new BuildException - ("Must specify 'path' attribute"); - } - - try { - execute("/sessions?path=" + URLEncoder.encode(this.path, getCharset())); - } catch (UnsupportedEncodingException e) { - throw new BuildException - ("Invalid 'charset' attribute: " + getCharset()); - } + execute(createQueryString("/sessions").toString()); } Modified: tomcat/trunk/java/org/apache/catalina/ant/StartTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/StartTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/StartTask.java (original) +++ tomcat/trunk/java/org/apache/catalina/ant/StartTask.java Fri Jun 3 22:22:35 2011 @@ -19,9 +19,6 @@ package org.apache.catalina.ant; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - import org.apache.tools.ant.BuildException; @@ -33,28 +30,7 @@ import org.apache.tools.ant.BuildExcepti * @version $Id$ * @since 4.1 */ -public class StartTask extends AbstractCatalinaTask { - - - // ------------------------------------------------------------- Properties - - - /** - * The context path of the web application we are managing. - */ - protected String path = null; - - public String getPath() { - return (this.path); - } - - public void setPath(String path) { - this.path = path; - } - - - // --------------------------------------------------------- Public Methods - +public class StartTask extends AbstractCatalinaCommandTask { /** * Execute the requested operation. @@ -65,16 +41,7 @@ public class StartTask extends AbstractC public void execute() throws BuildException { super.execute(); - if (path == null) { - throw new BuildException - ("Must specify 'path' attribute"); - } - try { - execute("/start?path=" + URLEncoder.encode(this.path, getCharset())); - } catch (UnsupportedEncodingException e) { - throw new BuildException - ("Invalid 'charset' attribute: " + getCharset()); - } + execute(createQueryString("/start").toString()); } Modified: tomcat/trunk/java/org/apache/catalina/ant/StopTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/StopTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/StopTask.java (original) +++ tomcat/trunk/java/org/apache/catalina/ant/StopTask.java Fri Jun 3 22:22:35 2011 @@ -19,9 +19,6 @@ package org.apache.catalina.ant; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - import org.apache.tools.ant.BuildException; @@ -33,28 +30,7 @@ import org.apache.tools.ant.BuildExcepti * @version $Id$ * @since 4.1 */ -public class StopTask extends AbstractCatalinaTask { - - - // ------------------------------------------------------------- Properties - - - /** - * The context path of the web application we are managing. - */ - protected String path = null; - - public String getPath() { - return (this.path); - } - - public void setPath(String path) { - this.path = path; - } - - - // --------------------------------------------------------- Public Methods - +public class StopTask extends AbstractCatalinaCommandTask { /** * Execute the requested operation. @@ -65,18 +41,9 @@ public class StopTask extends AbstractCa public void execute() throws BuildException { super.execute(); - if (path == null) { - throw new BuildException - ("Must specify 'path' attribute"); - } - try { - execute("/stop?path=" + URLEncoder.encode(this.path, getCharset())); - } catch (UnsupportedEncodingException e) { - throw new BuildException - ("Invalid 'charset' attribute: " + getCharset()); - } + execute(createQueryString("/stop").toString()); } - + } Modified: tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java (original) +++ tomcat/trunk/java/org/apache/catalina/ant/UndeployTask.java Fri Jun 3 22:22:35 2011 @@ -19,9 +19,6 @@ package org.apache.catalina.ant; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - import org.apache.tools.ant.BuildException; @@ -33,27 +30,7 @@ import org.apache.tools.ant.BuildExcepti * @version $Id$ * @since 4.1 */ -public class UndeployTask extends AbstractCatalinaTask { - - - // ------------------------------------------------------------- Properties - - /** - * The context path of the web application we are managing. - */ - protected String path = null; - - public String getPath() { - return (this.path); - } - - public void setPath(String path) { - this.path = path; - } - - - // --------------------------------------------------------- Public Methods - +public class UndeployTask extends AbstractCatalinaCommandTask { /** * Execute the requested operation. @@ -64,18 +41,8 @@ public class UndeployTask extends Abstra public void execute() throws BuildException { super.execute(); - if (path == null) { - throw new BuildException - ("Must specify 'path' attribute"); - } - - try { - execute("/undeploy?path=" + - URLEncoder.encode(this.path, getCharset())); - } catch (UnsupportedEncodingException e) { - throw new BuildException - ("Invalid 'charset' attribute: " + getCharset()); - } + execute(createQueryString("/undeploy").toString()); + } Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1131267&r1=1131266&r2=1131267&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jun 3 22:22:35 2011 @@ -147,6 +147,10 @@ Patch provided by Eiji Takahashi. (markt) + 51251: Add web application version support to the Ant tasks. + Based on a patch provided by Eiji Takahashi. (markt) + + 51294: Clarify behaviour of unpackWAR attribute of StandardContext components. (markt) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org