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