Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2006-2013 smartics, Kronseder & Reiner GmbH
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.redhat.rcm.maven.plugin.buildmetadata.scm.maven;
 
 import java.io.File;
 import java.util.List;
 
 
Provides access information to retrieve revision information from the SCM.

Author(s):
Robert Reiner
Version:
$Revision:591 $
 
 public final class ScmAccessInfo implements Serializable
 {
   // ********************************* Fields *********************************
 
   // --- constants ------------------------------------------------------------
 
  
The class version identifier.

The value of this constant is .

 
   private static final long serialVersionUID = 1L;

  
The number of retries to fetch the change log if the first attempt failed to return a non empty set.

The value of this constant is .

 
   public static final int DEFAULT_RETRY_COUNT = 5;
 
   // --- members --------------------------------------------------------------
 
  
The format of the dates understood by the SCM system.
 
   private String dateFormat;

  
The root directory that contains the files under SCM control.
 
   private File rootDirectory;

  
The range of the query in days to fetch change log entries from the SCM. If no change logs have been found, the range is incremented up to DEFAULT_RETRY_COUNT times. If no change log has been found after these DEFAULT_RETRY_COUNT additional queries, the revision number will not be set with a valid value.
 
   private int queryRangeInDays;

  
The flag to fail if local modifications have been found. The value is true if the build should fail if there are modifications (any files not in-sync with the remote repository), false if the fact is only to be noted in the build properties.
 
   private boolean failOnLocalModifications;

  
The flag to ignore files and directories starting with a dot for checking modified files. This implicates that any files or directories, starting with a dot, are ignored when the check on changed files is run. If the value is true, dot files are ignored, if it is set to false, dot files are respected.
 
   private boolean ignoreDotFilesInBaseDir;
 
   // ****************************** Initializer *******************************
 
  // ****************************** Constructors ******************************

  
Default constructor.
  public ScmAccessInfo()
  {
  }
  // ****************************** Inner Classes *****************************
  // ********************************* Methods ********************************
  // --- init -----------------------------------------------------------------
  // --- get&set --------------------------------------------------------------

  
Returns the format of the dates understood by the SCM system.

Returns:
the format of the dates understood by the SCM system.
  public String getDateFormat()
  {
    return ;
  }

  
Sets the format of the dates understood by the SCM system.

Parameters:
dateFormat the format of the dates understood by the SCM system.
  public void setDateFormat(final String dateFormat)
  {
    this. = dateFormat;
  }

  
Returns the root directory that contains the files under SCM control.

Returns:
the root directory that contains the files under SCM control.
  public File getRootDirectory()
  {
    return ;
  }

  
Sets the root directory that contains the files under SCM control.

Parameters:
rootDirectory the root directory that contains the files under SCM control.
  public void setRootDirectory(final File rootDirectory)
  {
    this. = rootDirectory;
  }

  
Returns the range of the query in days to fetch change log entries from the SCM. If no change logs have been found, the range is incremented up to DEFAULT_RETRY_COUNT times. If no change log has been found after these DEFAULT_RETRY_COUNT additional queries, the revision number will not be set with a valid value.

Returns:
the range of the query in days to fetch change log entries from the SCM.
  public int getQueryRangeInDays()
  {
    return ;
  }

  
Sets the range of the query in days to fetch change log entries from the SCM. If no change logs have been found, the range is incremented up to DEFAULT_RETRY_COUNT times. If no change log has been found after these DEFAULT_RETRY_COUNT additional queries, the revision number will not be set with a valid value.

Parameters:
queryRangeInDays the range of the query in days to fetch change log entries from the SCM.
  public void setQueryRangeInDays(final int queryRangeInDays)
  {
    this. = queryRangeInDays;
  }

  
Returns the flag to fail if local modifications have been found. The value is true if the build should fail if there are modifications (any files not in-sync with the remote repository), false if the fact is only to be noted in the build properties.

Returns:
the flag to fail if local modifications have been found.
  public boolean isFailOnLocalModifications()
  {
  }

  
Sets the flag to fail if local modifications have been found. The value is true if the build should fail if there are modifications (any files not in-sync with the remote repository), false if the fact is only to be noted in the build properties.

Parameters:
failOnLocalModifications the flag to fail if local modifications have been found.
  public void setFailOnLocalModifications(final boolean failOnLocalModifications)
  {
    this. = failOnLocalModifications;
  }

  
Returns the flag to ignore files and directories starting with a dot for checking modified files. This implicates that any files or directories, starting with a dot, are ignored when the check on changed files is run. If the value is true, dot files are ignored, if it is set to false, dot files are respected.

Returns:
the flag to ignore files and directories starting with a dot for checking modified files.
  public boolean isIgnoreDotFilesInBaseDir()
  {
  }

  
Sets the flag to ignore files and directories starting with a dot for checking modified files. This implicates that any files or directories, starting with a dot, are ignored when the check on changed files is run. If the value is true, dot files are ignored, if it is set to false, dot files are respected.

Parameters:
ignoreDotFilesInBaseDir the flag to ignore files and directories starting with a dot for checking modified files.
  public void setIgnoreDotFilesInBaseDir(final boolean ignoreDotFilesInBaseDir)
  {
    this. = ignoreDotFilesInBaseDir;
  }
  // --- business -------------------------------------------------------------

  
Returns the result of the change log query.

Parameters:
repository the repository to fetch the change log information from.
provider the provider to use to access the repository.
Returns:
the change log entries that match the query, null if none have been found.
Throws:
com.redhat.rcm.maven.plugin.buildmetadata.scm.ScmException if the change log cannot be fetched.
  public ChangeLogScmResult fetchChangeLog(final ScmRepository repository,
      final ScmProvider providerthrows ScmException
  {
    try
    {
      ChangeLogScmResult result = null;
      int currentRange = ;
      for (int i = 0; i <= i++)
      {
        result =
            provider.changeLog(repositorycreateFileSet(), nullnull,
                currentRange, (ScmBranchnull);
        if (!isEmpty(result))
        {
          return result;
        }
        currentRange += ;
      }
      return result;
    }
    catch (final org.apache.maven.scm.ScmException e)
    {
      throw new ScmException("Cannot fetch change log from repository."e);
    }
  }

  
Checks if the given result contains change logs or not.

Calls isEmpty(org.apache.maven.scm.command.changelog.ChangeLogSet) with argument list (<changeLogSet>).

Parameters:
result result the result to be checked.
Returns:
true if change logs have been found,false if any reference up the path to the change logs is null or the set is empty.
See also:
isEmpty(org.apache.maven.scm.command.changelog.ChangeLogSet)
  private boolean isEmpty(final ChangeLogScmResult result)
  {
    if (result != null)
    {
      final ChangeLogSet changeLogSet = result.getChangeLog();
      if (changeLogSet != null)
      {
        return isEmpty(changeLogSet);
      }
    }
    return false;
  }
  private boolean isEmpty(final ChangeLogSet changeLogSet)
  {
    final List<?> changeLogSets = changeLogSet.getChangeSets();
    if (changeLogSets != null)
    {
      return changeLogSets.isEmpty();
    }
    return false;
  }

  
Creates the file set on the root directory of the checked out project.

Returns:
the file set on the root directory of the checked out project.
  protected ScmFileSet createFileSet()
  {
    return new ScmFileSet();
  }

  
Checks whether the SCM configuration calls for a failure due to changed files.

Returns:
true if a fail is indicated (i.e. there are locally modified files that are to be considered for a check), false if there are none.
  public boolean isFailIndicated()
  {
  }
  // --- object basics --------------------------------------------------------

  
  public String toString()
  {
    final StringBuilder buffer = new StringBuilder();
    buffer.append("SCM access info: rootDirectory=").append();
    appendIfExists(buffer"dateFormat");
    appendIfExists(buffer"queryRangeInDays", String.valueOf());
    appendIfExists(buffer"failOnLocalModifications",
        String.valueOf());
    appendIfExists(buffer"ignoreDotFilesInBaseDir",
        String.valueOf());
    return buffer.toString();
  }
  private static void appendIfExists(final StringBuilder buffer,
      final String labelfinal String value)
  {
    if (StringUtils.isNotBlank(value))
    {
      buffer.append(", ").append(label).append('=').append(value);
    }
  }
New to GrepCode? Check out our FAQ X