Skip to content

Commit

Permalink
Updated code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ragavareddychalapala committed Feb 6, 2025
1 parent 3627235 commit fb0599f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
50 changes: 43 additions & 7 deletions src/LCT.SW360PackageCreator/CreatorValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using LCT.SW360PackageCreator.Model;
using System.Linq;
using LCT.Common.Constants;
using LCT.Facade;


namespace LCT.SW360PackageCreator
Expand Down Expand Up @@ -69,10 +70,8 @@ public static async Task TriggerFossologyValidation(CommonAppSettings appSetting
ReleasesAllDetails.Sw360Release validRelease = null;
int pageCount = 0;
while (!validReleaseFound && pageCount < 10)
{
HttpResponseMessage responseData = await sW360ApicommunicationFacade.GetAllReleasesWithAllData(page, pageEntries);
string response = responseData?.Content?.ReadAsStringAsync()?.Result ?? string.Empty;
ReleasesAllDetails releaseResponse = JsonConvert.DeserializeObject<ReleasesAllDetails>(response);
{
ReleasesAllDetails releaseResponse = await GetAllReleasesDetails(sW360ApicommunicationFacade,page,pageEntries);

if (releaseResponse != null)
{
Expand Down Expand Up @@ -100,13 +99,18 @@ public static async Task TriggerFossologyValidation(CommonAppSettings appSetting
}
}
}

else
{
Logger.Debug($"GetAllReleasesFullDetails():Fossology URl validation Failed");
}
}

if (validReleaseFound)
{
var releaseUrl = validRelease?.Links?.Self?.Href;
var releaseId = CommonHelper.GetSubstringOfLastOccurance(releaseUrl, "/");
var releaseId=string.Empty;
if (releaseUrl != null)
releaseId = CommonHelper.GetSubstringOfLastOccurance(releaseUrl, "/");
string sw360link = $"{validRelease?.Name}:{validRelease?.Version}:{appSettings?.SW360?.URL}{ApiConstant.Sw360ReleaseUrlApiSuffix}" +
$"{releaseId}#/tab-Summary";
FossTriggerStatus fossResult = await sw360CreatorService.TriggerFossologyProcessForValidation(releaseId, sw360link);
Expand All @@ -115,15 +119,47 @@ public static async Task TriggerFossologyValidation(CommonAppSettings appSetting
Logger.Logger.Log(null, Level.Info, $"SW360 Fossology Process validation successfull!!", null);
}
}
else
{
Logger.Debug($"GetAllReleasesFullDetails():Fossology URl validation Failed");
}

}
catch (AggregateException ex)
{
Logger.Debug($"\tError in TriggerFossologyValidation--{ex}");
Logger.Error($"Trigger Fossology Process failed.Please check fossology configuration in sw360");
Logger.Error($"Trigger fossology process failed.Please check fossology configuration in sw360");
environmentHelper.CallEnvironmentExit(-1);
}
}
private static async Task<ReleasesAllDetails> GetAllReleasesDetails(ISW360ApicommunicationFacade sW360ApicommunicationFacade, int page, int pageEntries)
{
ReleasesAllDetails releaseResponse = null;
try
{
var responseData = await sW360ApicommunicationFacade.GetAllReleasesWithAllData(page, pageEntries);
string response = responseData?.Content?.ReadAsStringAsync()?.Result ?? string.Empty;
releaseResponse = JsonConvert.DeserializeObject<ReleasesAllDetails>(response);
}
catch (HttpRequestException ex)
{
Logger.Debug($"GetAllReleasesDetails():", ex);
}
catch (InvalidOperationException ex)
{
Logger.Debug($"GetAllReleasesDetails():", ex);
}
catch (UriFormatException ex)
{
Logger.Debug($"GetAllReleasesDetails():", ex);
}
catch (TaskCanceledException ex)
{
Logger.Debug($"GetAllReleasesDetails():", ex);
}

return releaseResponse;
}
public static async Task<bool> FossologyUrlValidation(CommonAppSettings appSettings, HttpClient client, IEnvironmentHelper environmentHelper)
{
string url = appSettings.SW360.Fossology.URL.ToLower();
Expand Down
8 changes: 4 additions & 4 deletions src/LCT.Services/Sw360CreatorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,25 +793,25 @@ public async Task<FossTriggerStatus> TriggerFossologyProcessForValidation(string
catch (HttpRequestException ex)
{
Logger.Debug($"TriggerFossologyProcessForValidation():", ex);
Logger.Error($"Fossology Process failed.Please check fossology configuration or Token in sw360");
Logger.Error($"Fossology process failed.Please check fossology configuration or Token in sw360");
environmentHelper.CallEnvironmentExit(-1);
}
catch (InvalidOperationException ex)
{
Logger.Debug($"TriggerFossologyProcessForValidation():", ex);
Logger.Error($"Fossology Process failed.Please check fossology configuration in sw360");
Logger.Error($"Fossology process failed.Please check fossology configuration in sw360");
environmentHelper.CallEnvironmentExit(-1);
}
catch (UriFormatException ex)
{
Logger.Debug($"TriggerFossologyProcessForValidation():", ex);
Logger.Error($"Fossology Process failed.Please check fossology configuration in sw360");
Logger.Error($"Fossology process failed.Please check fossology configuration in sw360");
environmentHelper.CallEnvironmentExit(-1);
}
catch (TaskCanceledException ex)
{
Logger.Debug($"TriggerFossologyProcessForValidation():", ex);
Logger.Error($"Fossology Process failed.Please check fossology configuration in sw360");
Logger.Error($"Fossology process failed.Please check fossology configuration in sw360");
environmentHelper.CallEnvironmentExit(-1);
}
return fossTriggerStatus;
Expand Down

0 comments on commit fb0599f

Please sign in to comment.