View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.command.checkout;
20  
21  import java.util.List;
22  
23  import org.apache.maven.scm.ScmFile;
24  import org.apache.maven.scm.ScmResult;
25  
26  /**
27   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
28   * @author Olivier Lamy
29   *
30   */
31  public class CheckOutScmResult extends ScmResult {
32  
33      private static final long serialVersionUID = 3345964619749320210L;
34  
35      private List<ScmFile> checkedOutFiles;
36  
37      /**
38       * @since 1.8
39       */
40      private String revision;
41  
42      /**
43       * The relative path of the directory of the checked out project in comparison to the checkout directory, or
44       * an empty String in case the checkout directory equals the project directory.
45       * <p>
46       * With most SCMs, this is just an empty String, meaning that the checkout directory equals the project directory.
47       * But there are cases where within the checkout directory, the directory structure of the
48       * SCM system is repeated. E.g. if you check out the project "my/project" to "/some/dir", the project sources
49       * are actually checked out to "my/project/some/dir". In this example, relativePathProjectDirectory would
50       * contain "my/project".
51       */
52      protected String relativePathProjectDirectory = "";
53  
54      public CheckOutScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
55          super(commandLine, providerMessage, commandOutput, success);
56      }
57  
58      public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles) {
59          this(commandLine, null, checkedOutFiles);
60      }
61  
62      public CheckOutScmResult(String commandLine, String revision, List<ScmFile> checkedOutFiles) {
63          super(commandLine, null, null, true);
64  
65          this.revision = revision;
66  
67          this.checkedOutFiles = checkedOutFiles;
68      }
69  
70      public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
71          this(commandLine, null, checkedOutFiles);
72          if (relativePathProjectDirectory != null) {
73              this.relativePathProjectDirectory = relativePathProjectDirectory;
74          }
75      }
76  
77      public CheckOutScmResult(
78              String commandLine, String revision, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
79          this(commandLine, revision, checkedOutFiles);
80          if (relativePathProjectDirectory != null) {
81              this.relativePathProjectDirectory = relativePathProjectDirectory;
82          }
83      }
84  
85      public CheckOutScmResult(List<ScmFile> checkedOutFiles, ScmResult result) {
86          super(result);
87  
88          this.checkedOutFiles = checkedOutFiles;
89      }
90  
91      public List<ScmFile> getCheckedOutFiles() {
92          return checkedOutFiles;
93      }
94  
95      /**
96       * @return the contents of {@link #relativePathProjectDirectory}
97       * @see #relativePathProjectDirectory
98       */
99      public String getRelativePathProjectDirectory() {
100         return relativePathProjectDirectory;
101     }
102 
103     /**
104      * Checked-out revision.
105      * SCM's that have no revision per repository (or branch) should store <code>null</code> here.
106      *
107      * @return the revision that was checked out.
108      * @since 1.8
109      */
110     public String getRevision() {
111         return revision;
112     }
113 }