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: * Retrieves a read-only copy of the specified project or file
024: * from Visual SourceSafe via a SourceOffSite server.
025: *
026: * @ant.task name="sosget" category="scm"
027: */
028: public class SOSGet extends SOS {
029:
030: /**
031: * The Filename to act upon.
032: * If no file is specified then the tasks
033: * act upon the project.
034: *
035: * @param filename The new file value
036: */
037: public final void setFile(String filename) {
038: super .setInternalFilename(filename);
039: }
040:
041: /**
042: * Flag to recursively apply the action. Defaults to false
043: *
044: * @param recursive True for recursive operation.
045: */
046: public void setRecursive(boolean recursive) {
047: super .setInternalRecursive(recursive);
048: }
049:
050: /**
051: * Set the version number to get -
052: * only works with SOSGet on a file.
053: *
054: * @param version The new version value
055: */
056: public void setVersion(String version) {
057: super .setInternalVersion(version);
058: }
059:
060: /**
061: * The labeled version to operate on in SourceSafe.
062: *
063: * @param label The new label value
064: */
065: public void setLabel(String label) {
066: super .setInternalLabel(label);
067: }
068:
069: /**
070: * Build the command line <br>
071: *
072: * GetFile required parameters: -server -name -password -database -project -file<br>
073: * GetFile optional parameters: -workdir -revision -verbose -nocache -nocompression -soshome<br>
074: *
075: * GetProject required parameters: -server -name -password -database -project<br>
076: * GetProject optional parameters: -label -workdir -recursive -verbose -nocache
077: * -nocompression -soshome<br>
078: *
079: * @return Commandline the generated command to be executed
080: */
081: protected Commandline buildCmdLine() {
082: commandLine = new Commandline();
083:
084: // If we find a "file" attribute then act on a file otherwise act on a project
085: if (getFilename() != null) {
086: // add -command GetFile to the commandline
087: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
088: commandLine.createArgument().setValue(
089: SOSCmd.COMMAND_GET_FILE);
090: // add -file xxxxx to the commandline
091: commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
092: commandLine.createArgument().setValue(getFilename());
093: // look for a version attribute
094: if (getVersion() != null) {
095: //add -revision xxxxx to the commandline
096: commandLine.createArgument().setValue(
097: SOSCmd.FLAG_VERSION);
098: commandLine.createArgument().setValue(getVersion());
099: }
100: } else {
101: // add -command GetProject to the commandline
102: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
103: commandLine.createArgument().setValue(
104: SOSCmd.COMMAND_GET_PROJECT);
105: // look for a recursive option
106: commandLine.createArgument().setValue(getRecursive());
107: // look for a label option
108: if (getLabel() != null) {
109: commandLine.createArgument()
110: .setValue(SOSCmd.FLAG_LABEL);
111: commandLine.createArgument().setValue(getLabel());
112: }
113: }
114:
115: getRequiredAttributes();
116: getOptionalAttributes();
117:
118: return commandLine;
119: }
120: }
|