String exportDir = outputDirectory;
exportDir =
( ( null != exportDir && exportDir.length() > 0 ) ? exportDir : fileSet.getBasedir().getAbsolutePath() );
// Let the user know where we're going to be exporting the files...
getLogger().info( "Attempting to export files to " + exportDir );
ExportScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try
{
// Lets set our overall export success flag
boolean exportSuccess = true;
// Perform a fresh checkout of each file in the member list...
List<Member> projectMembers = iRepo.getProject().listFiles( exportDir );
// Initialize the list of files we actually exported...
List<ScmFile> scmFileList = new ArrayList<ScmFile>();
for ( Iterator<Member> it = projectMembers.iterator(); it.hasNext(); )
{
Member siMember = it.next();
try
{
getLogger().info( "Attempting to export file: " + siMember.getTargetFilePath() + " at revision "
+ siMember.getRevision() );
siMember.checkout( iRepo.getAPISession() );
scmFileList.add( new ScmFile( siMember.getTargetFilePath(), ScmFileStatus.UNKNOWN ) );
}
catch ( APIException ae )
{
exportSuccess = false;
ExceptionHandler eh = new ExceptionHandler( ae );
getLogger().error( "MKS API Exception: " + eh.getMessage() );
getLogger().debug( eh.getCommand() + " exited with return code " + eh.getExitCode() );
}
}
// Lets advice the user that we've checked out all the members
getLogger().info(
"Exported " + scmFileList.size() + " files out of a total of " + projectMembers.size() + " files!" );
if ( exportSuccess )
{
result = new ExportScmResult( "si co", scmFileList );
}
else
{
result = new ExportScmResult( "si co", "Failed to export all files!", "", exportSuccess );
}
}
catch ( APIException aex )
{
ExceptionHandler eh = new ExceptionHandler( aex );
getLogger().error( "MKS API Exception: " + eh.getMessage() );
getLogger().debug( eh.getCommand() + " exited with return code " + eh.getExitCode() );
result = new ExportScmResult( eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false );
}
return result;
}