KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > sos > SOSGet


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 package org.apache.tools.ant.taskdefs.optional.sos;
19
20 import org.apache.tools.ant.types.Commandline;
21
22 /**
23  * Retrieves a read-only copy of the specified project or file
24  * from Visual SourceSafe via a SourceOffSite server.
25  *
26  * @ant.task name="sosget" category="scm"
27  */

28 public class SOSGet extends SOS {
29
30     /**
31      * The Filename to act upon.
32      * If no file is specified then the tasks
33      * act upon the project.
34      *
35      * @param filename The new file value
36      */

37     public final void setFile(String JavaDoc filename) {
38         super.setInternalFilename(filename);
39     }
40
41     /**
42      * Flag to recursively apply the action. Defaults to false
43      *
44      * @param recursive True for recursive operation.
45      */

46     public void setRecursive(boolean recursive) {
47         super.setInternalRecursive(recursive);
48     }
49
50     /**
51      * Set the version number to get -
52      * only works with SOSGet on a file.
53      *
54      * @param version The new version value
55      */

56     public void setVersion(String JavaDoc version) {
57         super.setInternalVersion(version);
58     }
59
60     /**
61      * The labeled version to operate on in SourceSafe.
62      *
63      * @param label The new label value
64      */

65     public void setLabel(String JavaDoc label) {
66         super.setInternalLabel(label);
67     }
68
69     /**
70      * Build the command line <br>
71      *
72      * GetFile required parameters: -server -name -password -database -project -file<br>
73      * GetFile optional parameters: -workdir -revision -verbose -nocache -nocompression -soshome<br>
74      *
75      * GetProject required parameters: -server -name -password -database -project<br>
76      * GetProject optional parameters: -label -workdir -recursive -verbose -nocache
77      * -nocompression -soshome<br>
78      *
79      * @return Commandline the generated command to be executed
80      */

81     protected Commandline buildCmdLine() {
82         commandLine = new Commandline();
83
84         // If we find a "file" attribute then act on a file otherwise act on a project
85
if (getFilename() != null) {
86             // add -command GetFile to the commandline
87
commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
88             commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_FILE);
89             // add -file xxxxx to the commandline
90
commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
91             commandLine.createArgument().setValue(getFilename());
92             // look for a version attribute
93
if (getVersion() != null) {
94                 //add -revision xxxxx to the commandline
95
commandLine.createArgument().setValue(SOSCmd.FLAG_VERSION);
96                 commandLine.createArgument().setValue(getVersion());
97             }
98         } else {
99             // add -command GetProject to the commandline
100
commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
101             commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_PROJECT);
102             // look for a recursive option
103
commandLine.createArgument().setValue(getRecursive());
104             // look for a label option
105
if (getLabel() != null) {
106                 commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL);
107                 commandLine.createArgument().setValue(getLabel());
108             }
109         }
110
111         getRequiredAttributes();
112         getOptionalAttributes();
113
114         return commandLine;
115     }
116 }
117
Popular Tags