1 | /*
|
---|
2 | * Copyright 2002-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | package org.apache.tools.ant.taskdefs.optional.sos;
|
---|
18 |
|
---|
19 | import org.apache.tools.ant.types.Commandline;
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Retrieves a read-only copy of the specified project or file
|
---|
23 | * from Visual SourceSafe via a SourceOffSite server.
|
---|
24 | *
|
---|
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 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 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 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 | }
|
---|