KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > iplanet > DeployTask


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package org.apache.tools.ant.taskdefs.optional.iplanet;
25
26 import org.apache.tools.ant.Project;
27 import org.apache.tools.ant.BuildException;
28
29 import java.io.File JavaDoc;
30
31 public class DeployTask extends ComponentAdmin {
32     private static final String JavaDoc DEPLOY_COMMAND = "deploy";
33
34     protected void checkComponentConfig(Component comp) throws BuildException {
35         super.checkComponentConfig(comp);
36
37         // file must exist (either directory or file)
38
File JavaDoc theFile = comp.getFile();
39         if ((theFile == null) || (!theFile.exists())) {
40             String JavaDoc msg = "The file specified (" + theFile + ") could not be found.";
41             throw new BuildException(msg, getLocation());
42         }
43
44         // contextroot only makes sense when deploying web components
45
String JavaDoc theType = comp.getType();
46         if ((theType != null) && (!theType.equals(TYPE_WEB)) && (comp.contextRootIsSet())) {
47             String JavaDoc msg = "The \"contextroot\" attribute doesn't apply to "
48                             + comp.getType() + " files -- it only applies to war files.";
49             log(msg, Project.MSG_WARN);
50         }
51     }
52
53     protected String JavaDoc getCommandString(Server server, Component comp) {
54         StringBuffer JavaDoc cmdString = new StringBuffer JavaDoc(DEPLOY_COMMAND);
55         cmdString.append(server.getCommandParameters(true));
56         if (comp.getType() != null) {
57             cmdString.append(" --type ").append(comp.getType());
58             if (comp.getType().equals(TYPE_WEB)) {
59                 cmdString.append(" --contextroot ").append(comp.getContextroot());
60             }
61         }
62
63         cmdString.append(" --force=").append(comp.getForce());
64         cmdString.append(" --name ").append(comp.getName());
65         cmdString.append(" --upload=").append(comp.getUpload());
66         cmdString.append(" ").append(comp.getFile().getPath());
67
68         return cmdString.toString();
69     }
70 }
Popular Tags