diff --git a/CDP4Common.NetCore.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs b/CDP4Common.NetCore.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs
new file mode 100644
index 00000000..a5a897e7
--- /dev/null
+++ b/CDP4Common.NetCore.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs
@@ -0,0 +1,135 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
+//
+// This file is part of CDP4-COMET-SDK Community Edition
+//
+// The CDP4-COMET-SDK Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// The CDP4-COMET-SDK Community Edition 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.Tests.Helpers
+{
+ using System;
+
+ using NUnit.Framework;
+
+ using ExceptionHandlerService;
+
+ ///
+ /// Suite of tests for the class.
+ ///
+ [TestFixture]
+ public class ExceptionHandlerServiceTestFixture
+ {
+ private Uri uri;
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.uri = new Uri("http://www.stariongroup.eu");
+ }
+
+ [Test]
+ public void Test_if_basic_handling_works_and_returns_false()
+ {
+ var testExceptionHandler = new TestExceptionHandler(false);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.False);
+ Assert.That(testExceptionHandler.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_if_basic_handling_works_and_returns_true()
+ {
+ var testExceptionHandler = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(true);
+ var testExceptionHandler2 = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true_when_at_least_one_returns_true_1()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(true);
+ var testExceptionHandler2 = new TestExceptionHandler(false);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true_when_at_least_one_returns_true_2()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(false);
+ var testExceptionHandler2 = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+ }
+
+ public class TestExceptionHandler : IExceptionHandler
+ {
+ private bool result = false;
+ public bool WasExecuted = false;
+
+ public TestExceptionHandler(bool result)
+ {
+ this.result = result;
+ }
+
+ public bool HandleException(Exception exception, params object[] payload)
+ {
+ this.WasExecuted = true;
+ return this.result;
+ }
+ }
+}
diff --git a/CDP4Common.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs b/CDP4Common.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs
new file mode 100644
index 00000000..a5a897e7
--- /dev/null
+++ b/CDP4Common.Tests/ExceptionHandlerService/ExceptionHandlerServiceTestFixture.cs
@@ -0,0 +1,135 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft
+//
+// This file is part of CDP4-COMET-SDK Community Edition
+//
+// The CDP4-COMET-SDK Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// The CDP4-COMET-SDK Community Edition 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.Tests.Helpers
+{
+ using System;
+
+ using NUnit.Framework;
+
+ using ExceptionHandlerService;
+
+ ///
+ /// Suite of tests for the class.
+ ///
+ [TestFixture]
+ public class ExceptionHandlerServiceTestFixture
+ {
+ private Uri uri;
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.uri = new Uri("http://www.stariongroup.eu");
+ }
+
+ [Test]
+ public void Test_if_basic_handling_works_and_returns_false()
+ {
+ var testExceptionHandler = new TestExceptionHandler(false);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.False);
+ Assert.That(testExceptionHandler.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_if_basic_handling_works_and_returns_true()
+ {
+ var testExceptionHandler = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(true);
+ var testExceptionHandler2 = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true_when_at_least_one_returns_true_1()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(true);
+ var testExceptionHandler2 = new TestExceptionHandler(false);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+
+ [Test]
+ public void Test_that_multiple_handlers_return_true_when_at_least_one_returns_true_2()
+ {
+ var testExceptionHandler1 = new TestExceptionHandler(false);
+ var testExceptionHandler2 = new TestExceptionHandler(true);
+ var exceptionHandlerService = new ExceptionHandlerService(new[] { testExceptionHandler1, testExceptionHandler2 });
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(exceptionHandlerService.HandleException(new Exception()), Is.True);
+ Assert.That(testExceptionHandler1.WasExecuted, Is.True);
+ Assert.That(testExceptionHandler2.WasExecuted, Is.True);
+ });
+ }
+ }
+
+ public class TestExceptionHandler : IExceptionHandler
+ {
+ private bool result = false;
+ public bool WasExecuted = false;
+
+ public TestExceptionHandler(bool result)
+ {
+ this.result = result;
+ }
+
+ public bool HandleException(Exception exception, params object[] payload)
+ {
+ this.WasExecuted = true;
+ return this.result;
+ }
+ }
+}
diff --git a/CDP4Common/CDP4Common.csproj b/CDP4Common/CDP4Common.csproj
index fa5b53c7..3230a363 100644
--- a/CDP4Common/CDP4Common.csproj
+++ b/CDP4Common/CDP4Common.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4Common Community Edition
- 27.0.2
+ 27.1.0
CDP4 Common Class Library that contains DTOs, POCOs
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [ADD] Extension method for human readable texts on IRuleVerification
+ [ADD] Implement ExceptionHandlerService
README.md
diff --git a/CDP4Common/ExceptionHandlerService/ExceptionHandlerService.cs b/CDP4Common/ExceptionHandlerService/ExceptionHandlerService.cs
new file mode 100644
index 00000000..ff4e5daf
--- /dev/null
+++ b/CDP4Common/ExceptionHandlerService/ExceptionHandlerService.cs
@@ -0,0 +1,85 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary
+//
+// This file is part of CDP4-COMET-IME Community Edition.
+// The CDP4-COMET-IME Community Edition is the Starion Concurrent Design Desktop Application and Excel Integration
+// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The CDP4-COMET-IME Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or any later version.
+//
+// The CDP4-COMET-IME Community Edition 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.ExceptionHandlerService
+{
+ using System;
+ using System.Collections.Generic;
+#if NETFRAMEWORK
+ using System.ComponentModel.Composition;
+#endif
+ using System.Linq;
+
+ ///
+ /// The purpose of the is to check server exceptions and start Application processes accordingly
+ ///
+
+#if NETFRAMEWORK
+ [Export(typeof(IExceptionHandlerService))]
+ [PartCreationPolicy(CreationPolicy.Shared)]
+#endif
+ public class ExceptionHandlerService : IExceptionHandlerService
+ {
+ ///
+ /// The collection of s
+ ///
+ private readonly List exceptionHandlers;
+
+ ///
+ /// Creates a new instance of the class
+ ///
+ /// INJECTED collection of s registered in the application.
+#if NETFRAMEWORK
+ [ImportingConstructor]
+ public ExceptionHandlerService([ImportMany] IEnumerable exceptionHandlers)
+ {
+ this.exceptionHandlers = exceptionHandlers.ToList();
+ }
+#else
+ public ExceptionHandlerService(IEnumerable exceptionHandlers)
+ {
+ this.exceptionHandlers = exceptionHandlers.ToList();
+ }
+#endif
+
+ ///
+ /// Handles a specific and enables the Application to start a process based on the ocntent or type of the
+ ///
+ /// The
+ ///
+ /// a boolean value indicating if the was handled or not, so it could be thrown again
+ public bool HandleException(Exception exception, params object[] payload)
+ {
+ var isHandled = false;
+
+ foreach (var exceptionHandler in this.exceptionHandlers)
+ {
+ isHandled = exceptionHandler.HandleException(exception, payload) || isHandled;
+ }
+
+ return isHandled;
+ }
+ }
+}
diff --git a/CDP4Common/ExceptionHandlerService/IExceptionHandler.cs b/CDP4Common/ExceptionHandlerService/IExceptionHandler.cs
new file mode 100644
index 00000000..5ccd1c02
--- /dev/null
+++ b/CDP4Common/ExceptionHandlerService/IExceptionHandler.cs
@@ -0,0 +1,43 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary
+//
+// This file is part of CDP4-COMET-IME Community Edition.
+// The CDP4-COMET-IME Community Edition is the Starion Concurrent Design Desktop Application and Excel Integration
+// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The CDP4-COMET-IME Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or any later version.
+//
+// The CDP4-COMET-IME Community Edition 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.ExceptionHandlerService
+{
+ using System;
+
+ ///
+ /// The purpose of the is to check exceptions and start Application processes accordingly
+ ///
+ public interface IExceptionHandler
+ {
+ ///
+ /// Handles a specific and enables the application to start a process based on the content or type of the
+ ///
+ /// The
+ /// A collection of objects that can be used for exception handling
+ /// a boolean value indicating if the was handled or not, so it could be thrown again
+ bool HandleException(Exception exception, params object[] payload);
+ }
+}
diff --git a/CDP4Common/ExceptionHandlerService/IExceptionHandlerService.cs b/CDP4Common/ExceptionHandlerService/IExceptionHandlerService.cs
new file mode 100644
index 00000000..8871bf7e
--- /dev/null
+++ b/CDP4Common/ExceptionHandlerService/IExceptionHandlerService.cs
@@ -0,0 +1,43 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary
+//
+// This file is part of CDP4-COMET-IME Community Edition.
+// The CDP4-COMET-IME Community Edition is the Starion Concurrent Design Desktop Application and Excel Integration
+// compliant with ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The CDP4-COMET-IME Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or any later version.
+//
+// The CDP4-COMET-IME Community Edition 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.ExceptionHandlerService
+{
+ using System;
+
+ ///
+ /// The purpose of the is to check server exceptions and start Application processes accordingly
+ ///
+ public interface IExceptionHandlerService
+ {
+ ///
+ /// Handles a specific and enables the application to start a process based on the content or type of the
+ ///
+ /// The
+ /// A collection of objects that can be used for exception handling
+ /// a boolean value indicating if the was handled or not, so it could be thrown again
+ bool HandleException(Exception exception, params object[] payload);
+ }
+}
diff --git a/CDP4Common/Exceptions/IHaveCDPErrorTag.cs b/CDP4Common/Exceptions/IHaveCDPErrorTag.cs
new file mode 100644
index 00000000..e7a6a2c6
--- /dev/null
+++ b/CDP4Common/Exceptions/IHaveCDPErrorTag.cs
@@ -0,0 +1,37 @@
+// -------------------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2015-2024 Starion Group S.A.
+//
+// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Jaime Bernar
+//
+// This file is part of CDP4-COMET SDK Community Edition
+//
+// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// The CDP4-COMET SDK Community Edition 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
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program; if not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// -------------------------------------------------------------------------------------------------------------------------------
+
+namespace CDP4Common.Exceptions
+{
+ ///
+ /// Defines the properties and methods of classes that implement the interface
+ ///
+ public interface IHaveCDPErrorTag
+ {
+ ///
+ /// Gets or sets the CDPErrorTag (error code), typically found in the CDPErrorTag header of a CDP4-COMET Webservice http response
+ ///
+ string CDPErrorTag { get; set; }
+ }
+}
diff --git a/CDP4Dal/CDP4Dal.csproj b/CDP4Dal/CDP4Dal.csproj
index cd67d2ac..aa896207 100644
--- a/CDP4Dal/CDP4Dal.csproj
+++ b/CDP4Dal/CDP4Dal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4Dal Community Edition
- 27.0.2
+ 27.1.0
CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed
@@ -20,7 +20,8 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
+ [ADD] Use ExceptionHandlerService in Session
README.md
diff --git a/CDP4Dal/Exceptions/DalWriteException.cs b/CDP4Dal/Exceptions/DalWriteException.cs
index 43cf057b..bc598661 100644
--- a/CDP4Dal/Exceptions/DalWriteException.cs
+++ b/CDP4Dal/Exceptions/DalWriteException.cs
@@ -27,13 +27,20 @@ namespace CDP4Dal.Exceptions
using System;
using System.Runtime.Serialization;
+ using CDP4Common.Exceptions;
+
///
/// A is thrown the when a during a Write operation the data-source
/// returns an exception
///
[Serializable]
- public class DalWriteException : Exception
+ public class DalWriteException : Exception, IHaveCDPErrorTag
{
+ ///
+ /// Gets or sets the CDPErrorTag (error code), typically found in the CDPErrorTag header of a CDP4-COMET Webservice http response
+ ///
+ public string CDPErrorTag { get; set; } = string.Empty;
+
///
/// Initializes a new instance of the class.
///
diff --git a/CDP4Dal/ISession.cs b/CDP4Dal/ISession.cs
index a6edd032..8f301402 100644
--- a/CDP4Dal/ISession.cs
+++ b/CDP4Dal/ISession.cs
@@ -31,6 +31,7 @@ namespace CDP4Dal
using CDP4Common;
using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
+ using CDP4Common.ExceptionHandlerService;
using CDP4Common.SiteDirectoryData;
using CDP4Dal.Operations;
@@ -98,6 +99,11 @@ public interface ISession
///
IPermissionService PermissionService { get; }
+ ///
+ /// The
+ ///
+ IExceptionHandlerService ExceptionHandlerService { get; }
+
///
/// Gets the uri of the connected data-source
///
diff --git a/CDP4Dal/Session.cs b/CDP4Dal/Session.cs
index 688bbbaf..b190e59c 100644
--- a/CDP4Dal/Session.cs
+++ b/CDP4Dal/Session.cs
@@ -37,6 +37,7 @@ namespace CDP4Dal
using CDP4Common;
using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
+ using CDP4Common.ExceptionHandlerService;
using CDP4Common.Exceptions;
using CDP4Common.Extensions;
using CDP4Common.SiteDirectoryData;
@@ -57,6 +58,11 @@ namespace CDP4Dal
///
public class Session : ISession
{
+ ///
+ /// The
+ ///
+ public IExceptionHandlerService ExceptionHandlerService { get; private set; }
+
///
/// Executes just before data from an is written to the datastore.
///
@@ -87,6 +93,24 @@ public class Session : ISession
///
private readonly Dictionary cometTasks = new Dictionary();
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// the associated that is used to communicate with the data-source
+ ///
+ ///
+ /// the associated to the
+ ///
+ ///
+ /// The instance of
+ ///
+ /// The instance of
+ public Session(IDal dal, Credentials credentials, ICDPMessageBus messageBus, IExceptionHandlerService exceptionHandlerService) : this(dal, credentials, messageBus)
+ {
+ this.ExceptionHandlerService = exceptionHandlerService;
+ }
+
///
/// Initializes a new instance of the class.
///
@@ -832,11 +856,22 @@ private async Task AfterReadOrWriteOrUpdate(IList things,
public async Task Write(OperationContainer operationContainer, IEnumerable files)
{
var filesList = this.BeforeDalWriteAndProcessFiles(operationContainer, files);
- var dtoThings = await this.Dal.Write(operationContainer, filesList);
- var enumerable = dtoThings as IList ?? dtoThings.ToList();
+ try
+ {
+ var dtoThings = await this.Dal.Write(operationContainer, filesList);
- await this.AfterReadOrWriteOrUpdate(enumerable);
+ var enumerable = dtoThings as IList ?? dtoThings.ToList();
+
+ await this.AfterReadOrWriteOrUpdate(enumerable);
+ }
+ catch (Exception ex)
+ {
+ if (!this.ExceptionHandlerService?.HandleException(ex, this, operationContainer, files) ?? true)
+ {
+ throw;
+ }
+ }
}
///
@@ -873,16 +908,28 @@ public Task Write(OperationContainer operationContainer)
public async Task Write(OperationContainer operationContainer, int waitTime, IEnumerable files = null)
{
var filesList = this.BeforeDalWriteAndProcessFiles(operationContainer, files);
- var longRunningTaskResult = await this.Dal.Write(operationContainer, waitTime, filesList);
-
- if (longRunningTaskResult.IsWaitTimeReached)
+
+ try
{
- this.cometTasks[longRunningTaskResult.Task.Id] = longRunningTaskResult.Task;
- return longRunningTaskResult.Task;
+ var longRunningTaskResult = await this.Dal.Write(operationContainer, waitTime, filesList);
+
+ if (longRunningTaskResult.IsWaitTimeReached)
+ {
+ this.cometTasks[longRunningTaskResult.Task.Id] = longRunningTaskResult.Task;
+ return longRunningTaskResult.Task;
+ }
+
+ var things = longRunningTaskResult.Things as IList ?? longRunningTaskResult.Things.ToList();
+ await this.AfterReadOrWriteOrUpdate(things);
+ }
+ catch (Exception ex)
+ {
+ if (!this.ExceptionHandlerService?.HandleException(ex, this, operationContainer, files) ?? true)
+ {
+ throw;
+ }
}
- var things = longRunningTaskResult.Things as IList ?? longRunningTaskResult.Things.ToList();
- await this.AfterReadOrWriteOrUpdate(things);
return null;
}
diff --git a/CDP4DalCommon/CDP4DalCommon.csproj b/CDP4DalCommon/CDP4DalCommon.csproj
index 77e60461..cf93b6e6 100644
--- a/CDP4DalCommon/CDP4DalCommon.csproj
+++ b/CDP4DalCommon/CDP4DalCommon.csproj
@@ -5,7 +5,7 @@
Starion Group S.A.
latest
CDP4DalCommon Community Edition
- 27.0.2
+ 27.1.0
CDP4 Common Class Library that contains common types for any CDP4 server and the CDP4Dal
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime
@@ -21,7 +21,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
true
diff --git a/CDP4JsonFileDal/CDP4JsonFileDal.csproj b/CDP4JsonFileDal/CDP4JsonFileDal.csproj
index 8524d4bb..3d6ae584 100644
--- a/CDP4JsonFileDal/CDP4JsonFileDal.csproj
+++ b/CDP4JsonFileDal/CDP4JsonFileDal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4JsonFileDal Community Edition
- 27.0.2
+ 27.1.0
CDP4 Json File Dal Plugin
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4JsonSerializer/CDP4JsonSerializer.csproj b/CDP4JsonSerializer/CDP4JsonSerializer.csproj
index 11b7b3dc..e65ade8c 100644
--- a/CDP4JsonSerializer/CDP4JsonSerializer.csproj
+++ b/CDP4JsonSerializer/CDP4JsonSerializer.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4JsonSerializer Community Edition
- 27.0.2
+ 27.1.0
CDP4 JSON Serialization Library
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25 JSON
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj b/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj
index 9234ba16..89e78825 100644
--- a/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj
+++ b/CDP4MessagePackSerializer/CDP4MessagePackSerializer.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4MessagePackSerializer Community Edition
- 27.0.2
+ 27.1.0
CDP4 MessagePack Serialization Library
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Nathanael, Antoine, Omar
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25 MessagePack
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4Reporting/CDP4Reporting.csproj b/CDP4Reporting/CDP4Reporting.csproj
index 80356da6..4ff092f1 100644
--- a/CDP4Reporting/CDP4Reporting.csproj
+++ b/CDP4Reporting/CDP4Reporting.csproj
@@ -4,7 +4,7 @@
netstandard2.0
Starion Group S.A.
CDP4Reporting Community Edition
- 27.0.2
+ 27.1.0
CDP4 Reporting
Copyright © Starion Group S.A.
Sam, Alex, Alexander
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
latest
README.md
diff --git a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj
index ccff5865..17de439c 100644
--- a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj
+++ b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4RequirementsVerification Community Edition
- 27.0.2
+ 27.1.0
CDP4 Class Library that provides requirement verification
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4Rules/CDP4Rules.csproj b/CDP4Rules/CDP4Rules.csproj
index bc3ee0cd..548b4ee7 100644
--- a/CDP4Rules/CDP4Rules.csproj
+++ b/CDP4Rules/CDP4Rules.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4Rules Community Edition
- 27.0.2
+ 27.1.0
CDP4 Class Library that provides Model Analysis and Rule Checking
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4ServicesDal/CDP4ServicesDal.csproj b/CDP4ServicesDal/CDP4ServicesDal.csproj
index 51775310..901f5ffd 100644
--- a/CDP4ServicesDal/CDP4ServicesDal.csproj
+++ b/CDP4ServicesDal/CDP4ServicesDal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4ServicesDal Community Edition
- 27.0.2
+ 27.1.0
CDP4ServicesDal Dal Plugin
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4ServicesDal/CdpServicesDal.cs b/CDP4ServicesDal/CdpServicesDal.cs
index 18bcb36e..d8ea454b 100644
--- a/CDP4ServicesDal/CdpServicesDal.cs
+++ b/CDP4ServicesDal/CdpServicesDal.cs
@@ -195,10 +195,7 @@ public override async Task> Write(OperationContainer operatio
if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
{
- var errorResponse = await httpResponseMessage.Content.ReadAsStringAsync();
- var msg = $"The CDP4 Services replied with code {httpResponseMessage.StatusCode}: {httpResponseMessage.ReasonPhrase}: {errorResponse}";
- Logger.Error(msg);
- throw new DalWriteException(msg);
+ await this.ProcessWriteException(httpResponseMessage);
}
this.ProcessHeaders(httpResponseMessage);
@@ -240,6 +237,32 @@ public override async Task> Write(OperationContainer operatio
return result;
}
+ ///
+ /// Handles the situation where a Write failed
+ ///
+ /// The
+ /// Always throws a
+ /// An awaitable
+ private async Task ProcessWriteException(HttpResponseMessage httpResponseMessage)
+ {
+ var errorResponse = await httpResponseMessage.Content.ReadAsStringAsync();
+ var msg = $"The CDP4 Services replied with code {httpResponseMessage.StatusCode}: {httpResponseMessage.ReasonPhrase}: {errorResponse}";
+
+ if (httpResponseMessage.Headers.Contains(Headers.CDPErrorTag))
+ {
+ var cdpErrorTag = httpResponseMessage.Headers.GetValues(Headers.CDPErrorTag).FirstOrDefault() ?? string.Empty;
+
+ if (cdpErrorTag != null)
+ {
+ Logger.Error($"{Headers.CDPErrorTag} {cdpErrorTag} - {msg}");
+ throw new DalWriteException(msg) { CDPErrorTag = cdpErrorTag };
+ }
+ }
+
+ Logger.Error(msg);
+ throw new DalWriteException(msg);
+ }
+
///
/// Write all the s from an asynchronously for a possible long running task.
///
@@ -301,10 +324,7 @@ public override async Task Write(OperationContainer opera
if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
{
- var errorResponse = await httpResponseMessage.Content.ReadAsStringAsync();
- var msg = $"The CDP4 Services replied with code {httpResponseMessage.StatusCode}: {httpResponseMessage.ReasonPhrase}: {errorResponse}";
- Logger.Error(msg);
- throw new DalWriteException(msg);
+ await this.ProcessWriteException(httpResponseMessage);
}
this.ProcessHeaders(httpResponseMessage);
diff --git a/CDP4ServicesDal/Headers.cs b/CDP4ServicesDal/Headers.cs
index 90a53bc8..0cc440dd 100644
--- a/CDP4ServicesDal/Headers.cs
+++ b/CDP4ServicesDal/Headers.cs
@@ -68,5 +68,10 @@ internal static class Headers
/// The header that specifies the version of CDP extensions that are accepted
///
internal const string AcceptCdpVersionValue = "1.3.0";
+
+ ///
+ /// The header that specifies the the error tag of an http response message
+ ///
+ internal const string CDPErrorTag = "CDP-Error-Tag";
}
}
\ No newline at end of file
diff --git a/CDP4ServicesMessaging/CDP4ServicesMessaging.csproj b/CDP4ServicesMessaging/CDP4ServicesMessaging.csproj
index 7b537e75..6ee664ca 100644
--- a/CDP4ServicesMessaging/CDP4ServicesMessaging.csproj
+++ b/CDP4ServicesMessaging/CDP4ServicesMessaging.csproj
@@ -4,7 +4,7 @@
netstandard2.0
Starion Group S.A.
CDP4Common Community Edition
- 27.0.2
+ 27.1.0
CDP4 Services Messaging is a Class Library that contains clients and messages class that can be used for inter services communication
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Nathanael, Antoine
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
latest
diff --git a/CDP4Web/CDP4Web.csproj b/CDP4Web/CDP4Web.csproj
index d9a3f117..cb66ec5b 100644
--- a/CDP4Web/CDP4Web.csproj
+++ b/CDP4Web/CDP4Web.csproj
@@ -5,7 +5,7 @@
latest
Starion Group S.A.
CDP4Web Community Edition
- 27.0.2
+ 27.1.0
CDP4Web Dedicated Sdk for CDPServicesDal
Copyright © Starion Group S.A.
Sam, Alex, Alexander, Nathanael, Antoine, Omar, Jaime
@@ -21,7 +21,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md
diff --git a/CDP4WspDal/CDP4WspDal.csproj b/CDP4WspDal/CDP4WspDal.csproj
index e66b9607..1f24232d 100644
--- a/CDP4WspDal/CDP4WspDal.csproj
+++ b/CDP4WspDal/CDP4WspDal.csproj
@@ -4,7 +4,7 @@
net48;netstandard2.0
Starion Group S.A.
CDP4WspDal Community Edition
- 27.0.2
+ 27.1.0
CDP4 WSP Dal Plugin
Copyright © Starion Group S.A.
Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael
@@ -20,7 +20,7 @@
CDP COMET ECSS-E-TM-10-25
LGPL-3.0-only
- [BUMP] To CDP4Common 27.0.2
+ [BUMP] To CDP4Common 27.1.0
README.md