Skip to content

Commit 5db45d4

Browse files
authored
Merge pull request #797 from Project-MONAI/samrooke/AC-2215-fix-data-origin-check-in-workflow-validator
fix data origin check in workflow validator
2 parents c09c3eb + 7bb453f commit 5db45d4

File tree

17 files changed

+858
-25
lines changed

17 files changed

+858
-25
lines changed

CallbackApp.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
FROM python:3.10-alpine
1313

1414
RUN apk update && apk upgrade
15-
RUN apk add libcom_err=1.46.6-r0
15+
RUN apk add libcom_err=1.47.0-r2
1616
WORKDIR /app
1717
COPY src/TaskManager/CallbackApp/app.py ./
1818
COPY src/TaskManager/CallbackApp/requirements.txt ./

src/Shared/Configuration/InformaticsGatewayConfiguration.cs

+6
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ public class InformaticsGatewayConfiguration
2222
{
2323
[ConfigurationKeyName("apiHost")]
2424
public string ApiHost { get; set; }
25+
26+
[ConfigurationKeyName("username")]
27+
public string Username { get; set; }
28+
29+
[ConfigurationKeyName("password")]
30+
public string Password { get; set; }
2531
}
2632
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2022 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace Monai.Deploy.WorkflowManager.Common.Exceptions
18+
{
19+
public class MonaiInternalServerException : Exception
20+
{
21+
public MonaiInternalServerException()
22+
{
23+
}
24+
25+
public MonaiInternalServerException(string message)
26+
: base(message)
27+
{
28+
}
29+
30+
public MonaiInternalServerException(string message, Exception innerException)
31+
: base(message, innerException)
32+
{
33+
}
34+
}
35+
}

src/WorkflowManager/Monai.Deploy.WorkflowManager.Services/InformaticsGateway/InformaticsGatewayService.cs

+17-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
using System.Net;
18+
using System.Net.Http.Headers;
1819
using Microsoft.Extensions.Options;
20+
using Monai.Deploy.WorkflowManager.Common.Exceptions;
1921
using Monai.Deploy.WorkflowManager.Configuration;
2022

2123
namespace Monai.Deploy.WorkflowManager.Services.InformaticsGateway
@@ -31,17 +33,29 @@ IOptions<InformaticsGatewayConfiguration> options
3133
_options = options ?? throw new ArgumentNullException(nameof(options));
3234

3335
_httpClient.BaseAddress = new Uri(_options.Value.ApiHost);
36+
37+
var authenticationString = $"{_options.Value.Username}:{_options.Value.Password}";
38+
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(authenticationString));
39+
40+
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);
3441
}
3542

3643
private readonly HttpClient _httpClient;
3744

3845
private readonly IOptions<InformaticsGatewayConfiguration> _options;
3946

40-
public async Task<bool> OriginExists(string name)
47+
public async Task<bool> OriginExists(string aetitle)
4148
{
42-
var response = await _httpClient.GetAsync($"/config/source/{name}");
49+
try
50+
{
51+
var response = await _httpClient.GetAsync($"/config/source/aetitle/{aetitle}");
4352

44-
return response.StatusCode == HttpStatusCode.OK;
53+
return response.StatusCode == HttpStatusCode.OK;
54+
}
55+
catch (Exception ex)
56+
{
57+
throw new MonaiInternalServerException($"An error occured when cheking if the origin '{aetitle}' existed.", ex);
58+
}
4559
}
4660
}
4761
}

src/WorkflowManager/Monai.Deploy.WorkflowManager.Services/Monai.Deploy.WorkflowManager.Services.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
<ItemGroup>
4343
<ProjectReference Include="..\..\Shared\Configuration\Monai.Deploy.WorkflowManager.Configuration.csproj" />
44+
<ProjectReference Include="..\Common\Monai.Deploy.WorkflowManager.Common.csproj" />
4445
</ItemGroup>
4546

4647
<PropertyGroup>

0 commit comments

Comments
 (0)