1 18 19 package org.apache.tools.ant.taskdefs.optional.clearcase; 20 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.taskdefs.Execute; 24 import org.apache.tools.ant.types.Commandline; 25 26 30 31 70 public class CCUnlock extends ClearCase { 71 private String mComment = null; 72 private String mPname = null; 73 74 81 public void execute() throws BuildException { 82 Commandline commandLine = new Commandline(); 83 Project aProj = getProject(); 84 int result = 0; 85 86 if (getViewPath() == null) { 88 setViewPath(aProj.getBaseDir().getPath()); 89 } 90 91 commandLine.setExecutable(getClearToolCommand()); 95 commandLine.createArgument().setValue(COMMAND_UNLOCK); 96 97 checkOptions(commandLine); 99 100 103 if (!getFailOnErr()) { 104 getProject().log("Ignoring any errors that occur for: " 105 + getOpType(), Project.MSG_VERBOSE); 106 } 107 result = run(commandLine); 108 if (Execute.isFailure(result) && getFailOnErr()) { 109 String msg = "Failed executing: " + commandLine.toString(); 110 throw new BuildException(msg, getLocation()); 111 } 112 } 113 114 117 private void checkOptions(Commandline cmd) { 118 getCommentCommand(cmd); 120 121 if (getObjSelect() == null && getPname() == null) { 122 throw new BuildException("Should select either an element " 123 + "(pname) or an object (objselect)"); 124 } 125 getPnameCommand(cmd); 126 if (getObjSelect() != null) { 128 cmd.createArgument().setValue(getObjSelect()); 129 } 130 } 131 132 138 public void setComment(String comment) { 139 mComment = comment; 140 } 141 142 147 public String getComment() { 148 return mComment; 149 } 150 151 156 public void setPname(String pname) { 157 mPname = pname; 158 } 159 160 165 public String getPname() { 166 return mPname; 167 } 168 169 174 public void setObjselect(String objselect) { 175 setObjSelect(objselect); 176 } 177 178 184 public void setObjSel(String objsel) { 185 setObjSelect(objsel); 186 } 187 188 193 public String getObjselect() { 194 return getObjSelect(); 195 } 196 197 203 private void getCommentCommand(Commandline cmd) { 204 if (getComment() == null) { 205 return; 206 } else { 207 212 cmd.createArgument().setValue(FLAG_COMMENT); 213 cmd.createArgument().setValue(getComment()); 214 } 215 } 216 217 223 private void getPnameCommand(Commandline cmd) { 224 if (getPname() == null) { 225 return; 226 } else { 227 232 cmd.createArgument().setValue(FLAG_PNAME); 233 cmd.createArgument().setValue(getPname()); 234 } 235 } 236 237 242 private String getOpType() { 243 244 if (getPname() != null) { 245 return getPname(); 246 } else { 247 return getObjSelect(); 248 } 249 } 250 251 254 public static final String FLAG_COMMENT = "-comment"; 255 258 public static final String FLAG_PNAME = "-pname"; 259 } 260 261 | Popular Tags |