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 and locks files in Visual SourceSafe via a SourceOffSite server.
  21. *
  22. *
  23. * @ant.task name="soscheckout" category="scm"
  24. */
  25. public class SOSCheckout extends SOS {
  26. /**
  27. * The filename to act upon.
  28. * If no file is specified then the task
  29. * acts upon the project.
  30. *
  31. * @param filename The new file value
  32. */
  33. public final void setFile(String filename) {
  34. super.setInternalFilename(filename);
  35. }
  36. /**
  37. * Flag to recursively apply the action. Defaults to false.
  38. *
  39. * @param recursive True for recursive operation.
  40. */
  41. public void setRecursive(boolean recursive) {
  42. super.setInternalRecursive(recursive);
  43. }
  44. /**
  45. * Build the command line <br>
  46. *
  47. * CheckOutFile required parameters: -server -name -password -database -project -file<br>
  48. * CheckOutFile optional parameters: -workdir -verbose -nocache -nocompression -soshome<br>
  49. *
  50. * CheckOutProject required parameters: -server -name -password -database -project<br>
  51. * CheckOutProject optional parameters:-workdir -recursive -verbose -nocache
  52. * -nocompression -soshome<br>
  53. *
  54. * @return Commandline the generated command to be executed
  55. */
  56. protected Commandline buildCmdLine() {
  57. commandLine = new Commandline();
  58. // If we find a "file" attribute then act on a file otherwise act on a project
  59. if (getFilename() != null) {
  60. // add -command CheckOutFile to the commandline
  61. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
  62. commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_FILE);
  63. // add -file xxxxx to the commandline
  64. commandLine.createArgument().setValue(SOSCmd.FLAG_FILE);
  65. commandLine.createArgument().setValue(getFilename());
  66. } else {
  67. // add -command CheckOutProject to the commandline
  68. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
  69. commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_PROJECT);
  70. // look for a recursive option
  71. commandLine.createArgument().setValue(getRecursive());
  72. }
  73. getRequiredAttributes();
  74. getOptionalAttributes();
  75. return commandLine;
  76. }
  77. }