Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CallbackApp.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
FROM python:3.10-alpine

RUN apk update && apk upgrade
RUN apk add libcom_err=1.46.6-r0
RUN apk add libcom_err=1.47.0-r2
WORKDIR /app
COPY src/TaskManager/CallbackApp/app.py ./
COPY src/TaskManager/CallbackApp/requirements.txt ./
Expand Down
6 changes: 6 additions & 0 deletions src/Shared/Configuration/InformaticsGatewayConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ public class InformaticsGatewayConfiguration
{
[ConfigurationKeyName("apiHost")]
public string ApiHost { get; set; }

[ConfigurationKeyName("username")]
public string Username { get; set; }

[ConfigurationKeyName("password")]
public string Password { get; set; }
}
}
35 changes: 35 additions & 0 deletions src/WorkflowManager/Common/Exceptions/InternalServerException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Monai.Deploy.WorkflowManager.Common.Exceptions
{
public class MonaiInternalServerException : Exception
{
public MonaiInternalServerException()
{
}

public MonaiInternalServerException(string message)
: base(message)
{
}

public MonaiInternalServerException(string message, Exception innerException)
: base(message, innerException)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Options;
using Monai.Deploy.WorkflowManager.Common.Exceptions;
using Monai.Deploy.WorkflowManager.Configuration;

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

_httpClient.BaseAddress = new Uri(_options.Value.ApiHost);

var authenticationString = $"{_options.Value.Username}:{_options.Value.Password}";
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(authenticationString));

_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString);
}

private readonly HttpClient _httpClient;

private readonly IOptions<InformaticsGatewayConfiguration> _options;

public async Task<bool> OriginExists(string name)
public async Task<bool> OriginExists(string aetitle)
{
var response = await _httpClient.GetAsync($"/config/source/{name}");
try
{
var response = await _httpClient.GetAsync($"/config/source/aetitle/{aetitle}");

return response.StatusCode == HttpStatusCode.OK;
return response.StatusCode == HttpStatusCode.OK;
}
catch (Exception ex)
{
throw new MonaiInternalServerException($"An error occured when cheking if the origin '{aetitle}' existed.", ex);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

<ItemGroup>
<ProjectReference Include="..\..\Shared\Configuration\Monai.Deploy.WorkflowManager.Configuration.csproj" />
<ProjectReference Include="..\Common\Monai.Deploy.WorkflowManager.Common.csproj" />
</ItemGroup>

<PropertyGroup>
Expand Down
Loading