Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -re2e6d944af7b0cea6c9c34e77bd0644149526c37 -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision e2e6d944af7b0cea6c9c34e77bd0644149526c37) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -36,6 +36,10 @@ ..\..\..\..\packages\EntityFramework.6.1.3\lib\net40\EntityFramework.dll True + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + @@ -249,6 +253,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/BackedUpFileWriter.cs =================================================================== diff -u -r1803a3e6fa50608dd2498ad746126400253cdec5 -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/src/Application.Ringtoets.Storage/BackedUpFileWriter.cs (.../BackedUpFileWriter.cs) (revision 1803a3e6fa50608dd2498ad746126400253cdec5) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/BackedUpFileWriter.cs (.../BackedUpFileWriter.cs) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -21,6 +21,8 @@ using System; using System.IO; + +using Application.Ringtoets.Storage.Exceptions; using Application.Ringtoets.Storage.Properties; using Core.Common.Utils; @@ -61,9 +63,9 @@ /// The temporary file already exists and cannot be deleted. /// The temporary file cannot be created from the target file. /// When reverting, the original file cannot be restored. - /// When cleaning up, the temporary file cannot be removed. /// /// + /// When cleaning up, the temporary file cannot be removed. /// Any thrown by will be rethrown. public void Perform(Action writeAction) { @@ -84,7 +86,7 @@ /// /// Removes the temporary file if it was created. /// - /// The temporary file cannot be removed. + /// The temporary file cannot be removed. private void Finish() { if (isTemporaryFileCreated) @@ -209,7 +211,7 @@ /// /// Deletes the created temporary file. /// - /// The temporary file cannot be removed. + /// The temporary file cannot be removed. private void DeleteTemporaryFile() { try @@ -223,7 +225,7 @@ var message = string.Format( Resources.SafeOverwriteFileHelper_DeleteTemporaryFile_Cannot_remove_temporary_FilePath_0_Try_removing_manually, temporaryFilePath); - throw new IOException(message, e); + throw new CannotDeleteBackupFileException(message, e); } throw; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Exceptions/CannotDeleteBackupFileException.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Exceptions/CannotDeleteBackupFileException.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Exceptions/CannotDeleteBackupFileException.cs (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -0,0 +1,53 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +namespace Application.Ringtoets.Storage.Exceptions +{ + /// + /// The exception that is thrown when the original file cannot be restored by . + /// + public class CannotDeleteBackupFileException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public CannotDeleteBackupFileException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The error message that explains the reason for the exception. + public CannotDeleteBackupFileException(string message) : base(message) {} + + /// + /// Initializes a new instance of the class + /// with a specified error message and a reference to the inner exception that is + /// the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, + /// or a null reference if no inner exception is specified. + public CannotDeleteBackupFileException(string message, Exception inner) : base(message, inner) { } + } +} \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs =================================================================== diff -u -re2e6d944af7b0cea6c9c34e77bd0644149526c37 -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision e2e6d944af7b0cea6c9c34e77bd0644149526c37) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -34,6 +34,9 @@ using Core.Common.Base.Storage; using Core.Common.Utils; using Core.Common.Utils.Builders; + +using log4net; + using Ringtoets.Integration.Data; using UtilsResources = Core.Common.Utils.Properties.Resources; @@ -44,6 +47,8 @@ /// public class StorageSqLite : IStoreProject { + private static ILog log = LogManager.GetLogger(typeof(StorageSqLite)); + private string connectionString; public string FileFilter @@ -90,6 +95,10 @@ { throw new StorageException(e.Message, e); } + catch (CannotDeleteBackupFileException e) + { + log.Warn(e.Message); + } } /// @@ -134,7 +143,7 @@ /// Attempts to load the from the SQLite database. /// /// Path to database file. - /// Returns a new instance of with the data from the database or null when not found. + /// Returns a new instance of with the data from the database or null when not found. /// is invalid. /// Thrown when /// Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -re2e6d944af7b0cea6c9c34e77bd0644149526c37 -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision e2e6d944af7b0cea6c9c34e77bd0644149526c37) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -47,6 +47,10 @@ ..\..\..\..\packages\Fluent.Ribbon.3.4.0\lib\net40\Fluent.dll True + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + ..\..\..\..\packages\Fluent.Ribbon.3.4.0\lib\net40\Microsoft.Windows.Shell.dll True @@ -145,6 +149,7 @@ + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/BackedUpFileWriterTest.cs =================================================================== diff -u -r915779f7cc008eb27b22811020a7dd0e5d004435 -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/BackedUpFileWriterTest.cs (.../BackedUpFileWriterTest.cs) (revision 915779f7cc008eb27b22811020a7dd0e5d004435) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/BackedUpFileWriterTest.cs (.../BackedUpFileWriterTest.cs) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -23,6 +23,9 @@ using System.IO; using System.Security.AccessControl; using System.Security.Principal; + +using Application.Ringtoets.Storage.Exceptions; + using NUnit.Framework; namespace Application.Ringtoets.Storage.Test @@ -263,7 +266,7 @@ var expectedMessage = string.Format( "Kan het tijdelijke bestand ({0}) niet opruimen. Het tijdelijke bestand dient handmatig verwijderd te worden.", temporaryFilePath); - var message = Assert.Throws(test).Message; + var message = Assert.Throws(test).Message; Assert.AreEqual(expectedMessage, message); } finally Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/CannotDeleteBackupFileExceptionTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/CannotDeleteBackupFileExceptionTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Exceptions/CannotDeleteBackupFileExceptionTest.cs (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -0,0 +1,79 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +using Application.Ringtoets.Storage.Exceptions; + +using NUnit.Framework; + +namespace Application.Ringtoets.Storage.Test.Exceptions +{ + [TestFixture] + public class CannotDeleteBackupFileExceptionTest + { + [Test] + public void DefaultConstructor_InnerExceptionNullAndMessageDefault() + { + // Setup + string expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(EntityNotFoundException).FullName); + + // Call + var exception = new CannotDeleteBackupFileException(); + + // Assert + Assert.IsInstanceOf(exception); + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom() + { + // Setup + const string expectedMessage = "Some exception message"; + + // Call + var exception = new CannotDeleteBackupFileException(expectedMessage); + + // Assert + Assert.IsInstanceOf(exception); + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom() + { + // Setup + const string expectedMessage = "Some exception message"; + Exception expectedInnerException = new Exception(); + + // Call + var exception = new CannotDeleteBackupFileException(expectedMessage, expectedInnerException); + + // Assert + Assert.IsInstanceOf(exception); + Assert.AreSame(expectedInnerException, exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/packages.config =================================================================== diff -u -r91f159bc90faf3c55a62ae1441e9ff2bc6fd180b -rbdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/packages.config (.../packages.config) (revision 91f159bc90faf3c55a62ae1441e9ff2bc6fd180b) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/packages.config (.../packages.config) (revision bdc1bbd84aa923749a80dfb0cf20f5bbcb54b3fc) @@ -2,6 +2,7 @@ +