diff --git a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host index 22e782f..f8975a6 100644 --- a/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host +++ b/F4SDM42WebApi/C4ITF4SDM42WebApi.dll.host @@ -1,5 +1,11 @@ - + + + + + + + diff --git a/F4SDM42WebApi/F4SD - M42WebApi.csproj b/F4SDM42WebApi/F4SD - M42WebApi.csproj index a2ef080..1d3d151 100644 --- a/F4SDM42WebApi/F4SD - M42WebApi.csproj +++ b/F4SDM42WebApi/F4SD - M42WebApi.csproj @@ -13,7 +13,7 @@ false 6673a25d-33d6-4072-91d9-abed4be1a966 C4ITF4SD*.* - 1.4.0.4 + 1.4.0.5 true diff --git a/F4SDM42WebApi/F4SDM42WebApiController.cs b/F4SDM42WebApi/F4SDM42WebApiController.cs index a329dae..7cb47f2 100644 --- a/F4SDM42WebApi/F4SDM42WebApiController.cs +++ b/F4SDM42WebApi/F4SDM42WebApiController.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Matrix42.Common; using Matrix42.Contracts.ServiceManagement.ServiceContracts; -using Matrix42.Hosting.Contracts; using Matrix42.Pandora.Contracts; using Matrix42.Services.Description.Contracts; using Matrix42.WebApi.Contracts; @@ -32,9 +31,9 @@ namespace C4IT.F4SD public static F4SDM42WebApiController defaultInstance; //private readonly IIncidentService _incidentService; internal readonly GlobalConfigurationProvider _globalConfigurationProvider; - public readonly IJournalService _journalService; //public readonly IObjectService _objectService; //public readonly IFragmentService _fragmentService; + public readonly IJournalService _journalService; internal readonly IEntityDataService _entityDataService; internal readonly IPandoraUserProfile _userProfile; @@ -43,60 +42,15 @@ namespace C4IT.F4SD public string BaseUrl => Request?.RequestUri == null ? string.Empty : $"{Request.RequestUri.Scheme}://{Request.RequestUri.Host}"; public string EndpointBaseUrl => $"{BaseUrl}/m42Services/api/c4itf4sdwebapi"; - public F4SDM42WebApiController(IDependencyResolver resolver) + public F4SDM42WebApiController(IEntityDataService entityDataService, IJournalService journalService, IPandoraUserProfile userProfile) { defaultInstance = this; _globalConfigurationProvider = GlobalConfigurationProvider.Instance; _f4stHelperService = new F4SDHelperService(); EnsureInitialized(); - _entityDataService = ResolveOptional(resolver); - _journalService = ResolveOptional(resolver); - _userProfile = ResolveOptional(resolver); - } - - private static T ResolveOptional(IDependencyResolver resolver) where T : class - { - if (resolver == null) - return null; - - try - { - if (!resolver.IsRegistered()) - return null; - } - catch - { - } - - try - { - return resolver.TryGet(); - } - catch (Exception ex) - { - LogOptionalDependencyFailure(typeof(T), ex); - return null; - } - } - - private static void LogOptionalDependencyFailure(Type dependencyType, Exception exception) - { - try - { - LogEntry($"Matrix42 dependency '{dependencyType.FullName}' could not be resolved.", LogLevels.Warning); - LogException(exception); - } - catch - { - } - } - - private HttpResponseMessage CreateMissingDependencyResponse(Type dependencyType) - { - return HttpResponseExtensions.CreateResponse( - Request, - HttpStatusCode.ServiceUnavailable, - $"Matrix42 dependency '{dependencyType.FullName}' is not registered for this extension context."); + _entityDataService = entityDataService ?? throw new ArgumentNullException(nameof(entityDataService)); + _journalService = journalService ?? throw new ArgumentNullException(nameof(journalService)); + _userProfile = userProfile ?? throw new ArgumentNullException(nameof(userProfile)); } private static readonly object initLock = new object(); @@ -323,9 +277,6 @@ namespace C4IT.F4SD public async Task getPickup(string name, [FromUri] EntityEnumerationVisibilityMode mode = EntityEnumerationVisibilityMode.None, [FromUri] Int32 group = -1) { await Task.Delay(0); - if (_entityDataService == null) - return CreateMissingDependencyResponse(typeof(IEntityDataService)); - EntityEnumeration enumerationTemp = _entityDataService.GetEnumeration(name, mode); var vals = enumerationTemp.Values; @@ -352,9 +303,6 @@ namespace C4IT.F4SD [Route("getMyRoleMemberships"), HttpGet] public async Task getMyRoleMemberships() { - if (_userProfile == null) - return CreateMissingDependencyResponse(typeof(IPandoraUserProfile)); - var User = _userProfile.GetInteractiveUserInfo(); var filter = AsqlHelper.BuildInCondition("ID", new Guid[] { User.Id }); return HttpResponseExtensions.CreateResponse(Request, HttpStatusCode.OK, await _f4stHelperService.UserPermissionsInfo(filter));