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.BuildException;
  19. import org.apache.tools.ant.types.Commandline;
  20. /**
  21. * Labels Visual SourceSafe files via a SourceOffSite server.
  22. *
  23. *
  24. * @ant.task name="soslabel" category="scm"
  25. */
  26. public class SOSLabel extends SOS {
  27. /**
  28. * The version number to label.
  29. *
  30. * @param version The new version value
  31. */
  32. public void setVersion(String version) {
  33. super.setInternalVersion(version);
  34. }
  35. /**
  36. * The label to apply the the files in SourceSafe.
  37. *
  38. * @param label The new label value
  39. *
  40. * @ant.attribute group="required"
  41. */
  42. public void setLabel(String label) {
  43. super.setInternalLabel(label);
  44. }
  45. /**
  46. * The comment to apply to all files being labelled.
  47. *
  48. * @param comment The new comment value
  49. */
  50. public void setComment(String comment) {
  51. super.setInternalComment(comment);
  52. }
  53. /**
  54. * Build the command line <br>
  55. * AddLabel required parameters: -server -name -password -database -project -label<br>
  56. * AddLabel optional parameters: -verbose -comment<br>
  57. *
  58. * @return Commandline the generated command to be executed
  59. */
  60. protected Commandline buildCmdLine() {
  61. commandLine = new Commandline();
  62. // add -command AddLabel to the commandline
  63. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
  64. commandLine.createArgument().setValue(SOSCmd.COMMAND_LABEL);
  65. getRequiredAttributes();
  66. // a label is required
  67. if (getLabel() == null) {
  68. throw new BuildException("label attribute must be set!", getLocation());
  69. }
  70. commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL);
  71. commandLine.createArgument().setValue(getLabel());
  72. // -verbose
  73. commandLine.createArgument().setValue(getVerbose());
  74. // Look for a comment
  75. if (getComment() != null) {
  76. commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT);
  77. commandLine.createArgument().setValue(getComment());
  78. }
  79. return commandLine;
  80. }
  81. }