001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.maven.scm.command.checkout;
020
021import java.util.List;
022
023import org.apache.maven.scm.ScmFile;
024import org.apache.maven.scm.ScmResult;
025
026/**
027 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
028 * @author Olivier Lamy
029 */
030public class CheckOutScmResult extends ScmResult {
031
032    private static final long serialVersionUID = 3345964619749320210L;
033
034    private List<ScmFile> checkedOutFiles;
035
036    /**
037     * @since 1.8
038     */
039    private String revision;
040
041    /**
042     * The relative path of the directory of the checked out project in comparison to the checkout directory, or
043     * an empty String in case the checkout directory equals the project directory.
044     * <p>
045     * With most SCMs, this is just an empty String, meaning that the checkout directory equals the project directory.
046     * But there are cases where within the checkout directory, the directory structure of the
047     * SCM system is repeated. E.g. if you check out the project "my/project" to "/some/dir", the project sources
048     * are actually checked out to "my/project/some/dir". In this example, relativePathProjectDirectory would
049     * contain "my/project".
050     */
051    protected String relativePathProjectDirectory = "";
052
053    public CheckOutScmResult(String commandLine, String providerMessage, String commandOutput, boolean success) {
054        super(commandLine, providerMessage, commandOutput, success);
055    }
056
057    public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles) {
058        this(commandLine, null, checkedOutFiles);
059    }
060
061    public CheckOutScmResult(String commandLine, String revision, List<ScmFile> checkedOutFiles) {
062        super(commandLine, null, null, true);
063
064        this.revision = revision;
065
066        this.checkedOutFiles = checkedOutFiles;
067    }
068
069    public CheckOutScmResult(String commandLine, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
070        this(commandLine, null, checkedOutFiles);
071        if (relativePathProjectDirectory != null) {
072            this.relativePathProjectDirectory = relativePathProjectDirectory;
073        }
074    }
075
076    public CheckOutScmResult(
077            String commandLine, String revision, List<ScmFile> checkedOutFiles, String relativePathProjectDirectory) {
078        this(commandLine, revision, checkedOutFiles);
079        if (relativePathProjectDirectory != null) {
080            this.relativePathProjectDirectory = relativePathProjectDirectory;
081        }
082    }
083
084    public CheckOutScmResult(List<ScmFile> checkedOutFiles, ScmResult result) {
085        super(result);
086
087        this.checkedOutFiles = checkedOutFiles;
088    }
089
090    public List<ScmFile> getCheckedOutFiles() {
091        return checkedOutFiles;
092    }
093
094    /**
095     * @return the contents of {@link #relativePathProjectDirectory}
096     * @see #relativePathProjectDirectory
097     */
098    public String getRelativePathProjectDirectory() {
099        return relativePathProjectDirectory;
100    }
101
102    /**
103     * Checked-out revision.
104     * SCM's that have no revision per repository (or branch) should store <code>null</code> here.
105     *
106     * @return the revision that was checked out
107     * @since 1.8
108     */
109    public String getRevision() {
110        return revision;
111    }
112}