001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.ant;
019:
020: import java.net.URLEncoder;
021:
022: import org.apache.tools.ant.BuildException;
023:
024: /**
025: * Ant task that implements the <code>/install</code> command, supported by the
026: * Tomcat manager application.
027: *
028: * @author Craig R. McClanahan
029: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
030: * @since 4.1
031: * @deprecated Replaced by DeployTask
032: */
033: public class InstallTask extends AbstractCatalinaTask {
034:
035: // ------------------------------------------------------------- Properties
036:
037: /**
038: * URL of the context configuration file for this application, if any.
039: */
040: protected String config = null;
041:
042: public String getConfig() {
043: return (this .config);
044: }
045:
046: public void setConfig(String config) {
047: this .config = config;
048: }
049:
050: /**
051: * The context path of the web application we are managing.
052: */
053: protected String path = null;
054:
055: public String getPath() {
056: return (this .path);
057: }
058:
059: public void setPath(String path) {
060: this .path = path;
061: }
062:
063: /**
064: * URL of the web application archive (WAR) file, or the unpacked directory
065: * containing this application, if any.
066: */
067: protected String war = null;
068:
069: public String getWar() {
070: return (this .war);
071: }
072:
073: public void setWar(String war) {
074: this .war = war;
075: }
076:
077: // --------------------------------------------------------- Public Methods
078:
079: /**
080: * Execute the requested operation.
081: *
082: * @exception BuildException if an error occurs
083: */
084: public void execute() throws BuildException {
085:
086: super .execute();
087: if (path == null) {
088: throw new BuildException("Must specify 'path' attribute");
089: }
090: if ((config == null) && (war == null)) {
091: throw new BuildException(
092: "Must specify at least one of 'config' and 'war'");
093: }
094: StringBuffer sb = new StringBuffer("/install?path=");
095: sb.append(URLEncoder.encode(this .path));
096: if (config != null) {
097: sb.append("&config=");
098: sb.append(URLEncoder.encode(config));
099: }
100: if (war != null) {
101: sb.append("&war=");
102: sb.append(URLEncoder.encode(war));
103: }
104: execute(sb.toString());
105:
106: }
107:
108: }
|