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