View | Details | Raw Unified | Return to bug 51251
Collapse All | Expand All

(-)java/org/apache/catalina/ant/StopTask.java (-36 / +3 lines)
Lines 19-27 Link Here
19
package org.apache.catalina.ant;
19
package org.apache.catalina.ant;
20
20
21
21
22
import java.io.UnsupportedEncodingException;
23
import java.net.URLEncoder;
24
25
import org.apache.tools.ant.BuildException;
22
import org.apache.tools.ant.BuildException;
26
23
27
24
Lines 33-62 Link Here
33
 * @version $Id$
30
 * @version $Id$
34
 * @since 4.1
31
 * @since 4.1
35
 */
32
 */
36
public class StopTask extends AbstractCatalinaTask {
33
public class StopTask extends AbstractCatalinaCommandTask {
37
34
38
39
    // ------------------------------------------------------------- Properties
40
41
42
    /**
35
    /**
43
     * The context path of the web application we are managing.
44
     */
45
    protected String path = null;
46
47
    public String getPath() {
48
        return (this.path);
49
    }
50
51
    public void setPath(String path) {
52
        this.path = path;
53
    }
54
55
56
    // --------------------------------------------------------- Public Methods
57
58
59
    /**
60
     * Execute the requested operation.
36
     * Execute the requested operation.
61
     *
37
     *
62
     * @exception BuildException if an error occurs
38
     * @exception BuildException if an error occurs
Lines 65-82 Link Here
65
    public void execute() throws BuildException {
41
    public void execute() throws BuildException {
66
42
67
        super.execute();
43
        super.execute();
68
        if (path == null) {
44
        execute(createQueryString("/stop").toString());
69
            throw new BuildException
70
                ("Must specify 'path' attribute");
71
        }
72
        try {
73
            execute("/stop?path=" + URLEncoder.encode(this.path, getCharset()));
74
        } catch (UnsupportedEncodingException e) {
75
            throw new BuildException
76
                ("Invalid 'charset' attribute: " + getCharset());
77
        }
78
45
79
    }
46
    }
80
47
81
48
    
82
}
49
}
(-)java/org/apache/catalina/ant/StartTask.java (-35 / +2 lines)
Lines 19-27 Link Here
19
package org.apache.catalina.ant;
19
package org.apache.catalina.ant;
20
20
21
21
22
import java.io.UnsupportedEncodingException;
23
import java.net.URLEncoder;
24
25
import org.apache.tools.ant.BuildException;
22
import org.apache.tools.ant.BuildException;
26
23
27
24
Lines 33-62 Link Here
33
 * @version $Id$
30
 * @version $Id$
34
 * @since 4.1
31
 * @since 4.1
35
 */
32
 */
36
public class StartTask extends AbstractCatalinaTask {
33
public class StartTask extends AbstractCatalinaCommandTask {
37
34
38
39
    // ------------------------------------------------------------- Properties
40
41
42
    /**
35
    /**
43
     * The context path of the web application we are managing.
44
     */
45
    protected String path = null;
46
47
    public String getPath() {
48
        return (this.path);
49
    }
50
51
    public void setPath(String path) {
52
        this.path = path;
53
    }
54
55
56
    // --------------------------------------------------------- Public Methods
57
58
59
    /**
60
     * Execute the requested operation.
36
     * Execute the requested operation.
61
     *
37
     *
62
     * @exception BuildException if an error occurs
38
     * @exception BuildException if an error occurs
Lines 65-80 Link Here
65
    public void execute() throws BuildException {
41
    public void execute() throws BuildException {
66
42
67
        super.execute();
43
        super.execute();
68
        if (path == null) {
44
        execute(createQueryString("/start").toString());
69
            throw new BuildException
70
                ("Must specify 'path' attribute");
71
        }
72
        try {
73
            execute("/start?path=" + URLEncoder.encode(this.path, getCharset()));
74
        } catch (UnsupportedEncodingException e) {
75
            throw new BuildException
76
                ("Invalid 'charset' attribute: " + getCharset());
77
        }
78
45
79
    }
46
    }
80
47
(-)java/org/apache/catalina/ant/UndeployTask.java (-35 / +2 lines)
Lines 19-27 Link Here
19
package org.apache.catalina.ant;
19
package org.apache.catalina.ant;
20
20
21
21
22
import java.io.UnsupportedEncodingException;
23
import java.net.URLEncoder;
24
25
import org.apache.tools.ant.BuildException;
22
import org.apache.tools.ant.BuildException;
26
23
27
24
Lines 33-61 Link Here
33
 * @version $Id$
30
 * @version $Id$
34
 * @since 4.1
31
 * @since 4.1
35
 */
32
 */
36
public class UndeployTask extends AbstractCatalinaTask {
33
public class UndeployTask extends AbstractCatalinaCommandTask {
37
34
38
39
    // ------------------------------------------------------------- Properties
40
41
    /**
35
    /**
42
     * The context path of the web application we are managing.
43
     */
44
    protected String path = null;
45
46
    public String getPath() {
47
        return (this.path);
48
    }
49
50
    public void setPath(String path) {
51
        this.path = path;
52
    }
53
54
55
    // --------------------------------------------------------- Public Methods
56
57
58
    /**
59
     * Execute the requested operation.
36
     * Execute the requested operation.
60
     *
37
     *
61
     * @exception BuildException if an error occurs
38
     * @exception BuildException if an error occurs
Lines 64-81 Link Here
64
    public void execute() throws BuildException {
41
    public void execute() throws BuildException {
65
42
66
        super.execute();
43
        super.execute();
67
        if (path == null) {
44
        execute(createQueryString("/undeploy").toString());
68
            throw new BuildException
69
                ("Must specify 'path' attribute");
70
        }
71
45
72
        try {
73
            execute("/undeploy?path=" +
74
                    URLEncoder.encode(this.path, getCharset()));
75
        } catch (UnsupportedEncodingException e) {
76
            throw new BuildException
77
                ("Invalid 'charset' attribute: " + getCharset());
78
        }
79
    }
46
    }
80
47
81
48
(-)java/org/apache/catalina/ant/AbstractCatalinaCommandTask.java (+84 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 * 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 * 
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
19
package org.apache.catalina.ant;
20
21
import java.io.UnsupportedEncodingException;
22
import java.net.URLEncoder;
23
24
import org.apache.tools.ant.BuildException;
25
26
public abstract class AbstractCatalinaCommandTask extends
27
        AbstractCatalinaTask {
28
29
    /**
30
     * The context path of the web application we are managing.
31
     */
32
    protected String path = null;
33
34
    public String getPath() {
35
        return (this.path);
36
    }
37
38
    public void setPath(String path) {
39
        this.path = path;
40
    }
41
42
    /**
43
     * The context version of the web application we are managing.
44
     */
45
    protected String version = null;
46
47
    public String getVersion() {
48
        return (this.version);
49
    }
50
51
    public void setVersion(String version) {
52
        this.version = version;
53
    }
54
    
55
    // --------------------------------------------------------- Public Methods
56
57
    /**
58
     * Create query string for the specified command.
59
     * 
60
     * @param command Command to be executed
61
     *
62
     * @exception BuildException if an error occurs
63
     */
64
    public StringBuilder createQueryString(String command) throws BuildException {
65
        StringBuilder buffer = new StringBuilder();
66
67
        try {
68
            buffer.append(command);
69
            if (this.path != null) {
70
                buffer.append("?path=");
71
                buffer.append(URLEncoder.encode(this.path, getCharset()));
72
                if (this.version != null) {
73
                    buffer.append("&version=");
74
                    buffer.append(URLEncoder.encode(this.version, getCharset()));
75
                }
76
            }
77
        } catch (UnsupportedEncodingException e) {
78
            throw new BuildException
79
                ("Invalid 'charset' attribute: " + getCharset());
80
        }
81
        return buffer;
82
    }
83
84
}
(-)java/org/apache/catalina/ant/SessionsTask.java (-29 / +20 lines)
Lines 19-27 Link Here
19
package org.apache.catalina.ant;
19
package org.apache.catalina.ant;
20
20
21
21
22
import java.io.UnsupportedEncodingException;
23
import java.net.URLEncoder;
24
25
import org.apache.tools.ant.BuildException;
22
import org.apache.tools.ant.BuildException;
26
23
27
24
Lines 32-56 Link Here
32
 * @author Vivek Chopra
29
 * @author Vivek Chopra
33
 * @version $Revision$
30
 * @version $Revision$
34
 */
31
 */
35
public class SessionsTask extends AbstractCatalinaTask {
32
public class SessionsTask extends AbstractCatalinaCommandTask {
36
33
37
    // Properties
38
34
39
    /**
35
    protected String idle = null;
40
     * The context path of the web application we are managing.
36
    
41
     */
37
    public String getIdle() {
42
    protected String path = null;
38
        return this.idle;
43
44
    public String getPath() {
45
        return (this.path);
46
    }
39
    }
47
40
    
48
    public void setPath(String path) {
41
    public void setIdle(String idle) {
49
        this.path = path;
42
        this.idle = idle;
50
    }
43
    }
51
44
    
52
    // Public Methods
45
    @Override
53
46
    public StringBuilder createQueryString(String command) {
47
        StringBuilder buffer = super.createQueryString(command);
48
        if (path != null && idle != null) {
49
            buffer.append("&idle=");
50
            buffer.append(this.idle);
51
        }
52
        return buffer;
53
    }
54
    
54
    /**
55
    /**
55
     * Execute the requested operation.
56
     * Execute the requested operation.
56
     *
57
     *
Lines 60-77 Link Here
60
    public void execute() throws BuildException {
61
    public void execute() throws BuildException {
61
62
62
        super.execute();
63
        super.execute();
63
        if (path == null) {
64
        execute(createQueryString("/sessions").toString());
64
            throw new BuildException
65
                ("Must specify 'path' attribute");
66
        }
67
        
65
        
68
        try {
69
            execute("/sessions?path=" + URLEncoder.encode(this.path, getCharset()));
70
        } catch (UnsupportedEncodingException e) {
71
            throw new BuildException
72
                ("Invalid 'charset' attribute: " + getCharset());
73
        }
74
        
75
    }
66
    }
76
67
77
}
68
}
(-)java/org/apache/catalina/ant/ReloadTask.java (-35 / +2 lines)
Lines 19-26 Link Here
19
package org.apache.catalina.ant;
19
package org.apache.catalina.ant;
20
20
21
21
22
import java.io.UnsupportedEncodingException;
23
import java.net.URLEncoder;
24
22
25
import org.apache.tools.ant.BuildException;
23
import org.apache.tools.ant.BuildException;
26
24
Lines 33-62 Link Here
33
 * @version $Id$
31
 * @version $Id$
34
 * @since 4.1
32
 * @since 4.1
35
 */
33
 */
36
public class ReloadTask extends AbstractCatalinaTask {
34
public class ReloadTask extends AbstractCatalinaCommandTask {
37
35
38
39
    // ------------------------------------------------------------- Properties
40
41
42
    /**
36
    /**
43
     * The context path of the web application we are managing.
44
     */
45
    protected String path = null;
46
47
    public String getPath() {
48
        return (this.path);
49
    }
50
51
    public void setPath(String path) {
52
        this.path = path;
53
    }
54
55
56
    // --------------------------------------------------------- Public Methods
57
58
59
    /**
60
     * Execute the requested operation.
37
     * Execute the requested operation.
61
     *
38
     *
62
     * @exception BuildException if an error occurs
39
     * @exception BuildException if an error occurs
Lines 65-82 Link Here
65
    public void execute() throws BuildException {
42
    public void execute() throws BuildException {
66
43
67
        super.execute();
44
        super.execute();
68
        if (path == null) {
45
        execute(createQueryString("/reload").toString());
69
            throw new BuildException
70
                ("Must specify 'path' attribute");
71
        }
72
        try {
73
            execute("/reload?path=" + URLEncoder.encode(this.path, getCharset()));
74
        } catch (UnsupportedEncodingException e) {
75
            throw new BuildException
76
                ("Invalid 'charset' attribute: " + getCharset());
77
        }
78
46
79
80
    }
47
    }
81
48

Return to bug 51251