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.tools.ant.taskdefs.optional.sos;
019:
020: import org.apache.tools.ant.types.Commandline;
021:
022: /**
023: * Commits and unlocks files in Visual SourceSafe via a SourceOffSite server.
024: *
025: * @ant.task name="soscheckin" category="scm"
026: */
027: public class SOSCheckin extends SOS {
028:
029: /**
030: * The filename to act upon.
031: * If no file is specified then the task
032: * acts upon the project.
033: *
034: * @param filename The new file value
035: */
036: public final void setFile(String filename) {
037: super .setInternalFilename(filename);
038: }
039:
040: /**
041: * Flag to recursively apply the action. Defaults to false.
042: *
043: * @param recursive True for recursive operation.
044: */
045: public void setRecursive(boolean recursive) {
046: super .setInternalRecursive(recursive);
047: }
048:
049: /**
050: * The comment to apply to all files being labelled.
051: *
052: * @param comment The new comment value
053: */
054: public void setComment(String comment) {
055: super .setInternalComment(comment);
056: }
057:
058: /**
059: * Build the command line. <p>
060: *
061: * CheckInFile required parameters: -server -name -password -database -project
062: * -file<br>
063: * CheckInFile optional parameters: -workdir -log -verbose -nocache -nocompression
064: * -soshome<br>
065: * CheckInProject required parameters: -server -name -password -database
066: * -project<br>
067: * CheckInProject optional parameters: workdir -recursive -log -verbose
068: * -nocache -nocompression -soshome<br>
069: *
070: * @return Commandline the generated command to be executed
071: */
072: protected Commandline buildCmdLine() {
073: commandLine = new Commandline();
074:
075: // If we find a "file" attribute then act on a file otherwise act on a project
076: if (getFilename() != null) {
077: // add -command CheckInFile to the commandline
078: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
079: commandLine.createArgument().setValue(
080: SOSCmd.COMMAND_CHECKIN_FILE);
081: // add -file xxxxx to the commandline
082: commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
083: commandLine.createArgument().setValue(getFilename());
084: } else {
085: // add -command CheckInProject to the commandline
086: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
087: commandLine.createArgument().setValue(
088: SOSCmd.COMMAND_CHECKIN_PROJECT);
089: // look for a recursive option
090: commandLine.createArgument().setValue(getRecursive());
091: }
092:
093: getRequiredAttributes();
094: getOptionalAttributes();
095:
096: // Look for a comment
097: if (getComment() != null) {
098: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT);
099: commandLine.createArgument().setValue(getComment());
100: }
101: return commandLine;
102: }
103: }
|