Skip to content

Commit

Permalink
updates for COLID 2.14 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirthas committed Jun 27, 2023
1 parent 1ccff50 commit 06028fa
Show file tree
Hide file tree
Showing 62 changed files with 399 additions and 97 deletions.
7 changes: 7 additions & 0 deletions COLID.SchedulerService.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegrationTests", "tests\I
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FunctionalTests", "tests\FunctionalTests\FunctionalTests.csproj", "{6F3C5E00-AD14-40BD-8884-E7BF340A4B91}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F98DCEA5-1D81-4416-AAFA-8D8968F2C267}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
coding.ruleset = coding.ruleset
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
17 changes: 8 additions & 9 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project>
<PropertyGroup>
<!--
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors>true</WarningsAsErrors>
<CodeAnalysisRuleSet>..\coding.ruleset</CodeAnalysisRuleSet>
-->
<PropertyGroup>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<WarningsAsErrors>false</WarningsAsErrors>
<CodeAnalysisRuleSet>$(SolutionDir)coding.ruleset</CodeAnalysisRuleSet>

<Authors>COLID team</Authors>
<Company>Bayer AG</Company>
</PropertyGroup>

<!--<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.3" />
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ RUN dotnet publish -c release -o /app --no-restore

# final stage/image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine

ARG BUILD_CIPIPELINEID
ENV Build__CiPipelineId=${BUILD_CIPIPELINEID}

ARG BUILD_CICOMMITSHA
ENV Build__CiCommitSha=${BUILD_CICOMMITSHA}

ENV PORT=8080
ENV ASPNETCORE_URLS=http://*:${PORT}
EXPOSE $PORT
Expand Down
17 changes: 12 additions & 5 deletions coding.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<Rule Id="CA1027" Action="Error" />
<Rule Id="CA1028" Action="Error" />
<Rule Id="CA1030" Action="Error" />
<Rule Id="CA1031" Action="Error" />
<Rule Id="CA1031" Action="Warning" />
<Rule Id="CA1032" Action="Error" />
<Rule Id="CA1033" Action="Error" />
<Rule Id="CA1034" Action="Error" />
Expand All @@ -47,7 +47,7 @@
<Rule Id="CA1049" Action="Error" />
<Rule Id="CA1050" Action="Error" />
<Rule Id="CA1051" Action="Error" />
<Rule Id="CA1052" Action="Error" />
<Rule Id="CA1052" Action="Warning" />
<Rule Id="CA1053" Action="Error" />
<Rule Id="CA1054" Action="Error" />
<Rule Id="CA1055" Action="Error" />
Expand All @@ -64,7 +64,7 @@
<Rule Id="CA1300" Action="Error" />
<Rule Id="CA1301" Action="Error" />
<Rule Id="CA1302" Action="Error" />
<Rule Id="CA1303" Action="Error" />
<Rule Id="CA1303" Action="Warning" />
<Rule Id="CA1304" Action="Hidden" />
<Rule Id="CA1305" Action="Hidden" />
<Rule Id="CA1306" Action="Error" />
Expand Down Expand Up @@ -104,7 +104,7 @@
<Rule Id="CA1708" Action="Error" />
<Rule Id="CA1709" Action="Error" />
<Rule Id="CA1710" Action="Error" />
<Rule Id="CA1711" Action="Error" />
<Rule Id="CA1711" Action="Warning" />
<Rule Id="CA1712" Action="Error" />
<Rule Id="CA1713" Action="Error" />
<Rule Id="CA1714" Action="Error" />
Expand All @@ -115,7 +115,7 @@
<Rule Id="CA1720" Action="Error" />
<Rule Id="CA1721" Action="Error" />
<Rule Id="CA1722" Action="Error" />
<Rule Id="CA1724" Action="Error" />
<Rule Id="CA1724" Action="Warning" />
<Rule Id="CA1725" Action="Error" />
<Rule Id="CA1726" Action="Error" />
<Rule Id="CA1800" Action="Error" />
Expand Down Expand Up @@ -672,6 +672,13 @@
<Rule Id="C6995" Action="Error" />
<Rule Id="C6997" Action="Error" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.NetAnalyzers">
<Rule Id="CA1031" Action="Warning" />
<Rule Id="CA1052" Action="Warning" />
<Rule Id="CA1303" Action="Warning" />
<Rule Id="CA1711" Action="Warning" />
<Rule Id="CA1724" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
<Rule Id="CA1812" Action="Hidden" />
</Rules>
Expand Down
2 changes: 1 addition & 1 deletion src/COLID.Scheduler.Common/Constants/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class Metadata
.SetBasePath(_filePath)
.AddJsonFile("appsettings.json")
.Build();
public static readonly string _serviceUrl = _configuration.GetValue<string>("ServiceUrl");
private static readonly string _serviceUrl = _configuration.GetValue<string>("ServiceUrl");

public static readonly string Author = _serviceUrl + "kos/19050/author";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ColidEntryContactInvalidUsersDto
{
public string ContactMail { get; set; }

public List<ColidEntryInvalidUsersDto> ColidEntries { get; set; }
public IList<ColidEntryInvalidUsersDto> ColidEntries { get; set; }

public ColidEntryContactInvalidUsersDto()
{
Expand Down
2 changes: 1 addition & 1 deletion src/COLID.Scheduler.Common/RegexUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace COLID.Scheduler.Common
{
// Original from https://docs.microsoft.com/de-de/dotnet/standard/base-types/how-to-verify-that-strings-are-in-valid-email-format
public class RegexUtilities
public static class RegexUtilities
{
public static bool IsValidEmail(string email)
{
Expand Down
4 changes: 4 additions & 0 deletions src/COLID.Scheduler.Jobs/COLID.Scheduler.Jobs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
<ProjectReference Include="..\COLID.Scheduler.Services\COLID.Scheduler.Services.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Interface\" />
</ItemGroup>

</Project>
41 changes: 30 additions & 11 deletions src/COLID.Scheduler.Jobs/HangfireModules.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System;
using System.Threading;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Jobs.Filter;
using COLID.Scheduler.Jobs.Interface;
using COLID.Scheduler.Jobs.Implementation;
using COLID.Scheduler.Jobs.Interfaces;
using COLID.SchedulerService.Jobs.Implementation;
using COLID.SchedulerService.Jobs.Interface;
using COLID.SchedulerService.Jobs.Interfaces;
using Hangfire;
using Hangfire.MemoryStorage;
using Hangfire.MySql;
Expand Down Expand Up @@ -36,7 +37,9 @@ public static IServiceCollection RegisterJobs(this IServiceCollection services)
services.AddTransient<IUserInvalidNotificationJob, UserInvalidNotificationJob>();
services.AddTransient<IResourceStatisticsJob, ResourceStatisticsJob>();
services.AddTransient<IUniqueUserStatisticsJob, UniqueUserStatisticsJob>();
services.AddTransient<IInvalidDitributionEndpointNotificationJob, InvalidDitributionEndpointNotificationJob>();
services.AddTransient<IBrokenEndpointNotificationJob, BrokenEndpointNotificationJob>();
services.AddTransient<IBrokenContactNotificationJob, BrokenContactNotificationJob>();
services.AddTransient<ISetBrokenFlagsInElasticJob, SetBrokenFlagsInElasticJob>();
services.AddTransient<IDueResourcesNotificationJob, DueResourcesNotificationJob>();
services.AddTransient<ISaveSearchesSubscriptionsFavListStasticsJob, SaveSearchesSubscriptionsFavListStasticsJob>();

Expand Down Expand Up @@ -76,8 +79,8 @@ public static IServiceCollection RegisterHangfire(this IServiceCollection servic
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage(new MySqlStorage(config.GetConnectionString("MySQLConnection").
Replace("{DB_USER}", config.GetValue<string>("Database:User")).
Replace("{DB_PASSWORD}", config.GetValue<string>("Database:Password")),
Replace("{DB_USER}", config.GetValue<string>("Database:User"), StringComparison.Ordinal).
Replace("{DB_PASSWORD}", config.GetValue<string>("Database:Password"), StringComparison.Ordinal),
new MySqlStorageOptions
{
TransactionIsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
Expand Down Expand Up @@ -112,7 +115,7 @@ public static IApplicationBuilder SetupHangfireServer(this IApplicationBuilder a
DashboardOptions dOptions = new DashboardOptions();
dOptions.Authorization = new[] { new DashboardAuthorizationFilter() };

if (config.GetValue<string>("EnvironmentLabel").Equals("Production"))
if (config.GetValue<string>("EnvironmentLabel").Equals("Production", StringComparison.Ordinal))
{
dOptions.IsReadOnlyFunc = context => true;
}
Expand Down Expand Up @@ -187,11 +190,27 @@ public static IApplicationBuilder SetupHangfireJobs(this IApplicationBuilder app
TimeZoneInfo.Local,
Queue.Alpha);

var InvalidDitributionEndpointNotificationJob = config.GetValue<string>("CronJobConfig:InvalidDitributionEndpointNotificationJob");
logger.LogInformation("CronJob config for InvalidDitributionEndpointNotificationJob: {InvalidDitributionEndpointNotificationJob}", InvalidDitributionEndpointNotificationJob);
RecurringJob.AddOrUpdate<IInvalidDitributionEndpointNotificationJob>(nameof(InvalidDitributionEndpointNotificationJob),
var BrokenEndpointNotificationJob = config.GetValue<string>("CronJobConfig:BrokenEndpointNotificationJob");
logger.LogInformation("CronJob config for BrokenEndpointNotificationJob: {BrokenEndpointNotificationJob}", BrokenEndpointNotificationJob);
RecurringJob.AddOrUpdate<IBrokenEndpointNotificationJob>(nameof(BrokenEndpointNotificationJob),
job => job.ExecuteAsync(CancellationToken.None),
config.GetValue<string>("CronJobConfig:InvalidDitributionEndpointNotificationJob"),
config.GetValue<string>("CronJobConfig:BrokenEndpointNotificationJob"),
TimeZoneInfo.Local,
Queue.Alpha);

var BrokenContactsNotificationJob = config.GetValue<string>("CronJobConfig:BrokenContactsNotificationJob");
logger.LogInformation("CronJob config for BrokenContactsNotificationJob: {BrokenContactsNotificationJob}", BrokenContactsNotificationJob);
RecurringJob.AddOrUpdate<IBrokenContactNotificationJob>(nameof(BrokenContactsNotificationJob),
job => job.ExecuteAsync(CancellationToken.None),
config.GetValue<string>("CronJobConfig:BrokenContactsNotificationJob"),
TimeZoneInfo.Local,
Queue.Alpha);

var SetBrokenFlagsInElasticJob = config.GetValue<string>("CronJobConfig:SetBrokenFlagsInElastic");
logger.LogInformation("CronJob config for SetBrokenFlagsInElasticJob: {SetBrokenFlagsInElasticJob}", SetBrokenFlagsInElasticJob);
RecurringJob.AddOrUpdate<ISetBrokenFlagsInElasticJob>(nameof(SetBrokenFlagsInElasticJob),
job => job.ExecuteAsync(CancellationToken.None),
config.GetValue<string>("CronJobConfig:SetBrokenFlagsInElastic"),
TimeZoneInfo.Local,
Queue.Alpha);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Threading;
using System.Threading.Tasks;
using COLID.Scheduler.Services.Interfaces;
using Hangfire;
using Microsoft.Extensions.Logging;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Jobs.Interfaces;

namespace COLID.Scheduler.Jobs.Implementation
{
public class BrokenContactNotificationJob : IBrokenContactNotificationJob
{
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger<BrokenContactNotificationJob> _logger;
private readonly IRemoteRegistrationService _registrationService;

public BrokenContactNotificationJob(IBackgroundJobClient backgroundJobClient, ILogger<BrokenContactNotificationJob> logger, IRemoteRegistrationService registrationService)
{
_backgroundJobClient = backgroundJobClient;
_logger = logger;
_registrationService = registrationService;
}

[Queue(Queue.Beta)]
public async Task ExecuteAsync(CancellationToken token)
{
_backgroundJobClient.Enqueue<IBrokenContactNotificationJob>(x => x.CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers());
_logger.LogInformation("CheckInvalidContacts Job Finished");
}

public async Task CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers()
{
await _registrationService.CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text;
using Hangfire;
using System.Threading;
using System.Threading.Tasks;
using COLID.SchedulerService.Jobs.Interfaces;
using Microsoft.Extensions.Logging;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Services.Interfaces;

namespace COLID.SchedulerService.Jobs.Implementation
{
class BrokenEndpointNotificationJob : IBrokenEndpointNotificationJob
{
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger<BrokenEndpointNotificationJob> _logger;
private readonly IRemoteRegistrationService _registrationService;

public BrokenEndpointNotificationJob(IBackgroundJobClient backgroundJobClient, ILogger<BrokenEndpointNotificationJob> logger, IRemoteRegistrationService registrationService)
{
_backgroundJobClient = backgroundJobClient;
_logger = logger;
_registrationService = registrationService;
}

[Queue(Queue.Beta)]
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task ExecuteAsync(CancellationToken token)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
_backgroundJobClient.Enqueue<IBrokenEndpointNotificationJob>(x => x.NotifyUsersForInvalidDistributionEndpoints());
_logger.LogInformation("InvalidDitributionEndpointNotification Job Finished");
}

public void NotifyUsersForInvalidDistributionEndpoints()
{
_logger.LogInformation("Calling registration api for to check the invalid distribution endpoint(s)");
_registrationService.CheckDistributionEndpointValidityAndNotifyUsersAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Threading;
using System.Threading.Tasks;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Services.Interface;
using COLID.SchedulerService.Jobs.Interface;
using COLID.Scheduler.Services.Interfaces;
using COLID.SchedulerService.Jobs.Interfaces;
using Hangfire;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using COLID.Scheduler.Common.Constants;
using COLID.SchedulerService.Jobs.Interface;
using COLID.SchedulerService.Jobs.Interfaces;
using Hangfire;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using COLID.Scheduler.Services.Interfaces;
using COLID.SchedulerService.Jobs.Implementation;
using COLID.SchedulerService.Jobs.Interfaces;
using Hangfire;
using Microsoft.Extensions.Logging;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Jobs.Interfaces;

namespace COLID.Scheduler.Jobs.Implementation
{
public class InvalidContactNotificationJob : IInvalidContactNotificationJob
{
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger<InvalidContactNotificationJob> _logger;
private readonly IRemoteRegistrationService _registrationService;

public InvalidContactNotificationJob(IBackgroundJobClient backgroundJobClient, ILogger<InvalidContactNotificationJob> logger, IRemoteRegistrationService registrationService)
{
_backgroundJobClient = backgroundJobClient;
_logger = logger;
_registrationService = registrationService;
}

[Queue(Queue.Beta)]
public async Task ExecuteAsync(CancellationToken token)
{
_backgroundJobClient.Enqueue<IInvalidContactNotificationJob>(x => x.CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers());
_logger.LogInformation("CheckInvalidContacts Job Finished");
}

public async Task CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers()
{
await _registrationService.CheckDataStewardsAndDistributionEndpointContactsAndNotifyUsers();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Hangfire;
using System.Threading;
using System.Threading.Tasks;
using COLID.SchedulerService.Jobs.Interface;
using COLID.SchedulerService.Jobs.Interfaces;
using Microsoft.Extensions.Logging;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Services.Interface;
using COLID.Scheduler.Services.Interfaces;

namespace COLID.SchedulerService.Jobs.Implementation
{
Expand Down
4 changes: 2 additions & 2 deletions src/COLID.Scheduler.Jobs/Implementation/MessageDeletionJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Threading;
using System.Threading.Tasks;
using COLID.Scheduler.Common.Constants;
using COLID.Scheduler.Services.Interface;
using COLID.SchedulerService.Jobs.Interface;
using COLID.Scheduler.Services.Interfaces;
using COLID.SchedulerService.Jobs.Interfaces;
using Hangfire;
using Microsoft.Extensions.Logging;

Expand Down
Loading

0 comments on commit 06028fa

Please sign in to comment.