LoadFileBatchValidator
using Castle.Core;
using kCura.WinEDDS;
using kCura.WinEDDS.Exporters;
using Relativity.DataExchange.Export.VolumeManagerV2.Metadata.Paths;
using Relativity.DataExchange.Io;
using Relativity.DataExchange.Logger;
using Relativity.Logging;
using System.Threading;
namespace Relativity.DataExchange.Export.VolumeManagerV2.Batches
{
public class LoadFileBatchValidator : IBatchValidator
{
private readonly IDestinationPath _destinationPath;
private readonly IFile _fileWrapper;
private readonly IStatus _status;
private readonly ILog _logger;
public LoadFileBatchValidator(LoadFileDestinationPath destinationPath, IFile fileWrapper, IStatus status, ILog logger)
: this((IDestinationPath)destinationPath, fileWrapper, status, logger)
{
}
[DoNotSelect]
public LoadFileBatchValidator(IDestinationPath destinationPath, IFile fileWrapper, IStatus status, ILog logger)
{
_destinationPath = destinationPath;
_fileWrapper = fileWrapper;
_status = status;
_logger = logger;
}
public void ValidateExportedBatch(ObjectExportInfo[] artifacts, CancellationToken cancellationToken)
{
if (!_fileWrapper.Exists(_destinationPath.Path)) {
_logger.LogError("Load file {file} is missing.", new object[1] {
_destinationPath.Path.Secure()
});
_status.WriteError("Load file " + _destinationPath.Path + " is missing.");
} else if (_fileWrapper.GetFileSize(_destinationPath.Path) == 0) {
_logger.LogError("Load file {file} is empty.", new object[1] {
_destinationPath.Path.Secure()
});
_status.WriteError("Load file " + _destinationPath.Path + " is empty.");
}
}
}
}