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. import org.apache.tools.ant.types.Commandline;
  19. /**
  20. * Retrieves a read-only copy of the specified project or file
  21. * from Visual SourceSafe via a SourceOffSite server.
  22. *
  23. *
  24. * @ant.task name="sosget" category="scm"
  25. */
  26. public class SOSGet extends SOS {
  27. /**
  28. * The Filename to act upon.
  29. * If no file is specified then the tasks
  30. * act upon the project.
  31. *
  32. * @param filename The new file value
  33. */
  34. public final void setFile(String filename) {
  35. super.setInternalFilename(filename);
  36. }
  37. /**
  38. * Flag to recursively apply the action. Defaults to false
  39. *
  40. * @param recursive True for recursive operation.
  41. */
  42. public void setRecursive(boolean recursive) {
  43. super.setInternalRecursive(recursive);
  44. }
  45. /**
  46. * Set the version number to get -
  47. * only works with SOSGet on a file.
  48. *
  49. * @param version The new version value
  50. */
  51. public void setVersion(String version) {
  52. super.setInternalVersion(version);
  53. }
  54. /**
  55. * The labeled version to operate on in SourceSafe.
  56. *
  57. * @param label The new label value
  58. */
  59. public void setLabel(String label) {
  60. super.setInternalLabel(label);
  61. }
  62. /**
  63. * Build the command line <br>
  64. *
  65. * GetFile required parameters: -server -name -password -database -project -file<br>
  66. * GetFile optional parameters: -workdir -revision -verbose -nocache -nocompression -soshome<br>
  67. *
  68. * GetProject required parameters: -server -name -password -database -project<br>
  69. * GetProject optional parameters: -label -workdir -recursive -verbose -nocache
  70. * -nocompression -soshome<br>
  71. *
  72. * @return Commandline the generated command to be executed
  73. */
  74. protected Commandline buildCmdLine() {
  75. commandLine = new Commandline();
  76. // If we find a "file" attribute then act on a file otherwise act on a project
  77. if (getFilename() != null) {
  78. // add -command GetFile to the commandline
  79. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
  80. commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_FILE);
  81. // add -file xxxxx to the commandline
  82. commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
  83. commandLine.createArgument().setValue(getFilename());
  84. // look for a version attribute
  85. if (getVersion() != null) {
  86. //add -revision xxxxx to the commandline
  87. commandLine.createArgument().setValue(SOSCmd.FLAG_VERSION);
  88. commandLine.createArgument().setValue(getVersion());
  89. }
  90. } else {
  91. // add -command GetProject to the commandline
  92. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
  93. commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_PROJECT);
  94. // look for a recursive option
  95. commandLine.createArgument().setValue(getRecursive());
  96. // look for a label option
  97. if (getLabel() != null) {
  98. commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL);
  99. commandLine.createArgument().setValue(getLabel());
  100. }
  101. }
  102. getRequiredAttributes();
  103. getOptionalAttributes();
  104. return commandLine;
  105. }
  106. }